akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int x,y;
    cin >> x >> y;
    if((y-2*x)/2>=0 && (y-2*x)%2==0 && (4*x-y)/2>=0 &&(4*x-y)%2==0) cout << "Yes" << endl;
    else cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
#include<algorithm>
#include<string>
#include<cstring>

int dp[1002][1002] = { 0 };

int main() {
	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		string x, y;
		int cnt = 0;
		cin >> x >> y;
		memset(dp, 0, sizeof(dp));

		for (int j = 1; j <= x.size(); ++j) {
			for (int j2 = 1; j2 <= y.size(); ++j2) {
				if (x[j - 1] == y[j2 - 1]) {
					dp[j][j2] = max(dp[j][j2 - 1], dp[j - 1][j2 - 1] + 1);
				}
				else {
					dp[j][j2] = max(dp[j][j2 - 1], dp[j - 1][j2]);
				}
			}
		}
		cout << dp[x.size()][y.size()] << endl;
	}

	return 0;
}

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

class Program
{

	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] S = Console.ReadLine().Split(' ');
		long N = long.Parse(S[0]);
		long K = long.Parse(S[1]);

		/*

		//累積和を格納する配列
		long[] sumArr = new long[N+1];
		for(int i=1; i<N+1; i++){
				long idx = (long)i;
				sumArr[i] = idx*(idx+1)/2;
		}

		*/

		/*
		K<=i<=N+1となる各iについて、有り得る組み合わせの数は、
		それぞれ最大値-最小値+1通りである。（∵最小値から最大値までの全ての数を作成可能）
		最大値-最小値については、累積和から容易に求められる
		*/
		long ans = 0;

		/*

		for(long i=K; i<=N+1; i++){
					//最小値
					long min = sumArr[i-1];
					//最小値
					long max = sumArr[N] - sumArr[N-i];

					//組み合わせの数を答えに加算
					ans += (max-min+1);

				//上記計算式を一般化して解く
				//（sumArr[j] = j(j+1)/2であることに着目）
				ans += (i*N - i*(i-1) + 1);
		}

		*/


		/*

		ここからは、O(1)で求める為の式を導く

		*/

		/*
		(i*N - i*(i-1) + 1)について、K<=i<=N+1の和を求めれば良い
		（累積和と同様、1<=i<=N+1の和から1<=i<=K-1の和を引けば良い）
		以下、ans = sum1 - sum2として考える。
		*/

		//（１）まず、(i*N - i*(i-1) + 1)について、1<=i<=jまでの和を考える。
		/*
		i*Nの部分については、(j(j+1)/2) * N
		- i*(i-1)の部分については、-j(j+1)(2j+1)/6 + j(j+1)/2
		1の部分については、j
		*/
		/*
		以上より、1<=i<=jまでの和は、
		j(j+1)(3N-2j+2)/6 + jとなる。
		*/

		//（２）sum1とsum2
		//よってsum1は、j=N+1を代入し、
		//sum1 = N(N+1)(N+2)/6 + N+1
		//sum1 = (N+1)(N^2+2N+6)/6

		//sum2については、j=K-1を代入し、
		//sum2 = K(K-1)(3N-2K+4)/6 + K-1

		//（３）答え
		//ans = sum1 - sum2で求められる
		long sum1 = (N+1)*(N*N + 2*N + 6);
		sum1 /= 6;

		long sum2 = K*(K-1)*(3*N - 2*K + 4);
		sum2 /= 6;
		sum2 += (K-1);

		ans = sum1 - sum2;


		Console.WriteLine(ans%1000000007);
	}
}



Measured memory_bytes: 17860
#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;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    string s;
  	int t;
  	cin>>t;
  	cin>>s;
  	f(i, s.length()) {
  		int to = s[i] - 'A';
  		to += t;
  		to %= 26;
  		cout<<(char)(to + 'A');
  	}
    return 0;
}

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

int N;
int C[NUM], S[NUM], F[NUM];

void solve() {
  for (int i = 0; i < N; i++) {
    int time = 0;
    for (int j = i; j < N; j++) {
      if (time >= S[j]) {
        if (time % F[j] != 0) {
          time = (time / F[j] + 1) * F[j];
        }
        time += C[j];
      } else {
        time = S[j];
        time += C[j];
      }
    }
    cout << time << endl;
  }
  cout << 0 << endl;
}

int main() {
  cin >> N;
  N = N - 1;
  for (int i = 0; i < N; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }

  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int N = s.nextInt();

        String ans = "No";
        for (int i = 1; i < 10; i++) {
            if (ans == "Yes") break;
            for (int j = 1; j < 10; j++) {
               if (N == i * j )  {
                   ans = "Yes";
                   break;
               }
            }
        }

        System.out.println(ans);
        s.close();
    }
    
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=3005;
int n;
double a[maxn];
double f[maxn][maxn];
int main()
{
	cin>>n;
	rep(i,1,n)
	{
		cin>>a[i];
	}
	f[1][1]=a[1];f[1][0]=((double)1-a[1]);
	rep(i,2,n)
	{
		f[i][0]=f[i-1][0]*((double)1-a[i]);
		rep(j,1,i)
		{
			f[i][j]=f[i-1][j-1]*a[i];
			if(j!=i) f[i][j]+=f[i-1][j]*((double)1-a[i]);
		}
	}
	double ans=0;
	rep(i,n/2+1,n) ans+=f[n][i];
	printf("%.10f\n",ans);
	return 0;
}

