akhauriyash/Code-Regression huggingface dataset:
invtwos = [1]
i = 0
while abs(invtwos[i]) <= 10**10:
    invtwos.append(invtwos[i]*(-2))
    i += 1
invtwos.append(invtwos[-1]*(-2))

n = int(input())
ans = []
i = 0
while n != 0:
    if n%abs(invtwos[i+1]) != 0:
        ans.append(1)
        n -= invtwos[i]
    else:
        ans.append(0)
    i += 1
ans.reverse()

if len(ans) == 0:
    print("0")
else:
    for i in range(len(ans)):
        if i != len(ans)-1:
            print(ans[i],end="")
        else:
            print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<pair<int, int>> s;
	for( int i = 0; i < n; ++i ){
		int a, b; cin >> a >> b;
		s.emplace_back(b, a);
	}
	sort( s.begin(), s.end(), greater<pair<int, int>>() );
	int t = s[0].first;
	for( int i = 0; i < n; ++i ){
		if( s[i].first < t ) t = s[i].first;
		t -= s[i].second;
	}
	if( t >= 0 ) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) a[i] = in();
    VL dp(n, 1e18);
    dp[0] = 0;
    FOR(i,1,n-1){
        FORR(j,i-1,max(0,i-k)){
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll n;
ld p[3000];
ld dp[3000][3000];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(ll i=1; i<=n; i++){
		cin >> p[i];
	}
	dp[0][0]=1;
	for(ll i=0; i<n; i++){
		for(ll j=0; j<=n; j++){
			dp[i+1][j+1]+=dp[i][j]*p[i+1];
			dp[i+1][j]+=dp[i][j]*(1.0-p[i+1]);
		}
	}
	ld ans=0;
	for(ll i=n/2+1; i<=n; i++){
		ans+=dp[n][i];
	}
	cout << fixed << setprecision(18) << ans;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 140928
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

P channel[30];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N;

	int big = 0;
	int currentCount = 0;
	long long before = 0;
	for (int i = 0; i < N; ++i) {
		long long h;
		cin >> h;
		if (i != 0) {
			if (h <= before) {
				currentCount++;
			}
			else {
				big = max(big,currentCount);
				currentCount = 0;
			}
		}
		before = h;
	}
	big = max(big, currentCount);

	cout << big << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int a[128], i, j, k;

int main(){
  int W, Q;
  while(scanf("%d%d", &W, &Q) && W+Q){
    memset(a, -1, sizeof(a));
    char c[2];
    int id, w;
    rep(i, Q){
      scanf("%s", c);
      if(c[0] == 's'){
	scanf("%d%d", &id, &w);
	rep(j, W-w+1){
	  REP(k, j, j+w) if(a[k] != -1) break;
	  if(k == j+w) break;
	}
	if(j == W-w+1){
	  puts("impossible");
	}else{
	  printf("%d\n", j);
	  REP(k, j, j+w) a[k] = id;
	}
      }else{
	scanf("%d", &id);
	rep(j, W) if(a[j] == id) a[j] = -1;
      }
    }
    puts("END");
  }
  return 0;
}

Measured memory_bytes: 1196
#include<stdio.h>

int main()
{
    int n,m,x;
    int min = 1000;
    int sum = 0;

    scanf("%d%d", &n, &x);
    for (int i=0; n > i; i++) {
        scanf("%d", &m);
        sum += m;
        if (min > m) {
            min = m;
        }
    }
    printf("%d\n", n + (x-sum)/min);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    lint A, B;
    cin >> N >> A >> B;
    vector<lint> h(N);
    rep(i, N) cin >> h[i];
    
    int left = 0;
    int right = 1000000000;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        auto H = h;
        rep(i, N) H[i] -= B * mid;
        lint cnt = 0;
        rep(i, N) cnt += max((lint)0, (H[i] - 1 + (A - B)) / (A - B));
        if (cnt <= mid) right = mid;
        else left = mid;
    }
    cout << right << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC95();
}

void ABC95(){
    int n,x,i,ans=0;
    cin>>n>>x;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
        x-=vec[i];
        ans++;
    }
    sort(vec.begin(),vec.end());
    ans+=x/vec[0];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, l, r) for(int i = (int)l; i <= (int)r; ++i)

using namespace std;
const int Nmax = 1e5 + 11;
const int inf = 1e9 + 112;

int n, k, f[Nmax], h[Nmax];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    FOR(i, 1, n) {
        cin >> h[i];
    }
    FOR(i, 2, n) {
        f[i] = inf;
        FOR(j, i - k, i) {
            if (j < 1) continue;
            f[i] = min(f[i], f[j] + abs(h[j] - h[i]));
        }
    }
    cout << f[n];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;

