akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>

void solv(int N, int Y) {
	for(int i=0; i<=N; i++) {
		for(int j=0; j<= (N-i); j++) {
			int k = N-i-j;
			if (i * 10000 + j * 5000 + k * 1000 == Y) {
				printf("%d %d %d\n", i, j, k);
				return;
			}

		}
	}

	printf("-1 -1 -1\n");
}


int main(void) {
//	solv(9, 45000); // 4 0 5
//	solv(20, 196000); // -1;

	//return 0;
    int N;
    std::cin >> N;
    int Y;
    std::cin >> Y;

	solv(N, Y);
	
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int mod=998244353,N=4e5+9;
int f[N],iv[N];
int pw(int a,int t=mod-2){
	int x=1;
	while(t){
		if(t&1)x=x*a%mod;
		a=a*a%mod,t>>=1;
	}
	return x;
}
int C(int n,int r){
	if(r==0)return 1;
	return f[n]*iv[r]%mod*iv[n-r]%mod;
}
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    f[0]=1,iv[0]=1;
    for(int i=1;i<N;i++){
    	f[i]=i*f[i-1]%mod;
    	iv[i]=pw(f[i]);
    }
    int n,m,k,sum=0;
    cin >> n >> m >> k;
    for(int i=0;i<=k;i++){
    	sum=(sum+m*pw(m-1,n-1-i)%mod*C(n-1,i)%mod)%mod;
    }
    cout << sum;
}

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

using namespace std;

int n, a;
int sum = 0, res = 0;
bitset<4000001> sums;

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

    cin >> n;

    sums |= 1;
    for(int i = 0; i < n; ++i) {
        cin >> a;
        sum += a;
        sums |= sums << a;
    }

    for(int i = 0; i <= sum / 2; ++i)
        if(sums.test(i))
            res = i;

    cout << sum - res;
}

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

namespace ABC063B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            bool[] used = new bool[26];
            bool diff = true;
            foreach(char c in S)
            {
                if(used[c-'a'] == true)
                {
                    diff = false;
                    break;
                }
                used[c - 'a'] = true;
            }

            if(diff)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }

        }
    }
}


Measured memory_bytes: 13140
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

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

int qpow(int base, int e) {
    int ret = 1;
    for (; e; e >>= 1) {
        if (e & 1) {
            ret = (LL) ret * base % MOD;
        }
        base = (LL) base * base % MOD;
    }
    return ret;
}

int cnt[N], fac[N];
vector<int> vc[N];

