akhauriyash/Code-Regression huggingface dataset:
fun main() {
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val h = readLine()?.split(" ")?.map(String::toInt) ?: return
    val g = Array(n) { true }
    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        val aa = h[a - 1]
        val bb = h[b - 1]
        if (aa == bb) {
            g[a - 1] = false
            g[b - 1] = false
        }
        if (aa > bb) {
            g[b - 1] = false
        } else {
            g[a - 1] = false
        }
    }
    println(g.count { it }.toString())
}


Measured memory_bytes: 71024
char S[12];
char out[2<<20],*p=out;
int Slen;
main()
{
	int N,K;
	scanf("%d%d ",&N,&K);
	gets(S);
	Slen=strlen(S);
	S[Slen++]='\n';
	for(int i=0;i<K;i++)
	{
		memcpy(p,S,Slen);
		p+=Slen;
	}
	for(int i=K;i<N;i++)
	{
		*p++='7';
		*p++='\n';
	}
	write(1,out,p-out);
}

Measured memory_bytes: 2304
(defun create-data ()
  (let* ((h (read))
        (n (read))
        (a (make-array n)))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (values h n a)))

(defun common-raccoon-vs-monster (h n a)
  (loop for i below n
        do (setf h (- h (aref a i)))
        if (>= 0 h)
        do (return))
  (if (>= 0 h)
      "Yes"
      "No")) 

(multiple-value-bind (h n a) (create-data)
  (format t "~A~%" (common-raccoon-vs-monster h n a)))



Measured memory_bytes: 57704
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    X=input()
    cunt=0
    cunt_s=0
    for x in X:
        if x=='S':
            cunt_s+=1
        elif cunt_s>0:
            cunt_s-=1
        else:
            cunt+=1
    print(cunt+cunt_s)

if __name__=='__main__':
    main()

