akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int PMAX = 10000000;

template <typename T>
struct node {
	T val, add;
	node *l, *r;
	node() {}
	node(T val, T add) : val(val), add(add), l(nullptr), r(nullptr) {}
	void init(T v, T a, node *left, node *right) {
		val = v;
		add = a;
		l = left;
		r = right;
	}
};

node<ll> pool[PMAX];

template <typename T>
class SaikyoSegmentTree {
	const ll n;
	const T id;
	int it;
	vector<node<T>*> root;
	T getval(node<T> *x) {
		return x == nullptr ? id : x->val;
	}
	T getadd(node<T> *x) {
		return x == nullptr ? id : x->add;
	}
	node<T>* getl(node<T> *x) {
		return x == nullptr ? nullptr : x->l;
	}
	node<T>* getr(node<T> *x) {
		return x == nullptr ? nullptr : x->r;
	}
	ll size(ll n) {
		assert(n < (1ll << 62ll));
		ll res = 1;
		while (res < n) res <<= 1;
		return res;
	}
	node<T> *new_node(T val, T add, node<T> *l = nullptr, node<T> *r = nullptr) {
		pool[it].init(val, add, l, r);
		return &pool[it++];
	}
	node<T> *fix(node<T> *x, ll l, ll r, T val, ll lb, ll ub) {
		if (r <= lb || ub <= l) return x;
		if (l <= lb && ub <= r) return new_node(getval(x), getadd(x) + val, getl(x), getr(x));
		ll c = (lb + ub) / 2;
		auto nl = fix(getl(x), l, r, val, lb, c);
		auto nr = fix(getr(x), l, r, val, c, ub);
		return new_node(getval(x) + val * (min(r, ub) - max(l, lb)), getadd(x), nl, nr);
	}
	T sub(node<T> *x, ll l, ll r, ll lb, ll ub) {
		if (x == nullptr) return id;
		if (ub <= l || r <= lb) return id;
		if (l <= lb && ub <= r) return x->val + x->add * (ub - lb);
		ll c = (lb + ub) / 2;
		return sub(getl(x), l, r, lb, c) + sub(getr(x), l, r, c, ub) + x->add * (min(r, ub) - max(l, lb));
	}
public:
	SaikyoSegmentTree(ll n_, T id_) : n(size(n_)), id(id_), it(0) {
		root.push_back(nullptr);
	}
	void add(ll l, ll r, T val, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		root.push_back(fix(root[rt], l, r + 1, val, 0, n));
	}
	T find(ll l, ll r, int rt = -1) {
		if (rt == -1) rt = root.size() - 1;
		assert(0 <= rt && rt < (int)root.size());
		return sub(root[rt], l, r + 1, 0, n);
	}
};

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll N, M, Q;
	cin >> N >> M >> Q;
	vector<tuple<int, int, int>> vab(M);
	for (int i = 0; i < M; i++) {
		cin >> get<1>(vab[i]) >> get<2>(vab[i]) >> get<0>(vab[i]); get<1>(vab[i])--; get<2>(vab[i])--;
	}
	sort(vab.begin(), vab.end());
	SaikyoSegmentTree<ll> sst(N, 0);
	for (int i = 0; i < M; i++) {
		sst.add(get<1>(vab[i]), get<2>(vab[i]), 1);
	}
	ll x, y, j;
	while (Q--) {
		cin >> x >> y >> j; x--; y--;
		ll l = 0, r = M;
		while(l + 1 < r) {
			ll c = (l + r) / 2;
			if (sst.find(x, y, c) >= j) {
				r = c;
			}
			else {
				l = c;
			}
		}
		printf("%d\n", get<0>(vab[r - 1]));
	}
	return 0;
}

Measured memory_bytes: 266560
N,X=list(map(int,input().split()))
L=list(map(int,input().split()))
D=0
i=0
for i in range(1,N+1):
    D+=L[i-1]
    if D>X:
        break       
    elif i==N and D<=X:
        i=N+1
        pass
    else:
        pass
print(i)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N;
vv<int> A;
vector<int> idx;