int main() {
    int n = read(), x = read(), y = read();

    fac[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fac[i] = (LL) fac[i - 1] * i % MOD;
    }

    for (int i = 1; i <= n; ++i) {
        int c = read();
        vc[c].emplace_back(read());
    }

    multiset<int> s;
    for (int i = 1; i <= n; ++i) {
        if (vc[i].empty()) continue;
        sort(vc[i].begin(), vc[i].end());
        s.emplace(vc[i].front());
    }

    int tot = 0;

    for (int i = 1; i <= n; ++i) {
        if (vc[i].empty()) continue;
        s.erase(s.find(vc[i].front()));
        if (vc[i].front() + *s.begin() <= y) {
            for (int w : vc[i]) {
                if (w + vc[i].front() <= x || w + *s.begin() <= y) {
                    ++cnt[i]; ++tot;
                } else {
                    break;
                }
            }
        }
        s.emplace(vc[i].front());
    }

    int ans = fac[tot];
    for (int i = 1; i <= n; ++i) {
        if (cnt[i]) {
            ans = (LL) ans * qpow(fac[cnt[i]], MOD - 2) % MOD;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 17920
#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 INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x,y; cin >> x >> y;
  vector<int> g1 = {1,3,5,7,8,10,12},g2 = {4,6,9,11},g3 = {2};

  bool bool_x = false,bool_y = false;
  rep(i,g1.size()){
    if(x==g1[i]) bool_x = true;
    if(y==g1[i]) bool_y = true;
  }
  if(bool_x && bool_y){
    cout << "Yes" << endl;
    return 0;
  }

  bool_x = false;
  bool_y = false;
  rep(i,g2.size()){
    if(x==g2[i]) bool_x = true;
    if(y==g2[i]) bool_y = true;
  }
  if(bool_x && bool_y){
    cout << "Yes" << endl;
    return 0;    
  }

  bool_x = false;
  bool_y = false;
  if(x == g3[0] && y == g3[0]){
    bool_x = true;
    bool_y = true;
  }
  if(bool_x && bool_y){
    cout << "Yes" << endl;
    return 0;    
  }

  cout << "No" << endl;
  
  return 0;
}


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

int main(){
    int k,s;
    cin >> k >> s;
    int count=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if((s-i-j)>=0&&(s-i-j)<=k) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

vi cnt[26];

int main(){
	string s,t;
	cin >> s >> t;
	rep(i,s.size()){
		cnt[s[i]-'a'].push_back(i);
	}

	rep(i,t.size()){
		if(!cnt[t[i]-'a'].size()){
			cout << -1 << endl;
			return 0;
		}
	}

	ll now = 0;
	int index,tmp;
	rep(i,t.size()){
		tmp = t[i]-'a';
		index = lower_bound(all(cnt[tmp]),now%s.size())-cnt[tmp].begin();
		if(index != cnt[tmp].size()){
			now += cnt[tmp][index]-now%s.size();
		}else{
			now += s.size()-now%s.size();
			index = lower_bound(all(cnt[tmp]),0)-cnt[tmp].begin();
			now += cnt[tmp][index];			
		}
		now++;
	}

	cout << now << endl;
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define MOD 1000000007
template <typename Type>
istream &operator>>(istream &in, vector<Type> &vec) {
    ll n = vec.size();
    for (ll i = 0; i < n; i++)
        in >> vec[i];
    return in;
}
template <typename Type>
ostream &operator<<(ostream &out, vector<Type> &vec) {
    for (auto val : vec)
        out << val << " ";
    return out;
}
#define PI 3.14159265

int main()
{
   ll h,v;
   cin>>h>>v;
   string grid[h];
   for(ll i=0;i<h;i++)
   cin>>grid[i];
   ll dp[h][v];
   dp[0][0]=1;
   for(ll i=1;i<h;i++)
   {
       if(grid[i][0]=='#')
       dp[i][0]=0;
       else
       {
           dp[i][0] = dp[i-1][0]%MOD;
       }
    //    cout<<dp[i][0]<<" ";
   }
   for(ll i=1;i<v;i++)
   {
       if(grid[0][i]=='#')
       dp[0][i]=0;
       else
       {
           dp[0][i] = dp[0][i-1]%MOD;
       }
       
   }
   for(ll i=1;i<h;i++)
   {
       for(ll j=1;j<v;j++)
       {
           if(grid[i][j]=='#')
            dp[i][j]=0;
           else
           {
               dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
           }
       }
           
   }
//    for(ll i=0;i<h;i++)
//    {
//     //    for(ll j=0;j<v;j++)
//         // cout<<dp[i][j]<<" ";
//         // cout<<endl;
//    }
   cout<<dp[h-1][v-1]%MOD<<endl;
   return 0;
}
    


Measured memory_bytes: 9088
A,B,K=map(int,input().split())
while True:
  A-=A%2
  A,B=A//2,B+A//2
  K-=1
  if K==0:
    break
  B-=B%2
  B,A=B//2,A+B//2
  K-=1
  if K==0:
    break
print(A,B)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
int main(){
    char w[100], t[100];
    char *p;
    int c = 0;
    scanf("%s", w);
 
    while(1){
        scanf("%s", t);
        if(strcmp(t, "END_OF_TEXT")==0)break;
        for(p = t; *p!='\0'; p++){
            if('A'<=*p && *p <= 'Z')
                *p+='a'-'A';
        }
        if(strcmp(t, w)==0)c++; 
    }
    printf("%d\n", c);
 
    return 0;
}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[100010]; //dp[石の数] -> Grundy数
/*
dp[i]からの遷移
集合A内のi>=aとなる任意のaについて、i個からi-a個に遷移できる
Grundy数の定義よりdp[i]=mex(dp[i-a])
初期条件(?) 決着している盤面についてdp[i]=0
*/
int main(){
  cin >> n >> k;
  vector<int> a(n), cnt(n+1);
  for(int i=0;i<n;i++) cin >> a[i];
  auto mex = [&](int t){
    fill(cnt.begin(),cnt.end(),0);
    for(auto x:a) if(t-x>=0) cnt[dp[t-x]]++;
    for(int i=0;i<n+1;i++) if(cnt[i]==0) return i;
  };
  for(int i=0;i<=k;i++){
    dp[i]=mex(i);
  }
  cout << (dp[k]?"First":"Second") << endl;
}

Measured memory_bytes: 3984
#include<iostream>
#include<cstdio>

#include<vector>
#include<string>

#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF = 1e12+1;
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 N;
ll D = 1e9+7;

int main() {
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    
    sort(a.begin(),a.end(),greater<ll>());

    ll res = 1;
    for (int i = 0; i < N / 2; i++) {
        res = res * 2 % D;
    }
    int i = 0;
    bool flag = true;
    int tmp = N - 1;
    int tmp_c = 0;
    while (i < N) {
        if (a[i] == tmp) {
            tmp_c++;
        } else {
            flag = false;
            break;
        }
        if (tmp_c == 2) {
            tmp -= 2;
            tmp_c = 0;
        }
        i++;
    }

    if (flag) cout << res << endl;
    else cout << 0 << endl;


    

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  vector<int> as(n);
  for(int i=0;i<n;i++){int a;cin>>a;as.at(i)=a-1;}
  vector<bool> ons(n,0);
  int push=0,lighton=0;
  for(int i=0;i<n;i++){
    if(lighton==1){cout<<i<<endl;break;}
    if(ons.at(lighton)==1){cout<<-1<<endl;break;}
    else{ons.at(lighton)=1;lighton=as.at(lighton);}
  }
}

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

int S[11][11];
int p[11];

int main() {
  int n,m; cin>>n>>m;
  rep(i, m) {
    int k; cin>>k;
    rep(j, k) {
      cin>>S[i][j];
    }
  }
  rep(i, m) cin>>p[i];

  int res=0;
  rep(bit, (1<<n)) {
    bool frag=true;
    vector<int> cnt(m, 0);
    rep(i, n) {
      if (bit&(1<<i)) {
        rep(j, m) {
          rep(k, 11) {
            if (S[j][k]==i+1) cnt[j]++;
          }
        }
      }
    }
    rep(i, m) {
      if (cnt[i]%2!=p[i]) frag=false;
    }
    if (frag) res++;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
import sys
from fractions import gcd
from itertools import permutations, combinations, accumulate
from collections import deque
from heapq import heappush, heappop, heapify
from collections import deque

input = sys.stdin.readline
sys.setrecursionlimit(10**6)

class Edge:
    def __init__(self, first, second):
        self.color = 0
        self.first = first
        self.second = second

def main():
    def dfs(i, par, pcol):
        cc = 1
        for e in v[i]:
            if cc == pcol:
                cc += 1
            if e.color == 0:
                e.color = cc
                dfs(e.second, par, cc)
                cc += 1

    n = int(input())
    e = [[] for _ in range(n-1)]
    v = [[] for _ in range(n+1)]

    for i in range(n-1):
        a, b = list(map(int,input().split()))
        e[i] = Edge(a, b)
        v[a].append(e[i])

    dfs(1, -1, 0)

    m = 0
    for i in range(n-1):
        m = max(m,e[i].color)

    print(m)
    for i in range(n-1):
        print(e[i].color)

if __name__ == '__main__':
    main()

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

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

int main() {
    int n; cin >> n;
    int i = 0, cnt = 0;
    while(n/(int)pow(10, i)!=0){
        if(i%2==0){
            if(n/pow(10, i) < 10) cnt += n - pow(10, i) + 1;
            else cnt += 9 * pow(10, i);
        }
        i++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
t = gets.to_i

def f a,b,c,d
  return "No" if a<b
  return "No" if d<b
  return "Yes" if b<=c
  g = b.gcd(d)
  if b-g+(a%g)<=c
    return "Yes"
  else
    return "No"
  end
end

t.times{
  a,b,c,d = gets.split.map(&:to_i)
  puts f(a,b,c,d)
}


Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,c,d,e,f,g,h,i,x;
  cin >> a >> b;
  x = 0;
  
  for (; a <= b; a++) {
      c = a;
      d = c % 10;
      c /= 10; 
      e = c % 10;
      c /= 100;
      f = e * 10 + d;
      g = c % 10;
      c /= 10;
      h = c % 10;
      i = g * 10 + h;
      if (f == i) {
        x += 1;
      }
  }
  cout << x << endl;
}
        
      
      
     
    

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

int main(void)
{
    int n; cin >> n;
    long long k; cin >> k;
    vector<int> a(n);
    int _a;
    for (int i = 0; i < n; i++) 
    {
        cin >> _a; a[i] = _a - 1;
    }
    vector<int> tr(n, -1);
    int s = 0;
    int t = 0;
    while (tr[s] < 0)
    {
        tr[s] = t; 
        t++;
        s = a[s];
    }
    int loop_start = tr[s];
    int loop_size = (t - tr[s]);
    long long tar;
    if (k < (long long)loop_start) tar = k;
    else tar = (long long)loop_start + (k - (long long) loop_start) % (long long)loop_size;
    s = 0;
    for (long long t = 0; t < tar; t++) s = a[s];
    cout << s + 1 << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
int n,a,f[100005];
int fir[100005],nxt[100005],to[100005],cnt;
vector<int> g[100005];

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void dfs(int x){
	f[x]=0;
	for(int i=fir[x];i;i=nxt[i]){
		dfs(to[i]);
		g[x].push_back(f[to[i]]);
	}
	sort(g[x].begin(),g[x].end());
	reverse(g[x].begin(),g[x].end());
	for(int i=0;i<g[x].size();i++) f[x]=max(f[x],g[x][i]+i+1);
}

int main(){
	n=read();
	for(int i=2;i<=n;i++){
		a=read();
		to[++cnt]=i,nxt[cnt]=fir[a],fir[a]=cnt;
	}
	dfs(1);
	printf("%d\n",f[1]);

	return 0;
}

Measured memory_bytes: 13568
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int a, b, c, d;

int main() {
  cin >> a >> b >> c >> d;
  cout << max(a * b, c * d);
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(0) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
    string A, B; cin >> A >> B;
    ll n = sz(A);

    if (count(all(B), '1') == 0 && count(all(A), '1')) {
	cout << -1 << endl;
	return 0;
    }

    vl leftShiftsNeeded(n), rightShiftsNeeded(n);

    FOR(i, 0, n) {
	FOR(l, 0, n) {
	    ll ind = (i - l + n) % n;
	    if (B[ind] == '1') {
		leftShiftsNeeded[i] = l;
		break;
	    }
	}
	FOR(r, 0, n) {
	    ll ind = (i + r + n) % n;
	    if (B[ind] == '1') {
		rightShiftsNeeded[i] = r;
		break;
	    }
	}
    }

    ll ans = oo;

    // Shift left by l and but before right or left as neccessary
    FOR(l, 0, n) {
	vector<pll> intervals;
	FOR(i, 0, n) {
	    ll ind = (i - l + n) % n;
	    if (A[i] != B[ind]) {
		pll p;
		if (leftShiftsNeeded[i] < l) p.xx = 0;
		else p.xx = leftShiftsNeeded[i] - l;
		p.yy = rightShiftsNeeded[i];
		intervals.pb(p);
	    }
	}

	intervals.pb({0,0});
	sort(all(intervals));
	ll rma = 0;
	ll res = oo;
	FORD(i, 0, sz(intervals)) {
	    res = min(res, intervals[i].xx + rma);
	    rma = max(rma, intervals[i].yy);
	}
	ans = min(ans, 2*res+l+sz(intervals)-1);
    }
    // Shift right by r and but before right or left as neccessary
    FOR(r, 0, n) {
	vector<pll> intervals;
	FOR(i, 0, n) {
	    ll ind = (i + r + n) % n;
	    if (A[i] != B[ind]) {
		pll p;
		if (rightShiftsNeeded[i] < r) p.xx = 0;
		else p.xx = rightShiftsNeeded[i] - r;
		p.yy = leftShiftsNeeded[i];
		intervals.pb(p);
	    }
	}

	intervals.pb({0,0});
	sort(all(intervals));
	ll rma = 0;
	ll res = oo;
	FORD(i, 0, sz(intervals)) {
	    res = min(res, intervals[i].xx + rma);
	    rma = max(rma, intervals[i].yy);
	}
	ans = min(ans, 2*res+r+sz(intervals)-1);
    }
    cout << ans << endl;

} //cin.tie(0) bei schnellem Wechseln


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

int main(){
	int sum1 = 0, sum2 = 0, a1, a2;	
	for(int i = 0; i < 4; i++){
		cin >> a1;
		sum1 += a1;
	}
	for(int i = 0; i < 4; i++){
		cin >> a2;
		sum2 += a2;
	}

	if(sum1 >= sum2){
		cout << sum1 << endl;
	}else{
		cout << sum2 << endl;
	}

}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL N;
	cin >> N;

	vector<LL> D(N);
	LL M0 = 0;
	LL sign = 1;
	REP(i, N) {
		cin >> D[i];

		M0 += D[i] * sign;
		sign = -sign;
	}

	cout << M0 << " ";
	LL lastM = M0;
	FOR(i, 1, N) {
		LL m = D[i- 1] * 2 - lastM;
		cout << m << " ";
		lastM = m;
	}
	cout << endl;

	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

vector<pair<LL, LL>> prime_factorization(LL x) {
	assert(x > 0);
	
	vector<pair<LL, LL>> f;
	LL i = 2;
	while(true) {
		if(x == 1) { break; }
		
		if(i * i > x) { i = x; }
		if(x % i == 0) {
			f.EB(i, 0);
			while(x % i == 0) { f.back().SE++; x /= i; }
		}
		i++;
	}
	
	return f;
}

// ----

int n, b[100], dp[75 + 1];

int main() {
	cin >> n;
	
	incII(i, 2, n) {
		auto pf = prime_factorization(i);
		inc(j, pf.size()) { b[pf[j].FI] += pf[j].SE; }
	}
	
	dp[1] = 1;
	inc(i, 100) {
	dec1(j, 75) {
	inc1(k, b[i]) {
		int l = j * (k + 1);
		if(l <= 75) { dp[l] += dp[j]; }
	}
	}
	}
	
	cout << dp[75] << endl;
	
	return 0;
}


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


int main(){

    string s;
    cin>>s;
    int n = s.size();
    int ans = 0;
    for(int i = 0 ; i<n/2 ; i++){
        if(s[i]!=s[n-i-1]) ans++;


    }
    cout<<ans;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
int main() {
    string s; cin >> s;
    if (s <= "2019/04/30") cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let c = get!(String);
    println!("{}", (c.chars().next().unwrap() as u8+1) as char);
}


Measured memory_bytes: 8572
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  cout << a / b	<< " ";
  cout << a % b << " ";
  printf("%lf\n", (double)a / (double)b);
  return 0;
}

Measured memory_bytes: 1236
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }

//繰り返し2乗法(xのn乗を計算)
long long repeat_pow(long long x, int n){
	long long ans=1;

	while(n>0) {
		if((n&1)==1){
			ans=(ans*x)%MOD;
		}
		x=(x*x)%MOD; //一周する度にx, x^2, x^4, x^8となる
		n>>=1; //桁をずらす n = n >> 1
	}
	return ans;
}

//階乗のMOD逆元を利用した組合せの数の計算
class Comb_mod{
public:
	int n;
	vector<long long> fact, fact_rev;
	//1～nまでの階乗のmodを求める．fact[i]，fact_rev[i]はそれぞれ(iの階乗)%MOD，iの階乗のMOD逆元を格納

	Comb_mod(int _n){
		fact=vector<long long>(_n+1, 1);
		fact_rev=vector<long long>(_n+1, 1);
		n=_n;
	}

	//i=1～nについてfact[i]，fact_rev[i]を計算
	void factorial_mod()
	{
		long long temp=1;

		//factの計算
		for(int i=1; i<n+1; i++){
			temp*=i;
			if(temp>=MOD) temp%=MOD;
			fact[i]=temp;
		}

		//フェルマーの小定理:a/b≡a*b^(MOD-2) (mod MOD)
		fact_rev[n]=repeat_pow(fact[n], (int)MOD-2);

		//n!^-1=(n+1)!^-1*(n+1)
		for(int i=n; i>=1; i--){
			fact_rev[i-1]=(fact_rev[i]*i)%MOD;
			//cout<<fact_rev[i]<<endl;
		}
	}
	//組合せの数の計算(nCr，結果をMODで割った余りを返す)
	long long Comb(long long n, long long r)
	{
		//n, rが負またはn<rの時は失敗
		if(n<0||r<0||n<r) return 0;

		//r=0,1の時は計算する必要がない
		if(r==0) return 1;
		if(r==1) return n;

		return (((fact[n]*fact_rev[n-r])%MOD)*fact_rev[r])%MOD;
	}
};

int main(void)
{
	ll n, a, b, k, anssum=0;

	cin>>n>>a>>b>>k;

	Comb_mod cmd(4e5);

	cmd.factorial_mod();

	rep(i, n+1){
		if((k-a*i)%b) continue;
		ll tempa=i, tempb=(k-a*i)/b, tempans;
		tempans=(cmd.Comb(n, tempa)*cmd.Comb(n, tempb))%MOD;
		anssum=(anssum+tempans)%MOD;
		
	}
	cout<<anssum<<endl;
}


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

using namespace std;

int team1, team2, point1, point2;
int joinnum,ranking[100];
vector<int> rankpoint;

int main()
{
	cin >> joinnum;
	int teamwin[100];
	for (int i = 0; i < joinnum; i++)
	{
		teamwin[i] = 0;
	}
	for (int i = 0; i < joinnum * (joinnum - 1) / 2; i++)
	{
		cin >> team1 >> team2 >> point1 >> point2;
		if (point1 > point2)teamwin[team1-1] += 3;
		else if (point1 == point2)
		{
			teamwin[team1-1] += 1;
			teamwin[team2-1] += 1;
		}
		else if (point1 < point2)teamwin[team2-1] += 3;
	}
	for (int i = 0; i < joinnum; i++)
	{
		rankpoint.push_back(teamwin[i]);
	}
	sort(rankpoint.begin(), rankpoint.end());
	reverse(rankpoint.begin(), rankpoint.end());
	for (int i = 0; i < joinnum; i++)
	{
		if (i != 0 && rankpoint[i] == rankpoint[i - 1])continue;
		for (int j = 0; j < joinnum; j++)
		{
			if (rankpoint[i] == teamwin[j] && ranking[j]==0)ranking[j] = i + 1;
		}
	}
	for (int i = 0; i < joinnum; i++)
	{
		cout << ranking[i] << endl;
	}
	return 0;

}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String s = sc.next();

        StringBuilder result = new StringBuilder(n);
        result.append(s.substring(0, k - 1));
        result.append(String.valueOf(s.charAt(k - 1)).toLowerCase());
        result.append(s.substring(k));
        System.out.println(result.toString());
    }
}


Measured memory_bytes: 35348
#include <iostream> 
#include<vector>
#include<algorithm>
using namespace std; 
int main() {
	int N, K, P;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> K >> P;
		if (K <= P) {
			cout << K << endl;
	}
		else if (K > P && K % P !=0 ) {
			cout << K % P << endl;
		}
		else if (K > P && K % P == 0) {
			cout << P << endl;
		}
	}
}
	


Measured memory_bytes: 3084
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <map>

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))

using namespace std;

using ll = long long;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;
typedef vector<int> IntVector;
typedef list<int> IntList;

int main(){
  int N;
  cin >> N;
  char C[N];
  long long rCount = 0, gCount = 0, bCount = 0;
  for(int i=0;i<N;i++){
    cin >> C[i];
    if(C[i] == 'R') rCount++;
    if(C[i] == 'G') gCount++;
    if(C[i] == 'B') bCount++;
  }
  
  map<char, int> mp;
  mp['R'] = 0;
  mp['G'] = 0;
  mp['B'] = 0;
  long long all = rCount*gCount*bCount;
  long long no = 0;
  for(int i=1;i<=(N-1)/2;i++){
    for(int j=0;j<N-2*i;j++){
      mp['R'] = 0;
      mp['G'] = 0;
      mp['B'] = 0;
      mp[C[j]]++;
      mp[C[j+i]]++;
      mp[C[j+2*i]]++;
      if((mp['R'] == 1) && (mp['G'] == 1) && (mp['B'] == 1))
        no++;
    }
  }
  long long ans;
  ans = all-no;
  
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
import heapq
import sys
input = sys.stdin.readline

INF = 10 ** 18

class Edge():
    def __init__(self, start, end, cost):
        self.start = start
        self.end = end
        self.cost = cost
    def __str__(self):
        return 'Edge: {} -> {}, cost {}'.format(self.start, self.end, self.cost)

def dijkstra(n, G, s):
    dist = [[INF, INF, INF] for _ in range(n)]
    dist[s][0] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v][d%3] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for e in G[v]:
            tmp = dist[v][d%3] + e.cost
            if dist[e.end][tmp%3] > tmp:
                dist[e.end][tmp%3] = tmp
                heapq.heappush(h, (dist[e.end][tmp%3], e.end))
    return dist

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    g[u-1].append(Edge(u-1, v-1, 1))

s, t = map(int, input().split())

dist = dijkstra(n, g, s-1)
ans = dist[t-1][0]

if ans == INF:
    print(-1)
else:
    print(ans//3)



Measured memory_bytes: 84372
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

static RADIX: u32 = 10;
fn main() {
    let line = read_chars();
    let line = line.iter().map(|s| s.to_digit(RADIX).unwrap()).collect::<Vec<_>>();
    let mut stack = VecDeque::new();
    for &num in line.iter() {
        if let Some(top) = stack.pop_front() {
            if (num == 0 && top == 0) || (num == 1 && top == 1) {
                stack.push_front(top);
                stack.push_front(num);
            }
        } else {
            stack.push_front(num);
        }
    }
    println!("{}", line.len() - stack.len());
}

#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  int res = 1;
  rep(i, n) {
    if (i == 0) {
      res *= k;
    } else {
      res *= (k - 1);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
int dp[45][8005];
int main() {
	int N, Ma, Mb;
	cin >> N >> Ma >> Mb;
	int cnst = 4000;
	for (int i = 0; i < 45; ++i) {
		for (int j = 0; j < 8005; ++j) {
			dp[i][j] = 1e9;
		}
	}
	for (int i = 0; i < N; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		int diff = a * Mb - b * Ma;
		dp[i + 1][cnst + diff] = min(dp[i + 1][cnst + diff],c);
		for (int j = 0;j<8005; ++j) {
			dp[i + 1][j] = min(dp[i+1][j],dp[i][j]);
			dp[i + 1][j + diff] = min(dp[i+1][j+diff],dp[i][j]+c);
		}
	}
	if (dp[N][cnst]<1e9) {
		cout << dp[N][cnst]<<endl;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	long counter = 0;
	long bw = s[0];
	for (long i = 0; i < s.size(); i++) {

		if (bw != s[i]) {
			bw = s[i];
			counter++;
		}

	}
	cout << counter << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 100005


signed main(){
int n,k,x;
priority_queue<pii>pq;
cin>>n;
vi v;
vi b;

For(i,0,n){
	cin>>x;
	v.pb(x);
	// pq.push({x,i});
}
For(i,0,n){
	cin>>x;
	b.pb(x);
	if(b[i]!=v[i])
	pq.push({x,i});
}

int flag=0;
int move=0;
while(!pq.empty()){
	pii x = pq.top();
	pq.pop();
	int right = b[(x.S+1)%n];
	int left = b[(x.S-1+n)%n];
	int s=right+left;
	int diff = max({right,left,v[x.S]});
	int l = max((x.F-diff)/s,1LL);
	
	b[x.S]-= (l)*s;
    if (b[x.S] < v[x.S]) {
        flag=1;
        break;
    };
    if (b[x.S] != v[x.S]) pq.push({b[x.S], x.S});
	move=move+l;
	// cout<<move<<endl;
}
if(flag==1)
	cout<<-1;
else
	cout<<move;
}


Measured memory_bytes: 11376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << 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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  // vector<ll> b(n);
  // rep(i,n) { b[i] = a[i]-i; }

  ll ans = 0;
  map<ll,ll> cnts;
  rep(i,n) {
    if (cnts.find(a[i]-i) != cnts.end()) {
      ans += cnts[a[i]-i];
    }
    ++cnts[-a[i]-i];
  }
  cout << ans << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long N, long long D) {
  int tmp = N / (D * 2 + 1);
  if (N % (D * 2 + 1) != 0) {
    tmp++;
  }
  cout << tmp << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);
  solve(N, D);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#define int ll

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;

class unionfind {
private:
    int *p,n,*r;
    queue<int> q;
    int root(int m) {
        if(p[m] == -1) return m;
        int c = m;
        while(p[c] != -1) {
            q.push(c);
            c = p[c];
        }
        while(!q.empty()) {
            p[q.front()] = c;
            q.pop();
        }
        return c;
    }
public:
    unionfind(int n_) {
        n = n_;
        p = new int[n];
        r = new int[n];
        for(int i = 0;i < n;i++) {
            p[i] = -1;
            r[i] = 1;
        }
    }
    bool find(int s,int t) {
        return root(s) == root(t);
    }
    void uni(int s,int t) {
        r[root(t)] += r[root(s)];
        p[root(s)] = t;
    }
    int sz(int s) {
        return r[root(s)];
    }
};

#undef int
int main() {
#define int ll
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> ab(m);
    unionfind u(n+1);
    for(int i = 0;i < m;i++) cin >> ab[i].first >> ab[i].second;
    int c = n*(n-1)/2;
    vector<int> r;
    for(auto i = ab.crbegin();i != ab.crend();i++) {
        r.push_back(c);
        if(u.find(i->first,i->second)){

        } else {
            c -= u.sz(i->first) * u.sz(i->second);
            u.uni(i->first,i->second);
        }
    }
    for(auto i = r.crbegin();i != r.crend();i++) cout << *i << endl;
}


Measured memory_bytes: 5364
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Integer[] a = new Integer[3];
        a[0] = Integer.parseInt(sc.next());
        a[1] = Integer.parseInt(sc.next());
        a[2] = Integer.parseInt(sc.next());

        Arrays.sort(a);

        if(a[0] == 5) {
            if(a[1] == 5) {
                if(a[2] == 7) {
                    System.out.print("YES");
                } else {
                    System.out.print("NO");
                }
            }else {
                System.out.print("NO");
            }

        }else {
            System.out.print("NO");
        }


    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n; 
  auto isprime = [](auto k){
    int div;
    div = 0;
    for(int j=2 ; j<floor(sqrt(k)); j++){
      if(k % j == 0){
        div = j;
      }
    }
    if (div==0 || k==2){
      return(true);
    }
    else{
      return (false);
    }
  };
  int ans = n;
  while (!isprime(ans)){
    ans +=1;
  }
  cout << ans;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x;
    cin >> x;
    if(x >= 30)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto x = nx[1];

    if (x == 1 || x == N*2-1) {
        writeln("No");
        return;
    }
    writeln("Yes");

    int[] line;
    bool[] memo;
    line.length = N*2-1;
    memo.length = N*2;

    line[N-1] = x;
    memo[x] = true;
    line[N-2] = 1;
    memo[1] = true;
    line[N] = N*2-1;
    memo[N*2-1] = true;
    if (N > 2) {
        int i = N*2-2;
        while (memo[i]) --i;
        line[N-3] = i;
        memo[i] = true;

        int j = 2;
        while (memo[j]) ++j;
        line[N+1] = j;
        memo[j] = true;
    }

    x = 3;
    foreach (ref n; line) if (n == 0) {
        while (memo[x]) ++x;
        n = x;
        memo[x++] = true;
    }

    foreach (n; line) writeln(n);
}

Measured memory_bytes: 4220
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
  p[i]/=2
s=t=sum(p[:k])
for i in range(k,n):
  t=t-p[i-k]+p[i]
  s=max(s,t)
print(s+k/2)

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  ll K,s,t,a;
  cin >> K;
  ll ans=0,sum=0;
  vector<vector<int>> vec(12,vector<int>(12,0));
  for(int i=1;i<11;i++){
    vec[1][i]=1;
  }
  for(int i=2;i<12;i++){
    for(int j=1;j<11;j++){
      vec[i][j]=vec[i-1][j-1]+vec[i-1][j]+vec[i-1][j+1];
    }
  }
  //cout << vec[1][2] << endl;
  for(int i=1;i<12;i++){
    for(int j=2;j<11;j++){
      sum +=vec[i][j];
      if(sum>=K){
        s=i;
        t=j;
        ans +=pow(10,s-1)*(j-1);
        a=K-sum+vec[i][j];
        //cout << ans << endl;
        break;
      }
    }
    if(ans!=0)
      break;
  }
  //cout << a << endl;
  //cout << t << endl;
  while(s!=1||a==0){
    s--;
    int sum=0;
    for(int j=t-1;j<t+2;j++){
      //cout << vec[1][2] << endl;
      sum +=vec[s][j];
      //cout << sum << endl;
      if(sum>=a){
        //cout << s << " " << j << endl;
        t=j;
        ans+=pow(10,s-1)*(j-1);
        a =a-sum+vec[s][j];
        //cout << a << endl;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
As = list(map(int, input().split()))

cnt = Counter(As)
B = sum([k*(k-1)//2 for k in cnt.values()])
#print('B:', B)

anss = []
for A in As:
    x = cnt[A]
    ans = B - x*(x-1)//2 + (x-1)*(x-2)//2
    anss.append(ans)

print('\n'.join(map(str, anss)))


Measured memory_bytes: 39468
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
  double a, b, c, d, e, f;

  while (cin >> a >> b >> c >> d >> e >> f) {
    double x, y;
    x = (e * c - b * f) / (a * e - b * d);
    y = (a * f - d * c) / (a * e - b * d);

    if (x == -0) x = 0;
    else if (y == -0) y = 0;
    printf("%.3f %.3f\n", x, y);
  }
}

Measured memory_bytes: 3176
n = int(input())
a = list(map(int, input().split()))

# state_of_up_or_down = False
money = 1000
# min_price = a[0]
# max_price = a[0]
for i in range(1, n):
    if a[i] > a[i - 1]:
        # max_price = a[i]
        # state_of_up_or_down = True
        money = (money // a[i-1]) * a[i] + money % a[i-1]
    # elif a[i] == a[i - 1]:
    #     if i == n - 1:
    #         money = (money // min_price) * max_price + money % min_price        
    #     pass
    else:
        pass
    #     if state_of_up_or_down:
    #         money = (money // min_price) * max_price + money % min_price
    #         state_of_up_or_down = False
    #     min_price = a[i]
    # print(money, min_price, state_of_up_or_down)
print(money)

Measured memory_bytes: 9012
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([1, 3, 5, 4, 2]), 2)

    def test_2(self):
        self.assertEqual(think([9, 6, 3, 2, 5, 8, 7, 4, 1]), 5)


def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    count = 0
    for i in range(n):
        if i + 2 >= n:
            break
        if data[i] < data[i + 1] < data[i + 2] or data[i] > data[i + 1] > data[i + 2]:
            count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>

int main()
{
long long int a,b;
std::cin >> a >> b;
if(a < b){
    std::swap(a,b);
}
if((a > 0 && b < 0) || a == 0 || b == 0){
    std::cout << "Zero" << std::endl;
} else if(a < 0){
    if((a - b) % 2 == 1){
        std::cout << "Positive" << std::endl;
    } else {
        std::cout << "Negative" << std::endl;
    }
} else {
    std::cout << "Positive" << std::endl;
}
return 0;
}

Measured memory_bytes: 256
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

 /*
  * Всегда прогоняй макс-тест перед 
  * нажатием «Отослать». Всегда.
  */ 

int main() {
    ll s, c;
    cin >> s >> c;

    c /= 2ll;

    if (s > c) {
        cout << c << endl;
    } else {
        cout << s + (c-s)/2ll << endl;
    }

    return 0;
}


Measured memory_bytes: 256