Measured memory_bytes: 3752
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n, d;
  cin >> n >> d;
  vector<vector<int>> in(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> in[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int x = 0;
      for (int k = 0; k < d; k++) {
        x += (in[i][k] - in[j][k]) * (in[i][k] - in[j][k]);
      }
      int y = sqrt(x);
      for (int k = y - 1; k <= y + 1; k++) {
        if (k * k == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <queue>
#include <cstdlib>
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 QCLR(q) while(!q.empty()) q.pop();

int dx[]={0,0,-1,1,-1,1};
int dy[]={-1,1,0,-1,1,0};

int N,K,rx[100],ry[100],gx,gy;

class Hex
{
public:
	int px[8], py[8];
	Hex(int tpx[8], int tpy[8])
	{
		REP(i,N) 
		{
			px[i]=tpx[i];
			py[i]=tpy[i];
		}
	}

	bool operator<(const Hex& h) const
	{
		REP(i,N)
		{
			if(px[i]!=h.px[i]) return px[i]<h.px[i];
			if(py[i]!=h.py[i]) return py[i]<h.py[i];
		}
		return false;
	}
};

class State
{
public:
	Hex h;
	int c;
	State(Hex h, int c)
	:h(h),c(c)
	{}
};

set<Hex> s;
queue<State> q;

int dist60(int x1, int y1, int x2, int y2)
{
	return (abs(x1-x2)+abs(y1-y2)+abs((x1+y1)-(x2+y2)))/2;
}

bool crash(Hex& h, int p)
{
	REP(i,K) if(h.px[p]==rx[i]&&h.py[p]==ry[i]) return true;
	
	return false;
}

bool connect(Hex& h, int j)
{
	REP(i,j)
	{
		if(h.px[i]==h.px[j]&&h.py[i]==h.py[j]) return false;
		
		int cnt=0;
		REP(k,6)
		{
			int tx=h.px[i]+dx[k], ty=h.py[i]+dy[k];
			if(h.px[j]==tx&&h.py[j]==ty) 
			{
				cnt++;
				break;
			}
		}
		
		if(abs(i-j)==1&&cnt!=1) return false;
		if(abs(i-j)!=1&&cnt==1) return false;
	}
	
	return true;
}

bool create(int p, Hex& h, int c, bool sk)
{
	if(p==N) 
	{
		if(!s.count(h)) 
		{
			s.insert(h);
			q.push(State(h,c+1));
			return true;
		}
		return false;
	}
	
	int cnt=0;
	if(connect(h,p)) create(p+1,h,c,false);
	if(!sk)
	{
		REP(i,6)
		{	
			h.px[p]+=dx[i], h.py[p]+=dy[i];
			if(crash(h,p) || !connect(h,p))
			{
				h.px[p]-=dx[i], h.py[p]-=dy[i];
				continue;
			}
			
			if(create(p+1,h,c,true)) cnt++;
			h.px[p]-=dx[i], h.py[p]-=dy[i];
			
			if(p==0||p==N-1) { if(cnt==2) break; }
			else { if(cnt==1) break; }
		}
	}
	
	return false;
}

int bfs(int ix[8], int iy[8])
{
	q.push(State(Hex(ix,iy), 0));

	while(1)
	{
		State s=q.front(); q.pop();
		if(s.h.px[0]==gx&&s.h.py[0]==gy) return s.c;
		int dist=dist60(gx,gy,s.h.px[0],s.h.py[0]);
		//if(dist>=1) dist+=(dist-1)*1.5;
		if(dist> 20-s.c) continue;
		if(dist60(gx,gy,s.h.px[0],s.h.py[0]) > 20-s.c) continue;
		create(0,s.h,s.c,false);
	}
	
	return 0;
}
int main()
{
	while(scanf("%d", &N),N)
	{
		QCLR(q);
		s.clear();
		int px[8], py[8];
		REP(i,N) scanf("%d %d", &px[i], &py[i]);
		
		scanf("%d", &K);
		REP(i,K) scanf("%d %d", &rx[i], &ry[i]);

		scanf("%d%d", &gx,&gy);
		printf("%d\n", bfs(px,py));
	}
}

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

int main() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    vector<vector<int64_t>> row(n, vector<int64_t>(n));
    vector<vector<int64_t>> col(n, vector<int64_t>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (i != j) cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= 0; --j) {
            row[i][j] = a[i][j];
            if (j + 1 < n) row[i][j] += row[i][j + 1];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= 0; --j) {
            col[i][j] = a[j][i];
            if (j + 1 < n) col[i][j] += col[i][j + 1];
        }
    }
    constexpr int64_t kInf = 1'000'000'000'000'000'000;
    vector<vector<int64_t>> dp(n, vector<int64_t>(n, kInf));
    dp[n - 1][n - 1] = 0;
    for (int i = n - 2; i >= 0; --i) {
        vector<vector<int64_t>> nxt(n, vector<int64_t>(n, kInf));
        for (int j = 0; j < n; ++j) {
            for (int k = j; k < n; ++k) {
                if (dp[j][k] == kInf) continue;
                int64_t cost = (row[i][i + 1] - (j + 1 < n ? row[i][j + 1] : 0)) + (k + 1 < n ? col[i][k + 1] : 0);
                nxt[j][k] = min(nxt[j][k], dp[j][k] + cost);
                cost = (j + 1 < n ? col[i][j + 1] : 0);
                nxt[i][j] = min(nxt[i][j], dp[j][k] + cost);
            }
        }
        dp = nxt;
    }
    int64_t ans = kInf;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) ans = min(ans, dp[i][j]);
    }
    cout << ans << "\n";
}


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

using namespace std;

long long cnt(long long t, const vector<long long> v1, const vector<long long> v2){
    int p1 = 0, p2 = v2.size()-1;
    long long res = 0;
    while(p1<v1.size()){
        while(p2>=0 && v1[p1] * v2[p2] > t){
            p2--;
        }

        res += p2+1;
        p1++;
    }

    return res;
}