P f(int x) {
	int a = x % 10;
	int b = 0;
	while (x) {
		b = x;
		x /= 10;
	}
	return P(a, b);
}

int main() {
	int n; cin >> n;
	map<P, int> cnt;
	REP(i, n) {
		P p = f(i + 1);
		cnt[p]++;
	}
	int res = 0;
	REP(i, n) {
		P p = f(i + 1);
		P q(p.second, p.first);
		res += cnt[q];
	}
	cout << res << '\n';
	return 0;
}


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

#include <string>
void _150() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << endl;
}

void _151() {
    int n, k, m;
    cin >> n >> k >> m;
    int a[100];
    int goal = m * n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a[i];
        goal -= a[i];
    }

    if (goal > k) {
        cout << -1 << endl;
    } else {
        cout << max(goal, 0) << endl;
    }
}

void _152() {
    int a, b;
    cin >> a >> b;

    string result("");
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            result += to_string(a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            result += to_string(b);
        }
    }
    cout << result << endl;
}

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int x;
  cin >> x;
  int k = 1;
  for(int i=1;i<=360;i++){
  	if((i * x )%360 == 0){
    	cout << i;
      return 0;
    }
  }
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <math.h>
#include <tgmath.h>

using namespace std;
int main() {
    int x,a,b,r,p;
    cin>>x;
    cin>>a;
    cin>>b;

    r = sqrt((x-a)*(x-a));
    p = sqrt((x-b)*(x-b));

    if(r>p){
        cout<<"B"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }
    

    return 0;
}

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

int main() {
  int x; cin>>x;
  if(x<1200){
  cout << "ABC" << endl;}
  else if(1200<=x&&x<2800){
  cout << "ARC" << endl;}
  else{
  cout << "AGC" << endl;}
}


