akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    print(str(min(A*N, B)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == '__main__':
    main()


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



int main(){
    int ans=2020;
    int64_t l,r;
    cin >> l>>r;

    if((l/2019)==(r/2019)){
        for(int i = l%2019; i <= r%2019; i++){
            for(int j = l%2019; j <= i; j++){
                if(i==j)continue;
                ans=min(ans,(i*j)%2019);
            }
        }
    }else{
        ans=0;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN      
const ll mod=1e9+7;
const int N=1e5+4;

int main()                  
{
	int n,x,t; cin>>n>>x>>t;
  
  	int val = (n+x-1)/x; val*=t;
  
  	cout<<val;
  
    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<string> a(n);
	rep(i,n) cin >> a.at(i);
	bool ans=true;
	rep(i,n){
		rep(j,i){
			if(j==i-1){
				if(a.at(j).at(a.at(j).size()-1)!=a.at(i).at(0)) ans=false;
			}
			if(a.at(j)==a.at(i)) ans=false;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using std::cin;
using std::cout;
using std::endl;

int main(){
	int x,y,z,k;cin>>x>>y>>z>>k;
	std::vector<long long> a(x),b(y),c(z);
	for(int i=0;i<x;i++)cin>>a[i];
	for(int i=0;i<y;i++)cin>>b[i];
	for(int i=0;i<z;i++)cin>>c[i];
	std::sort(a.rbegin(),a.rend());
	std::sort(b.rbegin(),b.rend());
	std::sort(c.rbegin(),c.rend());
	std::vector<long long> sum;
	for(int i=0;i<x;i++){
	for(int j=0;j<y;j++){
		sum.push_back(a[i]+b[j]);
	}}
	std::sort(sum.rbegin(),sum.rend());

	int s=0,t=0;
	int u,v;
	std::vector<long long> ans;
	for(int i=0;i<std::min(x*y,k);i++){
	for(int j=0;j<std::min(z,k);j++){
		ans.push_back(sum[i]+c[j]);
	}}
	std::sort(ans.rbegin(),ans.rend());
	for(int i=0;i<k;i++)cout<<ans[i]<<endl;

	return 0;
}

Measured memory_bytes: 42984
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

//unordered_map<ll,vector<int>> mp;
unordered_map<ll,vector<int>> mp2;

void solve(int ca){
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
        //mp[(ll)a[i]+i].push_back(i);
        mp2[(ll)i-a[i]].push_back(i);
    }
    //cout<<mp2[-2].size()<<endl;
    ll ans=0ll;
    for (int i = 0; i < N; ++i) {
        int key=a[i]+i;
        auto itr=lower_bound(mp2[key].begin(),mp2[key].end(),i+1);
        ans+=(ll)(mp2[key].end()-itr);
    }

    cout<<ans<<"\n";

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

void main()
{
    auto S = readln.chomp.to!(char[]);
    auto T = readln.chomp.to!(char[]);
    auto N = S.length;
    auto M = T.length;
    foreach_reverse (i; 0..N-M+1) {
        foreach (j; 0..M) {
            if (S[i+j] != '?' && S[i+j] != T[j]) goto ng;
        }
        S[i..i+M] = T[];
        goto ok;
        ng:
    }
    writeln("UNRESTORABLE");
    return;
    ok:
    foreach (ref c; S) if (c == '?') c = 'a';
    writeln(S);
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????

		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
        int[] n = new int[X];
        long sum = 0;
        for(int i = 0; i < X; i++){
        	n[i] = scan.nextInt();
        	sum = sum + n[i];
        }

        // ?????????????????????????????????
        Arrays.sort(n);

        // ?????????????????????
        System.out.print(String.format("%d", n[0]));
        System.out.print(" ");
        System.out.print(String.format("%d", n[X-1]));
        System.out.println(" " + sum);
	}

}

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

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
#ifdef TEST
    freopen("input.txt", "r", stdin);
#endif

    int a, b;
    cin >> a >> b;

    int c = a * b;
    if (c % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;
}


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

int main()
{
	for(int n;cin>>n && n;){
		vector<int> a(n);
		for(int& x:a) cin>>x;

		vector<int> is(n); iota(begin(is),end(is),0);
		sort(begin(is),end(is),[&](int i,int j){return a[i]>a[j];});

		map<int,int> range;
		long long res=0;
		for(int i:is){
			auto it=range.emplace(i,i+1).first;
			auto it2=it;
			if(it!=begin(range) && (--it2)->second==i){
				it2->second++;
				range.erase(it--);
			}
			it2=it;
			if(++it2!=end(range) && i+1==it2->first){
				it->second=it2->second;
				range.erase(it2);
			}
			it=--range.upper_bound(i);
			int l=i-it->first+1,r=it->second-i;
			res+=1ll*a[i]*l*r;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 4096
import Data.List

main = do
  n <- readLn :: IO Int
  as <- (sortBy (flip compare) . map read . words) <$> getLine :: IO [Int]
  let alice = [ as !! i | i <- [0,2..(length as - 1)] ]
  let bob   = [ as !! i | i <- [1,3..(length as - 1)] ]
  print $ (sum alice) - (sum bob)


Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    string N;
    int K;
    cin >> N >> K;

    int L = N.length();

    if (L < K) {
        cout << 0 << endl;
        return 0;
    }

    ll count = 0;
    FOR(i, 1, L) {
        if (i >= K) {
            // (i - 1) C (K - 1)
            if (K == 1) {
                count += 9;
            }
            else if (K == 2) {
                count += 9 * 9 * (i - 1);
            }
            else {
                count += 9 * 81 * (i - 1) * (i - 2) / 2;
            }
        }
    }
    // L-th digit
    // N[L -1] == p
    int p = (int)(N[0] - '0');
    ll lp = 0;
    // L-th digit is less than p
    if (K == 1) lp = p - 1;
    else if (K == 2) lp = (p - 1) * 9 * (L - 1);
    else lp = (p - 1) * 81 * (L - 1) * (L - 2) / 2;

    // L-th digit is equal to p
    if (K == 1) lp += 1;
    else if (K == 2) {
        ll c = 0;
        bool f = false;
        FOR(i, 1, L) {
            if (f) {
                c += 9;
            }
            else {
                int a = (int)(N[i] - '0');
                if (a > 0) {
                    f = true;
                    c += a;
                }
            }
        }
        lp += c;
    }
    else {
        // search non-zero digit
        int d = 1;
        FOR(i, 1, L) {
            int a = (int)(N[i] - '0');
            if (a > 0) {
                d = i;
                break;
            }
        }

        int q = (int)(N[d] - '0');
        ll lq = 0;
        // d-th digit is equal to 0
        lq += 81 * (L - d - 1) * (L - d - 2) / 2;
        // d-th digit is 1 ~ q-1
        lq += (q - 1) * 9 * (L - d - 1);

        // (L-1)-th digit is equal to q
        ll c = 0;
        bool f = false;
        FOR(i, d + 1, L) {
            if (f) {
                c += 9;
            }
            else {
                int a = (int)(N[i] - '0');
                if (a > 0) {
                    f = true;
                    c += a;
                }
            }
        }
        lq += c;
        lp += lq;
    }
    cout << count + lp << endl;

    return 0;
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	string S;
	cin>>S;
	string ans = "Yes";
    if(S[2]!=S[3]){
        ans = "No";
    }
    if(S[4]!=S[5]){
        ans = "No";
    }

    cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int a, b;
	cin >> a >> b;

	int ans = a - b;
	if (ans < 0) ans *= -1;

	if (ans % 2 != 0) cout << "IMPOSSIBLE" << endl;
	else if (a > b) cout << a - ans / 2 << endl;
	else cout << b - ans / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int b, r, g, c, s, t;
	while(1) {
		cin >> b >> r >> g >> c >> s >> t;
		if(!(b||r||g||c||s||t))break;
		int nb = b*5 + r*3; // ??????????????????????????°
		int no = t - nb;// ????????????????????°
		int cur = 100;
		int result = cur + 15*b + 15*r + 15*nb + 7*g + 2*c - 3*(no-s) - 2*nb;
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include <cstdio>
using namespace std;

int n;

int main(){
    while(true){
        scanf("%d", &n);
        if(n == 0){
            break;
        }
        for(int i = 0; i < 9; i++){
            int l;
            scanf("%d", &l);
            n -= l;
        }
        printf("%d\n", n);
    }
    return 0;
}

Measured memory_bytes: 1028
import math
# N, M, K = [int(_) for _ in input().split()]
N = int(input())

def num_divisors_table(n):
  table = [0] * (n + 1)

  for i in range(1, n + 1):
    for j in range(i, n + 1, i):
      table[j] += 1

  return table

cd_table = num_divisors_table(N)
ans = 0
for i in range(1, N+1):
  ans += i * cd_table[i]
print(ans)


Measured memory_bytes: 146080
#include <bits/stdc++.h>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n)	for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define form(l, r, i)	for(int i = l; i <= r; ++i)
#define forv(r, l, i)	for(int i = r; i >= l; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
#define elif else if
 
const int inf = 1e9 + 7;
const lld EPS = 0.00000001;
const ll modwdop = 998244353ll;
 
ll pp = 13337ll;
ll modw = 1e9 + 7;
 
using namespace std;

int main()
{
	barnarnar
	string a;
	cin >> a;	
	forn(i, a.si)
	{
		if(a[i] == '7')
		{
			cout << "Yes";
			r0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <stdlib.h>
using namespace std;

int main() 
{
	int n;
	scanf("%d", &n);
	
	int M[n][n]; //initialize? 

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			M[i][j] = 0;
		}
	}	

	for(int i = 1; i <= n; i++)   
	{
		int u,k,v;
		scanf("%d %d", &u, &k);
		for(int j = 0; j < k; j++)
		{
			scanf("%d", &v);
			M[u-1][v-1] = 1;
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(j) printf(" ");
			printf("%d", M[i][j]);
		}
		printf("\n");
	}
	
//	system("pause");
	return 0;
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	string s;
	cin >> s;
	
	ll sum = 0;
	for(int i = 0; i < s.length(); i++) {
		int c = s[i];
		sum += (c - '0');
	}
	
	cout << (sum % 9 ? "No" : "Yes") << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

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

using namespace std;

typedef long long int ll;
const ll N=800;
ll n,mas,a,b,f=0,cnt=0,re,x,y,m[N],ma[N][N],xp[N],yp[N],h[N];
vector <ll> v[N];
bitset <N> dp,dp1;
void dfs(ll s)
{
    m[s]=1;
    if(h[s]%2==0)
        xp[cnt]++;
    else
        yp[cnt]++;
    for(auto y:v[s])
    {
        if(m[y]==1 && h[y]%2==h[s]%2)
            f=1;
        if(m[y]==1) continue;
        h[y]=h[s]+1;
        dfs(y);
    }
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin >> n >> mas;
    for(int i=1; i<=mas; i++)
    {
        cin >> a >> b;
        if(a>b) swap(a,b);
        ma[a][b]=1;
    }
    for(int i=1; i<=n; i++)
        for(int j=i+1; j<=n; j++)
            if(ma[i][j]==0)
                v[i].push_back(j),v[j].push_back(i);
    for(int i=1; i<=n; i++)
    {
        if(m[i]==0)
        {
            cnt++;
            h[i]=0;
            dfs(i);
        }
    }
    if(f==1)
    {
        cout << -1;
        return 0;
    }
    dp[0]=1;
    for(int i=1; i<=cnt; i++)
    {
        dp1=dp<<xp[i];
        dp=dp<<yp[i];
        dp|=dp1;
    }
    y=re=n;
    x=0;
    for(int i=0; i<=n; i++)
    {
        if(dp[i]==1)
        {
            if(abs(n-i-i)<re)
            {
                re=abs(n-i-i);
                x=n-i;
                y=i;
            }
        }
    }
    x*=(x-1),x/=2;
    y*=(y-1),y/=2;
    cout << x+y;
}


Measured memory_bytes: 6016
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>


#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;

ll modd = 1000 * 1000 * 1000 + 7;



int main()   {


      ios_base::sync_with_stdio(false);

      cout.precision(17);
      mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
      uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no



//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readll(a); readll(b); readll(c); readll(d);
        vector<ll> x{a,b};
        vector<ll> y{c,d};
        if (a*b<=0) {x.push_back(0);}
        if (c*d<=0) {y.push_back(0);}
        ll ret = -modd*modd;
        for(auto q1 : x) {
            for(auto q2 : y) {
                ret = max(ret, q1*q2);
            }
        }
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if ((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;


int main() {

	char S[1];

	cin >> S;

	if((S[0] == 'a') || (S[0] == 'i') || (S[0] == 'u') || (S[0] == 'e') || (S[0] == 'o')) {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool b;
};
int main(){
    ll H,W,K;
    cin>>H>>W>>K;
    
    vector<string> t(H);
    REP(i,H){
        cin>>t[i];
    }
    ll mmm=0;
    REP(i,pow(2,H)){
        REP(j,pow(2,W)){
            //sl(i,j,":")
            ll cnt=0;
            REP(y,H){
                //s((i>>y)&1);
                
                if(((i>>y)&1)==0)
                REP(x,W){
                    //s((j>>x)&1);
                    if(((j>>x)&1)==0){
                        //cout<<t[y][x];
                        if(t[y][x]=='#'){
                            cnt++;
                        }
                    }
                }
                //sl();
            }
            if(cnt==K){
                mmm++;
            }
            //sl();
        }
    }
    cout<<mmm;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4132
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
bool is(string s, string rs){
    rep(i, s.size()){
        if(s[i] != rs[i]){
            return false;
        }
    }
    return true;
}
int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    rep(i, n) cin >> a[i];

    rep(i, n){
        mp[a[i]]++;
    }
    map<ll,ll> tt;
    ll total = 0;
    for(auto &i : mp){
        if(i.second < 2) continue;
        ll tmp = nCr(i.second, 2LL);
        total += tmp;
        tt[i.first] = tmp;
    }


    rep(i, n){
        cout << total - (mp[a[i]] - 1) << endl;
    }


    
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

template<class T> T sum(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    T ans = T();
    for(typename vector<T>::iterator t = begin; t != end; t++) ans += *t;
    return ans;
}

template<class T> T min(const vector<T>& v) {
    return *min_element(v.begin(), v.end());
}

template<class T> T min(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *min_element(begin, end);
}

template<class T> T max(const vector<T>& v) {
    return *max_element(v.begin(), v.end());
}

template<class T> T max(const typename vector<T>::iterator& begin, const typename vector<T>::iterator& end) {
    return *max_element(begin, end);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int A = next<int>(), B = next<int>(), C = next<int>(), D = next<int>(), P = next<int>();

    cout << min(A * P, B + D * max(P - C, 0)) ln;

    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n, k;
  cin >> n >> k;
  vi l(n);
  rep(i, n) cin >> l[i];
  sort(all(l), greater<int>());
  int ans = 0;
  rep(i, k) ans += l[i];
  out(ans);
}
int main(void) { solve(); }

Measured memory_bytes: 3616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	if (b == 0)return a;

	gcd(b, a%b);
}

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

int main() {

	LL N, M; cin >> N >> M;
	string a, b; cin >> a >> b;


	LL L = lcm(N, M);

	map<LL, char> m;
	
	int index = 0;
	int diff = L / N;

	for (int i = 0; i < N;i++) {
		m[index] = a[i];
		index += diff;
	}

	index = 0;
	diff = L / M;

	for (int i = 0; i < M; i++) {

		if (m.find(index) != m.end()) {
			if (m[index] != b[i]) {
				cout << "-1" << endl;
				return 0;
			}
		}
		
		index += diff;
	}

	cout << L << endl;

	
	return 0;
}

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

void trace(int A[], int n) {
	for (int i = 0; i < n; i++) {
		if (i != n - 1){
			cout << A[i] << " ";
		}
		else {
			cout << A[i] << endl;
		}
	 }
}


int main() {
	int n, A[100];
	cin >> n;

	for (int i = 0; i < n; i++) cin >> A[i];
	trace(A, n);

	for (int i = 1; i < n; i++) {
		int j = i - 1;
		int v = A[i];

		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, n);
		
	}
 
 
}



Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int a[200000];

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> a[i];
    int max_index = 0;
    for(int i=1; i<n; i++)
        if(a[i] > a[max_index])
            max_index = i;
    int second_index =0;
    if(max_index == 0)
        second_index = 1;
    for(int i=1; i<n; i++)
        if(a[i] > a[second_index] && i != max_index)
            second_index = i;
    
    for(int i=0; i<n; i++){
        if(i != max_index)
            cout << a[max_index] << endl;
        else
            cout << a[second_index] << endl;
    }
}

Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int A[100001],B[100001],N,M,i,j,k;

using Graph=vector<vector<int>>;

Graph E;

deque<int> Q;

int main()
{
  cin>>N>>M;
  
  E.assign(N,vector<int>());
  for(i=0;i<M;i++)
  {
    cin>>j>>k;
    j--;
    k--;
    E[j].push_back(k);
    E[k].push_back(j);
  }
  
    for(i=0;i<N;i++)
  {
    B[i]=-1;
  }
  A[0]=0;
  B[0]=0;
  Q.push_back(0);
  while(Q.size()>0)
  {
    i=Q.front();
    Q.pop_front();
    
    for(auto u:E[i])
    {
      if(B[u]==-1)
      {
        B[u]=0;
        A[u]=i;
        Q.push_back(u);
      }
    }
  }
  
  cout<<"Yes"<<endl;
  for(i=1;i<N;i++)
  {
    j=A[i]+1;
    cout<<j<<endl;
  }
  
}


Measured memory_bytes: 10620
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100000 + 5
#define INF 0x3f3f3f3f

int n, mnr = INF, ans, L[N], R[N], OrdL[N], Pmnr[N], Smnr[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%d%d", L + i, R + i);
		OrdL[i] = i;
		mnr = min(mnr, R[i]);
	}
	sort(OrdL + 1, OrdL + n + 1, [](int u, int v) {
		return L[u] < L[v];
	});
	Pmnr[0] = Smnr[n + 1] = INF;
	for (int i = 1; i <= n; i ++)
		Pmnr[i] = min(Pmnr[i - 1], R[OrdL[i]]);
	for (int i = n; i; i --)
		Smnr[i] = min(Smnr[i + 1], R[OrdL[i]]);
	for (int i = 1; i <= n; i ++)
	{
		int tmp = R[OrdL[i]] - L[OrdL[i]] + 1;
		int mxl = i == n ? L[OrdL[n - 1]] : L[OrdL[n]];
		int mnr = min(Pmnr[i - 1], Smnr[i + 1]);
		tmp += max(0, mnr - mxl + 1);
		ans = max(ans, tmp);
	}
	for (int i = 1; i < n && L[OrdL[i]] <= mnr; i ++)
	{
		int l = L[OrdL[n]], r = Smnr[i + 1];
		int tmp = (mnr - L[OrdL[i]] + 1) + max(0, r - l + 1);
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}

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

const int siz = 100005;
vector<pair<int, int>> pre[siz];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, m; cin >> n >> m;
	for(int i = 0; i < m;i++){
		int p, y; cin >> p >> y;
		pre[p].push_back(make_pair(y,i));
	}
	vector<pair<int, int>> ans(m);
	for(int i = 1; i < n + 1; i++){
		sort(pre[i].begin(), pre[i].end());
		for(int j = 0; j < pre[i].size(); j++){
			ans[pre[i][j].second] = make_pair(i, j + 1);
	}
	}
	for(int i = 0; i < m; i++){
		printf("%06d%06d\n", ans[i].first, ans[i].second);
	}
	return 0;	
}
  

Measured memory_bytes: 7808
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    int a[200020];
    int mx1[200020], mx2[200020];
    mx1[0]=0;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        mx1[i]=max(mx1[i-1], a[i]);
    }
    mx2[n+1]=0;
    for(int i=n; i>=1; i--){
        mx2[i]=max(mx2[i+1], a[i]);
    }
    for(int i=1; i<=n; i++){
        cout<<max(mx1[i-1], mx2[i+1])<<endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;


typedef long long ll;
const ll INF = 1e18;


int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> P(N + 1), C(N + 1);
	for (int i = 1; i <= N; ++i) cin >> P[i];
	for (int i = 1; i <= N; ++i) cin >> C[i];

	ll ans = -INF;
	for (int s = 1; s <= N; ++s) {
		// find loop
		ll tot = 0, len = 0;
		int x = s;
		do {
			tot += C[x]; len++;
		} while ((x = P[x]) != s);

		// search max
		ll now = 0;
		for (int i = 1; i <= len; ++i) {
			x = P[x]; now += C[x];
			if (i > K) break;
			ll sc = now;
			if (tot > 0) sc += ((K - i) / len) * tot;
			ans = max(ans, sc);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>

int main(void){

    long n, res=0;

    scanf("%ld", &n);

    for(;n>=500;){
        n = n -500;
        res += 1000;
    }

    for(; n>=5;){

        n = n - 5;
        res += 5;
    }

    printf("%ld\n", res);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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 DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vll a(m);
    for (ll i = 0; i < m; i++) cin >> a[i];
    ll total = accumulate(ALL(a), 0LL);
    if (total > n) cout << -1 << '\n';
    else cout << n - total << '\n';
    return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x);
Node treeMaximum(Node x);
Node treeSearch(Node u, int k);
Node treeSuccessor(Node x);
void treeDelete(Node z);
void insert(int k);
void inorder(Node u);
void preorder(Node u);

int main(){
  int n, i, m;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &m);
      Node t = treeSearch(root, m);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &m);
      insert(m);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &m);
      treeDelete(treeSearch(root, m));
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 20492
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<char> vc;
#define rep(i,n) for(int i=0; i<n; i++)


int main() {
  int N;
  cin >> N;
  string S;
  // rep(i,N) {
  //   cin >>  S[i];
  // }
  cin >> S;
  int cnt = 1;
  rep(i,N-1) {
    if(S[i] != S[i+1]) {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
void swap(int*,int*);
int main(){
  int x,n,A[100000],j,i,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  r=n-1;
  i=0;
  x=A[r];
  for(j=0;j<r;j++){
    if(A[j]<=x){
      swap(&A[i++],&A[j]);
    }
  }
  swap(&A[i],&A[r]);
  for(j=0;j<=r;j++){
    if(j>0)printf(" ");
    if(j==i)printf("[%d]",A[j]);
    else printf("%d",A[j]);
  }
  printf("\n");
    return 0;
  }
void swap(int *a,int *b){
  int temp = *a;
  *a=*b;
  *b=temp;
}


Measured memory_bytes: 2144
def bunkai(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

n=int(input())
s=[0]*(n+1)
for i in range(1,n+1):
    fact=bunkai(i)
    for j in fact:
        s[j]+=1
ans=1

for i in range(0,n+1):
    ans*=(s[i]+1)
    ans%=10**9+7

print(ans)






Measured memory_bytes: 9180
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x[10];
    for(int i=1;i<=5;i++)
    {
        cin>>x[i];


    if(x[i]==0)
        {cout<<i<<endl;}
}
return 0;
}


Measured memory_bytes: 3532
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)


A, B, C, D = map(int, input().split())
N = B - A + 1
nC = B//C - (A-1)//C
nD = B//D - (A-1)//D
lcm_CD = lcm(C, D)
nCD = B//(lcm_CD) - (A-1)//(lcm_CD)

print(N - nC - nD + nCD)

Measured memory_bytes: 3064
//srinivas
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
// using namespace __gnu_pbds;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define fr(x,in,n,r) for(x=in;x<n;x+=r)
#define ifr(x,n) for(x=0;x<n;x++)
#define dfr(x,n) for(x=n-1;x>=0;x--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pof(a) pop_front(a)
#define pob(a) pop_back(a)
#define eb(a) emplace_back(a)
#define ef(a) emplace_front(a)
typedef long long ll;
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007

struct chash{ 
    ll operator()(ll x) const {return hash<ll>{}(x);}
};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    ll n,k;
    cin>>n;
    string s;
    cin>>s;
    ll i,j;
    cin>>k;
    ifr(i,s.length()){
    	if(s[i]!=s[k-1])
    		cout<<"*";
    	else
    		cout<<s[i];
    }
    cout<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/dp/submissions/13960132

def MAX(a, b):
    d = a + ms - b
    return b + ((ms - ((d & ms) >> (K - 1))) & mask & d)

def tolist(n):
    sx = bin(n)[2:] + "_"
    return [int(sx[-(i+1) * K - 1:-i * K - 1], 2) for i in range((len(sx)+K-2) // K)]

K = 52
N, W = map(int, input().split())

ms = int(("1" + "0" * (K - 1)) * (W + 1), 2)
mask = int(("0" + "1" * (K - 1)) * (W + 1), 2)
tt = (1 << K - 1) - 1
one = int(("0" * (K - 1) + "1") * (W + 1), 2)

s = 1 << K - 2 + (W * K)
for _ in range(N):
    w, v = map(int, input().split())
    s = MAX(s, (s >> w * K) + one * v)

print(max(tolist(s)) - (1 << K - 2))

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

int main(){
  int k;
  cin >> k;
  ll sum = 0;
  int a, b, c;
  rep(i, k){
    a = i+1;
   rep(j, k){
     b = j+1;
     rep(l, k){
       c = l+1;
       sum += gcd(a, gcd(b, c));
     }
   }
  }
    
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; int L; cin>>N>>L;
  int Taste=0;
  if(L>=0){
 for(int i=1; i<N; i++){
   Taste+=L+i;
 }
  cout<<Taste<<endl;
  }
  else if(L+N-1>=0){
     for(int i=0; i<N;i++){
   Taste+=L+i;
 }
  cout<<Taste<<endl;
  }
  else{
    for(int i=0; i<N-1; i++){
   Taste+=L+i;
 }
  cout<<Taste<<endl;
  }
}


Measured memory_bytes: 3508
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long llu;
typedef long long ll;
typedef unordered_map<llu,llu>mymap;
typedef unordered_set<llu >myset;
#define endl '\n'

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s;
	llu k;
	cin>>k;
	cin>>s;
	if(s.length()<=k){cout<<s;}
	else{
		for(llu i=0;i<k;i++){
			cout<<s[i];}
		cout<<"...";}

	return 0;
	}



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

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

  set<char> alpha;

  for (int i = 0; i < S.size(); i++){
    alpha.insert(S.at(i));
  }

  for (char i = 'a'; i <= 'z'; i++)
  {
    if (!alpha.count(i)){
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 3756
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
if a>0:
  if d>0:
    print(b*d)
  else:
    print(a*d)
else:
  if b>0:
    if d>0:
      if b*d>a*c:
        print(b*d)
      else:
        print(a*c)
    else:
      print(a*c)
  else:
    if c>0:
      print(b*c)
    else:
      print(a*c)

Measured memory_bytes: 9208
#include <stdio.h>

int main(){
	
	char a;
	scanf ("%[^\n]", &a);
	
	if (a >='A' && a <= 'Z'){
		printf("A\n");
	}
	if (a >='a' && a <= 'z'){
		printf("a\n");
	}
	getchar();
		
	return 0;
}

Measured memory_bytes: 1576
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f40;
const long long mod=2e9+7;
const long double PI = acos(0);
// }}} End Header
int main() {
	int n, x, t;
	cin >> n >> x >> t;
	if(n%x == 0) cout << (n/x)*t;
	else cout << (n/x+1)*t;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <boost/range/irange.hpp>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;

    auto is_possible = false;
    for (auto const t_num : boost::irange(x + 1)) {
        if ((x - t_num) * 2 + t_num * 4 == y) {
            is_possible = true;
            break;
        }
    }

    cout << (is_possible ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
const ll sze=1e5+2;
int main(){
 ll A,B,K;
 sl(A);
 sl(B);
 sl(K);
 if(K<=A){
	 A=A-K;
	 cout<<A<<" "<<B<<endl;
 }
 else{
	// cout<<A<<" "<<B<<" "<<K<<" ";
	K=K-A;
	 A=0;
	 
	 //cout<<K<<" ";
	 if(B>=K)B=B-K;
	 else B=0;
	 cout<<A<<" "<<B<<endl;
 }
}


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

int main() {
    int alp[26] = {0};
    string s;
    while (getline(cin, s)) {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] >= 'a' && s[i] <= 'z')
                alp[s[i] - 'a']++;
            else if (s[i] >= 'A' && s[i] <= 'Z')
                alp[s[i] - 'A']++;
        }
    }
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", i + 'a', alp[i]);
    }
}


Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  string t;
  for(int i=0;i<n;i++){
    t+=a.at(i);
  }
  cout<<t<<endl;
  return 0;
}

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

int main()
{
    int n, m, sum = 0;
    char c;

    cin >> n;

    bool judge = true;
    for( int i = 0; i < n; i++ )
    {
        cin >> c >> m;
        if( c == '(' )
            sum += m;
        else
            sum -= m;
        if( sum < 0 )
            judge = false;
    }

    if( judge == 1 && sum == 0 )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3124