int main() {
    cin >> N;
    A = vvec(N, N - 1, 0);
    rep(i, N) rep(j, N - 1) {
        cin >> A[i][j];
        A[i][j]--;
    }

    set<int> canUpd, nxtUpd;
    rep(i, N) {
        if (A[A[i][0]][0] == i) canUpd.insert(i);
    }
    int cntFin = 0;
    vector<bool> fin(N);
    idx.resize(N);
    int ans = 0;
    vector<int> tmp;
    set<int> used;

    for (; cntFin < N; ans++) {
        //tmp.resize(0);
        nxtUpd.clear();
        used.clear();
        bool update = false;

        for (int i : canUpd) {
            if (used.find(i) != used.end()) continue;

            int vs = A[i][idx[i]];
            if (A[vs][idx[vs]] == i && used.find(vs) == used.end()) {
                if (++idx[i] == N - 1) {
                    cntFin++;
                }
                else {
                    nxtUpd.insert(A[i][idx[i]]);
                }
                if (++idx[vs] == N - 1) {
                    cntFin++;
                }
                else {
                    nxtUpd.insert(A[vs][idx[vs]]);
                }

                //tmp.push_back(i);
                //tmp.push_back(vs);
                used.insert(i);
                used.insert(vs);

                update = true;
            }
            else {
                nxtUpd.insert(i);
            }
        }

        if (!update) {
            write(-1);
            return 0;
        }
        swap(canUpd, nxtUpd);
    }

    write(ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define maxn 352534

using namespace std;
typedef long long ll;
ll a[maxn],n,m,k,r,d,s[maxn],ans,mm;
ll c(ll x){
    ll res=x*r+(s[n]-s[n-x])*5;
    m=n-x; k=5;
    while (m){
        mm=max(0ll,m-x);
        res+=k*(s[m]-s[mm]);
        if (res>=2e15) return 2e15;
        k+=2; m=mm;
    }
    return res;
}

int main(){
    cin >> n >> r;
    for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
    ans=c(1);
    for (int i=2;i<=n;i++) ans=min(ans,c(i));
    cout << ans+r*n << endl;
}


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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    
    if(n % 2 == 0){
        for(int i = n - 1; i >= 0; i -= 2){
            cout << vec[i] << " ";
        }
        
        for(int i = 0; i < n; i += 2){
            cout << vec[i] << " ";
        }
        cout << endl;
    } else {
        for(int i = n - 1; i >= 0; i -= 2){
            cout << vec[i] << " ";
        }
        
        for(int i = 1; i < n; i += 2){
            cout << vec[i] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 2944
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
ll A[201];
ll B[201]={};
ll total=1000000000;
int main() {
		cin>>N;
		for(int i=0;i<N;i++){
			cin>>A[i];
			if(A[i]%2==0){
				while(A[i]%2==0){
					if(A[i]%2==0){
						B[i]+=1;
						A[i]=A[i]/2;
					}
					if(A[i]%2!=0)break;
				}
			}
		}

		for(int i=0;i<N;i++){
			total=min(total,B[i]);
		}
		cout<<total<<endl;
		return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;

namespace AGC015A
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(long.Parse);
            var A = ss.Next(long.Parse);
            var B = ss.Next(long.Parse);

            if (N == 1 && A != B)
            {
                sw.WriteLine(0);
                return;
            }

            if (A == B)
            {
                sw.WriteLine(1);
                return;
            }

            if (A > B)
            {
                sw.WriteLine(0);
                return;
            }

            sw.WriteLine(B * (N - 2) - A * (N - 2) + 1);
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<ld> vld;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

ll llabs(ll x)
{
	return x >= 0? x : -x;
}

int main()
{
	fastIO;
	ll x, k, d; cin >> x >> k >> d;
	ll d1, d2, d3;
	ll n;
	x = llabs(x);
	n = x/d;
	if(llabs(x - n*d) <= llabs(x - (n + 1)*d)) d1 = x - n*d;
	else d1 = x - (n + 1)*d, n++;

	if(n >= k) cout << x - k*d << endl;
	else
	{
		d2 = d1 - d, d3 = d1 + d;

		k -= n;
		d = llabs(d2) < llabs(d3)? llabs(d2) : llabs(d3);
		if(k & 1) cout << d << endl;
		else cout << llabs(d1) << endl;
	}

	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) {
   if (a < b) {
      a = b;
      return 1;
   }
   return 0;
}
template<class T>bool chmin(T &a, const T &b) {
   if (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
string S, T;
string ans;

int main()
{
   cout << fixed << setprecision(10);
   cin >> N >> S >> T;
   REP(i, N) {
      ans += S[i];
      ans += T[i];
   }
   cout << ans << endl;
   return 0;
}



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

template <typename T>
struct SegmentTree{
private:
    int n;
    T init;
    std::vector<T> node;

public:
    explicit SegmentTree(int sz,T initv=0){
        n=1;
        init=initv;
        while(n<sz)n=n*2;
        node.resize(static_cast<unsigned int>(2 * n - 1), init);
        for (int i = 0; i <sz ; ++i) node[i+n-1]=init;
        for (int i = n-2; i >= 0 ; --i) node[i]=node[2*i+1]+node[2*i+2];
    }

    void update(int x, T val){//x:0-indexed
        x+=n-1;
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=node[2*x+1]+node[2*x+2];
        }
    }

    T getsum(int p,int q,int k=0,int l=0,int r=-1){//[p,q):0-indexed
        if(r<0)r=n;
        if(r<=p||l>=q)return 0;
        if(p<=l&&r<=q)return node[k];

        return getsum(p,q,2*k+1,l,(l+r)/2)+getsum(p,q,2*k+2,(l+r)/2,r);
    }
};


using namespace std;
using ll=long long;

int main(){
    int n,k;
    cin>>n>>k;
    SegmentTree<double> st(n);
    for (int i = 0; i < n; ++i) {
        ll a;
        cin>>a;
        st.update(i,double(1+a)/2);
    }
    double ans=-1;
    for (int i = 0; i+k-1 < n; ++i) {
        ans=max(ans,st.getsum(i,i+k));
    }
    /*
    vector<double> p(n);
    for (int i = 0; i < n; ++i) {
        cin>>p[i];
        p[i]=(1+p[i])/2;
    }
    double ma=0.0;
    double ts=0;
    for (int i = 0; i < k; ++i) {
        ts+=p[i];
    }
    ma=ts;
    for (int i = 0; i+k-1 < n; ++i) {
        double tts=ts;
        tts-=p[i];
        tts+=p[i+k-1];
        if(ma<tts){
            ma=tts;
        }
        ts=tts;
    }
     */
    cout<<setprecision(16);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4352
import java.lang.Math.*
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()
    val K = scn.nextInt()

    var h = arrayOfNulls<Int>(N + 1)
    for (i in 1..N) {
        h[i] = scn.nextInt()
    }
    h[0] = 0

    var dp = arrayOfNulls<Int>(N + 1)
    for (i in 1..N) {
        dp[i] = Int.MAX_VALUE
    }
    dp[0] = 0
    dp[1] = 0

    for (i in 2..N) {
        for (k in 1..K) {
            if (k < i) dp[i] = min(dp[i]!!, abs(h[i]!! - h[i - k]!!) + dp[i - k]!!)
        }
    }

    println(dp[N])
}

Measured memory_bytes: 111164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[4];
	int m=0;
	cin>>s;
	for(int i=0;i<3;i++)
	if(s[i]=='R')
	m++;
	if(s[1]=='S'&&m!=0)
	m=1;
	cout<<m;
 } 

Measured memory_bytes: 3632
def main():
    N,K,Q = map(int, input().split())
    solve_player=[int(input()) for i in range(Q)]

    player_scores = [(K-Q) for i in range(N)]
    for player in solve_player:
        player_scores[player-1]+=1
    
    for score in player_scores:
        if(score>0):
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 11772
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define REP(inc, bgn, end) for (int inc = bgn; inc < end; inc++)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;

int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b * 100 + 0.5;
    a *= ib;
    a /= 100;
    cout << a << endl;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define pie 3.141592653589793
using namespace std;


int main()
{
   double n,s=0,v;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>v;
       s+=(1/v);
   }
   s=1/s;
   printf("%.14lf\n",s);
   return 0;
}


Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-09-11
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long a, b, x;
    cin >> a >> b >> x;
    a = (a + x - 1) / x * x;
    b = b / x * x;
    if (b >= a) {
        cout << (b - a) / x + 1 << '\n';
    }
    else {
        cout << 0 << '\n';
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n,k,s;
  cin >> n >> k >> s;
  REP(i,k)cout << s << " ";
  ll a;
  s == 1 ? a = 10000 : a = s-1;
  REP(i,n-k)cout << a << " ";

  

  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int w[10], k[10];
	for (int i = 0; i < 10; i++)
		cin >> w[i];
	for (int i = 0; i < 10; i++)
		cin >> k[i];
	sort(w, w + 10);
	sort(k, k + 10);
	cout << w[7] + w[8] + w[9] << " " << k[7] + k[8] + k[9] << endl;
}

Measured memory_bytes: 1180
//Sinhov : "Hi stalker!"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    ll n,val,i,ans=0;
    map<ll,ll>occ;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>val;
        if(occ[val]==1)
            occ[val]=0;
        else
            occ[val]=1;
    }
    for(auto e:occ){
        if(e.second==1)
            ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6528
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  int a=sc.nextInt();
    int b=sc.nextInt();
    int ab=sc.nextInt();int x=sc.nextInt();
    int y=sc.nextInt();
    int sum=0;
    if(a+b>ab*2){
        int po=Math.min(x,y);
        sum+=po*ab*2;
        x-=po;
        y-=po;
    }
    sum+=(a>ab*2)?x*ab*2:x*a;
    sum+=(b>ab*2)?y*ab*2:y*b;
    System.out.println(sum);
}

}


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

int main(){
    using namespace std;
    using cmp = complex<unsigned long>;
    constexpr unsigned long MOD{1000000007};
    unsigned long S;
    cin >> S;
    const auto& mod_pow = [MOD](cmp a, unsigned long n, const cmp& b) -> cmp {
        const auto& mul_ass = [MOD](cmp& x, cmp y){
            x += MOD;
            y += MOD;
            x *= y;
            x.real(x.real() % MOD);
            x.imag(x.imag() % MOD);
        };
        cmp r{b};
        while(n){
            if(n & 1)mul_ass(r, a);
            mul_ass(a, a);
            n >>= 1;
        }
        return r;
    };
    cout << (mod_pow(622947620, S, 451009450) + 2UL * mod_pow({188526194, 594405036}, S, {274495279, 16512442})).real() % MOD << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner
import scala.collection.immutable

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val output: String = sc.nextLine.toInt match {
      case a if immutable.Set(7, 5, 3).contains(a) => "YES"
      case _ => "NO"
    }
    println(output)
  }
}


Measured memory_bytes: 25768
#include <iostream>
int main() {
    int x, y;
    while (true) {
        std::cin >> x >> y;
        if (!x && !y) {
            break;
        }

        std::cout << ((x < y) ? x : y)
                  << " "
                  << ((x < y) ? y : x)
                  << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3072
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n,i,j,k,x,y,ans,curr,temp,m;
	int tc;
    string s;
    string t;
    cin >> s >> t;
    t.pop_back();
    if(s == t) cout << "Yes\n";
    else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll d,t,s;
	cin>>d>>t>>s;
	if(s*t>=d)
		cout<<"Yes";
	else
		cout<<"No";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
        solve();
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3768
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
ll X,Y ;
int ans ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  ans = 0 ; 
  cin >> X >> Y ;
  while( X <= Y){
    X = X*2 ;
    ans++;
  }
  cout << ans << endl; 
   

  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#define INF INT_MAX
using namespace std;

string n;

int main(){

	cin >> n;
	
	for (int i = 0; i < 3; i++){
		if (n[i] == '1'){
			n[i] = '9';
		}
		else if (n[i] == '9'){
			n[i] = '1';
		}
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll p=1000000000+7;
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n),b(n);
  rep(i,n){cin>>a[i];}
  rep(i,n){rep(j,n){
    if(a[i]>a[j]){b[i]++;}}}//iより小さい要素の数
  ll s=0,t=0;
  rep(i,n-1){for(ll j=i+1;j<n;j++){if(a[i]>a[j]){s++;}}}
  rep(i,n){t+=b[i];}
  cout<<(s*k%p+((k*(k-1)/2)%p)*t%p)%p<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 3223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
//#define leng length()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invp(a,p)pom(a,p-2,p)
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.fi.se>b.fi.se;
}
ll cmp2(pair<Pll,ll> a,pair<Pll,ll> b){
        return a.se<b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll n,d;cin>>n>>d;
    ll ans=0;
    for(ll i=0;i<n;i++){
        ll x,y;cin>>x>>y;
        double a = pow((double)(x*x+y*y),0.5);
        if(a<=(double)d)ans++;
    }
    cout<<ans<<Endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 4308
from heapq import heapify, heappop
from sys import stdin
def input():
    return stdin.readline().strip()

def main():
    n, k = map(int, input().split())

    dt = [(0, 0)] * n
    for i in range(n):
        t, d = map(int, input().split())
        dt[i] = (d, t-1)

    dt.sort(key=lambda x: x[0], reverse=True)

    # select k biggest points
    base = 0
    variety = [0] * n
    bonus = 0
    heap = []
    for d, t in dt[:k]:
        base += d
        if variety[t] == 0:
            bonus += 1
        variety[t] += 1
        heap.append((d, t))
    heapify(heap)

    # select exchange candidates
    new_dt = []
    for d, t in dt[k:]:
        if variety[t] == 0:
            variety[t] = 1
            new_dt.append((d, t))

    # exchange
    ans = base + bonus * bonus
    for new_d, new_t in new_dt:
        d, t = heappop(heap)
        while len(heap) > 0 and variety[t] == 1:
            d, t = heappop(heap)
        if len(heap) == 0:
            break
        variety[t] -= 1

        base -= d - new_d
        bonus += 1
        if ans < base + bonus * bonus:
            ans = base + bonus * bonus

    print(ans)

main()

Measured memory_bytes: 91572
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <ctime>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;


int main(){
	string t; cin >> t;
	rep(i,t.size()){
		if(t[i] == '?') t[i] = 'D';
	}
	cout << t << endl;
}

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

signed main(){

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

  vector<list<int>> a(n);

  while(q--){
    int com;cin>>com;
    if(com==0){
      int t,x;
      cin>>t>>x;
      a[t].push_back(x);
    }
    if(com==1){
      int t;
      cin>>t;
      for(auto itr=a[t].begin();itr!=a[t].end();++itr){
        if(itr!=a[t].begin())cout<<" ";
        cout<< *itr ;
      }
      cout<<endl;
    }
    if(com==2){
      int s,t;
      cin>>s>>t;
      a[t].splice(a[t].end(),move(a[s]));
    }
  }

}


Measured memory_bytes: 18648
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;


int main() {
	long long X;
	long long now = 100;
	int ans = 0;

	cin >> X;

	while (now < X) {
		now += now / 100;
		ans++;
	}

	cout << ans;
}

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

using pii = pair<int, int>;

struct edge {
    int to, cap, cost, rev;
};

using edges = vector<edge>;
using graph = vector<edges>;

void add_edge(graph& g, int from, int to, int cap, int cost) {
    g[from].push_back(edge{to, cap, cost, (int)g[to].size()});
    g[to].push_back(edge{from, 0, -cost, (int)g[from].size()-1});
}

int min_cost_flow(graph& g, int s, int t, int f) {
    constexpr int INF = 1e9;
    int res = 0;
    const int N = g.size();
    vector<int> h(N);
    vector<int> dist(N);
    vector<int> prevv(N), preve(N);
    while(f > 0) {
        priority_queue<pii, vector<pii>, greater<pii>> que;
        fill(dist.begin(), dist.end(), INF);
        dist[s] = 0;
        que.push(make_pair(0, s));
        while(!que.empty()) {
            pii p = que.top();
            que.pop();
            int v = p.second;
            if(dist[v] < p.first) {
                continue;
            }
            for(int i=0; i<g[v].size(); ++i) {
                edge& e = g[v][i];
                if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.push(make_pair(dist[e.to], e.to));
                }
            }
        }
        if(dist[t] == INF) {
            return -1;
        }
        for(int v=0; v<N; ++v) {
            h[v] += dist[v];
        }
        int d = f;
        for(int v=t; v!=s; v=prevv[v]) {
            d = min(d, g[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d*h[t];
        for(int v=t; v!=s; v=prevv[v]) {
            edge& e = g[prevv[v]][preve[v]];
            e.cap -= d;
            g[v][e.rev].cap += d;
        }
    }
    return res;
}

int main() {
    int N;
    while(cin >> N, N) {
        graph g(366);
        for(int i=0; i<365; ++i) {
            add_edge(g, i, i+1, 2, 0);
        }
        for(int i=0; i<N; ++i) {
            int s, t, w;
            cin >> s >> t >> w;
            add_edge(g, s-1, t, 1, -w);
        }
        cout << -min_cost_flow(g, 0, 365, 2) << endl;
    }
}


Measured memory_bytes: 3248
from itertools import permutations
n,m=map(int,input().split())
lis=[i for i in range(1,n+1)]
nm=[[] for _ in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    nm[a].append(b)
    nm[b].append(a)
count=0
for i in permutations(lis):
    if i[0]==1:
        temp=nm[1]
        for j in range(n-1):
            if not i[j+1] in set(temp):
                break
            temp=nm[i[j+1]]
        else:
            count+=1
print(count)

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	int n,k;
	cin >> n >> k;
	int h[n];
	for(auto &x : h) cin >> x;
	int dp[n];
	memset(dp,0x3f3f3f,sizeof dp);
	dp[0] = 0;
	for(int i = 0;i < n;i++){
		for(int j = max((int)0,i-k);j < i;j++){
			dp[i] = min(dp[i],dp[j] + abs(h[i]-h[j]));
		}
	}
	cout << dp[n-1] << "\n";
}

Measured memory_bytes: 5156
while True:
  hw = [int(x) for x in input().split()]
  h, w = hw[0], hw[1]

  if h == 0 and w == 0:
    break
  for hh in range(h):
    for ww in range(w):
      if hh % 2 == 0:
        if ww % 2 == 0:
          print('#', end = '')
        else:
          print('.', end = '')
      else:
        if ww % 2 == 0:
          print('.', end = '')
        else:
          print('#', end = '')
    print('')
  print('')

Measured memory_bytes: 9040
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/ICPC/Prelim/1608?year=2016

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;

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

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

        auto ans = (int) 1e9;
        for (int i = 0; i < n - 1; ++i) {
            ans = min(ans, a[i + 1] - a[i]);
        }

        cout << ans << endl;
    }

    return 0;
}

/*
 *
 */


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int A, B;
  cin >> A >> B;

  if(A>=6&&A<=12){
    cout << B/2 << endl;
  }else if(A<=5){
    cout << 0 << endl;
  }else{
    cout << B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>
#include<bitset>
#include<stack>
#include<fstream>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> lltpl;
typedef tuple<int, int, int> tpl;

int dy8[8] = { 2,2,-2,-2,1,1,-1,-1 };
int dx8[8] = { 1,-1,1,-1,2,-2,2,-2 };
int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };


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

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}

// 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 << "}"; 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; }



const int IINF = 1e9 + 7;
const ll LINF = 1e18 + 7;
constexpr ll MOD = 1e9 + 7;

//ここから書くこと




ll dp[3005];

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, t;
	cin >> n >> t;
	vector<pii> a(n), b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());

	

	dp[0] = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = t - 1; j >= 0; j--)
		{
			dp[min(j + a[i].first,t)] = max(dp[min(j + a[i].first,t)], dp[j] + a[i].second);
		}
	}

	ll maxi = 0;

	for (int i = 0; i < 3005; i++)
	{
		maxi = max(maxi, dp[i]);
	}
	cout << maxi << endl;


	return 0;
}


