akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) (v.begin(),v.end())
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int N,K;
int n(int c){
    static map<int, int> m;
    if(m.count(c)==0){
        if(c < K){
            m[c] = n(c*2) + 1;
            return m[c];    
        }
        else
            return 0;
    }else{
        return m[c];
    }
}

int main(void)
{
    cin >> N >> K;
    vector<int> a(N+1);
    REP(i, N){
        a[i] = n(i+1);
    }

    double ans = 0;
    REP(i, N){
        ans += pow(0.5, a[i]);
    }
    printf("%.9lf\n", ans/(double)N);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
vector<int>e[N];
int in[N],ans[200000];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int i=0;i<n+m-1;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;b--;
		e[a].push_back(b);
		in[b]++;
	}
	queue<int>que;
	for(int i=0;i<n;i++)
	{
		if(in[i]==0)
		{
			ans[i]=0;
			que.push(i);
		}
	}
	while(!que.empty())
	{
		int p=que.front();
		que.pop();
		for(int u:e[p])
		{
			in[u]--;
			if(!in[u])
			{
				ans[u]=p+1;
				que.push(u);
			}
		}
	}
	for(int i=0;i<n;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    double n, m, d;
    cin >> n >> m >> d;

    cout << fixed;

    if (d == 0) {
        cout << setprecision(10) << (m-1) / n << endl;
    } else {
        cout << setprecision(10) << (2 * (n-d) * (m-1)) / n / n << endl;
    }
}


Measured memory_bytes: 256
/* ex5_4
   key_tree */

#include <stdio.h>
#include <string.h>

