akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
const int MOD =1e9+7;
#define oset(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1LL;}return res%p;}
const int N=2*1e5+2,M=201;

void solve()
{
	string s;
	cin>>s;
	int n=s.length();
	stack<char> st;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='T')
		{
			if(st.size())
			{
				if(st.top()=='S')
				{
					st.pop();
				}
				else{
					st.push(s[i]);
				}
			}
			else st.push(s[i]);
		}
		else st.push(s[i]);
	}
	cout<<st.size()<<"\n";
}

int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
} 

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n,c,k;
	cin>>n>>c>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll ans=1;
	int ptr = 0;
	for(int i=0;i<n;i++)
	{
		if(a[i]-a[ptr]<=k&&i-ptr+1<=c)
		{
			
		}
		else
		{
			ptr=i;
			ans++;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr
n = int(input())
if n == 1:
  print(0)
else:
  arr = factorization(n)
  arr_len = len(arr)
  count = 0
  for i in range(arr_len):
    arr_i = arr[i]
    if arr_i < 3:
      count += 1
    elif arr_i < 6:
      count += 2
    elif arr_i < 10:
      count += 3
    elif arr_i < 15:
      count += 4
    elif arr_i < 21:
      count += 5
    elif arr_i < 28:
      count += 6
    elif arr_i < 36:
      count += 7
    else:
      count += 8
  print(count)

Measured memory_bytes: 9460
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>

int main()
{
	int N, M;
	std::vector<long> A;
	std::vector<std::pair<long, int>> CB;
	
	std::cin >> N >> M;
	A.resize(N);
	for (auto& a : A) {
		std::cin >> a;
	}
	CB.resize(M);
	for (auto& cb : CB) {
		std::cin >> cb.second >> cb.first;
	}
	
	std::sort(A.begin(), A.end());
	std::sort(CB.rbegin(), CB.rend());

	long sum = 0;
	int pos = 0;
	for (auto& cb : CB) {
		for (int i = 0; i < cb.second && pos < N; ++i, ++pos) {
			if (A[pos] < cb.first) {
				sum += cb.first;
			}
			else
				goto remain;
		}
	}
remain:
	for (; pos < N; ++pos) {
		sum += A[pos];
	}
	
	std::cout << sum << "\n";
}


Measured memory_bytes: 2560
#include <iostream>

int main() {
    
    int a, b;
    std::cin >> a >> b;
    
    if (a < b) std::cout << "a < b" << std::endl;
    else if (a > b) std::cout << "a > b" << std::endl;
    else if (a == b) std::cout << "a == b" << std::endl;
    
    return 0;
}


Measured memory_bytes: 3092
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

int cnt = 0;
string s;

int main(){
    cin >> s;
    stringstream geek(s);
    int x = 0;
    geek >> x;
    for(int i = 0; i < s.size(); i++){
        cnt += s[i] - '0';
    }
    if(x % cnt == 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(100005);
 
// M * (M-1)^(N-1-K) * N-1 C K
int main(int argc, const char * argv[]) {
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    
    mint min_sum = 0;
    mint max_sum = 0;
    
    
    for(ll i=0;i<N-K+1;i++){
        min_sum += (mint)A[i] * c(N-i-1,K-1);
    }
    for(ll i=0;i<N-K+1;i++){
        max_sum += (mint)A[N-i-1] * c(N-i-1,K-1);
    }
    
    mint ans = max_sum - min_sum;
    
    cout << ans << endl;

    
}



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


int n, k, q;
ll a[2005];
void solve() {
    cin >> n >> k >> q;
    rep(i, n) cin >> a[i];

    ll ans = inf;
    rep(i, n) {
        vector<ll> res, tmp;
        rep(j, n) {
            if (a[j] >= a[i]) tmp.push_back(a[j]);
            else {
                all(sort, tmp);
                rep(l, tmp.size() - k + 1) res.push_back(tmp[l]);
                tmp.clear();
            }
        }
        all(sort, tmp);
        rep(l, tmp.size() - k + 1) res.push_back(tmp[l]);
        all(sort, res);
        if (sz(res) < q) continue;
        mins(ans, res[q - 1] - a[i]);
    }
    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 384
($I,$O,$T,$J,$L,$S,$Z)=glob<>;
printf"%d\n",sort{$b-$a}$I>0&&$L>0&&$J>0&&($I-1>>1)*2+($J-1>>1)*2+($L-1>>1)*2+3+$O,($I>>1)*2+($J>>1)*2+($L>>1)*2+$O


Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
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; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
#define vecP vector<P>
// cout << setprecision(15) << std::fixed;


int main() {
	int n, k;
	cin >> n >> k;
	ll cut = 0;
	vec A;
	A.resize(n);
	for (int i = 0;i < n;i++) {
		cin >> A[i];
	}
	sort(all(A));
	reverse(all(A));
	for (int i = 0;i < n;i++) {
		if (i < k) continue;
		cut += A[i];
	}
	print(cut);
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    N,K=map(int,input().split())
    N= str(N)

    S={i for i in range(10)}
    D=set(map(int,input().split()))
    D=S-D

    def search(N):
        for i in range(len(N)):
            if int(N[i]) not in D:
                return True
            elif i==len(N)-1:
                return False

    while True:
        if search(N) ==True:
            N=str(int(N)+1)
        else:
            print(N)
            break









resolve()

Measured memory_bytes: 41052
n=int(input())
d=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ans = "Draw";
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (ab[0] == 1)
            {
                if (ab[1] == 1)
                {
                    //なにもしない
                }
                else
                {
                    ans = "Alice";
                }

            }
            else if (ab[1] != 1)
            {
                if (ab[0] == ab[1])
                {
                    //なにもしない
                }
                else if (ab[0] > ab[1])
                {
                    ans = "Alice";
                }
                else
                {
                    ans = "Bob";
                }
            }
            else
            {
                ans = "Bob";

            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}


int main(){
    
    fastio;
    
   int x, y, z;
   cin >> x >> y >> z;
   swap(x, y);
   swap(x, z); 
    cout << x << " " << y << " " << z << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int n, k; cin >> n >> k;
	int sum = 0;
	rep(i, n) {
		int x; cin >> x;
		sum += min(abs(0 - x), abs(k - x));
	}
	cout << 2*sum << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


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

int main() {
	ll l, r;
	cin >> l >> r;
	if (((l <= (l / 2019) * 2019) && (l / 2019) * 2019 <= r) || (l <= (1 + (l / 2019)) * 2019 && (1 + (l / 2019)) * 2019 <= r)) {
		cout << 0 << endl;
		return 0;
	}
	l %= 2019;
	r %= 2019;
	ll ans = 6000000;
	for (int i = l; i <= r - 1; i++) {
		for (int j = i + 1; j <= r; j++) {
			ll mod = (i * j) % 2019;
			ans = min(ans, mod);
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>

char s[500][500];
char t[500][500];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%s", s[i]);

    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            char a = 1;
            for(int k=0; k<n; k++)
                if(s[i][(n+k+j-i)%n] != s[k][j])
                    a = 0;
            if(a) 
                t[i][j] = 1;
            //printf("%d ", t[i][j]);
        }
        //printf("\n");
    }

    int r = 0;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++) {
            char a = 1;
            for(int k=0; k<n; k++)
                if(!t[(i+k)%n][(j+k)%n]) a = 0;

            if(a)
                r ++;
        }

    printf("%d\n", r);
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

int main() {
  int n, k, t = 1;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    if (t < k) t *= 2;
    else t += k;
  }
  cout << t << endl;
}



Measured memory_bytes: 256
a, b, k = map(int, input().split())

for i in range(k):
    if(i % 2 == 0):
        if(a % 2 == 0):
            a //= 2
            b += a
        else:
            a -= 1
            a //= 2
            b += a
    else:
        if(b % 2 == 0):
            b //= 2
            a += b
        else:
            b -= 1
            b //= 2
            a += b

print(str(a)+" "+str(b))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    map<int, int> m;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        m[a]++;
    }
    vector< pair<int, int> > v;
    for(auto x : m){
        pair<int,int> p = make_pair(x.second, x.first);
        v.push_back(p);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    if(v.size() > k){
        for(int i = 0; i < v.size() - k; i++){
            ans += v[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11768
a, b = map(int, input().split())


"""
10**12 < 2**40
任意の整数について、n ^ (n+1) = 1
"""
def f(n):
    if n%2!=0:
        if ((n+1)//2)%2!=0:
            return 1
        else:
            return 0
    else:
        if (n//2)%2!=0:
            return n ^ 1
        else:
            return n

print(f(a-1)^f(b))

Measured memory_bytes: 9172
n,q=map(int,input().split())
s=str(input())
arr=[0]
count=0
i=1
while(i<n):
	if(s[i-1]=='A' and s[i]=='C'):
		count+=1
	arr.append(count)
	i+=1
ansarr=[]
for i in range(q):
	a,b=map(int,input().split())
	ansarr.append(arr[b-1]-arr[a-1])
print(*ansarr)



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

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

  long long max_sq_factor = 1;
  for(long long i = 1; i * i <= N; i++){
    if(N % i == 0){
      max_sq_factor = i;
    }
  }

  cout << (max_sq_factor - 1) + (N / max_sq_factor - 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int top = 0 , stack[100];
void push (int);
int pop (void);
 
int main(){
  int x , y , flag =0 , ini ,suuji , res ;
  char c , t , input[100];
 
  while( scanf("%s", input) != EOF){
    if ( input[0]  == '+' ){
      x = pop();
      y =pop();
      res = x + y;
      push( res);
    } else if ( input[0]== '-' ){
     x = pop();
      y =pop();
      res = y -x;
      push( res);
    } else if ( input[0] == '*' ){
          x = pop();
      y =pop();
      res = x * y;
      push(res);

    }else{
              res = atoi(input);
      push (res);
    }
  }
  printf("%d\n", pop());
  return 0;
}
 
void push ( int in ){
  top++;
  stack[top] = in;
}
 
int pop (){
  int ret ;
  ret = stack[top];
  top--;
  return ret;
}


Measured memory_bytes: 2076
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(){
    string a, a1, b;
    long len_a1, len_b;
    int i, j;
    int k=0;
 
    cin >> a >> b;
    
    a1 = a + a;
    len_a1 = a1.length();
    len_b = b.length();
    
    for (j = 0; j < len_a1 ; j++){
        if (b[0] == a1[j]){
            if (b == a1.substr(j,len_b)){
                k=1;
            }
        }
    }
    
    if (k==1?cout<<"Yes":cout<<"No")
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){

	int N;
	cin>>N;
	
	double ans = 0.0;
	
	for(int i=0;i<N;i++){
		double A;
		cin>>A;
		ans += 1.0/A;
	}
	
	cout<<fixed<<setprecision(20)<<1.0/ans<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second



int main() {
	ll n, a[300010], ans = -INF3, fsum[300010] = { 0 }, bsum[300010] = { 0 };
	cin >> n;
	priority_queue<ll, vector<ll>,greater<ll>>p;
	priority_queue<ll>q;
	for (int i = 0;i < 3 * n;i++)cin >> a[i];
	for (int i = 0;i < n;i++)p.push(a[i]), fsum[i+1] += fsum[i]+a[i];
	for (int i = n;i <= 2 * n;i++) {
		p.push(a[i]);
		fsum[i+1] = fsum[i] + a[i];
		fsum[i+1] -= p.top(), p.pop();
	}
	for (int i = 3 * n - 1;i >= 2*n;i--) {
		q.push(a[i]),bsum[i - 1] = bsum[i] + a[i];
	}
	for (int i = 2*n-1;i >= n-1;i--) {
		q.push(a[i]);
		bsum[i-1] = bsum[i] + a[i];
		bsum[i-1] -= q.top(), q.pop();
	}
	for (int i = n;i <=2 * n;i++) {
		ans = max(fsum[i] - bsum[i-1], ans);
		//cout << fsum[i] << ' ' << bsum[i-1] << endl;
	}
	cout << ans << endl;
	return 0;
}

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

int arr[200000];
int max1[200000]; //max1[i] = max from i to i - k + 2
int min1[200000]; //min1[i] = min from i to i - k + 2
int count1[200000];

set<int> numbers;

int main()
{
    int n, k;
    cin >> n >> k;
    int c = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (i > 0 && arr[i] > arr[i - 1])
        {
            c++;
        }
        else
        {
            c = 1;
        }
        count1[i] = c;
    }
    for (int i = 0; i < n; i++)
    {
        numbers.insert(arr[i]);
        if (i >= k - 1) {numbers.erase(arr[i - k + 1]);}
        if (i >= k - 2)
        {
            auto it = numbers.end();
            it--;
            max1[i] = *it;
            min1[i] = *(numbers.begin());
        }
    }
    bool noChange = false;
    int result = 0;
    for (int i = k - 1; i < n; i++)
    {
        if (count1[i] >= k)
        {
            if (!noChange)
            {
                result++;
            }
            noChange = true;
        }
        else if (i == k - 1)
        {
            result++;
        }
        else if (arr[i] < max1[i - 1])
        {
            result++;
        }
        else if (arr[i - k] > min1[i - 1])
        {
            result++;
        }
    }
    cout << result << endl;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> arr(n), ans(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
		arr[i]--;
		ans[arr[i]] = i + 1;
	}
	
	for(int i = 0; i < n; i++) {
		cout << ans[i] << " \n"[i==n-1];
	}
}


Measured memory_bytes: 1664
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,10) REP(j,10) if(n==i*j){
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
	return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            var ab = ReadAndParseIntArr();
            int a = ab[0];
            int b = ab[1];
            if( (a*b)%2==0)
            {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
        
        
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

set< string > a;
string s;
ll n;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(ll i=0; i<n; i++) cin >> s , a.insert( s );
    cout << a.size();

    return 0;
}


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

int main() {
    int a,b,x;
    cin>>a>>b>>x;
    if (a<=x&&x<=a+b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
sum = 0
ans = 0
dp=[]
for i in reversed(range(1,n)):
    sum += int(a[i])
    dp.append(sum % (10**9+7))

for i in range(n-1):
     ans += a[i] * dp[n-2-i]
     ans %= (10**9+7)
print(ans)


Measured memory_bytes: 31580
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

const int MAX_N = (1 << 18);

long long N, M, X[MAX_N], A[MAX_N], B[MAX_N], Y[MAX_N], col[MAX_N];
long long group[MAX_N], s[MAX_N]; vector<int>G[MAX_N]; vector<pair<int, int>> I[MAX_N];
vector<tuple<long long, long long, long long>>tup;

vector<pair<long long, long long>>vec;

void init() {
	for (int i = 1; i <= N; i++) { group[i] = i; s[i] = X[i]; G[i].push_back(i); }
}
void unite(int u, int v, long long w) {
	u = group[u]; v = group[v];
	if (u == v) return;

	if (G[u].size() < G[v].size()) swap(u, v);

	for (int i = 0; i < G[v].size(); i++) {
		G[u].push_back(G[v][i]); group[G[v][i]] = u;
	}
	G[v].clear();
	s[u] += s[v]; s[v] = 0;

	if (s[u] >= w) vec.push_back(make_pair(u, s[u]));
}

void dfs(int pos, long long weight) {
	if (col[pos] != -1) return;
	col[pos] = weight;
	for (int i = 0; i < I[pos].size(); i++) {
		if (I[pos][i].second > weight) continue;
		dfs(I[pos][i].first, weight);
	}
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) cin >> X[i];
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i] >> Y[i];
		I[A[i]].push_back(make_pair(B[i], Y[i]));
		I[B[i]].push_back(make_pair(A[i], Y[i]));
		tup.push_back(make_tuple(Y[i], A[i], B[i]));
	}
	sort(tup.begin(), tup.end());
	init();

	for (int i = 0; i < tup.size(); i++) {
		unite(get<1>(tup[i]), get<2>(tup[i]), get<0>(tup[i]));
	}

	for (int i = 1; i <= N; i++) col[i] = -1;
	for (int i = vec.size() - 1; i >= 0; i--) {
		dfs(vec[i].first, vec[i].second);
	}

	int cnt = 0;
	for (int i = 0; i < M; i++) {
		if (min(col[A[i]], col[B[i]]) >= Y[i]) cnt++;
	}
	cout << M - cnt << endl;
	return 0;
}

Measured memory_bytes: 43568
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define pb push_back
#define f first
#define s second
#define endl '\n'
vector<vector<pair<int, int>>>vec;
int t[2000005];

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, q;
	cin>>n>>q;
	int c[n];
	int last[n+1];
	int ind[n+1];
	for(int i=0; i<=n;i++){
		last[i]=-1;
		ind[i]=-1;
	}
	
	for(int i=0; i<n; i++){
		cin>>c[i];
		ind[i]=last[c[i]];
		last[c[i]]=i;
	}
	
	vec.resize(n);
	for(int i=0; i<q; i++){
		int l, r;
		cin>>l>>r;
		l--;
		r--;
		vec[r].pb({l, i});
	}
	
	int ans[q];
	for(int i=0; i<n; i++){
		update(1, 0, n-1, i, 1);
		if(ind[i]!=-1){
			update(1, 0, n-1, ind[i], 0);
		}
		for(auto u:vec[i]){
			ans[(u.s)]=sum(1, 0, n-1, u.f, i);
		}
	}
	for(int i=0; i<q; i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 52464
n = int(input())
C = {}
s = 0
for a in map(int, input().split()):
    if a not in C: C[a] = 0
    C[a] += 1
    s += a
q = int(input())
for _ in range(q):
    b, c = map(int, input().split())
    if b in C:
        if c not in C: C[c] = 0
        s += (c - b) * C[b]
        C[c] += C[b]
        C[b] = 0
    print(s)


Measured memory_bytes: 21756
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s);

            int h = n / 3600;
            int m = (n - h * 3600) / 60;
            int s2 = n % 60;

            Console.WriteLine(h + ":" + m + ":" + s2);
            ////??\??????????????????????????????
            //string a = Console.ReadLine();
            
            //int n = int.Parse(a);


            //int[] s = new int[13];
            //int[] h = new int[13];
            //int[] c = new int[13];
            //int[] d = new int[13];

            ////???????????§??°?????????
            //for (int i = 0; i < n; i++)
            //{
            //    //??????????????????????????????
            //    string[] ss = Console.ReadLine().Split(' ');
            //    //ss[0]???mark???
            //    string mark = ss[0];
            //    //ss[1]???rank???
            //    int rank = int.Parse(ss[1]);

            //    //??????mark???????????£?????? s[rank - 1]????????¨??????
                
            //    if (mark == "S")
            //    {
            //        s[rank - 1] = 1;
            //    }
            //    //??????mark???????????£?????? h[rank - 1]????????¨??????
                
            //    if (mark == "H")
            //    {
            //        h[rank - 1] = 1;

            //    }
            //    //??????mark???????????£?????? c[rank - 1]????????¨??????
                
            //    if (mark == "C")
            //    {
            //        c[rank - 1] = 1;

            //    }
            //    //??????mark???????????£?????? d[rank - 1]????????¨??????
            //    if (mark == "D")
            //    {
            //        d[rank - 1] = 1;
            //    }
            //}
            ////0?????????????????§??°?????????????????§????????£??????S??¨one+1?????????
            //for (int one = 0; one < 13; one++) 
            //{
            //    if (s[one] != 1)
            //    {
            //        Console.WriteLine("S "+(one+1));
            //    }

            //}
            ////0?????????????????§??°?????????????????§????????£??????S??¨two+1?????????
            //for (int two = 0; two < 13; two++)
            //{
            //    if (h[two] != 1)
            //    {
            //        Console.WriteLine("H " +(two+1));
            //    }
            //}
            ////0?????????????????§??°?????????????????§????????£??????S??¨three+1?????????
            //for (int three = 0; three < 13; three++)
            //{
            //    if (c[three] != 1)
            //    {
            //        Console.WriteLine("C " + (three+1));
            //    }
            //}
            ////0?????????????????§??°?????????????????§????????£??????S??¨four+1?????????
            //for (int four = 0; four < 13; four++)
            //{
            //    if (d[four] != 1)
            //    {
            //        Console.WriteLine("D " + (four+1));
            //    }
            //}


        }
    }
}

Measured memory_bytes: 19928
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#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;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///

void solve(){
	ll n; double d;
	cin>>n>>d;
	int c=0;
	for(int i=0; i<n;  i++){
		double x,y;
		cin>>x>>y;
		if(sqrt(x*x+y*y)>d) c++;
	}
	cout<<n-c<<endl;
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3764
import math
N,K=map(int,input().split())
X=[(b,a*b)for a,b in zip(sorted(list(map(int,input().split()))),sorted(list(map(int,input().split())))[::-1])]
min_i, max_i, index = 0, 10**12, 1
while True:
    index, max_i, min_i = ((index-1 + min_i)//2, index-1, min_i) if sum(math.ceil(max(0,c-index)/b)for b, c in X)<=K else((index+1 + max_i)//2, max_i, index+1)
    if min_i > max_i:
        print(min_i)
        break

Measured memory_bytes: 123340
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

template <typename T>
inline auto enumerate_divisors (T n)
{
  set <T> res;
  for (T i = 1; i * i <= n; ++ i)
  {
    if (n % i == 0)
    {
      res.insert (i);
      res.insert (n / i);
    }
  }
  return res;
}

template <typename Container>
inline auto set_intersection (const Container & a, const Container & b)
{
  auto first1 = begin (a);
  auto last1 = end (a);
  auto first2 = begin (b);
  auto last2 = end (b);
  using T = typename iterator_traits <decltype(first1)>::value_type;
  vector <T> res;
  while (first1 != last1 && first2 != last2)
  {
    if (* first1 == * first2)
    {
      res.push_back (* first1);
      ++ first1;
      ++ first2;
    }
    else if (* first1 < * first2)
    {
      ++ first1;
    }
    else
    {
      ++ first2;
    }
  }
  return res;
}

template <typename T>
inline constexpr auto gcd (T m, T n) noexcept -> T
{
  return n == 0 ? abs (m) : gcd (n, m % n);
}

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  ll a, b;
  cin >> a >> b;

  auto yakusuu = set_intersection (enumerate_divisors (a), enumerate_divisors (b));
  vector <ll> ans;
  for (auto && elem : yakusuu)
  {
    if (all_of (ALL (ans), [&] (auto x) { return gcd (elem, x) == 1; }))
    {
      ans.push_back (elem);
    }
  }
  cout << ans.size () << endl;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,k=mii()
arr=limii()

visited=[0]*n

i=0

town=[0]

while visited[i]==0:
    visited[i]=1
    if i==0:
        visited[i]=1
    
    i=arr[i]-1

    town.append(i)

#town=[0, 5, 1, 4, 2, 1]
b=town.index(town[-1])
#at=[1, 4, 2]
at=deepcopy(town[b:-1])
#print(at,b)

if k<=b:
    print(town[k]+1)
    exit()

else:
    k-=b
    #print(k)
    a=k%len(at)
    #print(a)
    #print(at)
    print(at[a]+1)





Measured memory_bytes: 106380
lm = []
N,L = input().split()
N = int(N)
L = int(L)
for x in range(1,N+1):
    lm.append((abs(L+x-1),L+x-1))
lm.sort()
lm = lm[1::]
s = 0
for u in range(len(lm)):
    s = s + lm[u][1]
print('{}'.format(s))

Measured memory_bytes: 3064
<?php

$map = array_fill(0, 10, array_fill(0, 10, 0));
while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d,%d,%d', $x, $y, $size);
    //1は別処理
    if ($size === 1) {
        isset($map[$y - 1]) && $map[$y - 1][$x]++;
        isset($map[$y + 1]) && $map[$y + 1][$x]++;
        isset($map[$y][$x - 1]) && $map[$y][$x - 1]++;
        isset($map[$y][$x + 1]) && $map[$y][$x + 1]++;
        $map[$y][$x]++;
        continue;
    }

    //3だけが有する部分
    if ($size === 3) {
        isset($map[$y - 2]) && $map[$y - 2][$x]++;
        isset($map[$y + 2]) && $map[$y + 2][$x]++;
        isset($map[$y][$x - 2]) && $map[$y][$x - 2]++;
        isset($map[$y][$x + 2]) && $map[$y][$x + 2]++;
    }

    //2と3の共通部分
    for ($y2 = $y - 1; $y2 <= $y + 1; $y2++) {
        if ($y2 < 0 || $y2 > 9) {
            continue;
        }
        for ($x2 = $x - 1; $x2 <= $x + 1; $x2++) {
            if ($x2 >= 0 && $x2 < 10) {
                $map[$y2][$x2]++;
            }
        }
    }
}

$cnt = 0;
$max = 0;
for ($y = 0; $y < 10; $y++) {
    for ($x = 0; $x < 10; $x++) {
        $n = $map[$y][$x];
        $max = max($max, $n);
        !$n && $cnt++;
    }
}

printf("%d\n%d\n", $cnt, $max);

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

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 3003;
const int mod = 998244353;

int dp[N][N][3];

void add(int& x, int y) {
	x += y;
	if (x >= mod) {
		x -= mod;
	}
}

int prod(int x, int y) {
	return 1ll * x * y % mod;
}

int main() {
	int a = nxt(), b = nxt(), c = nxt(), d = nxt();
	dp[a][b][1] = 1;
	for (int i = a; i <= c; ++i) {
		for (int j = b; j <= d; ++j) {
			for (int state : {1, 2}) {
				if (!dp[i][j][state]) {
					continue;
				}
				// fprintf(stderr, "dp[%d][%d][%d] = %d\n", i, j, state, dp[i][j][state]);
				if (i < c) {
					add(dp[i + 1][j][1], dp[i][j][state]);
					add(dp[i + 1][j][state == 1], prod(dp[i][j][state], j - 1));
				}
				if (j < d && state) {
					add(dp[i][j + 1][2], prod(dp[i][j][state], i));
				}
			}
		}
	}

	int ans = 0;
	for (int state : {1, 2}) {
		add(ans, dp[c][d][state]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 109212
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	string S; cin >> S;
	int ans = 1000;
	vector<string> s(S.size() - 2);
	rep(i, s.size()) {
		s[i] = S.substr(i, 3);
	}

	rep(i, s.size()) {
		int num = atoi(s[i].c_str());
		ans = min(ans, abs(num - 753));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;

  int a[n];
  int sum = 0;

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

  float h = (float)sum/n;
  float dis = 1000;
  int ans = 0;

  for (int i = 0 ; i < n ; i ++)
    {
      if (abs(a[i]-h)<dis){
	dis = abs(a[i]-h);
	ans = i;
      }
    }
  cout << ans << endl;
}


Measured memory_bytes: 256