Measured memory_bytes: 384
n,m,nx,ny = map(int, input().split())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.sort()
y.sort()

if (x[n-1] < y[0]) and (nx < y[0]) and (x[n-1] < ny) :
   print('No War')
else :
   print('War')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;

struct st{
	ll t;
	int s;
	int d;
	
	st(){}
	st(ll t,int s,int d): t(t), s(s), d(d){}
	
	bool operator< (const st &s) const{
		return this->t < s.t;
	}
};

bool solve(){
	int n, m;
	cin>> n>> m;
	if(n==0 && m==0) return false;
	
	vector<st> vst;
	for(int i=0;i<m;i++){
		ll t; int s, d;
		cin>> t>> s>> d;
		st tmp(t,s-1,d-1);
		vst.pb(tmp);
	}
	sort(vst.begin(), vst.end());
	
	vector<bool> com(n);
	fill(com.begin(), com.end(), false);
	com[0] = true;
	for(int i=0;i<m;i++){
		if(com[vst[i].s]) com[vst[i].d] = true;
	}
	
	cout<< count(com.begin(), com.end(), true)<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[100100][3];

int main() {
    cin >> n;
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j < 3; ++j) {
            dp[i][j] = 0;
        }
    }

    vector<int> a(n, 0);
    vector<int> b(n, 0);
    vector<int> c(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }

    for(int i = 0; i < n; ++i) {
        dp[i+1][0] = a.at(i) + max(dp[i][1], dp[i][2]);
        dp[i+1][1] = b.at(i) + max(dp[i][0], dp[i][2]);
        dp[i+1][2] = c.at(i) + max(dp[i][0], dp[i][1]);
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

int solve(int n, std::vector<int>& as, std::vector<int>& bs) {
  int ans = 0;
  for(int k = 0; k < 29; k++) {
    const int T = 1 << k;
    int tmp = 0;
    std::vector<int> cs;
    for(int b: bs) {
      cs.push_back(b % (2 * T));
    }
    std::sort(cs.begin(), cs.end());
    for(int a: as) {
      a = a % (T * 2);
      int t1 = lower_bound(cs.begin(), cs.end(), T - a) - cs.begin();
      int t2 = lower_bound(cs.begin(), cs.end(), 2 * T - a) - cs.begin();
      int t3 = lower_bound(cs.begin(), cs.end(), 3 * T - a) - cs.begin();
      int t4 = n;
      tmp += ((t2 - t1) + (t4 - t3));
    }
    if ((tmp % 2) != 0) {
      ans += T;
    }
  }

  return ans;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as, bs;

  for(int i=0; i < n; i++){
    int a;
    std::cin >> a;
    as.push_back(a);
  }
  
  for(int i=0; i < n; i++){
    int b;
    std::cin >> b;
    bs.push_back(b);
  }

  std::cout << solve(n, as, bs) << std::endl;
}


Measured memory_bytes: 3680
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

def ra(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

import bisect
n=int(input())
if n==1:
    print(0)
    exit()
a=ra(factorize(n))
b=0
c=[-1]
for i in range(100):
    c.append(i+c[-1])
c.pop(0)
for i in a:
    b+=bisect.bisect_left(c,i)-1
print(b)

Measured memory_bytes: 9252
def e(n,p):
  i = 2
  ans = 1
  if p == 1:
    return n
  else:
    while i * i <= n:
      b = 0
      while n % i == 0:
        n /= i
        b += 1
      else:
        ans *= i**(b//p)
      i += 1
    return ans
  
n,p = map(int, input().split())

a = e(p,n)
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

ll n, ans = 0;

void dfs(ll x, bool a, bool b, bool c) {
  if (x > n) return;

  if (a && b && c) ++ans;
  dfs(x * 10 + 7, true, b, c);
  dfs(x * 10 + 5, a, true, c);
  dfs(x * 10 + 3, a, b, true);
}

int main() {
  cin >> n;

  dfs(0, false, false, false);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back   
#define sz(a) ((int)a.size())
#define all(a) a.begin() , a.end()
using namespace std;
typedef long long ll ; 
const ll inf = 1e18 ;
const int mod = 1e9 + 7;
const int N = 3e5 + 5; 
const int SZ = 101;
ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

const int M = 1e4 + 1;

bool can_get(vector<int>& a, int x){
    if(a.empty()) return !x;
    bitset<2 * M + 5> bt; 
    bt[M] = 1; 
    for(int& x : a)   
        bt=(bt<<x)|(bt>>x);
    return bt[x + M];
}

void solve(){
    string s; int x , y;
    cin >> s >> x >> y ;
    reverse(all(s));
    while(!s.empty() && s.back() == 'F') --x , s.pop_back();
    if(s.empty()){
        cout <<(!x && !y ? "Yes\n" : "No\n" );
        return ;
    }
    reverse(all(s));
    
    vector<int> mv[2];
    int n = sz(s) , d = 0 , cur = 0;
    for(int i = 0 ; i < n ; ++i){
        if(s[i] == 'T'){
            if(cur) mv[d].pb(cur);
            cur = 0;
            d ^= 1;
        }else cur++ ;
    }
    if(cur) mv[d].pb(cur);
    cout << ( can_get(mv[0], x) && can_get(mv[1] , y) ? "Yes\n" : "No\n" );
}

int main()
{
    ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
    int TC = 1, t = 0;
    // cin >> TC ;
    while(t++ < TC)
    {
        // cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 3692
N, M = map(int, input().split())

cities = []
prefecture_count = [0 for _ in range(N)]
result = []

for i in range(M):
    p, y = map(int, input().split())
    cities.append((i, p, y))

for c in sorted(cities, key=lambda x: x[2]):
    i, p, y = c
    prefecture_count[p-1] += 1
    count = prefecture_count[p-1]
    code = '{0:06d}{1:06d}'.format(p, count)
    result.append((i, code))

result.sort(key=lambda x: x[0])
for r in result:
    print(r[1])


Measured memory_bytes: 37572
#include<iostream>
#include<cstdio> 
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int *a=new int [n];
	for(int i=0;i<=n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n%2!=0)          
	{
		for(int i=n-1;i>=0;i-=2)
		cout<<a[i]<<" ";
		for(int i=1;i<=n-2;i+=2)
		cout<<a[i]<<" ";
	}
	else
	{
	    for(int i=n-1;i>=1;i-=2)
		cout<<a[i]<<" ";
		for(int i=0;i<=n-2;i+=2)
		cout<<a[i]<<" ";
	}
	return 0;
} 

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

using namespace std;

#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define fr(n) for(int i=n-1;i>=0;i--)
#define chlo(i,a,n) for(int i=a;i<n;i++)
#define vi vector<int>
#define vs vector<string>
#define int long long int
#define all(a) (a).begin(),(a).end()

#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define zerbits(x) __builtinctzll(x)
#define mod 1000000007
#define sz(x) (int)x.size()
#define inf 1e18
#define W(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define INT_SIZE 32
#define pr pair<int,int>
void aeh()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("aana.txt", "r", stdin);
	freopen("jj.txt", "w", stdout);
#endif
}

int32_t main()
{
	int n, k;
	cin >> n >> k;
	vi a(n);
	fi(n)
	cin >> a[i];
	int dp[n] {0}; //dp[i]would give the minimum cost to reach ith step
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < min(n, k); i++)
	{
		int mnn = INT_MAX;
		for (int j = 0; j < i; j++)
		{
			mnn = min(mnn, dp[j] + abs(a[j] - a[i]));
		}
		dp[i] = mnn;
	}
	for (int i = k; i < n; i++)
	{
		int mn = INT_MAX;
		for (int j = i - k; j < i; j++)
		{
			mn = min(mn, dp[j] + abs(a[j] - a[i]));
		}
		dp[i] = mn;
	}
	cout << dp[n - 1] << endl;

}

Measured memory_bytes: 1792
#include<stdio.h>

void trace(int A[], int N) {
    for ( int i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N) {
    int i, j, v;
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        //未ソート部の銭湯に一時変数vを代入
        A[j + 1] = v;
        trace(A, N);
    }
}
    


int main() {
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    
    //初めの状態を出力
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}


Measured memory_bytes: 2032