int main(){
    long long n, k;
    cin >>n>>k;

    vector<long long> pos, neg;
    long long zero = 0;

    for(int i=0;i<n;i++){
        int a;
        cin >>a;
        if(a > 0){
            pos.push_back(a);
        }
        else if(a<0){
            neg.push_back(a);
        }
        else
            zero++;
    }

    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    vector<long long> rneg(neg.rbegin(), neg.rend());
    vector<long long> rpos(pos.rbegin(), pos.rend());

    long long ncnt = (long long)pos.size() * neg.size();
    long long zcnt = zero *(zero-1) / 2 + zero * (n - zero);
    long long pcnt = n*(n-1)/2 - ncnt - zcnt;

    if(k > ncnt && k<= ncnt + zcnt){
        cout << 0<<endl;
    }
    else if(k<=ncnt){
        long long l = -(long long)1e18, r =-1 , m;

        while(l<r){
            long long m = (l+r-1)/2;

            long long res = cnt(m, rpos, neg);

            if(res < k){
                l = m+1;
            }
            else{
                r = m;
            }
        }
        cout <<l<<endl;
    }
    else{
        k -= ncnt + zcnt;
        long long l = 1, r = (long long) 1e18, m;

        while(l<r){
            long long m = (l+r)/2;
            long long res = cnt(m, pos, pos) + cnt(m, rneg, rneg);
            for(long long i:pos){
                if(i * i<=m)
                    res--;
            }
            for(long long i:neg){
                if(i * i <= m)
                    res--;
            }
            res /= 2;

            if(res < k){
                l = m+1;
            }
            else{
                r = m;
            }
        }
        cout <<l<<endl;
    }

}


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int temp = a[i];
    for (int i = 0; i < 40; i++) {
      if (temp % 2 == 0) {
        temp /= 2;
        ans++;
      } else {
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0)
    cout<<"0";
    else
    cout<<min(a*b,min(b*c,c*a));
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>

#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
typedef long long int ll;

int main() {
  ll a, b, c, d ,e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double noudod=-1;
  double sugard = -1, sum = -1;
  rep(ia, 30) rep(ib, 30){
    ll water = a*ia + b*ib;
    if(100*water>f) break;

    rep(ic, 3000){
      ll id=0;
      while(100*water + c*ic + d*id <=f && (c*ic+d*id)<=e*water) ++id;
      --id;if(id==-1) break;
      double sugar = c*ic + d*id;
      if(sugar>e*water) break;

      double noudo = 1.0/(0.01+water/sugar);
      if(noudo>noudod){
        noudod = noudo;
        sum = sugar + water*100;
        sugard = sugar;
      }
    }

  }
  cout << sum << " " << sugard << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double d;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n,m;
    cin>>n>>m;
    cout<<(n==m?"Yes\n":"No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m,n,ans=0,a[10007],sz[10007],cost[10007],sum[10007],siz[10007],dp[507][10007];
int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=m;i++){
        cin>>sz[i]>>cost[i];
    }
    sort(a+1,a+1+n,greater<int>());
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    for(int i=1;i<=m;i++) siz[i]=siz[i-1]+sz[i];
    for(int i=1;i<=m;i++){
        for(int j=1;j<=min(siz[i],n);j++){
            int low=max(0,j-sz[i]);
            dp[i][j]=max(dp[i-1][j],dp[i-1][low]+sum[j]-sum[low]-cost[i]);
        }
    }
    for(int i=0;i<=n;i++) ans=max(ans,dp[m][i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 22756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
using static Read;

class Program
{
    public static void Main()
    {
        var n = StringArray();
        WriteLine($"A{n[1][0]}C");
    }
}

static class Read
{
    static Queue<string> queue = new Queue<string>();
    static void Enqueue()
    {
        ReadLine().Split(' ').ToList().ForEach(a => queue.Enqueue(a));
    }
    public static int Int()
    {
        if(queue.Count == 0)
            Enqueue();
        return int.Parse(queue.Dequeue());
    }
    public static long Long()
    {
        if(queue.Count == 0)
            Enqueue();
        return long.Parse(queue.Dequeue());
    }
    public static double Double()
    {
        if(queue.Count == 0)
            Enqueue();
        return double.Parse(queue.Dequeue());
    }
    public static string String()
    {
        if(queue.Count == 0)
            Enqueue();
        return queue.Dequeue();
    }
    public static int[] IntArray()
    {
        return ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static long[] LongArray()
    {
        return ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
    }
    public static double[] DoubleArray()
    {
        return ReadLine().Split(' ').Select(a => double.Parse(a)).ToArray();
    }
    public static string[] StringArray()
    {
        return ReadLine().Split(' ');
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}

template <class T>
T lcm(T a,T b){
    return a*(b/gcd(a,b));//a,bがばかでかい時のために割ってからかける
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll g=lcm(c,d);
    ll ans=b-a+1;
    ll c1=b/c,c2=(a+c-1)/c;
    ll d1=b/d,d2=(a+d-1)/d;
    ll g1=b/g,g2=(a+g-1)/g;
    ll cnt=c1-c2+1+d1-d2+1-(g1-g2+1);
    //cout<<cnt<<endl;
    cout<<ans-cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int x[4], y[4];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  x[2] = x[1] - (y[1]-y[0]);
  y[2] = y[1] + (x[1]-x[0]);
  x[3] = x[2] - (y[2]-y[1]);
  y[3] = y[2] + (x[2]-x[1]);
  cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int H, W;
vector<string> grid(51);
vector<string> ans(51);

int main(void){
    
    scanf("%d %d", &H, &W);
    for(int i = 0; i < H; ++i){ string temp; cin >> temp; grid[i] = temp; }
    for(int i = 0; i < H; ++i){ string temp(W, '.'); ans[i] = temp; } 
    
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(grid[i][j] == '.') continue;
            if(i + 1 < H && grid[i + 1][j] == '#') ans[i][j] = '#', ans[i + 1][j] = '#';
            if(i - 1 >= 0 && grid[i - 1][j] == '#') ans[i][j] = '#', ans[i - 1][j] = '#';
            if(j + 1 < W && grid[i][j + 1] == '#') ans[i][j] = '#', ans[i][j + 1] = '#';
            if(j - 1 >= 0 && grid[i][j - 1] == '#') ans[i][j] = '#', ans[i][j - 1] = '#';
        }
    }
    
    int cnt = 0;
    for(int i = 0; i < H; ++i) if(grid[i] == ans[i]) ++cnt;
    printf("%s\n", (cnt == H) ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>

using namespace std;


int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double temp = 1.0 / n;
		int now = i;
		while (now < k) {
			now *= 2;
			temp /= 2;
		}
		ans += temp;
	}

	cout << fixed << setprecision(12) << ans << endl;
}




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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll X;
    cin >> X;
    ll m = 100;
    ll cnt = 0;
    while (m < X)
    {
        m += m / 100;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

#ifdef LOCAL

template<typename T>
void show(vector<T>& v) {
    cout << '[';
    for (const T& e : v) {
        cout << e << ',';
    }
    cout << ']' << endl;
}

#endif

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

template <long long MAX>
class CombinationCalculator {
  long long mod_;
  long long fac[MAX];
  long long finv[MAX];
  long long inv[MAX];

public:
  CombinationCalculator(long long mi = MOD): fac(), finv(), inv() {
    mod_ = mi;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % mod_;
      inv[i] = mod_ - inv[mod_ % i] * (mod_ / i) % mod_;
      finv[i] = finv[i - 1] * inv[i] % mod_;
    }
  }

  long long c(long long n, long long k) const {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod_) % mod_;
  }
};

template <long long MAX = 210000>
using CC = CombinationCalculator<MAX>;

template<typename T>
T modpow(T a, T n, T mod = MOD) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template<typename T>
T modinv(T a, T m = MOD) {
    T b = m, u = 1, v = 0;
    while (b) {
        T t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

template<typename T>
vector<T> read_n(const size_t n) {
    T dummy;
    vector<T> v(n);
    for (size_t i = 0; i < n; i++) {
        cin >> dummy;
        v[i] = dummy;
    }
    return v;
}

template<typename T>
vector<T> read_n() {
    size_t n;
    cin >> n;
    return read_n<T>(n);
}

int main() {
  init();

  int n, m, c;
  cin >> n >> m >> c;

  vector<vector<int>> a(n);
  vector<int> b = read_n<int>(m);

  for (int i = 0; i < n; i++) {
      a[i] = read_n<int>(m);
  }

  int res = 0;
  for (const auto& v: a) {
      ll sum = c;
      for (int i = 0; i < m; i++) {
          sum += v[i] * b[i];
      }
      if (sum > 0) {
          res++;
      }
  }

  cout << res << endl;

  return 0;
}


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

int main()
{
   int r  ;
   cin >> r ;
   int ans = 0;
   ans = 3*r*r;
   cout << ans << endl; 


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int 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 pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  string s;
  cin >> s;
  if(s == "ABC")cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3624
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
HA = str(input()).split()
H = int(HA[0])
A = int(HA[1])
count = 1

while(H>A):
    H=H-A
    count+=1
print(count)


Measured memory_bytes: 20868
let split s = Str.split (Str.regexp_string " ") s;;
let (r,c) =
  let nth =read_line () |> split |> List.map int_of_string |> List.nth in
  (nth 0,nth 1);;

let total = Array.init (c+1) (fun x->0);;
let rec loop (sh:'a array list) = function
    0 -> sh@[total]
  | i ->
     let line = read_line () |> split
                |> List.map int_of_string in
     let l = line @ [(List.fold_left (+) 0 line)] |> Array.of_list in
     for i = 0 to (Array.length l)-1 do
       total.(i) <- total.(i) + l.(i)
     done;
     loop (sh@[l] ) (i-1);;

let rec print_list = function
    [] -> ()
  | (h:'a array)::t -> print_array h;print_list t and
    print_array a =
      Array.fold_left (fun x y -> (if x="" then "" else x^" ")^(string_of_int y)) "" a
      |> print_endline;;

let () = loop [] r |> print_list;;

Measured memory_bytes: 4456
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    if(n>k){
        cout << k*x+ (n-k)* y << endl;
    }else{
        cout << n*x << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int n;
        scanf("%d", &n);
        std::map<std::string,int> mp;
        mp["AC"] = mp["WA"] = mp["TLE"] = mp["RE"] = 0;
        while(n--){
                std::string s;
                std::cin >> s;
                mp[s]++;
        }
        printf("AC x %d\n", mp["AC"]);
        printf("WA x %d\n", mp["WA"]);
        printf("TLE x %d\n", mp["TLE"]);
        printf("RE x %d\n", mp["RE"]);

        return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define fi first
#define se second
#define mod 1000000007
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pi;

int n,mx;
LL ans;

int main() {
	scanf("%d",&n);
	for( int i = 0 , x ; i < n ; i++ ) {
		scanf("%d",&x);
		if(x < mx)
			ans += mx-x;
		else
			mx = x;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3716
A,B,C,D = list(map(int,input().split()))
a=0
c=0
while A > 0:
  A -= D
  a += 1#何回でやられたか
while C > 0:
  C -= B
  c += 1#何回で倒したか
if a < c:
  print('No')
elif a >= c:
  print('Yes')


Measured memory_bytes: 9144
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    vi dp(4);
    REP(i, 3)
    {
        if (S[i] == 'R')
        {
            dp[i + 1] = dp[i] + 1;
        }
        else
        {
            dp[i + 1] = 0;
        }
    }
    ll ans = 0;
    REP1(i, 3)
    {
        CH(max, ans, dp[i]);
    }
    OUT(ans);
}

Measured memory_bytes: 3596
import java.util.*;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		
		long sum1 = 0;
		long sum2 = 0;
		for(int i = 1; i < N; i++) {
			sum2 += a[i];
		}
		sum1 += a[0];
		long min = Long.MAX_VALUE;
		for(int i = 1; i < N; i++) {
			min = Math.min(Math.abs(sum1 - sum2),min);
			
			sum1 += a[i];
			sum2 -= a[i];
		}
		System.out.println(min);
		
		
	}
}

Measured memory_bytes: 64668
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int c = 0;
    for (int i = 1; i <= n; i += 2) {
        int count = 0;
        for (int j = 1; j <= i; j += 2) {
            if (i % j == 0) count++;
        }
        if (count == 8) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc147_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int cnt = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if(s.Substring(i,1)!=s.Substring(s.Length-1-i,1))
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt/2);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11092
n =int(input())
p = list(map(int,input().split()))

cnt = 0

for i in range(1,n-1):
    
    if((p[i] != max(p[i-1],p[i],p[i+1])) and (p[i] != min(p[i-1],p[i],p[i+1]))):
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::f64::consts::PI;

#[fastout]
fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }
    let alpha = (h * 60.0 + m) / 720.0 * 2.0 * PI;
    let a_x = a * alpha.cos();
    let a_y = a * alpha.sin();
    let beta = m / 60.0 * 2.0 * PI;
    let b_x = b * beta.cos();
    let b_y = b * beta.sin();
    let ans = ((a_x - b_x).powi(2) + (a_y - b_y).powi(2)).powf(0.5);
    println!("{}", ans);
}


Measured memory_bytes: 2912
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int x;
	cin>>x;
	cout<<(!x)<<"\n";
}

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

int main(){
    long long N,M;
    cin>>N>>M;

    if(N==2&&M==2){
        cout<<"0"<<endl;
    }else if(N==1&&M>1){
        cout<<M-2<<endl;
    }else if(M==1&&N>1){
        cout<<N-2<<endl;
    }else{
        cout<<(M-2)*(N-2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+";
	else if(a*b==15)cout<<"*";
	else cout<<"x";
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<(int)s.size();i++){
    if(ans==0&&s[i]=='C')ans++;
    if(ans==1&&s[i]=='F')ans++;
  }
  cout<<(ans==2?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,q;
  cin >> n >> q;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  vec x(q);
  for(ll i=0;i<q;i++) cin >> x[i];
  vec s(n+1);
  for(ll i=0;i<n;i++) {
    s[i+1]=s[i]+a[i];
  }
  vec ss(n);
  for(ll i=0;i<n;i++) {
    ss[i]=a[i];
    if(i>1) ss[i]+=ss[i-2];
  }
  for(ll i=0;i<q;i++) {
    ll ok=0,ng=n;
    while(ok+1<ng) {
      ll m=(ok+ng)/2;
      ll f=1;
      if(a[n-m]<x[i]) {
        f=0;
      }
      else {
        ll d=a[n-m]-x[i];
        ll id=lower_bound(a.begin(),a.end(),x[i]-d)-a.begin();
        if(n-m-id<m-1) f=0;
      }
      if(f) ok=m;
      else ng=m;
    }
    ll ans=s[n]-s[n-ok];
    if(n-1-2*ok>=0) ans+=ss[n-1-2*ok];
    cout << ans << endl;
  }
}

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

using namespace std;

int main() { 
	long long n,a,b,sum=0;
	cin>>n>>a>>b;
	long long c=n/(a+b),d=n%(a+b);
	string s;
	if(d>=a)sum+=a;
	else sum+=d;
	sum+=a*c;
	cout<<sum;
	return 0;
}

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

int N;
const int MAX_N = 1.0e5 + 100;
pair<int, int> AB[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB, AB+N);

    cout << AB[N-1].first + AB[N-1].second << endl;
    
    return 0;
}


Measured memory_bytes: 1024
const main = (input) => {
  const num = Number(input);
  var flag = true;
  if(num < 10){
    console.log('Yes')
  }
  else{
    for(var i = 2; i < 10; i++){
      if(num % i === 0) {
        if(num / i < 10) {
          flag = false;
          console.log('Yes');
          break;
        }
      }
    }
    if(flag)
      console.log('No');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll A, B, T;
ll ret = 0;

void input() {
  IN(A);
  IN(B);
  IN(T);
}

void solve() {
  ll t = T / A;
  ll out = B * t;
  PRINT(out);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,u,v;
int dist1[maxn],dist2[maxn];
vector<int> graph[maxn];
void dfs1(int x,int par)
{
	for(int i=0;i<graph[x].size();i++)
	{
		int to=graph[x][i];
		if(to==par)
			continue;
		dist1[to]=dist1[x]+1;
		dfs1(to,x);
	}
}
void dfs2(int x,int par)
{
	for(int i=0;i<graph[x].size();i++)
	{
		int to=graph[x][i];
		if(to==par)
			continue;
		dist2[to]=dist2[x]+1;
		dfs2(to,x);
	}
}
int main()
{
	cin>>n>>u>>v;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	dfs1(u,-1);
	dfs2(v,-1);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(dist1[i]<dist2[i])
		{
			ans=max(ans,dist2[i]-1);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11648
#include<iostream>

using namespace std;

int main()
{
    int n, d[50], ans=0;
    cin >> n;

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

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
    
}

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

int a[200050];
int b[200050];

bool cmp(int x,int y)
{
	return x>y;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int t;
	while(cin>>t)
	{
		for(int i=0; i<t; i++)
		{
			cin>>a[i];
			b[i]=a[i];
		}
		
		sort(b,b+t,cmp);
		for(int i=0;i<t;i++)
		{
			if(a[i]==b[0])
			cout<<b[1]<<endl;
			else
			cout<<b[0]<<endl;
		}
		

	}
	return 0;
}

Measured memory_bytes: 3200
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Functions
fn dfs(n:usize, x:i64, total:Vec<i64>, patty:Vec<i64>) -> i64{
    if n==0{
        // Lv.0
        if x>0{
            return 1;
        // 対象外
        }else{
            return 0;
        }
    // 下側のLv.n-1 まで
    }else if x <= total[n-1]+1{
        return dfs(n-1, x-1, total, patty);
    // 真ん中のパティまで
    }else if x == total[n-1]+2{
        return patty[n-1] +1;
    // 上側のLv.n-1 まで
    }else{
        return patty[n-1] + 1 + dfs(n-1, x-2-total[n-1], total, patty);
    }
}

// Main
fn main(){
    input!{
        N: usize,
        X: i64,
    }
    // Lv N バーガーの層数と、バンの数を事前計算
    let mut total = vec![0; N+1];
    let mut patty = vec![0; N+1];
    total[0] = 1; patty[0] = 1;
    for i in 1..N+1{
        total[i] = total[i-1]*2 + 3; 
        patty[i] = patty[i-1]*2 + 1;
    }
    // 与えられた問題を解く
    let ans = dfs(N, X, total, patty);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>

int cnt = 0;

void insertionSort(int arr[], int n, int g) {

	for (int i = g; i < n; ++i) {
		int v = arr[i];
		int j = i - g;
		while (j >= 0 && arr[j] > v) {
			arr[j + g] = arr[j];
			j = j - g;
			++cnt;
		}
		arr[j + g] = v;
	}

}

void shellSort(int arr[], int n) {

	std::vector<int> G;
	int h = 1;
	while (h <= n) {
		G.push_back(h);
		h = h * 3 + 1;
	}
	for (int i = 1; i < n; i = i * 3 + 1) {
	}
	std::cout << G.size() << std::endl;

	int i = 0;
	std::vector<int>::reverse_iterator it = G.rbegin();
	while (it != G.rend()) {
		insertionSort(arr, n, *it);
		if (i != 0) {
			std::cout << " ";
		}
		std::cout << *it;
		++i;
		++it;
	}
	std::cout << std::endl;
}

int main() {

	int n;
	std::cin >> n;

	int arr[n];
	for (int i = 0; i < n; ++i) {
		std::cin >> arr[i];
	}

	shellSort(arr, n);

	std::cout << cnt << std::endl;

	for (int i = 0; i < n; ++i) {
		std::cout << arr[i] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 6980
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}
int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n - 1; i++){
        long long N = n - i;
        const auto &pf = prime_factorize(N);
        long long res = 1;
        for (auto p : pf) res *= p.second + 1;
        ans += res;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    string s,p = "keyence";
    bool b = false;
    cin >> s;
    if(s[0] == 'k' &&s[1] == 'e' &&s[2] == 'y' &&s[3] == 'e' &&s[4] == 'n' &&s[5] == 'c' &&s[6] == 'e'){
            b = true;
    }
    if(s[s.length()-7] == 'k' &&s[s.length()-6] == 'e' &&s[s.length()-5] == 'y' &&s[s.length()-4] == 'e' &&s[s.length()-3] == 'n' &&s[s.length()-2] == 'c' &&s[s.length()-1] == 'e'){
            b = true;
    }
    
        if(s[0] == 'k' && s[s.length()-1] == 'e' && s[s.length()-2] == 'c' &&s[s.length()-3] == 'n' &&s[s.length()-4] == 'e' &&s[s.length()-5] == 'y' &&s[s.length()-6] == 'e'){
            b = true;
        }
        if(s[0] == 'k' && s[1] == 'e' && s[s.length()-1] == 'e' && s[s.length()-2] == 'c' &&s[s.length()-3] == 'n' &&s[s.length()-4] == 'e' &&s[s.length()-5] == 'y'){
           b = true;
        }
         if(s[0] == 'k' && s[1] == 'e' && s[2] == 'y'&& s[s.length()-1] == 'e' && s[s.length()-2] == 'c' &&s[s.length()-3] == 'n' &&s[s.length()-4] == 'e'){
            b = true;
        }
         if(s[0] == 'k' && s[1] == 'e' && s[2] == 'y'&& s[3] == 'e'&& s[s.length()-1] == 'e' && s[s.length()-2] == 'c' &&s[s.length()-3] == 'n'){
            b = true;
        }
         if(s[0] == 'k' && s[1] == 'e' && s[2] == 'y'&& s[3] == 'e'&& s[4] == 'n'&& s[s.length()-1] == 'e' && s[s.length()-2] == 'c'){
            b = true;
        }
         if(s[0] == 'k' && s[1] == 'e' && s[2] == 'y'&& s[3] == 'e'&& s[4] == 'n'&& s[5] == 'c'&& s[s.length()-1] == 'e'){
           b = true;
        }
       
    if(b){
        cout << "YES" << endl;
        return 0;
    }else{
        cout << "NO"<< endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;

ll power(const ll a, const ll n, const ll mod)
{
    if (n == 0) {
        return 1;
    } else if (n % 2 == 1) {
        return power(a, n - 1, mod) * a % mod;
    } else {
        const ll aa = power(a, n / 2, mod);
        return aa * aa % mod;
    }
}

class ModCombination
{
public:
    ModCombination(const int n, const ll mod) : size{n + 1}, mod{mod}, fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)  // mod should be prime
    {
        for (ll i = 2; i <= n; i++) {
            fact[i] = (fact[i - 1] * i) % mod;
            inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod;
            inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod;
        }
    }
    ll combination(const int n, const int k) const
    {
        assert(n < size);
        assert(k <= n);
        return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod;
    }

private:
    const int size;
    const ll mod;
    vector<ll> fact;
    vector<ll> inv;
    vector<ll> inv_fact;
};
int main()
{
    int N;
    cin >> N;
    ll M;
    cin >> M;

    vector<ll> pp(N + 1);
    for (int i = 0; i <= N; i++) { pp[i] = power(2, power(2, i, M - 1), M); }
    ModCombination mod(N + 1, M);
    vector<vector<ll>> b(N + 1, vector<ll>(N + 1, 0));
    b[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= i; j++) { b[i][j] = (b[i - 1][j - 1] + j * b[i - 1][j] % M) % M; }
    }
    vector<ll> weight(N + 1, 0);
    for (int k = 1; k <= N; k++) {
        const ll p = power(2, N - k, M);
        const ll PP = pp[N - k] * mod.combination(N, k) % M;
        for (ll x = 0, q = 1; x <= k; x++, (q *= p) %= M) { (weight[k] += b[k][x] * q % M) %= M; }
        for (ll x = 1, q = 1; x <= k; x++, (q *= p) %= M) { (weight[k] += (b[k][x] * q % M) * x % M) %= M; }
        (weight[k] *= PP) %= M;
    }
    ll minus = 0;
    for (int i = 1; i <= N; i++) { (minus += (i % 2 == 0 ? weight[i] : M - weight[i])) %= M; }
    cout << (pp[N] + minus) % M << endl;

    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  1000000007;

     signed main(){
     
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    if(n==2){
         cout<<max(a[0],a[1])<<endl;
         return 0;
    }
    int x[n][3];
    x[0][0]=a[0];x[0][1]=MOD*MOD;x[0][2]=MOD*MOD;
    x[1][0]=MOD*MOD;x[1][1]=a[1];x[1][2]=MOD*MOD;
    x[2][0]=a[0]+a[2];x[2][1]=MOD*MOD;x[2][2]=a[2];
    x[3][0]=MOD*MOD;x[3][1]=max(a[1],a[0])+a[3];x[3][2]=MOD*MOD;
    for(int i=4;i<n;i++){
      
              if(x[i-2][0]!=MOD*MOD)x[i][0]=x[i-2][0]+a[i];
              else x[i][0]=MOD*MOD;
         
        
            if(x[i-3][0]!=MOD*MOD)  x[i][1]=x[i-3][0]+a[i];
            else x[i][1]=MOD*MOD;
             if(x[i-3][1]!=MOD*MOD)  x[i][2]=x[i-3][1]+a[i];
            else x[i][2]=MOD*MOD;

        if(x[i-4][0]!=MOD*MOD){
             if(x[i][2]!=MOD*MOD)x[i][2]=max(x[i][2],x[i-4][0]+a[i]);
             else x[i][2]=x[i-4][0]+a[i];
        }
        if(x[i][2]!=MOD*MOD)x[i][2]=max(x[i][2],x[i-2][2]+a[i]);
      else x[i][2]=x[i-2][2]+a[i];
       if(x[i][1]!=MOD*MOD)x[i][1]=max(x[i][1],x[i-2][1]+a[i]);
      else x[i][1]=x[i-2][1]+a[i];
    }
    if(n%2){
         if(n==3)cout<<x[n-2][1]<<endl;
        else  cout<<max(x[n-2][1],x[n-1][2])<<endl;
    }else{
         cout<<max(x[n-2][0],x[n-1][1])<<endl;
       //  cerr<<x[n-2][0]<<' '<<x[n-1][1]<<endl;
    }
      }

        


Measured memory_bytes: 9888