Measured memory_bytes: 68992
//bismillah
//created by anaksoleh
//24 Dec 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
int N,W;
ll dp[103][100005];
ll w[103];
ll v[103];

void solve()
{
    for(int i = 1 ; i <= N ; i++){
        for(int c = 0 ; c <= W ; c++){
            ll best = dp[i-1][c];
            if(c >= w[i]){
                best = max(best,dp[i-1][c - w[i]] + v[i]);
            }
            dp[i][c] = best;
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> N >> W;
    for(int i = 1 ; i <= N ; i++){
        cin >> w[i] >> v[i];
    }
    solve();
    cout << dp[N][W] << '\n';

    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
long long a,b;
/* 
int get(int x)
{
	if(x==fa[x])	return x;
	return fa[x]=get(fa[x]);
}//路径压缩 
int merge(int x,int y)
{
	fa[get(x)]=get(y);
}//合并 */ 
int ans=1;
int main()
{
	cin>>a>>b;
	if(a<b)
	{
		long long c=a;
		a=b;
		b=c;
	}
//	cout<<a;
	while(b!=0)
	{
		a=a%b;
		if(a<b)
		{
			long long c=a;
			a=b;
			b=c;
		}
	}
	//cout<<a;
	for(int i=2;(long long)i*i<=a;i++)
	{
		if(a%i==0)
		{
			ans++;
			while(a%i==0)	a/=i;
		}
	}
	if(a>1) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
hoge = []
cnt = 0
for i in range(k):
    d = int(input())
    c = list(map(int,input().split()))
    for i in range (len(c)):
        hoge.append(c[i])
for i in range (n):
    if i+1 in hoge:
        cnt += 0
    else:
        cnt += 1
print(cnt)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,ans;
std::vector<int> c,v;
int main(){
  cin >> n;
  c.resize(n);v.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (size_t i = 0; i < n; i++) {
    cin >> c[i];
    if(v[i]-c[i] > 0)ans+= v[i]-c[i];
  }
  cout << ans << endl; 
}


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

using namespace std;
using ll = long long;



void dfs(int node, vector<int> dir[], int dp[], bool vis[]) {
    vis[node] = 1;
    for(int i = 0; i < dir[node].size(); i++) {
        if(!vis[dir[node][i]]) {
            dfs(dir[node][i], dir, dp, vis);
        }

        dp[node] = max(dp[node], 1 + dp[dir[node][i]]);
    }
}




int longest(vector<int> dir[], int N) {
    int dp[N + 1];
    memset(dp, 0, sizeof(dp));

    bool vis[N + 1];
    memset(vis, 0, sizeof(vis));

    for(int i = 1; i < N + 1; i++) {
        if(!vis[i]) {
            dfs(i, dir, dp, vis);
        }
    }

    int res = 0;
    for(int i = 1; i < N + 1; i++) {
        res = max(res, dp[i]);
    }

    return res;

}


int main() {
    int N, M, X, Y;
    cin >> N >> M;
    vector<int> dir[N + 1];

    for (size_t i = 1; i < M + 1; i++)
    {
        cin >> X >> Y;
        dir[X].push_back(Y);
    }

    cout << longest(dir, N) << endl;
    
}


/*ダメ，時間かかる，元のところに来たときがやばい
int main() {
    int N = 0, M;
    cin >> M >> N;
    vector<int> x(N,0);
    vector<int> y(N,0);
    vector<int> longest(M,0);
    for(int i = 0; i < N; i++) {
        cin >> x.at(i);
        cin >> y.at(i);
    }
    
    for (size_t i = 0; i < N; i++)
    {
        longest.at(y.at(i) - 1) = max(longest.at(y.at(i) - 1), 1 + longest.at(x.at(i) - 1));
    }
    *


    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = 0; j < N; j++)
        {
            longest.at(y.at(i) - 1) = max(longest.at(y.at(i) - 1), 1 + longest.at(x.at(i) - 1));
        }
    }
    sort(longest.begin(),longest.end());
    cout << longest.at(longest.size() - 1) << endl;
    


    return 0;
}

*/

Measured memory_bytes: 12768
#include <bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define int long long


int solve() {
	int N, W;
	cin >> N >> W;
	int w[N], v[N];
	int i;
	for (i = 0; i < N; i++)cin >> w[i] >> v[i];
	int dp[N + 1][W + 1];

	for (i = 0; i <= N; i++)dp[i][0] = 0;
	for (i = 0; i <= W; i++)dp[0][i] = 0;
	int j;
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= W; j++) {
			if (j >= w[i - 1])dp[i][j] = max(dp[i - 1][j] , dp[i - 1][j - w[i - 1]] + v[i - 1]);
			else dp[i][j] = dp[i - 1][j];
		}
	}

	return dp[N][W];
}




int32_t main() {
	std::ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	cout << solve();
	return 0;
}

Measured memory_bytes: 82416
#include <iostream>
#include <bits/stdc++.h>
#define MAX_SIZE 500010
#define INFTY 2000000000
using namespace std;

int H;
int A[MAX_SIZE];

int left(int i) {
    return 2 * i;
}
int right(int i) {
    return 2 * i + 1;
}
int parent(int i) {
    return i / 2;
}

void maxHeapify(int i) {
    int largest = i;
    int l = left(i);
    int r = right(i);
    if (l <= H && A[l] > A[i]) {
        largest = l;
    } 
    if (r <= H && A[r] > A[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

void buildMaxHeap() {
    for (int i=H/2; i > 0; i--) {
        maxHeapify(i);
    }
}

int main(){
    int a;
    cin >> H;
    for (int i=1; i <= H; i++) {
        scanf("%d", &a);
        A[i] = a;
    }
    buildMaxHeap();
    for (int i=1; i <= H; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");
    return 0;
} 


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

int main () {
    string a, b;
    cin >> a >> b;
    int n = a.size();
    int res = 0;
    for (int i = 0; i < n; i++) res += a[i] != b[i];
    cout << res << "\n";
}



Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5,mod=1e9+7;
vector<ll> build_lps(vector<ll> p){
    ll sz = p.size();
    vector<ll> lps(sz,0);
    for(ll i=1,j=0;i<sz;i++){
        while(j >= 0 && p[i] != p[j]){
            if(j >= 1) j = lps[j - 1];
            else j = -1;
        }
        j++;
        lps[i] = j;
    }
    return lps;
}
vector<ll>ans;
void kmp(vector<ll> lps, vector<ll> s, vector<ll> p){
	ll psz = p.size(), sz = s.size();
	for(ll i=0,j=0;i<sz;i++){
		while(j>=0&&p[j]!=s[i]){
			if(j>=1)j=lps[j - 1];
			else j=-1;
		}
		j++;
		if(j==psz)j=lps[j - 1],ans.push_back(i-psz+1);
	}
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll b[n];for(ll i=0;i<n;i++)cin>>b[i];
    vector<ll>c;for(ll i=0;i<n;i++)c.push_back(a[i]^a[(i+1)%n]);
    vector<ll>d;for(ll i=0;i<n;i++)d.push_back(b[i]^b[(i+1)%n]);
    for(ll i=0;i<n;i++)d.push_back(d[i]);
    vector<ll>lps=build_lps(c);
    kmp(lps,d,c);
    reverse(ans.begin(),ans.end());
    for(auto &x:ans)if(x)cout<<n-x<<" "<<(a[0]^b[x%n])<<"\n";
}

Measured memory_bytes: 20532
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
typedef long long ll;
#define pb(x) push_back(x) 

ll mod1=1e9+7,mod2=1e9+9;
ll base1=1007,base2=1311;
ll power1[N],power2[N];
void InitPower(int n){
    power1[0]=power2[0]=1;
    for(int i=1;i<=n;++i){
        power1[i]=power1[i-1]*base1%mod1;
        power2[i]=power2[i-1]*base2%mod2;
    }
}
struct Hash{
    Hash(ll hash1=0,ll hash2=0):hash1_(hash1),hash2_(hash2){}
    bool operator <(Hash h)const{
        if (hash1_==h.hash1_)return hash2_<h.hash2_;
        else return hash1_<h.hash1_;
    }
    ll hash1_,hash2_;
};
vector<Hash> ha[N];
Hash GetHash(int i,int x,int y){
    return Hash(((ha[i][y].hash1_-ha[i][x-1].hash1_*power1[y-x+1])%mod1+mod1)%mod1,
                ((ha[i][y].hash2_-ha[i][x-1].hash2_*power2[y-x+1])%mod2+mod2)%mod2);
}
vector<int> str[N];
map<Hash,vector<int>> mp;

int cnt[26];
int main(){
    InitPower(N-1);
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        str[i].pb(0);
        int ch;
        do{
            ch=getchar();
        }while(isspace(ch));
        do{
            str[i].pb(ch-'a');
        }while(!isspace(ch=getchar()));
        ha[i].resize(str[i].size());

        for(int j=1;j<str[i].size();++j){
            ha[i][j].hash1_=(ha[i][j-1].hash1_*base1+str[i][j]+17)%mod1;
            ha[i][j].hash2_=(ha[i][j-1].hash2_*base2+str[i][j]+11)%mod2;
        }
        Hash hash(0,0);
        if(str[i].size()!=2)
            hash=GetHash(i,2,str[i].size()-1);
        if(mp.find(hash)==mp.end())
            mp[hash]=vector<int>(26,0);
        ++mp[hash][str[i][1]];
    }
    ll ans=0;
    for(int i=1;i<=n;++i){
        memset(cnt,0,sizeof(cnt));
        for(int j=1;j<str[i].size();++j)
            ++cnt[str[i][j]];
        for(int j=str[i].size();j>1;--j){
            Hash hash(0,0);
            if(j!=str[i].size()){
                hash=GetHash(i,j,str[i].size()-1);
                --cnt[str[i][j]];
            }
            if(mp.find(hash)==mp.end())continue;
            vector<int> &tmp=mp[hash];
            for(int k=0;k<26;++k)
                if(cnt[k]>0){
                    //assert(tmp[k]<=1);
                    ans+=tmp[k];
                }
        }
    }
    ans-=n;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 122724
h, w, k = gets.split.map(&:to_i)
c = Array.new(h){gets.chomp.bytes}
cnt = 0
[0, 1].repeated_permutation(h).each do |x|
  m = Marshal.load(Marshal.dump(c))
  x.each_with_index do |y, i|
    next if y == 0
    w.times do |j|
      m[i][j] = '.'.ord
    end
  end
  [0, 1].repeated_permutation(w) do |u|
    mc = Marshal.load(Marshal.dump(m))
    u.each_with_index do |v, j|
      next if v == 0
      h.times do |i|
        mc[i][j] = '.'.ord
      end
    end
    cnt += 1 if mc.flatten.count('#'.ord) == k
  end
end
puts cnt

Measured memory_bytes: 14376
#include <stdio.h>
#include <math.h>
int main(void)
{
    int n;
    int i,j;
    int count;
    int prime[999999] = {0};

    while(scanf("%d", &n) != EOF){
        count = 0;
        for (i = 2; i <= sqrt(n); i++){
            if (prime[i] != 1){
                for (j = 2*i; j <= n; j += i){
                    prime[j] = 1;
                }
            }
        }
        for (i = 2; i <= n; i++){
            if (prime[i] != 1){
                count++;
            }
        }
        
        
        printf("%d\n",count);
    }
    
    return (0);
}


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

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

using namespace std;

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

  for (int i = 0; 4 * i <= N; ++i) {
    for (int j = 0; 7 * j <= N; ++j) {
      if (4 * i + 7 * j == N) {
        cout << "Yes";
        return 0;
      }
    }
  }

  cout << "No";
}

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

int main() {
  vector<int> a(5);
  for(int i=0; i<5; i++){
  cin >> a[i];
  }
  
  int p = 0;
  int min = 10;
  for(int i=0; i<5; i++){
    if(a[i]%10 == 0){
      p += a[i]; 
    }
    else{
      if(a[i]%10 < min){
        min = a[i]%10;
      }
      p += 10 + a[i] - a[i]%10;
    }
  }
  
  p -= 10 - min;
  cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int p = (a + d - 1) / d;
  int q = (c + b - 1) / b;
  if(p >= q)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int n,x,ans = 0 ;
    cin>>n;
    vector<int> V;
    for(int i=0;i<n;i++){
        cin >> x;
        V.push_back(x);
    }   
    sort(V.begin(),V.end());
    int s=V[0];
    for(int i=1;i<n;i++){
        ans += abs(s - V[i]);
        s = V[i];
    }
    cout<< ans;
}


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

using namespace std;

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

typedef long long int ll;


int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

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

	int i = min(a,b);
	while(k > 0)
	{
		if(a%i == 0 && b%i == 0)
			k--;
			
		if(k == 0)
		{
		    cout << i;
		    return 0;
		}
		i--;
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp

pattern1 = '01' * (s.size / 2)
pattern1 += '0' if s.size % 2 == 1
pattern2 = '10' * (s.size / 2)
pattern2 += '1' if s.size % 2 == 1

tiles1 = (pattern1.to_i(2) ^ s.to_i(2)).to_s(2).count('1')
tiles2 = (pattern2.to_i(2) ^ s.to_i(2)).to_s(2).count('1')

puts tiles1 < tiles2 ? tiles1 : tiles2


Measured memory_bytes: 4476
#include<iostream>

using namespace std;

int n, A[50];

int solve (int i, int m){
  if(m == 0)
    return 1;
  if(i >= n)
    return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;

  cin >> n;
  for(i = 0; i < n; i++)
    cin >> A[i];
  cin >> q;
  for(i = 0; i < q; i++){
    cin >> M;
    if( solve(0, M) )
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }

  return 0;
}

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

void solve(long long n, std::vector<std::string> S) {
  vector<map<char, int>> counts;
  for (auto &s : S) {
    map<char, int> m;
    for (auto c : s) {
      m[c]++;
    }
    counts.push_back(m);
  }
  map<char, int> resMap;
  for (int i = 'a'; i <= 'z'; i++) {
    bool valid = true;
    int minVal = INT_MAX;
    for (auto m : counts) {
      if (!m.count(i)) {
        valid = false;
      } else {
        minVal = min(minVal, m[i]);
      }
    }
    if (valid) {
	resMap[i] = minVal;
    }
  }
  string res;
  for (auto elem : resMap) {
    for (int i = 0; i < elem.second; i++) {
	res.push_back(elem.first);
    }
  }
  cout << res << endl;
}

int main() {

  long long n;
  scanf("%lld", &n);
  std::vector<std::string> S(n);
  for (int i = 0; i < n; i++) {
    std::cin >> S[i];
  }
  solve(n, std::move(S));
  return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
suma=[0]*(n+1)
suma[1]=a[0]
acnt=1
for i in range(2,n+1):
  if suma[i-1] > k:
    break
  suma[i] = suma[i-1]+a[i-1]
  acnt+= 1
#acnt:sumaが入っている範囲
btt=0
btl=0
res=0
ans=0
for i in reversed(range(acnt+1)):
  res=suma[i]+btt
  if res > k:
    continue
  for j in range(btl,m):
    if res+b[j] <= k:
      res += b[j]
      btt += b[j]
      btl += 1
    else:
      break
  ans = max(ans, i+btl)
print(ans)

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

long b[111111], l[111111], u[111111], k[111111];
int main() {
	int n, x;
	cin >> n >> x;
	iota(k, k + n, 0);
	long t = 0, a = 0;
	for (int i = 0; i < n; i++)
		scanf("%ld%ld%ld", b + i, l + i, u + i), t += l[i] * b[i];
	sort(k, k + n, [&](auto i, auto j) {
		return u[i] * x - (u[i] - l[i])*b[i] > u[j] * x - (u[j] - l[j])*b[j];
	});
	for (; t > 0; a++)
		t -= u[k[a]] * x - (u[k[a]] - l[k[a]])*b[k[a]];
	a--;
	long r = 1e11;
	for (int i = 0; i < a; i++)
		r = min(min(r, (t + u[k[i]] * x - (u[k[i]] - l[k[i]])*b[k[i]] + l[k[i]] - 1) / l[k[i]]),
		(t + u[k[i]] * x + u[k[i]] - 1) / u[k[i]]);
	t += u[k[a]] * x - (u[k[a]] - l[k[a]])*b[k[a]];
	for (int i = a; i < n; i++)
		r = min(min(r, (t + l[k[i]] - 1) / l[k[i]]),
		(t + (u[k[i]] - l[k[i]])*b[k[i]] + u[k[i]] - 1) / u[k[i]]);
	cout << a * x + r << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <set>
#include <string>

int main(void)
{
    int n;
    std::cin >> n;
    std::set<std::string> se;
    for(int i = 0;i < n;i++){
        std::string s;
        std::cin >> s;
        se.insert(s);
    }
    std::cout << se.size() << std::endl;
    return 0;
}

Measured memory_bytes: 19052
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
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; }


int N, K;
int A[200010];
int B[200010];
map<int, int> m;


signed main(){
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    repe(i, 1, N) B[i] = B[i-1]+A[i-1];
    repe(i, 0, N) (B[i]-=i)%=K;

    int ans = 0;
    rep(i, 0, min(N+1, K)) m[B[i]]++;
    for(auto p : m) if(p.second > 1) ans += p.second*(p.second-1)/2;
    if(K <= N) repe(i, 0, N-K){
        m[B[i]]--;
        ans += m[B[i+K]];
        m[B[i+K]]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    string s; cin >> s;
    int slen = s.length();
    reverse(s.begin(), s.end());
    int x = 1, rest = 0;
    vector<int> cnt(2019);
    ll ans = 0;
    for(int i = 0; i < slen; ++i) {
        cnt[rest]++;
        rest += (s[i] - '0')*x;
        rest %= 2019;
        ans += cnt[rest];
        x = x*10%2019;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin >> c;
  int count=0;
   for (int i = 0; i < c.size(); i++) {
        if (c[i] == '1') {
            count++;
        }
    }
  cout << count <<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      if(A-B<=C){
        System.out.println(C-(A-B));
      }else{
        System.out.println(0);
      }
    }
}
      

Measured memory_bytes: 35736
import sys
input = sys.stdin.readline

n = int(input())
g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

# topological sort
s = []
s.append(0)
parent = [-1]*n
order = []
while s:
    v = s.pop()
    order.append(v)
    for u in g[v]:
        if u == parent[v]:
            continue
        parent[u] = v
        s.append(u)

dp = [1]*n
c = [0]*n
order.reverse()
for v in order:
    dp[v] *= g1[c[v]]
    dp[v] %= mod
    c[v] += 1
    if parent[v] == -1:
        continue
    c[parent[v]] += c[v]
    dp[parent[v]] *= (dp[v]*g2[c[v]])
    dp[parent[v]] %= mod

order.reverse()
ans = [0]*n
for v in order:
    ans[v] = dp[v]
    for u in g[v]:
        if u == parent[v]:
            continue
        dp[u] *= ans[v]*g2[c[v]-1]*g1[c[v]-1-c[u]]*g1[c[u]]*pow(dp[u],(mod-2),mod)
        dp[u] *= g2[c[u]-1]
        dp[u] *= g1[c[v]-1]
        dp[u] *= g2[c[v]-c[u]]
        dp[u] %= mod
        c[u] = c[v]
for i in range(n):
    print(ans[i]%mod)


Measured memory_bytes: 148456
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #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 REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

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

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,a[100010],gcdl[100010],gcdr[100010];
int ugcd(int a, int b){
    if (a > b) swap(a,b);
    return a == 0 ? b : ugcd(b%a, a);
}

int ret = 1;
signed main(){
    I(n);
    REP(i,n) I(a[i]);

    gcdl[0] = a[0];
    FOR(i,1,n) gcdl[i] = ugcd(gcdl[i-1], a[i]);
    gcdr[n-1] = a[n-1];
    REPN(i,n-1) gcdr[i] = ugcd(gcdr[i+1], a[i]);

    ret = gcdr[1];
    FOR(i,1,n) ret = max(ret, ugcd(gcdl[i-1], gcdr[i+1]));

    cout << ret << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int ar[200005] = {};
    long long ans =0;
    int n, k, x;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    sort(ar, ar + n, greater<int>());
    for (int i = k; i < n; i++)
    {
        ans += ar[i];
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

ll gcd(ll x, ll y) {
    if(x < y) return gcd(y, x);
    while (y != 0LL) {
        ll tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

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

int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll cd = lcm(c,d);
    ll X = b/c - (a-1)/c;
    ll Y = b/d - (a-1)/d;
    ll Z = b/cd - (a-1)/cd; 
    cout << (b-a+1) - (X+Y-Z) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxb = 5000 + 10;
const int INF = maxn * maxb + 10;
int n, a[maxn], f[maxn][2], dp[maxn][maxb];
vector<int> E[maxn];
void dfs(int x)
{
	for(auto v : E[x])
		dfs(v);
	for(int k = 0; k < 2; ++k)
	{
		for(int i = 0; i <= E[x].size(); ++i)
			fill(dp[i], dp[i] + a[x] + 1, INF);
		dp[0][0] = 0;
		for(int i = 1; i <= E[x].size(); ++i)
		{
			int v = E[x][i - 1];
			for(int j = 0; j <= a[x]; ++j)
			{
				if(j >= a[v]) dp[i][j] = min(dp[i][j], dp[i - 1][j - a[v]] + f[v][k ^ 1]);
				if(j >= f[v][k]) dp[i][j] = min(dp[i][j], dp[i - 1][j - f[v][k]] + a[v]);
			}
		}
		f[x][k] = INF;
		for(int j = 0; j <= a[x]; ++j) f[x][k] = min(f[x][k], dp[E[x].size()][j]);
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 2; i <= n; ++i) 
	{
		int v;
		scanf("%d", &v); 
		E[v].push_back(i);
	}
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	dfs(1);
	if(min(f[1][0], f[1][1]) < INF) puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}
	

Measured memory_bytes: 17280
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int sum = 0;
			int tmp = i;
			while (tmp > 0) {
				sum += tmp % 10;
				tmp /= 10;
			}

			if (sum >= a && sum <= b) {
				ans += i;
			}
		}

		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
package main

import "fmt"

func main() {
	var X int
	fmt.Scan(&X)
	for x := X; true; x++ {
		isPrime := true
		for i := 2; i*i <= x; i++ {
			if x%i == 0 {
				isPrime = false
				break
			}
		}
		if isPrime {
			fmt.Println(x)
			return
		}
	}
}


Measured memory_bytes: 1772
#include <stdio.h>
void mergesort(int*,int,int); 
void merge(int*,int,int,int); 
int c=0;
int main(){
  int n,a[500000],i,mid;
  scanf("%d",&n);
   for(i=0;i<n;i++) scanf("%d",&a[i]);
   mid=n/2;
   mergesort(a,0,n);
  for(i=0;i<n-1;i++)  
    printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],c);
  return 0;
}
void mergesort(int A[], int left,int right){
  int mid;
  if (left+1 < right){
    
mid = (left + right)/2;
    mergesort(A, left, mid);
      mergesort(A, mid, right);
      merge(A, left, mid, right);
}
}
  void merge(int A[],int left,int mid,int right){
  int i,j,k,n1,n2,L[500000],R[500000];  

  n1 = mid - left;
  n2 = right - mid;

  for (i = 0; i<n1;i++)
    L[i] = A[left + i];
  for (i = 0; i<n2;i++)
    R[i] = A[mid + i];
  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = 0;
  j = 0;
  for (k = left;k< right;k++)
{
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      c++;
    }
    else {
      A[k] = R[j];
      j = j + 1;
      c++;    
}
  }
  }

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;

const int INF = 100000000;
const ll LINF = 1e18+5;

const ll M = 998244353; // modの値

vector<ll> fac(12000000); // n! mod M
vector<ll> ifac(12000000); // k^{M-2} mod M

ll mpow(ll x, ll n){ // x^n(modM)
    ll ans = 1;
    while (n!=0) {
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n= n>>1;
    }
    return ans;
}

ll comb(ll a, ll b) { // aCb mod M
    if (a==0 && b==0) return 1;
    if (a<b || a<0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % M;
    return tmp * fac[a] % M;
}

void init_comb() {
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i=0;i<12000000;i++) {
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i] * mpow(i+1, M-2) % M; // k^{M-2} mod M
    }
}

int main() {
    ll N;
    cin >> N;
    init_comb();
    ll Anum = 0LL;
    REP(k,N/2+1,N+1) {
        Anum += (mpow(2, N-k) * comb(N, k)) % M;
        Anum %= M;
    }
    ll ans = (mpow(3, N) - 2 * Anum + 3*M) % M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 187776
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int k;
  cin >> k;
  for (int i = 0; i < k; i++){
    cout << "ACL";
  }
  
  cout << '\n';

  return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;





int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,j,n;
	cin>>n;
	int c[n-1],s[n],f[n-1];
	rep(i,n-1) cin>>c[i]>>s[i]>>f[i];
	s[n-1]=0;
	//動き続けてアップアップ！！
	//mod切り上げをしよう
	//O(N^2) でとけるはず！ 
	int ans;
	for(i=0;i<n-1;i++){
		ans=s[i];
//		cout<<"1:"<<ans<<endl;
		for(j=i;j<n-2;j++){
			ans+=c[j];
//			cout<<"2:"<<ans<<endl;
			if(ans<=s[j+1]){
				ans=s[j+1];
			}
			else{
			//ans切り上げ作業 
//			cout<<ans<<" "<<s[j+1]<<" "<<f[j+1]<<endl;
				ans=s[j+1]+f[j+1]*ceil((double)(ans-s[j+1])/(double)f[j+1]);
			}
//			cout<<"3:"<<ans<<endl;
		}
		cout<<ans+c[n-2]<<endl;
	}
	cout<<0<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
N = int(input())

div = []
for n in range(1, int(N ** 0.5) + 1):
    if N % n == 0:
        div.append(n)
        div.append(N // n)

ans = 0

for d in div:
    if d - 1 <= 0:
        continue
    if N // (d - 1) != (N % (d - 1)):
        continue

    if (d - 1) ** 2 <= N:
        continue
    ans += (d - 1)

print(ans)


Measured memory_bytes: 40172
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN, PP;


  std::cin >> NN>>PP;


  // soinsu bunkai of PP
  int max_lis = 10000;
  ll soinsu_list[max_lis];
  ll soinsu_num[max_lis];
  int sonisu_len = 0;



  for (size_t i = 2; i*i < PP + 1; i++) {

    if (PP%i == 0) {
      soinsu_list[sonisu_len] = i;
      soinsu_num[sonisu_len] = 0;

      while (PP%i == 0) {
        PP /= i;
        soinsu_num[sonisu_len]++;
      }
      sonisu_len++;
    }

  }

  if (PP > 1) {
    soinsu_list[sonisu_len] = PP;
    soinsu_num[sonisu_len] = 1;
    sonisu_len++;
  }
  // std::cout << "finishi bunkai" << '\n';
  //
  // for (size_t i = 0; i < sonisu_len; i++) {
  //   std::cout << soinsu_list[i]<< "   " << soinsu_num[i]<<'\n';
  // }

  ll ans = 1;
  for (size_t i = 0; i < sonisu_len; i++) {
    // ans *= pow(soinsu_list[i], soinsu_num[i]/NN );
    for (size_t i3 = 0; i3 < soinsu_num[i]/NN; i3++) {
      ans*=soinsu_list[i];
    }
  }

  std::cout << ans << '\n';


  return 0;
}


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

using namespace std;

#define loop(i, a, b) for(int i = a; i < b ; i++)
#define rep(i, a) loop(i, 0, a)
#define MAX 1000000

int main()
{
  bool prime[MAX];
  rep(i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  loop(i, 2, sqrt(MAX)){
    for(int j = i * 2; j < MAX; j += i){
      prime[j] = false;
    }
  }
  
  int n;
  while(cin >> n) {
    int cnt = 0;
    loop(i, 2, n + 1) if(prime[i] == true) cnt++;
    cout << cnt << endl;
  }
}

Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>

using namespace std;
/**==Info==
*Program:3
*Problem:Fennec VS. Snuke
*Date:2017-7-16
*Algorithm:BFS*/
int df[100005];
int ds[100005];
pair<int,int> roads[100005];
queue<int> q;
vector<int> nei[100005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		roads[i]=(a>b?make_pair(b,a):make_pair(a,b));
		nei[a].push_back(b);
		nei[b].push_back(a);
	}
	
//	for(int i=0;i<n;i++){
//		for(int j=0;j<nei[i].size();j++){
//			cout<<nei[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	
	//First BFS
	q.push(0);
	df[0]=1;
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		//cout<<last<<" "<<nei[last].size();
		for(int i=0;i<nei[last].size();i++){
			if(df[nei[last][i]]==0){
				df[nei[last][i]]=df[last]+1;
				q.push(nei[last][i]);
			}
		}
	}
	
//	for(int i=0;i<n;i++){
//		cout<<df[i]<<" ";
//	}

	//Second BFS
	q.push(n-1);
	ds[n-1]=1;
	while(!q.empty()){
		int last=q.front();
		q.pop();
		for(int i=0;i<nei[last].size();i++){
			if(ds[nei[last][i]]==0){
				ds[nei[last][i]]=ds[last]+1;
				q.push(nei[last][i]);
			}
		}
	}
//	
//	for(int i=0;i<n;i++){
//		cout<<df[i]<<" ";
//	}
//	cout<<endl;
//	for(int i=0;i<n;i++){
//		cout<<ds[i]<<" ";
//	}
	cout<<endl;
	int fwin=0,swin=0;
	
	for(int i=0;i<n;i++){
		if(df[i]<=ds[i])fwin++;else swin++;
	}
	
	cout<<(fwin>swin?"Fennec":"Snuke");
	return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

int main() {
	int A, B; cin >> A >> B;
	for (int i = 0; i <= 100000; i++) {
		int t1 = i * 8 / 100;
		int t2 = i * 10 / 100;
		if (t1 == A && t2 == B) { cout << i << endl; return 0; }
	}
	cout << "-1" << endl;
	return 0;
}

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;

}

Measured memory_bytes: 256
//y14-1
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int d,c;
    cin >> d >> c;
    cout << d * c << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, r, ans;

	cin >> n >> r;
	if (n < 10) ans = r + 100 * (10 - n);
	else ans = r;

	cout << ans << "\n";
		

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<int> e(n+1,0);
  for(int i=0;i<n;i++)
    e.at(i+1)=e.at(i)+(s.at(i)=='E'?1:0);
  int m=s.size();
  for(int i=0;i<n;i++)
    m=min(m,(i-e.at(i))+(e.at(n)-e.at(i+1)));
  cout<<m<<endl;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    ll ans = n%1000;
    if (ans==0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-ans << endl;
    }
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
from queue import Queue
k = int(input()) + 1
q = Queue()
q.put(0)
while not q.empty():
    n = q.get()
    k -= 1
    if k == 0:
        print(n)
        exit()
    if n == 0:
        for i in range(9):
            q.put(i + 1)
    else:
        last = int(str(n)[-1])
        if last > 0:
            q.put(n * 10 + last - 1)
        q.put(n * 10 + last)
        if last < 9:
            q.put(n * 10 + last + 1)


Measured memory_bytes: 51540
import java.io.*;
public class Main {

	public static void main(String[] args) throws IOException{
		String s;
		BufferedReader kbd = new BufferedReader(new InputStreamReader(System.in));
			s = kbd.readLine();
			for(int i = 0; i < s.length(); i++){
				if(Character.isUpperCase(s.charAt(i)))
					System.out.print(Character.toLowerCase(s.charAt(i)));
				else if(Character.isLowerCase(s.charAt(i)))
					System.out.print(Character.toUpperCase(s.charAt(i)));
				else
					System.out.print(s.charAt(i));
			}
				System.out.println("");
	}

}

Measured memory_bytes: 16976
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll k = a*500;
	if(k>=b)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

int main(){
                                                                     

    string s;

    int i;

    int k = 0;

    
    cin >> s;

    int r = s.size() - 1;

    int l = 0;


    for(  ; l < r ;  ){

         if( s.at(l) == s.at(r) ){

             l += 1;

             r -= 1;

             }

         else if( s.at(l) == 'x' ){

                  l += 1;

                  k += 1;

                  }

         else if( s.at(r) == 'x' ){

                  r -= 1;

                  k += 1;

                  }

         else{ 

               k = -1;

               break;

               }             

         }


    cout << k << endl;


    return 0;

    }

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(){
	int n, ans;
	while(~scanf("%d", &n)){
		ans = 0;
		for(int i = 1; i <= n; i++)
			ans += i;
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    a, b = [int(e) for e in input().split()]
    if a >= 13:
        print(b)
    elif 12 >= a >= 6:
        print(int(b/2))
    else:
        print(0)

main()


Measured memory_bytes: 2940
N, M = map(int,input().split())
edges = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

def dfs(i, used):
    if len(used) == N:
        return 1
    ans = 0
    for j in edges[i]:
        if j not in used:
            ans += dfs(j, used+[j])
    return ans
print(dfs(0, [0]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005,inf=0x3f3f3f3f;
int n,js,a[N],s[N],b[N],tr[N];
int lowbit(int x) {return x&(-x);}
void add(int x) {while(x<=js) ++tr[x],x+=lowbit(x);}
int query(int x) {
	int re=0;
	while(x) re+=tr[x],x-=lowbit(x);
	return re;
}
int check(int x) {
	for(RI i=1;i<=n;++i)
		s[i]=s[i-1]+(a[i]>=x?1:-1),b[i]=s[i];
	b[n+1]=0,sort(b+1,b+2+n);
	js=1;for(RI i=2;i<=n+1;++i) if(b[i]!=b[js]) b[++js]=b[i];
	LL res=0,num=1LL*n*(n-1)/2+n;
	for(RI i=1;i<=js;++i) tr[i]=0;
	for(RI i=0;i<=n;++i) {
		int k=lower_bound(b+1,b+1+js,s[i])-b;
		res+=query(k),add(k);
	}
	return res>=(num+1)/2;
}
int main()
{
	int l=inf,r=0,ans;
	n=read();
	for(RI i=1;i<=n;++i)
		a[i]=read(),l=min(a[i],l),r=max(a[i],r);
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792