int main(void){
    int length, i, ans = 0, count = 0;
    // 文字数制限は10
    // 部分文字列の長さを見るarray
    char text[11], array[11];
    scanf("%s", &text);

    length = strlen(text);
    for(i = 0; i < length; i++){
        // ACGTであればcountを+1してarrayに記録
        if(text[i] == 'A'|| text[i] == 'C'|| text[i] == 'G'|| text[i] == 'T'){
            count++;
            array[i] = count;
        }
        // AGCTでなければcountを0に戻して記録
        else{
            count = 0;
            array[i] = count;   
        }
    }
    // 現時点でAGCT部分文字列の長さがarrayに記録されている
    for(i = 0; i < length; i++){
        // arrayから最大の要素を取り出す
        if(ans < array[i]){
            ans = array[i];
        }
    }

    printf("%d\n", ans);

    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

template<typename T>
struct Bit {
  int n; // 2のべき乗でなくてもOK
  vector<T> node;
  Bit(int n) : n(n), node(n + 1, 0) {}
  void add(int i, T a) { // node[i] += w
    for (int x = ++i; x <= n; x += x & -x) node[x] += a;
  }
  T sum(int i) { // return sum [0, i)
    T a = 0;
    for (int x = i; x > 0; x -= x & -x) a += node[x];
    return a;
  }
  T sum(int i, int j) { // return sum [i, j)
    return sum(j) - sum(i);
  }
  vector<T> debug() { // for debug
    vector<T> a;
    rep(i, n) a.push_back(sum(i, i + 1));
    return a;
  }
};

struct mint {
  ll v;
  mint() : v(0) {}
  mint(ll v) : v((v % MOD + MOD) % MOD) {}
  operator ll() const { return v; }
  mint pow(ll t) const;
  mint inv() const;
};
mint& operator+=(mint& a, mint b) { return a = a.v + b.v; }
mint& operator-=(mint& a, mint b) { return a = a.v - b.v; }
mint& operator*=(mint& a, mint b) { return a = a.v * b.v; }
mint operator+(mint a, mint b) { return a += b; }
mint operator-(mint a, mint b) { return a -= b; }
mint operator*(mint a, mint b) { return a *= b; }
mint operator-(mint a) { return (mint)0 - a; }
mint& operator/=(mint& a, mint b) { return a *= b.inv(); }
mint operator/(mint a, mint b) { return a /= b; }
mint mint::pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t >> 1);
  a *= a;
  if (t & 1) a *= *this;
  return a;
}
mint mint::inv() const { return pow(MOD - 2); }
bool operator==(mint a, mint b) { return a.v == b.v; }
bool operator!=(mint a, mint b) { return a.v != b.v; }
istream& operator>>(istream& os, mint& a) { return (os >> a.v); }
ostream& operator<<(ostream& os, const mint& a) { return (os << a.v); }

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  dump(a);
  mint ans = 0;
  rep(b, 60) {
    ll x = (1L << b);
    Bit<int> bit(n);
    rep(i, n) {
      if (a[i] & x) bit.add(i, 1);
    }
    // dump(bit.debug());
    rep(i, n - 1) {
      ll cnt = bit.sum(i + 1, n);
      if (a[i] & x) cnt = n - i - 1 - cnt;
      // dump(b, i+1, n, cnt);
      ans = ans + (mint)x * (mint)cnt;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

const int maxn = 1e5 + 5;

int n, h[maxn], d[maxn] = {0};

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> h[i];
    d[0] = 0;
    d[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; ++i) {
        d[i] = min(d[i - 1] + abs(h[i - 1] - h[i]), d[i - 2] + abs(h[i - 2] - h[i]));
    }
    printf("%d\n", d[n - 1]);
    return 0;
}

Measured memory_bytes: 1024
n, a, b, c = map(int, input().split())
L = [int(input()) for i in range(n)]
INF = 10 ** 9

def dfs(cur, x, y, z):
    if cur == n:
        if min(x, y, z) > 0:
            return abs(x - a) + abs(y - b) + abs(z - c) - 30
        else:
            return INF
    ret0 = dfs(cur + 1, x, y, z)
    ret1 = dfs(cur + 1, x + L[cur], y, z) + 10
    ret2 = dfs(cur + 1, x, y + L[cur], z) + 10
    ret3 = dfs(cur + 1, x, y, z + L[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))        

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 mod = 1e9 + 7;
i64 fact_memo[200001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}
i64 fact_inv_memo[200001];
i64 fact_inv(i64 x) {
  if (fact_inv_memo[x]) return fact_inv_memo[x];
  return fact_inv_memo[x] = inv(fact(x));
}
i64 perm(i64 a, i64 b) {
  return fact(a) * fact_inv(a - b) % mod;
}
i64 conb(i64 a, i64 b) {
  return fact(a) * fact_inv(b) % mod * fact_inv(a - b) % mod;
}

i64 h, w, n;
using P = pair<i64, i64>;
vector<P> ps;
int main() {
  cin >> h >> w >> n;
  init_n(ps, n + 1);
  for (i64 i = 0; i < n; ++i) {
    cin >> ps[i].first >> ps[i].second;
  }
  ps[n] = { h, w };
  sort(begin(ps), end(ps));
  
  vector<i64> dp(n + 1);
  for (i64 i = 0; i <= n; ++i) {
    i64 r, c;
    tie(r, c) = ps[i];
    dp[i] = conb(r + c - 2, r - 1);
    for (i64 j = 0; j < i; ++j) {
      i64 r2, c2;
      tie(r2, c2) = ps[j];
      if (r2 <= r && c2 <= c) {
        dp[i] += mod - dp[j] * conb(r - r2 + c - c2, c - c2) % mod;
      }
    }
    dp[i] %= mod;
    // fprintf(stderr, "%lld: (%lld, %lld)\t%lld\n", i, r, c, dp[i]);
  }
  cout << dp[n] << endl;
  return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    for(int i = 1; i <= B; i++) {
        int a = A*i;
        if(a % B  == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<5; i++) {
            int x = sc.nextInt();
            if(x == 0) {
                System.out.println(i+1);
                break;
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 35720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
void go(){
    int n,q;
    string s;
    R(n,q,s);
    s=" "+s;
    vi a(n+10,0);
    rep(i,2,n){
        a[i]+=a[i-1];
        if(s[i-1]=='A'&&s[i]=='C'){
            a[i]++;
        }
    }
    rep(i,1,q){
        int x,y;
        R(x,y);
        W(a[y]-a[x]);
    }
}


Measured memory_bytes: 1516
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222





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


  cin >> n >> m;
  ans = 1;
  ll cur = m;
  for (ll i = 2; i*i <= m; i++) {
    ll cnt = 0;
    while (cur%i == 0) {
      cur /= i;
      cnt++;
    }
    if (cnt >= n) {
      tmp = 1;
      rep(j, cnt / n) tmp *= i;
      ans *= tmp;
    }
  }
  if (cur != 1 && n == 1) ans *= cur;
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 5e5 + 69;
const int base = 311;
// dung igt thay cho gt luc tinh giai thua
// 10
// cach tao hoan vi tu n so : n*(n+1)/2;
ll gt[e];
ll igt[e];
ll  b[e];
ll n;
ll a[e];

bool palin(string t)
{
    for(int i=0; i<t.size(); i++)
    {
        if(t[i] != t[t.size() - 1 - i])
            return false;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;
    string t;
    string t1;
    ll n = s.size();
    t = s.substr(0, (n-1)/2);
    if(palin(s) && palin(t)) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define in(x) (read(x))
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ld eps = 1e-9;
const int inf = mod;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a){if(a<0)return -1;if(a>0)return 1;return 0;}


template<typename T> inline void in(T &x){
    x = 0; T f = 1; char ch = getchar();
    while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
    while (isdigit(ch))  {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

int main(){
	REP(i,0,4){
		char c;cin>>c;cout<<c;
	}
	cout<<' ';
	REP(i,0,8){
		char c;cin>>c;cout<<c;
	}
	cout<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAXN = 200005;
const int inf = 1e9+5;

vector<int> a(MAXN), ans(MAXN);
vector<int> g[MAXN];
vector<int> dp(MAXN);

void dfs(int v, int p = -1){
    int pos = lower_bound(ALL(dp), a[v]) - dp.begin();
    int prev = dp[pos];
    dp[pos] = a[v];
    ans[v] = lower_bound(ALL(dp), inf) - dp.begin() - 1;
    for(int u : g[v]){
        if(u == p) continue;
        dfs(u, v);
    }
    dp[pos] = prev;
}


int main(){
    int n; cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    rep(i,MAXN) dp[i] = inf;
    dp[0] = -inf;
    dfs(0);
    rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 27892
#include <stdio.h>

int main(void) {
	int a, b, c, x, total, answer = 0;
	scanf("%d\n%d\n%d\n%d", &a, &b, &c, &x);
	
	for (int i = 0; i <= a; i++) {
		if (500 * i > x) { 
			break; 
		}
		for (int j = 0; j <= b; j++) {
			if (500 * i + 100 * j > x) {
				break;
			}
			for (int k = 0; k <= c; k++) {
				total = 500 * i + 100 * j + 50 * k;
				if (total == x) {
					answer++;
				}
				else if (total > x) {
					break;
				}
			}
		}
	}

	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int res=0;
  rep(i,4){
    if(s[i]=='+')res++;
    else res--;
  }
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 256
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val list =
      for{
        in <- Source.stdin.getLines.toList
      } yield in.split(" ").map(_.toInt)

    boc(list.flatten)
  }

  def boc(a: List[Int])={
    if(a.head == a.last) println("a == b")
    else if(a.head - a.last > 0) println("a > b")
    else if(a.head - a.last < 0) println("a < b")
    else println()
  }
}

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

S = []

while abs(N)>0:
    x = N%2
    S.append(str(x))
    if len(S)%2 ==0:
        N = (N+x)//2
    else:
        N //= 2

S.reverse()

if len(S)==0:
    S=['0']
    
print(''.join(S))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        int A = n[0];
        int B = n[1];
        int count = 0;
        string s = "";
        for (int i = A; i <= B; i++)
        {
            s = i.ToString();
            if (s[0] == s[4] && s[1] == s[3]) count++;
        }
        Console.WriteLine(count);
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


Measured memory_bytes: 13396
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        HashSet<String> set = new HashSet<>();
        for (int i = 0; i < N; i ++) {
            set.add(sc.nextLine());
        }

        System.out.println(set.size());
    }
}


Measured memory_bytes: 79712
#include <bits/stdc++.h>
using namespace std;
 
const int64_t MOD=1e9+7;
 
int main(){
  int N;
  cin>>N;
  vector<int64_t> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
 
  int64_t ans=0;
  int64_t tp=1;
  for(int i=0;i<60;++i){
    int64_t a=0,b=0;
    for(int j=0;j<N;++j){
      bitset<60> s(A[j]);
      if(s.test(i)) ++a;
      else ++b;
    }
    ans += (((tp*a)%MOD)*b)%MOD;
    ans %= MOD;
    tp *=2;
    tp %= MOD;
  }
 
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int H,W,h,w;
    scanf("%d %d",&H,&W);
    scanf("%d %d",&h,&w);
    printf("%d",H*W-h*W-H*w+h*w);
    return 0;
}

Measured memory_bytes: 1696
import numpy as np
N = int(input())
A = list(map(int, input().split()))

res_plus = np.cumsum(A)
res_minus = np.cumsum(A)
ans_plus = 0
ans_minus = 0

tmp_tmp = 0
# 奇数項を正とする
for i in range(N):
    res_plus[i] += tmp_tmp
    if i % 2 == 0:         # 奇数項   
        if res_plus[i] > 0:
            pass
        else:
            tmp = 1 - res_plus[i]
            ans_plus += tmp
            tmp_tmp += tmp
    else:                  # 偶数項
        if res_plus[i] < 0:
            pass
        else:
            tmp = res_plus[i] + 1
            ans_plus += tmp
            tmp_tmp -= tmp


tmp_tmp = 0
# 奇数項を負とする
for i in range(N):
    res_minus[i] += tmp_tmp
    if i % 2 == 0:      # 奇数項
        if res_minus[i] < 0:
            pass
        else:
            tmp = res_minus[i] + 1
            ans_minus += tmp
            tmp_tmp -= tmp
    else:               # 偶数項
        if res_minus[i] > 0:
            pass
        else:
            tmp = 1 - res_minus[i]
            ans_minus += tmp
            tmp_tmp += tmp

##print(ans_minus, ans_plus)
print(min(ans_plus, ans_minus))

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

typedef long long ll;

int main(){
    ll N,M,tmp,ans;
    cin>>N>>M;
    tmp = M;
    tmp -= (N*2);
    
    if(tmp < 0){
        ll kake = M/2;
        ans = kake;
    }

    else{
        ans = N;
        ans += (tmp/4);
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

I,O,T,J,L,S,Z = map(int,input().split())

# T,S,Z は無関係
# I,O,J,Lに注目
# Oは足すだけ
# I,J,Lが問題
# II, JIL, JJ, LL

x = (I//2 + J//2 + L//2) * 2
if I>0 and J>0 and L>0:
    x = max(x,((I-1)//2 + (J-1)//2 + (L-1)//2) * 2 + 3)
x += O

print(x)

Measured memory_bytes: 3064
/*
    Problem 55
    https://atcoder.jp/contests/abc134/tasks/abc134_e
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    reverse(a.begin(), a.end());
    vector<int> LIS(N+1, INF);
    for (int i = 0; i < N; i++) {
        *upper_bound(LIS.begin(), LIS.end(), a[i]) = a[i];
    }
    cout << lower_bound(LIS.begin(), LIS.end(), INF) - LIS.begin() << '\n';
}

Measured memory_bytes: 4036
#include<stdio.h>

int main()
{
    int n,x,i,sum=2,ans=0,cn=1,ar[1000];


    scanf("%d%d",&n,&x);

    for(i=1; i<=n; i++)
    {
        scanf("%d",&ar[i]);
    }

    for(i=1;i<=n;i++)
    {
        ans=((sum-1))+(ar[i]-1);
        sum=sum+ar[i];
        if(ans<=x)
        {
            cn++;
            ans=0;
        }
        else
        {
            ans=0;
        }
    }

    printf("%d\n",cn);

    return 0;
}

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

int main(void)
{
    long long int a,b,c,i,j,k,n;
    char s[50];
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> s[i];
        if(i==k-1) s[i] += 32;
    }
    for(i=0;i<n;i++){
        cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [(2,2),(3,1)]
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base ** exponent
    return a


# 入力:整数n      ex)100
# 出力:約数リスト ex)[1, 5, 25, 2, 10, 50, 4, 20, 100]
def divisorEnumulation(n):
    divisor = []
    for div in divisorize(factorize(n)):
        divisor.append(num(div))
    return divisor


# 使用例
# print(divisorEnumulation(100))

n, p = [int(i) for i in input().split()]
fact = factorize(p)
out = 1
for i in range(len(fact)):
    out *= fact[i][0] ** (fact[i][1]//n)
print(out)


Measured memory_bytes: 3444
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }
    let mut dp = vec![vec![0; n + 1]; n + 1];
    for (i, &arg) in arg_sort_descending(&a).iter().enumerate() {
        for l in 0..=i {
            let r = n - (i - l) - 1;
            dp[i + 1][l + 1] =
                dp[i + 1][l + 1].max(dp[i][l] + a[arg] * (arg as isize - l as isize));
            dp[i + 1][l] = dp[i + 1][l].max(dp[i][l] + a[arg] * (r as isize - arg as isize));
        }
    }

    println!("{}", dp.last().unwrap().iter().max().unwrap());
}

fn arg_sort_descending<T: Ord>(a: &Vec<T>) -> Vec<usize> {
    let mut i: Vec<_> = (0..a.len()).collect();
    i.sort_by(|&x, &y| a[y].cmp(&a[x]));
    i
}


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

using namespace std;

using ll = long long;

int main (void){

  int c;

  cin >> c;

  int a[3];
  a[0] = c / 100;
  a[1] = (c % 100) / 10;
  a[2] = c % 10;

  int sum;

  sum = a[0] + a[1] + a[2];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
m,i,j,t,u;z[2002],*a=z,*b=z+999;main(n){for(;m=scanf("%d",&n)-++n;printf("%d\n",m))for(i=n;i--;j=a,a=b,b=j)for(j=n;j--;t>m?m=t:0)b[j]=t=n+~i&&getchar()>45?1+fmin(u=a[j],t<u?t:u):0;}

Measured memory_bytes: 0
N, Y = map(int, input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if k < 0:
            continue
        if 10000*i + 5000*j + 1000*k == Y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 65972
n = int(input())


def factorization(n):
    retval = []
    tmp = n
    for i in range(2, int(-(-n**.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            retval.append([i, cnt])
    if tmp != 1:
        retval.append([tmp, 1])
    return retval


fact = factorization(n)
m = len(fact)
ans = 0
for i in range(1, 1000):
    update = 0
    for j in range(m):
        if i <= fact[j][1]:
            fact[j][1] -= i
            ans += 1
            update = 1
    if not update:
        break
print(ans)

Measured memory_bytes: 9516
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * x+y>(t - t_1)の場合には不可
 * x+yと(t-t_1)の偶奇が一致していない場合は不可
 */
int main() {
  int n; cin >> n;
  vector<int> A(n), B(n);
  loop(i,0,n) cin >> A[i];
  loop(i,0,n) cin >> B[i];
  int max_ = 0;
  loop(k,0,n) {
    int sum = 0;
    loop(i,0,n) {
      if (i==k) sum += A[i] + B[i];
      else if (i < k) sum += A[i];
      else sum += B[i];
    }
    max_ = max(max_, sum);
  }
  cout << max_ << endl;
  return 0;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int[] count = new int[N];
    int max =0;
    for (int i=0; i<N; i++) {
      HashSet<Character> X = new HashSet<Character>();
      HashSet<Character> Y = new HashSet<Character>();
      for (int j=0; j<i; j++) {
        X.add(S.charAt(j));
      }
      for (int j=i; j<N; j++) {
        Y.add(S.charAt(j));
      }
      for (char a : Y) {
        if (X.contains(a)) count[i]++;
      }
      max = Math.max(count[i],max);
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        v.emplace_back(a, b);
    }

    std::sort(v.begin(), v.end());

    std::multiset<int> ss;
    auto it = v.begin();
    int ret = 0;
    for (int i = 1; i <= m; i++) {
        while (it != v.end() && it->first == i) {
            ss.insert(-it->second);
            it++;
        }
        if (ss.empty()) continue;
        ret += -*ss.begin();
        ss.erase(ss.begin());
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 10;

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; cin >> n;
	set<int> s;
	for(int i = 1 ;i <= 9 ;i ++ ) {
		for(int j = 1 ; j <= 9 ; j ++ ) {
			s.insert(i*j);
		}
	}
	if(s.find(n) == s.end() ) {
		cout << "No";
		return 0;
	}
	
	cout << "Yes";
}
		


Measured memory_bytes: 256
#include <stdio.h>

int na[32],n;

int narabi(int noko,int hai,int depth){
	int i;
	++depth;
//	if(hai>n)return 0;
//	printf("depth %d noko %d hai %d\n",depth,noko,hai);
	if(noko==0){
		for(i=0;i<=hai-1;i++){
			printf("%d ",na[i]);
		}
		printf("%d\n",na[hai]);
		return 0;
	}else{
		for(i=noko;i>0;i--){
			if(na[hai]<i){
				continue;
				na[hai+1]=na[hai];
				narabi(noko-na[hai],hai+1,depth);
			}else{
				na[hai+1]=i;
				narabi(noko-i,hai+1,depth);
			}
		}
	}
	return 0;
}

int main(){
	int i;
	
	while(~scanf("%d",&n)){
		if(n==0)break;
		
		for(i=n;i>0;i--){
			na[0]=i;
			narabi(n-i,0,0);
		}		
	}
	return 0;
}

Measured memory_bytes: 0
a,b,c,d = map(int, input().split())
y = 0
if abs(a-b) <= d:
    if abs(b-c) <= d:
        y = 1
else:
    if abs(a-c) <= d:
        y = 1
if y == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9164
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = pi*r*r;
        double length = 2*pi*r;
        System.out.printf("%f %f",area, length);
    }
}


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

int main() {
	int n; cin >> n;
	int arr[n];
	int able = 0;
	for (int i = 0; i < n; i++) cin >> arr[i];
	for (int i = 0; i < n; i++) {
	    if (arr[i] != i + 1) {
	        able++;
	    }
	}
	if (able == 2 || able == 0) cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            for (int i = 0; i < 4 - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    Console.WriteLine("Bad");
                    return;
                }
            }
            Console.WriteLine("Good");
        }
    }
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main(){
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	ll v[n+1],pf[n+1];
	memset(pf,0,sizeof(pf));
	for(int i=1;i<=n;i++){
		cin >> v[i];
		pf[i] += pf[i-1] + v[i];
	}
	ll ans = 2*1ll*INT_MAX;
	for(int i=1;i<=n-1;i++){
		ll ss = pf[i]-pf[0],rr = pf[n]-pf[i];
		ans = min(ans,abs(ss-rr));
	}
	cout << ans << "\n";

	return 0;
} 

Measured memory_bytes: 3328
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();
		String[] s = new String[N];

		for(int i = 0; i < N; i++) {
			s[i] = scan.next();
		}
		scan.close();

		// 文字列をソートして比較
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		String sortString = null;
		int count = 0;
		long result = 0;
		// 文字型の配列に変換してからソート
		// ソート済の文字型配列を文字列型に変換する
		char[] charS = new char[10];
		for(int i = 0; i < N; i++) {
			charS = s[i].toCharArray();
			Arrays.sort(charS);
			sortString = String.valueOf(charS);
			if(map.containsKey(sortString)) {
				count = map.get(sortString);
				result += count;
				map.put(sortString, ++count);
			}else {
				map.put(sortString, 1);
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 52148
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;

int n,m;
const int N=5e5+10;
int a[N],ans[N],st[N<<2];

void upd(int i,int l,int r,int v,int k) {
	if(l==r) {
		st[i] = v;
		return;
	}
	int md=(l+r)/2;
	if(md < k)
		upd(i*2+1,md+1,r,v,k);
	else 
		upd(i*2,l,md,v,k);
	st[i] = st[i*2] + st[i*2+1];
}
int qry(int i,int l,int r,int ql,int qr) {
	if(l>qr||r<ql)return 0;
	if(l>=ql&&r<=qr) {
		return st[i];
	}
	int md=(l+r)/2;
	return qry(i*2,l,md,ql,qr) + qry(i*2+1,md+1,r,ql,qr);
}

void solve(){
	cin >> n >> m;
	map<int,int>res;
	for(int i=0;i<n;++i) {
		cin >> a[i];
		res[a[i]]=-1;
	}
	vector<pair<pair<int,int>,int>>q;
	for(int i=0;i<m;++i) {
		int l,r;
		cin >> l >> r;
		q.push_back({{l-1,r-1},i});
	}
	sort(all(q) , [](pair<pair<int,int>,int>a , pair<pair<int,int>,int>b) {
		return a.first.second <= b.first.second;
	});

	int j=0;
	for(int i=0;i<n&&j<m;++i) {
		if(res[a[i]]==-1)
			upd(1,0,n-1,1,i) , res[a[i]] = i;
		else 
			upd(1,0,n-1,0,res[a[i]]) , upd(1,0,n-1,1,i) , res[a[i]] = i;
		while(q[j].first.second<=i&&j<m) {
			ans[q[j].second] = qry(1,0,n-1,q[j].first.first,q[j].first.second);
			j++;
		}
	}

	for(int i=0;i<m;++i)
		cout << ans[i] << "\n";
}	

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 41256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>

using namespace std;

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

	int x;
	cin >> x;

	int ans = 1;
	for (int b = 2; b <= x; b++) {
		int power = b * b;
		for (int p = 2; ; p++) {
			if (power > x)  break;
			ans = max(ans, power);
			power *= b;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
puts a.product(b).map { |x, y| x + y }.sort.reverse[0, k].product(c).map{ |x, y| x + y }.sort.reverse[0, k]


Measured memory_bytes: 287472
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int l, r;
	int d;
	cin >> l >> r >> d;
	int ans = 0;
	rep(i, l, r + 1) {
		if (i%d == 0)ans++;
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  ll q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;

  int v=min(d,min(2*s,min(4*h,8*q)));
  int f;
  if(v==8*q) f=0;
  else if(v==4*h) f=1;
  else if(v==2*s) f=2;
  else f=3;

  ll ans;
  if(f==0) ans=n*4*q;
  else if(f==1) ans=n*2*h;
  else if(f==2) ans=n*s;
  else ans=n/2*d+n%2*min(s,min(2*h,4*q));

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
  ull N;
  cin >> N;
  ull max=0;
  for(int i=1;i*i<=N;i++) {
    if(max<i*i) {
      max = i*i;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

vector<int> g[100010];
int col[100010];
ll a[100010];
int mi,mit;

void dfs(int now,int c){
  col[now]=c;
  if(mi>a[now]){
    mi=a[now];
    mit=now;
  }
  for(int i=0;i<g[now].size();i++){
    int u=g[now][i];
    if(col[u]!=0) continue;
    dfs(u,c);
  }
  return;
}

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  if(n<2*(n-m-1)){
    cout<<"Impossible"<<endl;
    return 0;
  }else if(m==n-1){
    cout<<0<<endl;
    return 0;
  }

  int cnt=1;
  ll ans=0;
  for(int i=0;i<n;i++){
    if(col[i]==0){
      mi=1e9+10;
      mit=0;
      dfs(i,cnt);
      cnt++;
      ans=ans+mi;
      col[mit]=-1;
    }
  }

  vector<ll> v;
  for(int i=0;i<n;i++){
    if(col[i]!=-1) v.push_back(a[i]);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<v.size();i++){
    if(cnt-1>=2*(n-m-1)) break;
    ans=ans+v[i];
    cnt++;
  }

  cout<<ans<<endl;

  return 0;
}


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

int main(){
  int n;  cin >> n;
  int t[n];
  for (int i = 0; i < n; ++i){
    cin >> t[i];
  }
  int ans = accumulate(t, t+n, 0);
  int m;  cin >> m;
  int minus = 0;
  for (int i = 0; i < m; ++i){
    int p, x; cin >> p >> x;
    cout << ans-(t[p-1]-x) << endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#define  _USE_MATH_DEFINES

#define  rep(i, n) for(int i = 0; i < n; i++)
#define  repx(i, a, n) for(int i = a; i < n; i++)
#define  loop while(1)
#define  lli long long int
#define  aryout(ary) rep(i, ary.size()) cout << ary[i] << (i < ary.size() - 1 ? " " : "\n");
#define  arysort(v) sort(v.begin(), v.end())
#define  aryreverse(v) reverse(v.begin(),v.end())
#define  arysum(v) accumulate(v.begin(), v.end(), 0)
 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <utility>
#include <set>

using namespace std;

int main() {

  long long int n, p;
  cin >> n >> p;

  if (n == 1) {
    cout << p << endl;
  } else {

    stack<pair<int, int>> st;
    int m = (int)sqrt(p);
    repx(i, 2, m) {
      int cnt = 0;
      while (p >= i && p % i == 0) {
        p /= i;
        cnt += 1;
      }
      st.push({i, cnt});
      if (p < i) break;
    }

    int ans = 1;

    while (!st.empty()) {
      pair<int, int> tmp = st.top();
      if (tmp.second / n > 0) {
        rep(i, tmp.second / n) ans *= tmp.first;
      }
      st.pop();
    }

    cout << ans << endl;
  }

  return 0;
}


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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def main():
    A,B,K = map(int, input().split())
    a = make_divisors(A)
    b = make_divisors(B)
    a = set(a) & set(b)
    a = sorted(list(a), reverse=True)
    print(a[K-1])

if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
   long N,power=1;
   int i;
   cin>>N;
   long E=pow(10,9)+7;

   for(i=2;i<=N;i++){
    power*=i;
    if(power>=E) power%=E;
   }

   cout<<power<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;

/*printf("? %c %c\n",x,y);
		fflush(stdout);
		char ret;scanf(" %c", &ret);
		*/
int main(void){
	int i,j,k,N=200,chousei=7,a,b;
	vector<pair<int,int>> kotae;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j+=chousei){
			printf("? ");
			for(k=0;k<N;k++){
				if(k==i||(j<=k&&k<j+chousei)){a=1;} else{a=0;}
				printf("%d",a);
			}
			printf("\n");
			fflush(stdout);
			scanf("%d",&a);
			if(a!=0){
				for(k=j;k<min(j+chousei,N);k++){
					printf("? ");
					for(int l=0;l<N;l++){
						if(l==i||k==l){b=1;} else{b=0;}
						printf("%d",b);
					}
				printf("\n");
				fflush(stdout);
				scanf("%d",&b);
				if(b!=0){kotae.pub(mp(i,k));}
				}
			}
		}
	}
	printf("!");
	for(i=0;i<kotae.size();i++){
		printf(" (%d,%d)",kotae[i].first,kotae[i].second);
		
	}
	printf("\n");
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 852
#include <iostream>

using namespace std;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C;
	cin >> K;

	if(A >= B && B >= C) {
		for(int i = 0; i < K; i++) A *= 2;
	} else if(B >= C && C >= A) {
		for(int i = 0; i < K; i++) B *= 2;
	} else {
		for(int i = 0; i < K; i++) C *= 2;
	}

	cout << (A + B + C) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <memory>

using namespace std;
void insertionSort(int *A, int N);
void printArray(int *A, int N);

int main()
{
	int n;
	cin >> n;
	unique_ptr<int[]> A(new int[n]);
	for(int i=0; i<n; i++){
		cin >> A[i];
	}
	printArray(A.get(), n);
	insertionSort(A.get(), n);
}

void insertionSort(int *A, int N)
{
	int temp = 0;
	int k = 0;
	for(auto j=1; j<N; j++){
		temp = A[j];
		k = j - 1;
		while(k>=0 && A[k]>temp){
			A[k+1] = A[k];
			k--;
			A[k+1] = temp;
		}
		printArray(A, N);

	}
}

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

}

Measured memory_bytes: 1196
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n,a,b;
  cin >> n >> a >> b;

  if(a > b || ( a != b && n == 1))
  {
    cout << 0 << endl;
  }
  else if(a == b && n == 1)
  {
    cout << 1 << endl;
  }
  else
  {
    cout << (n - 2) * (b - a) + 1 << endl; 
  }


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
N = int(input())
XY = [list(map(int, input().split())) for i in range(N)]

z = sum(XY[0])%2
for xy in XY:
    x, y = xy
    if not (x+y)%2==z:
        print(-1)
        exit()

D = [1<<i for i in range(34)]
if z==0:
    D.append(1)
print(len(D))
print(" ".join(map(str, D)))
for x, y in XY:
    if z==0:
        x-=1
    s=""
    yy = x+y
    xx = x-y
    for i, d in enumerate(D[:34]):
        if i==33:
            if xx>0:
                if yy>0:
                    s+="R"
                else:
                    s+="D"
            else:
                if yy>0:
                    s+="U"
                else:
                    s+="L"
            break
        #print("xy", xx, yy)
        xq, xm = divmod(xx, 4)
        yq, ym = divmod(yy, 4)
        if xm==1:
            if ym==1:
                s+="L"
            elif ym==3:
                s+="U"
            else:
                while True:
                    print(1)
        elif xm==3:
            if ym==1:
                s+="D"
            elif ym==3:
                s+="R"
            else:
                while True:
                    print(1)
        else:
            while True: print(1)
        #xx //=2
        #yy //=2
        xx>>=1
        yy>>=1
        if xx%2==0:
            xx+=1
        if yy%2==0:
            yy+=1
    if z == 0:
        s += "R"
    print(s)



Measured memory_bytes: 3444