Measured memory_bytes: 256
from collections import*
h,*t=open(0)
h,w=map(int,h.split())
f=o=0
for i in Counter(''.join(t)).values():f+=i//4;o+=i&1
print('YNeos'[o-h%2>h*w%2or f-h//4<h//2*(w//2)::2])

Measured memory_bytes: 3316
// AOJ GRL_7_A
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;


// ????£???????????????????(Ford-Fulkerson???)
class Flow_min{
	public:
		int N;	// ????????°
		vector<vc> F, C, edge;	// F:????????°?????? C:???????????? edge:??£??\????????????
		vc bf;	// ??????????????£???????????????

		// ????????????????????? n:????????°
		Flow_min(int n): N(n), F(n,vc(n)), C(n,vc(n)), edge(n) {}

		// f->t????????????c?????????????????????(??????f->t??????????????????????????????????????¨?????????)
		void addEdge(int f, int t, int c){
			F[f][t] = C[f][t] = c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// ?¢?????????????DFS??§??¢???
		int dfs(int n, int c, int T){
			int f = c * (n==T);
			bf[n] = 1;
			for(int v: edge[n]) if( !f && F[n][v] && !bf[v] ){
				f = dfs(v, min(c, F[n][v]), T);
				F[n][v] -= f;
				F[v][n] += f;
			}
			return f;
		}

		// ???????????????(S,T?????°?????????)
		void maxFlow(int S, int T){
			while( bf.assign(N,0), dfs(S, INF, T) ){}
		}

		// ??????????????????????????????????????????
		int flow(int f, int t){ return C[f][t] - F[f][t]; }

		// ??£??\?????????????????????????¨???????????????????n=S,T??\????????´?????????????????????1/2????????????????????????????????????
		int flow(int n){
			int ret=0;
			for(int v: edge[n]) ret += abs( C[n][v] - F[n][v] );
			return ret;
		}

		// ??°???????????????????????????
		void reset(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int X, Y, E;
	cin >> X >> Y >> E;
	int S = X+Y;
	int T = S+1;

	Flow_min fm(T+1);
	rep(i, E){
		int x, y;
		cin >> x >> y;
		fm.addEdge( x, X+y, 1 );
	}
	rep(i,X) fm.addEdge( S, i, 1 );
	rep(i,Y) fm.addEdge( X+i, T, 1 );

	fm.maxFlow(S, T);
	cout << fm.flow(T) << endl;

	return 0;
}

Measured memory_bytes: 3428
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
vector<char> G[MAX_N];
map<vector<char>, ll> D;

void solve() {
	cin >> N;
	rep(i, 0, N) {
		G[i].resize(10);
		rep(j, 0, 10) cin >> G[i][j];
		sort(all(G[i]));
		D[G[i]]++;
	}
	ll res = 0;
	for(auto& p: D) {
		// debug(p);
		res += p.sec * (p.sec - 1) / 2;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

#define ll long long int

int main(){
    int n;
    cin>>n;
    ll a[n+1],b[n];
    for(int i=0;i<=n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    ll c = 0;
    for(int i=0;i<n;i++){
        if(a[i] >= b[i]){
            c += b[i];
            a[i] = a[i]-b[i];
            b[i] = 0;
        }
        else{
            c += a[i];
            b[i] = b[i] - a[i];
            a[i] = 0;
        }
        if(a[i+1] >= b[i]){
            c += b[i];
            a[i+1] = a[i+1]-b[i];
            b[i] = 0;
        }
        else{
            c += a[i+1];
            b[i] = b[i] - a[i+1];
            a[i+1] = 0;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        String s = sc.next();
        for (int i = 0; i < 4; i++) {
            if (s.charAt(i) == '+') {
                ans++;
            } else {
                ans--;
            }
        }
        System.out.println(ans);
    }
}




Measured memory_bytes: 23380
import sys
input = sys.stdin.readline
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]

N,M=map(int,input().split())
A=[]
B=[]
for i in range(M):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

ans=[None]*M
ans[M-1]=N*(N-1)//2
uf=UnionFind(N)
for i in range(M-1,0,-1):
    x,y=A[i]-1,B[i]-1
    if uf.is_same(x,y):
        ans[i-1]=ans[i]
    else:
        ans[i-1]=ans[i]-(uf.get_size(x)*uf.get_size(y))
    uf.union(x,y)
for a in ans:
    print(a)


Measured memory_bytes: 103132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
map<ll, ll> mp;
// メモ化再帰について触れたことがなかったけど難しい
ll dp(ll n, ll a, ll b, ll c, ll d) {
	if (n == 0) return 0;
	if (n == 1) return d;
	if (mp.find(n) != mp.end()) return mp[n];
	// floorとceilを考える
	ll c2 = (2 - n % 2) % 2;
	ll c3 = (3 - n % 3) % 3;
	ll c5 = (5 - n % 5) % 5;
	ll f2 = 2 - c2 % 2;
	ll f3 = 3 - c3 % 3;
	ll f5 = 5 - c5 % 5;
	ll res = (d < 2 * UPPER / n) ? d * n : 2 * UPPER; // ここから操作dのみ行ったときのコストか2*10^18の小さいほう
	chmin(res, dp(n / 2, a, b, c, d) + a + f2 * d);
	chmin(res, dp((n + 1) / 2, a, b, c, d) + a + c2 * d);
	chmin(res, dp(n / 3, a, b, c, d) + b + f3 * d);
	chmin(res, dp((n + 2) / 3, a, b, c, d) + b + c3 * d);
	chmin(res, dp(n / 5, a, b, c, d) + c + f5 * d);
	chmin(res, dp((n + 4) / 5, a, b, c, d) + c + c5 * d);
	mp[n] = res;
	return mp[n];
}
void solve() {
	mp.clear();
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	cout << dp(n, a, b, c, d) << endl;

}
int main() {
	int t;
	cin >> t;
	rep(qqq, t) {
		solve();
	}
	return 0;
}

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

typedef long long ll;
const int maxn=200010;
int n;
ll ans, c[maxn];
char s[maxn];
vector<int> g[30];
int p[maxn], cnt[30], cc[30];

int lowbit(int x){ return x&(-x); }
void add(int x){ while(x<maxn){ c[x]++; x+=lowbit(x); } }
ll sum(int x){
	int ret=0;
	while(x){ ret+=c[x]; x-=lowbit(x); }
	return ret;
}

int main(){

	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;i++) g[ s[i]-'a' ].push_back(i);
	int tot=0, k=0;
	for(int i=0;i<26;i++) if(g[i].size()&1) tot++, k=i;
	if(tot>1){ puts("-1"); return 0; }
	// for(int i=0;i<26;i++) if(g[i].size()) printf("%d %d\n", i, g[i].size());
	for(int i=0;i<26;i++) cc[i]=g[i].size();
	int st=0;
	for(int i=1;i<=n;i++){
		int now=s[i]-'a';
		if((++cnt[now])*2<=cc[now]){
			// printf("%d %d\n", i, st+1);
			p[i]=++st; p[g[now].back()]=n+1-st; g[now].pop_back();
		}else if(cnt[now]*2==cc[now]+1){
			p[i]=(n+1)>>1;
		}
		// printf("s = %c %d %d\n", s[i], cnt[now], (int)g[now].size());
	}
	// for(int i=1;i<=n;i++) printf("%d ",p[i]); puts("");
	for(int i=1;i<=n;i++){
		ans+=i-1-sum(p[i]-1); add(p[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3832
<?php
fscanf(STDIN, "%d", $N);
$arr = array();
for ($n=0;$n<$N;$n++){
    fscanf(STDIN, "%d", $tmp);
    #var_dump($tmp);
    if (!in_array($tmp, $arr)){
        $arr[] = $tmp;
    }
}
#var_dump($arr);
echo count($arr);

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

using i64 = long long int;

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int main(){
    i64 a, b, x, y;
    cin >> a >> b;
    extgcd(a, b, x, y);
    cout << x << " " << y << endl;

    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    while(m--){
        int a;
        cin>>a;
        sum+=a;
    }
    int ans=n-sum;
    if(ans>=0){
    cout<<ans<<endl;}
    else{
        cout<<"-1"<<endl;
    }

}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n=100'000;
    std::vector<lint>sieve(n+1);
    for(lint p=2;p*p<=n;p++){
        if(sieve.at(p))continue;
        for(lint i=p*p;i<=n;i+=p)sieve.at(i)=true;
    }
    std::vector<lint>a(n+1);
    for(lint i=2;i<=n;i++){
        a.at(i)=a.at(i-1)+(!sieve.at(i)&&(i+1)%2==0&&!sieve.at((i+1)/2));
    }
    lint q;std::cin>>q;
    while(q--){
        lint l,r;std::cin>>l>>r;
        std::cout<<a.at(r)-a.at(l-1)<<'\n';
    }
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
   int a, b, c, d; cin >> a >> b >> c >> d;
   if(a+b<c+d)cout << "Right" << ln;
   else if(a+b>c+d) cout << "Left" << ln;
   else cout << "Balanced" << ln;
}


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


struct State {
	int id;
	int c;
	int cost;
	State(int aa, int bb, int cc) {
		id = aa;
		c = bb;
		cost = cc;
	}
  bool operator<( const State& right ) const {
        return cost > right.cost;
  }
};

struct Edge {
	long long to;
	int cost;
	Edge(long long a, int b) {
		to = a;
		cost = b;
	}
};

struct Data {
	int id;
	int c;
	int cost;
	bool visit;
	vector<Edge> next;
	Data(int a = -1, int b = -1, int cc = 2 << 28) {
		id = a;
		c = b;
		cost = cc;
		visit = false;
		next.reserve(10);
	}

  bool operator<( const Data& right ) const {
        return cost < right.cost;
  }
};


int main() {
	std::ios::sync_with_stdio(false);
  std::cin.tie(0);
	std::unordered_map<long long,Data> Map;
	long long PP = 1000005;
	int INF = 2 << 28;
	int N,M;
  cin >> N >> M;
	int p[M];
  int q[M];
  int c[M];
	for(int i = 0; i < M; i++) {
		cin >> p[i] >> q[i] >> c[i];
	}
	for(int i = 1; i <= N; i++) {
		Map[i * PP - 1] = Data(i,-1);
	}
	for(int I = 0; I < M; I++) {
		int P = p[I];
		int Q = q[I];
		int C = c[I];
		long long PPP = P * PP;
		long long QQQ = Q * PP;
		if(Map.find(PPP + C) == Map.end()) {
			Data tmp = Data(P,C);
			tmp.next.push_back(Edge(PPP - 1, 0));
			Map[PPP + C] = tmp;
			Map[PPP - 1].next.push_back(Edge(PPP + C,1));
		}
		if(Map.find(QQQ + C) == Map.end()) {
			Data tmp = Data(Q,C);
			tmp.next.push_back(Edge(QQQ - 1, 0));
			Map[QQQ + C] =  tmp;
			Map[QQQ - 1].next.push_back(Edge(QQQ + C,1));
		}
		Map[PPP + C].next.push_back(Edge(QQQ + C, 0));
		Map[QQQ + C].next.push_back(Edge(PPP + C, 0));

	}
	priority_queue<State> Q;
	Q.push(State(1,-1,0));
	while(!Q.empty()) {
		State pp = Q.top();
		Q.pop();
		if(pp.id == N) {
			Map[N * PP - 1].cost = pp.cost;
			break;
		}
		Data *nn =  &Map[pp.id * PP + pp.c];
		if(nn->visit) continue;
		nn->visit = true;

		int pns = nn->next.size();
		for(int i = 0; i < pns; i++) {
			Edge next = nn->next.at(i);
			Data *nextD = &Map[next.to];
			if(nextD->cost <= pp.cost + next.cost) continue;
			State st = State(nextD->id,nextD->c,pp.cost + next.cost);
			nextD->cost = pp.cost + next.cost;
			Q.push(st);
		}
	}
	Data goal = Map[N * PP - 1];
	if(goal.cost == INF) {
    cout << -1 << endl;
	}
	else {
		cout << goal.cost << endl;
	}
}


Measured memory_bytes: 128500
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
lo a,b,d,e,x,y,n,p,m,t,a1[500005],a2[500000],c;
lo k;
string s1,s2,s3;
queue <pair<lo,lo> > q;
priority_queue <lo> pq;
map <string,lo> mp1;
vector <lo> v;
lo vis[100000];
lo top;
set <string> stt;
int main(){
	// atcoder contest
	// freopen("gir.gir","r",stdin);
	// freopen("cik.cik","w",stdout);
	cin >> n;
	lo mx = -1;
	for(lo i = 0 ; i < n ; i++){
		cin >> s1;
		stt.insert(s1);
		mp1[s1]++;
		mx = max(mx, mp1[s1]);
	}
	for(set <string>::iterator it = stt.begin() ; it != stt.end() ; it++){
		s1 = *it;
		if(mp1[s1] == mx){
			cout << s1 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 34560
#include<stdio.h>

int main()
{
    int x1,x2,x3,x4,x5;
    scanf("%d",&x1);
    scanf("%d",&x2);
    scanf("%d",&x3);
    scanf("%d",&x4);
    scanf("%d",&x5);
    if(x1==0){
        printf("%d",1);
    }
    else if(x2==0){
        printf("%d",2);
    }
    else if(x3==0){
        printf("%d",3);
    }
    else if(x4==0){
        printf("%d",4);
    }
    else if(x5==0){
        printf("%d",5);
    }
    return(0);
}



Measured memory_bytes: 1704
<?php
 fscanf(STDIN,"%d",$n);
 fscanf(STDIN,"%s",$s);
 $c=1;
 for($i=0;$i<$n-1;$i++){
  if($s[$i] != $s[$i+1]){
    $c++;
  }
 }

echo $c;

Measured memory_bytes: 4728
N,M=map(int,input().split())
if M>=1:
    s=[0]*M
    c=[0]*M
    for i  in range(M):
      s[i],c[i]=map(int,input().split())

    a=0
    for i in range(M-1):
       for j in range(i+1,M):
        if s[i]==s[j] and c[i]!=c[j]:
          a+=1
    if a==0:
      u_=[0,0,0]
      for i in range(M):
        u_[s[i]-1]=c[i]
      if max(s)!=3 and N==2:
        if min(s)!=1 and u_[0]==0:
          print(10+u_[1])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(u_[0]*10+u_[1])
      elif N==3:
        if min(s)!=1 and u_[0]==0:
          print(100+u_[1]*10+u_[2])
        elif min(s)==1 and u_[0]==0:
          print(-1)
        else:
          print(100*u_[0]+10*u_[1]+u_[2])
      elif N==1 and max(s)==1 and min(s)==1:
        print(c[0])
      else:
        print(-1)
    else:
      print(-1)
else:
  if N==1:
    print(0)
  else:
      print(10**(N-1))
      

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int n=Readint()[0];
    string s=ReadLine();
    string alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int x=0;
    string res="";
    for(int i=0;i<s.Length;i++){
      x=(alp.IndexOf(s.Substring(i,1))+n) % 26;
      res+=alp.Substring(x,1);
    }
    WriteLine(res);
  }

  int[] Readint(){
    string[] s = ReadLine().Split();
    int[] res=new int[s.Length];
    Parallel.For(0,s.Length,i=>{
      res[i]=int.Parse(s[i]);
    });
    return res;
  }
}

Measured memory_bytes: 37568
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
s = ns()

if s.count('R') > s.count('B'):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
from collections import Counter


def solve(string):
    n, *aqbc = map(int, string.split())
    a, _, bc = aqbc[:n], aqbc[n], aqbc[n + 1:]
    s = sum(a)
    t = Counter(a)
    ans = []
    for b, c in zip(*[iter(bc)] * 2):
        s += (c - b) * t[b]
        t[c] += t[b]
        t[b] = 0
        ans.append(s)
    return "\n".join(map(str, ans))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 44224
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> w(n);
    for (int i=0; i<n; ++i) cin >> w[i];
    int ans = 1e9;
    vector<int> sum(n+1);
    sum[0] = 0;
    for (int i=0; i<n; ++i) sum[i + 1] = sum[i] + w[i];
    for (int i=1; i<=n; ++i) ans = min(ans, abs(sum[n] - 2 * sum[i]));
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	private boolean adjMatrix[][];
    private int numVertices;

    public Main(int numVertices) {
        this.numVertices = numVertices;
        adjMatrix = new boolean[numVertices][numVertices];
  }

    public void addEdge(int i, int j) {
              adjMatrix[i][j] = true;
  }

  public String toString() {
      StringBuilder s = new StringBuilder();
      for (int i = 0; i < numVertices; i++) {
          //s.append((i) + ": ");
    	  int k = 0;
          for (boolean j : adjMatrix[i]) {
        	  
        	  if( k == adjMatrix[i].length-1 )
        		  s.append((j?1:0) + "\n");
        	  else
        		  s.append((j?1:0) + " ");
        	  k++;
          }
          //s.append("\n");
      }
      return s.toString();
  }
  public static void main(String args[]) {
      
    //              ArrayList<Integer> kValues = new ArrayList<>();
  	// input:
  	Scanner in = new Scanner(System.in);
  	String input = in.nextLine();
  	String[] nVals = input.split("\\s");
  	int n = Integer.parseInt(nVals[0]);
  	Main graph = new Main(n);
  	// var n to give number of following lines
  	for(int i = 0; i < n; i++) {
  		// each line has:
  		String line = in.nextLine();
  		String[] info = line.split("\\s");
  		// var u to tell vertex ID
  		int u = Integer.parseInt(info[0]);
  		// var k to tell how many values follow to place
  		int k = Integer.parseInt(info[1]);
  		// take in k number of values
  		for(int j = 0; j < k; j++) {
  			// mess with the k values
  			int kVal = Integer.parseInt(info[j+2]);
  			graph.addEdge(u - 1, kVal - 1);
  		}
  	}
  	System.out.print(graph.toString());
  	
  	
  }
}


Measured memory_bytes: 28956
# -*- coding: utf-8 -*-
"""
A - Something on It
https://beta.atcoder.jp/contests/abc095/tasks/abc095_a

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    ans = 700
    S = input().strip()
    ans += S.count('o') * 100
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
int C[2666];
int nC[2666];
void solve(istream& cin, ostream& cout) {
	string S;
	cin >> S;
	int n = S.size();
	int cmod = 0;
	int tenmod = 1;
	int posledni = n-1;
	int sum = 0;
	ll ans = 0;
	for(int prvni = posledni; prvni >= 0; prvni--) {
		sum = (sum+((tenmod*(S[prvni]-'0'))%2019))%2019;
		C[sum]++;
		tenmod = (10*tenmod)%2019;
//		cout << sum << endl;
	}
	ans += C[0];
//	cout << "Adding " << cnt[0] <<endl;
	for(int k = 0; k < n-1; k++) {
		REP(i, 2019) nC[i] = 0;
		int sub = (-(S[n-k-1]-'0')+2019)%2019;
		REP(i, 2019) {
			int newZb = (i+sub)%2019;
			newZb = (newZb*202)%2019;
			nC[newZb] += C[i];
		}
		REP(i, 2019) C[i]= nC[i];
		C[0]--;
		ans += C[0];
//		cout << "Adding " << cnt[0] <<endl;
	}
	cout <<ans<<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3344
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
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*b/gcd(a,b);}
int main()
{
	fast();
	ll a,b;
	cin>>a>>b;
	cout<<lcm(a,b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
	int n;
	double d;
	cin >> n >> d;
	int cnt=0;
	for(int i=0;i<n;++i){
		double x,y;cin >>x>>y;
		double r = sqrt(x*x + y*y);
		if(r<=d) ++cnt;
	}
	cout << cnt << endl;
  return 0;
}


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

int32_t main()
{
	int nn;
	cin >> nn;
	string ss;
	cin >> ss;
	int rr = 0, w = 0, ty, temp = 0;
	for (int i = 0; i < nn; i++)
	{

		if (ss[i] == 'W')
		{
			w++;
		}
		else
		{
			rr++;
		}
	}
	for (int i = nn - 1; i >= nn - w; i--)
	{
		if (ss[i] == 'W')
		{
			temp++;
		}
	}
	ty = abs(w - temp);
	cout << ty;
	return 0;
}

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

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
  ;
  int i;
  cin >> i;
  cout<<a[i-1]<<endl;
  return 0;
}

  

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/numeric>
using namespace std;
using namespace __gnu_cxx;
#define ll unsigned long long int
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);


   int n ;
   cin >> n ;
   cout << power(n,3)<<endl;
    return 0;
}


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

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

  bool can = true;

  if(s[0] == s[1]) can = false;
  else if (s[1] == s[2]) can = false;
  else if (s[2] == s[3]) can = false;

  if(can) cout << "Good" << endl;
  else cout << "Bad" << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
data = [0] * n
cnt = [1] * n
data[0] = 1
for i in range(m):
    x, y = [int(i) for i in input().split()]
    if data[x-1] == 1: data[y-1] = 1
    if cnt[x-1] == 1: data[x-1] = 0
    cnt[x-1] -= 1
    cnt[y-1] += 1
print(data.count(1))

Measured memory_bytes: 10376
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double dot(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

double cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

double cross0(const Point &P0, const Point &P1)
{
	return (P0.x * P1.y) - (P1.x * P0.y);
}

double onenorm(const Vector &v)
{
    return abs(v.vx) + abs(v.vy);
}

double norm(const Vector &v)
{
	return sqrt(v.vx * v.vx + v.vy * v.vy);
}

int ccw(const Point &P0, const Point &P1, const Point &P2)
{
    Vector V1 = set_v(P0, P1);
    Vector V2 = set_v(P0, P2);
    double c = cross(V1, V2);
    if(c > 0){ return 1; }else if(c < 0){ return -1; }
    if(dot(V1, V2) < 0){ return -2; }
    if(onenorm(V1) < onenorm(V2)){ return 2; }
    return 0;
}

int intersect(const Point &P0, const Point &P1, const Point &P2, const Point &P3)
{
    if(ccw(P0, P1, P2) * ccw(P0, P1, P3) <= 0 && ccw(P2, P3, P0) * ccw(P2, P3, P1) <= 0){
        return 1;
    }else{
        return 0;
    }
}

double dist_seg(const Point &P0, const Point &P1, const Point &P2) // Segment P0P1 & Point P2.
{
    Vector V01 = set_v(P0, P1), V12 = set_v(P1, P2), V02 = set_v(P0, P2);
    if(dot(V01, V12) > 0) return norm(V12);
    if(dot(V01, V02) < 0) return norm(V02);
    double c_sum;
    c_sum = cross0(P0, P1) + cross0(P1, P2) + cross0(P2, P0);
    if(c_sum < 0) c_sum *= -1.0;
    return c_sum / norm(V01);
}

int main()
{
    int n;
    double x, y, u1, u2, v1, v2;
    Point P0, P1, P2;
    Vector U, V;
    scanf("%d", &n);

    double sum = 0;
    scanf("%lf %lf %lf %lf", &x, &y, &u1, &u2);
    P0 = set_p(x, y);
    P1 = set_p(u1, u2);
    U = set_v(P0, P1);
    for(int i = 2; i < n; i++){
        scanf("%lf %lf", &v1, &v2);
        P2 = set_p(v1, v2);
        V = set_v(P0, P2);
        sum += 0.5 * cross(U, V);
        U = V;
    }
    if(sum > 0){ printf("%.1f\n", sum); }else{ printf("%.1f\n", (-1.0) * sum); }

    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll A, B;
    cin >> A >> B;
    vector<ll> X(40, 0);
    FOR(i, 0, 39+1) {
        ll p = pow(2, i + 1);
        ll m = B % p;
        X[i] = (m >= p/2) ? m - p/2 + 1 : 0;
        X[i] += B / p * (p / 2);
    }
    FOR(i, 0, 39+1) {
        ll p = pow(2, i + 1);
        ll m = (A-1) % p;
        X[i] -= (m >= p/2) ? m - p/2 + 1 : 0;
        X[i] -= (A-1) / p * (p / 2);
        X[i] = X[i] % 2 == 0 ? 0 : 1;
    }
    ll ans = 0;
    REP(i, 39+1) {
        ans |= X[i] << i;
    }
    cout << ans << LF;

    return 0;
}


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

ll ff(ll x)
{
	return x*x*x*x*x;
}

int main()
{
	ll x;
	cin >> x;
	for(ll i = 0;i<(1<<13);i++)
	{
		for(ll j=0;j<(1<<13);j++)
		{
			if(ff(i)-ff(j)==x)
			{
				cout<<i<<' '<<j<<endl;
				return 0;
			}
			if(ff(i)-ff(-j)==x)
			{
				cout<<i<<' '<<-j<<endl;
				return 0;
			}
			if(ff(-i)-ff(j)==x)
			{
				cout<<-i<<' '<<j<<endl;
				
				return 0;
			}
			if(ff(-i)-ff(-j)==x)
			{
				cout<<-i<<' '<<-j<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3592
// Oh boi here we go again
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pi pair < int, int >
#define pii pair < int, pi >
#define next next123
#define left left123

const int N = 1e5 + 7;
const int INF = 1e9 + 7;

pi seg[N];
int n, ans;
pi x, y;

vector < pi > lr;

int inter (int i, int j){
    return max(0, lr[i].sc - lr[j].fr + 1);
}

void brute (int k){
    pi x, y;
    x = {INF, 0};
    y = {0, 0};
    for (int i = 1; i <= n; i++){
        if (i == k)
            continue;
        if (x.fr > seg[i].sc)
            x = {seg[i].sc, i};
        if (y.fr < seg[i].fr)
            y = {seg[i].fr, i};
    }
    ans = max(ans, seg[k].sc - seg[k].fr + 1 + max(x.fr - y.fr + 1, 0));
}

main(){
    cin >> n;
    for (int i = 1; i <= n; i++)
        scanf("%d%d", &seg[i].fr, &seg[i].sc);
    sort(seg + 1, seg + n + 1);
    stack < int > st;
    x = {INF, 0};
    int mn = INF, mx = 0;
    for (int i = 1; i <= n; i++){
        while (!st.empty() && seg[st.top()].fr <= seg[i].fr && seg[i].sc <= seg[st.top()].sc)
            st.pop();
        st.push(i);
        mn = min(mn, seg[i].sc - seg[i].fr + 1);
        mx = max(mx, seg[i].sc - seg[i].fr + 1);
        if (x.fr > seg[i].sc)
            x = {seg[i].sc, i};
        if (y.fr < seg[i].fr)
            y = {seg[i].fr, i};
    }
    for (int i = 1; i <= n; i++)
        if (i != x.sc && i != y.sc)
            ans = max(ans, max(x.fr - y.fr + 1, 0) + seg[i].sc - seg[i].fr + 1);
    brute(x.sc);
    brute(y.sc);
    if (st.size() == 1){
        cout << mn + mx;
        return 0;
    }
    while (!st.empty()){
        lr.pb(seg[st.top()]);
        st.pop();
    }
    sort(all(lr));
    for (int i = 0; i < lr.size() - 1; i++)
        ans = max(ans, inter(0, i) + inter(i + 1, lr.size() - 1));
    cout << ans;
}


Measured memory_bytes: 2488
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <random>
using namespace std;
typedef long long ll;


int main()
{
	double d, t, s;
	cin >> d >> t >> s;
	double ans = d / t;
	if (ans <= s)cout << "Yes";
	else cout << "No";
}

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

int main(){
	int n,m;
	cin >> n >>m;
	
	int data[n];
	
	double sum=0;
	for(int i = 0; i < n ;i ++){
		cin >> data[i];
		sum+=data[i];
	}
	sum/=(4*m);
	for(int i = 0; i < n; i++)
		if(data[i] >= sum) 
			m--;
	
	cout << ((m > 0) ? "No" : "Yes");
		
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define fo(i,n) for(int i=1;i<=n;i++)
#define fo1(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

int main()
{
	//fast;
    int t=1;
    //cin>>t;
    while(t--)
	{
		int n;
		cin>>n;
		int a[n+1];
		for(int i=1;i<=n;i++)
			cin>>a[i];
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			if((i*i)%2!=0 && a[i]%2!=0)
				cnt++;
		}
		cout<<cnt<<"\n";
	}
}


Measured memory_bytes: 3476
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
ll power(ll a, ll n) {ll p = 1; while (n > 0) {if (n % 2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1; while (n > 0) {if (n % 2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
	ll temp;
	for (ll i = 0; i < n ; i++)
	{
		cin >> temp;
		v.pb(temp);
	}
	return v;
}

bool fun(ll d, ll x, ll y) {
	ll inside = (x*x) + (y*y);
	if((long double)sqrt(inside) <= (long double)d) {
		return true;
	}
	return false;
}
void solve() {
	ll n,d;
	cin>>n>>d;
	ll ans = 0;
	while(n--){
		ll x,y;
		cin>>x>>y;
		if(fun(d,x,y)) {ans++;}
	}
	cout<<ans<<endl;
}

int main() {
	FAST
// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output.txt", "w", stdout);
// #endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3644