akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};




LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,j,k,n,ans=0;
    const LL mod=1e9+7;
    cin >> n >> k;
    LL cnt[k+5];
    for(i=1;i<=k;i++)cnt[i]=big_mod(k/i,n,mod);
    for(i=k;i>0;i--)
    {
        for(j=i+i;j<=k;j+=i)cnt[i]=(cnt[i]-cnt[j]+mod)%mod;
    }
    for(i=1;i<=k;i++)ans=(ans+(cnt[i]*i)%mod)%mod;
    cout << ans;
    return 0;
}


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

using namespace std;
typedef long long ll;

#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(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

bool is_hershad(int x)
{
    int tmp = x;
    int res = 0;
    while (tmp)
    {
        res += tmp % 10;
        tmp /= 10;
    }
    return (x % res == 0);
}

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

    cout << (is_hershad(n) ? "Yes" : "No") << endl;

    return 0;
}


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

int main()
{
    ll n, ans = 1, cnt = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());

    rep(i, n - 1)
    {
        if (a[i] == a[i + 1])
        {
            ans *= a[i];
            cnt++;
            i++;
        }
        if (cnt == 2)
        {
            cout << ans << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = input.nextInt();
		}
		int UP = Integer.MIN_VALUE;
		int DOWN = Integer.MIN_VALUE;
		Arrays.sort(arr);
		/*for (int TOP = 0; TOP < N; TOP++) {
			for (int BOT = TOP+1; BOT<N; BOT++) {
				int Num = Math.max(arr[TOP], arr[BOT]);
				int Den = Math.min(arr[TOP], arr[BOT]);
				if (Num>=UP&&Den>=DOWN&&Num-Den>=UP-DOWN) {
					UP=Num;
					DOWN=Den;
				}
			}
		}*/
		int LDiff = 0;
		int RDiff = Integer.MAX_VALUE;
		for (int i = 0; i < N-1; i++) {
			int L = arr[i];
			int R = arr[N-1]-arr[i];
			if (Math.abs(L-R)<=Math.abs(RDiff-LDiff)) {
				RDiff = arr[N-1]-arr[i];
				LDiff = arr[i];
				DOWN=arr[i];
			}
		} 
		System.out.println(arr[N-1]+" "+DOWN);
		//for int i = 0
	}
}

Measured memory_bytes: 50904
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    
    vi a(n);
    vpi cb(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> cb[i].second >> cb[i].first;

    sort(a.begin(), a.end());
    sort(cb.begin(), cb.end(), greater<pair<int, int>>());

    int j = 0;
    rep(i, m){
        int cnt = 0;
        while(cb[i].first > a[j] && cnt < cb[i].second && j < n){
            a[j] = cb[i].first;
            j++;cnt++;
        }
    }
    ll s=0;
    rep(i, n) {
        s+=a[i];
    }
    cout << s << endl;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
typedef pair<int,int> P;

const int kN = 1002, kInf = 1 << 28;
int N, A[kN], B[kN];
int dp[2][kN];

int solve() {
  int *prev = dp[0], *next = dp[1];
  rep(i,2) rep(j,kN) dp[i][j] = kInf;
  dp[1][0] = dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < kN; ++j) {
      if (prev[j] + A[i] <= B[i]) {
        next[j+1] = min(prev[j] + A[i], prev[j+1]);
      } else {
        next[j+1] = prev[j+1];
      }
    }
    // rep(ii,2) {
    //   rep(jj,20) printf("%3d", dp[ii][jj] != kInf ? dp[ii][jj] : -1 ); puts("");
    // } puts("");
    swap(prev, next);
  }
  int ret = -1;
  rep(i,N+1) if (prev[i] != kInf) ret = max(ret, i);
  return ret;
}

int main() {
  while (scanf("%d", &N) != -1) {
    int a, b;
    vector<P> v;
    rep(i,N) {
      scanf("%d%d", &a, &b);
      v.push_back(P(b, a));
    }
    sort(v.begin(), v.end());
    rep(i,N) A[i] = v[i].second, B[i] = v[i].first;
    printf("%d\n", solve());
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> a_;
    a_ = a;
    sort(a_.begin(), a_.end());
    int M = a_[n-1];
    int m = a_[n-2];
    rep(i, n) {
        if (a[i] == M) cout << m << endl;
        else cout << M << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
#define M 1000000007
#define MM 998244353
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define r2 1.41421356237
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
  ll ans=0;
  int n;
  cin>>n;
  int p;
  cin>>p;
  for(int i=1;i<n;i++) {
  	int q;
  	cin>>q;
  	if(q<p) { ans+=p-q; }
  	else { p=q; }
  }
  cout<<ans;
  //}
  return 0;
}

Measured memory_bytes: 3620
#![allow(non_snake_case)]
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let A: i32 = read();
    let B: i32 = read();
    println!("{}", std::cmp::max(0, A - (B * 2)));
}


Measured memory_bytes: 4352
fun readList() = readLine()!!.split(" ").map{it.toInt()}
fun min(a:Int,b:Int) = if(a > b)b else a
fun main(args:Array<String>){
  val n = readLine()!!.toInt()
  val b = readList()
  var answer = b[0]+b[n-2]
  for(i in 0 until n-2){
    answer += min(b[i],b[i+1])
  }
  println(answer)
}

Measured memory_bytes: 37800
#include<iostream>
#include<algorithm>
#include<math.h>
#define N 10000
using namespace std;

int isPrime(int n)
{
	if (n == 2 || n == 3)
		return 1;
	if (n == 5)
		return 1;
	if (n % 6 != 1 && n % 6 != 5)
	{
		return 0;

	}
	else
	{
		int m = sqrt(n);
		for (int i = 5; i <= m; i += 6)
		{
			if (n%i == 0 || n % (i + 2) == 0)
				return 0;
		}
		return 1;
	}

	
}

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++)
	{
		int m;
		cin >> m;
		if (isPrime(m))
			sum++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗

int main() {
  long double n,m,d;
  cin >> n >> m >> d;
  long double ok=(n-d)*2;
  if(d==0) ok/=2;
  long double tot=n*n;
  long double ans=(ok/tot)*(m-1);
  cout << fixed << setprecision(15);
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,A; cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int a[225816],b[225816],c[225816],d[225816];
P v[225816],u[225816];

int main(void){
	int n,i,j,l,r;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a[i];
		++c[a[i]];
	}
	for(i=0; i<n; ++i){
		std::cin >> b[i];
		++d[b[i]];
	}
	for(i=1; i<=n; ++i){
		if(c[i]+d[i]>n){
			std::cout << "No" << std::endl;
			return 0;
		}
		u[i-1] = P(c[i]+d[i],i);
	}
	std::cout << "Yes" << std::endl;
	std::sort(u,u+n,std::greater<P>());
	l = 0; r = n-1;
	for(i=0; i<n; ++i){
		while(l<=r && c[u[i].second]){
			v[l].first = u[i].second;
			++l; --c[u[i].second]; --u[i].first;
		}
		while(l<=r && d[u[i].second]){
			v[r].second = u[i].second;
			--r; --d[u[i].second]; --u[i].first;
		}
		if(u[i].first){
			for(j=0; j<n; ++j){
				if(v[j].first == u[i].second || v[j].second == u[i].second ){
					continue;
				}
				if(v[j].first && d[u[i].second]){
					v[j].second = u[i].second;
					--d[u[i].second]; --u[i].first;
				}else if(v[j].second && c[u[i].second]){
					v[j].first = u[i].second;
					--c[u[i].second]; --u[i].first;
				}
			}
			break;
		}
	}
	l = 0; r = 0;
	for(i=0; i<n; ++i){
		while(c[u[i].second]){
			if(v[l].first){
				++l; continue;
			}
			v[l].first = u[i].second;
			++l; --c[u[i].second]; --u[i].first;
		}
		while(d[u[i].second]){
			if(v[r].second){
				++r; continue;
			}
			v[r].second = u[i].second;
			++r; --d[u[i].second]; --u[i].first;
		}
	}
	std::sort(v,v+n);
	for(i=0; i<n; ++i){
		std::cout << (i?" ":"") << v[i].second;
	}
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 9816
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
 
def main():
    s = input().strip()
    # tmp = 0
    # mx = 0
    # for ch in s:
    #     if ch == ">"
    #         tmp -= 1
    #     else:
    #         tmp += 1
    #
    #     if abs(tmp) > mx:
    #         mx = abs(tmp)
    #
    fwd = [0]
    rev = [0]
    tmp = 0
    mn = 0
    for ch in s:
        # print(ch)
        if ch == "<":
            tmp += 1
        else:
            tmp = 0
        fwd.append(tmp)
 
    for ch in s[::-1]:
        # print(ch)
        if ch == ">":
            tmp += 1
        else:
            tmp = 0
        rev.append(tmp)
    rev.reverse()
    # print(fwd, rev)
    print(sum([max(i, j) for i, j in zip(fwd, rev)]))
 
    #     if mn > tmp:
    #         mn = tmp
    #     print(tmp)
    #
    # ans = 0
    # print(mn)
    # ttmp = max(0, -mn)
    # for ch in s:
    #     ans += ttmp
    #     if ch == ">":
    #         ttmp -= 1
    #     else:
    #         ttmp += 1
    #
    # print(ans)
    return
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 102164
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	vector<int>v(10);
	vector<int>w({ 0,2,5,5,4,5,6,3,7,6 });
	for (int i = 0; i < M; i++) {
		cin >> K;
		v[K]++;
	}
	vector<string>dp(10011);
	for (int i = 0; i <= 10000; i++) {
		for (int j = 1; j <= 9; j++) {
			if (!v[j])continue;
			if (i&&dp[i].empty())continue;
			if (dp[i + w[j]].empty())dp[i + w[j]] = dp[i] + char('0' + j);
			else if (dp[i + w[j]].size() <= dp[i].size())dp[i + w[j]] = dp[i] + char('0' + j);
			else if (dp[i + w[j]].size() > dp[i].size() + 1)continue;
			dp[i + w[j]] = max(dp[i] + char('0' + j), dp[i + w[j]]);
		}
	}
	//for (int i = 0; i <= 30; i++) {
//	//	cout << i << " " << dp[i] << endl;
	//}
	//while (N > 300) {
	//	int nx = 0;
	//	for (int i = 9; i >= 1; i--) {
	//		if (!v[i])continue;
	//		if (!nx)nx = i;
	//		if (w[nx] > w[i])nx = i;
	//	}
	//	N -= w[nx];
	//	cout << nx;
	//}
//	cout << N << endl;
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 46336
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] v = new int[N];
		int[] w = new int[N];
		for(int i=0; i<N; i++) {
			v[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}
		
		int[] dp = new int[W+1];
		for(int i=0; i<N; i++) {
			for(int j=W; j>=0; j--) {
				if(j-w[i] >= 0 && dp[j-w[i]] + v[i] > dp[j]) {
					dp[j] = dp[j-w[i]] + v[i];
				}
			}
		}
		
		int max = 0;
		for(int j=0; j<=W; j++) {
			if(dp[j] > max) {
				max = dp[j];
			}
		}
		System.out.println(max);
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 2e5 + 10;
const ll mod = 1e9 + 7;

int n, k;
ll a[maxN];

int minProduct() {
  ll ret = 1;
  if (k == n) {
    for (int i = 1; i <= n; ++i) {
      ret = (ret * a[i] + mod * mod) % mod;
    }
    return ret;
  }
  if (a[1] >= 0) {
    for (int i = n; i > n - k; --i) {
      ret = (ret * a[i] + mod * mod) % mod;
    }
    return ret;
  }
  if (a[n] < 0){
    if (k % 2 == 0) {
      for (int i = 1; i <= k; ++i) {
        ret = (ret * a[i] + mod * mod) % mod;
      }
      return ret;
    } else {
      for (int i = n; i > n - k; --i) {
        ret = (ret * a[i] + mod * mod) % mod;
      }
      return ret;
    }
  }
  int i = 1, j = n;
  if (k % 2 == 1) {
    ret = a[j]; --j; --k;
  }
  while (1) {
    if (k == 0) break;
    k -= 2;
    if (a[i] * a[i+1] > a[j] * a[j-1]) {
      ret = (ret * a[i] + mod * mod) % mod;
      ret = (ret * a[i+1] + mod * mod) % mod;
      i += 2;
    } else {
      ret = (ret * a[j] + mod * mod) % mod;
      ret = (ret * a[j-1] + mod * mod) % mod;
      j -= 2;
    }
  }

  return ret;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);

  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  cout << minProduct();

  return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y,z;
  cin>>x>>y;
  --x;
  --y;
  if(y%x==0)
    z=y/x;
  else
    z=(y/x)+1;
  cout<<z;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<":"<<x<<endl;
constexpr int INF = 1LL<<30;

int dp[44][404][404];

int main() {
  int n,ma,mb;scanf("%d%d%d",&n,&ma,&mb);
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);

  for(int i=0;i<44;++i)
    for(int j=0;j<404;++j)
      fill_n(dp[i][j], 404, INF);

  dp[0][0][0] = 0;

  for(int i=0;i<n;++i){
    for(int j=0;j<404;++j){
      for(int k=0;k<404;++k){
        if(j-a[i]>=0 && k-b[i]>=0) {
          dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]] + c[i]);
        } else {
          dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        }
      }
    }
  }

  int ans = INF;
  for(int i=1;i<404;++i){
    if(ma*i>=400 || mb*i>=400) break;
    ans = min(ans, dp[n][ma*i][mb*i]);
  }
  if(ans==INF) ans = -1;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 28416
#!ruby -nalrprime
$F.map!(&:to_i)
exit if $F.any?{|x| 0 == x}

$F.map! do |x|
  hoge = Prime.prime_division(x)
  hoge.map!{|y| y[0]}
  result = hoge.pop
  result -= hoge.inject(:+) unless hoge.empty?
  result
end

if $F[0] > $F[1]
  puts 'a'
else
  puts 'b'
end

Measured memory_bytes: 6244
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

typedef pair<ll,ll> P;
int main(){
  ll N, C; cin >> N >> C;
  vector<tuple<ll,ll,ll>> cst(N);
  REP(i,N){
    ll s,t,c; cin >> s >> t >> c;
    cst[i] = make_tuple(c,s,t);
  }
  sort(ALL(cst));
  ll pc = -1, ps = -1, pt = -1;
  vector<pair<ll,ll>> st;
  REP(i,N){
    ll c,s,t;
    tie(c,s,t) = cst[i];
    if(c!=pc || s != pt){
      st.push_back({s,t});
      pc = c; ps = s; pt = t;
      continue;
    }
    st.erase(prev(st.end()));
    st.push_back({ps,t});
    pc = c; pt = t;
  }
  sort(ALL(st));
  priority_queue<ll,vector<ll>,greater<ll>> pq;
  pq.push(0);
  ll ans = 1;
  REP(i,SZ(st)){
    // DUMP(i);
    // DUMP(st[i].first);
    // DUMP(st[i].second);
    ll u =  pq.top();
    //DUMP(u);
    pq.pop();
    if(st[i].first<=u){
      ans++;
      pq.push(st[i].second);
      pq.push(u);
      continue;
    }
    u = st[i].second;
    pq.push(u);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

void solve(long long N, std::vector<long long> H)
{
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        bool can = true;
        for (int j = 0; j <= i - 1; j++)
        {
            if (H[j] <= H[i])
            {
                continue;
            }
            else
            {
                can = false;
            }
        }

        if(can){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5, MAXLOG = 17;

int v[MAXN];
int to[MAXN][MAXLOG];

void solve(){
	int n, l, q;
	scanf("%d", &n);
	REPN(i, 1, n){
		scanf("%d", &v[i]);
	}
	scanf("%d%d", &l, &q);
	for(int i = 1, j = 1; i <= n; i++){
		for(; j <= n && v[j] <= v[i] + l; j++);
		to[i][0] = j - 1;
	}
	REP(j, 1, MAXLOG){
		REPN(i, 1, n){
			to[i][j] = to[to[i][j - 1]][j - 1];
		}
	}
	/*REPN(i, 1, n){
		REP(j, 0, MAXLOG){
			cout << to[i][j] << " ";
		}
		cout << endl;
	}*/
	while(q--){
		int a, b;
		scanf("%d%d", &a, &b);
		if (a > b){
			swap(a, b);
		}
		int ans = 0;
		for(int j = MAXLOG - 1; j >= 0; j--){
			if (to[a][j] < b){
				ans += (1 << j);
				a = to[a][j];
			}
		}
		ans++;
		printf("%d\n", ans);
	}
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 7808
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int w,h;
	int x,y;
	
	while(1)
	{
		cin>>h>>w;
		if (w==0 && h==0)
			break;
		for(y=0 ; y<h ; y++)
		{
			for(x=0 ; x<w ; x++)
			{
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define rfor(i, n) for (int i = n-1; i>=0; --i)
#define rmod(x, y) (((x%y)+y)%y)
#define pb(x) push_back(x)
using namespace std;
typedef vector<int>::iterator vit;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef long long ll;
const int MAXN = 1024;

//OPERATORS


//GLOBALS


//FUNCTIONS


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> fu(n);
	for(int i = 0; i < n; i++){
		cin >> fu[i];
	}
	vector<int> desdeI(n);
	vector<int> desdeD(n);
	
	for(int i = 0; i < n; i++){
		if(i == 0)
			desdeI[i] = fu[i];
		else{
			desdeI[i] = __gcd(fu[i],desdeI[i-1]);
		}
	}

	for(int i = n-1; i >= 0; i--){
		if(i == n-1)
			desdeD[i] = fu[i];
		else{
			desdeD[i] = __gcd(fu[i],desdeD[i+1]);
		}
	}
	int mxG = 0;
	if(1 <= n-1){
		mxG = (desdeD[1]);
	}
	if(n-2 >= 0){
		mxG = max(mxG,desdeI[n-2]);
	}
	
	for(int i = 0; i < n-2; i++){
		if(__gcd(desdeI[i],desdeD[i+2]) > mxG){
			mxG = __gcd(desdeI[i],desdeD[i+2]);
		}
	}
	cout << mxG << endl;

	return 0;
}


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

int main(){
  int N,M;
  int ans = 0;

  cin >> N >> M;
  vector<int> vec(N);
  vector<bool> check(N,true);

  for(int i=0;i<N;++i){
    cin >> vec.at(i);
  }

  for(int i=0;i<M;++i){
    int a,b;
    cin >> a >> b;
    if(vec.at(a-1) > vec.at(b-1)){
      check.at(b-1) = false;
    }else if(vec.at(a-1) == vec.at(b-1)){
      check.at(b-1) = false;
      check.at(a-1) = false;
    }else{
      check.at(a-1) = false;
    }
  }

  for(int i=0;i<N;++i){
    if(check.at(i)) ans += 1;
  }

  cout << ans << endl;
  return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int m;
  cin >> m;
  
  int p, q;
  int sum = 0;
  for(int i=0; i<m; i++) {
    cin >> p >> q;
    for(int j=0; j<n; j++) {
      if(j==p-1) sum += q;
      else sum += v[j];
      if(j==n-1) cout << sum << endl;
    }
    sum = 0;
  }
  return 0;
}

Measured memory_bytes: 3644
using System;

class Program
{
    static void Main(string[] args)
    {
        int x, y, z;

        while (true)
        {
            string[] num = Console.ReadLine().Split(' ');
            x = int.Parse(num[0]);
            y = int.Parse(num[1]);

            if (x > y)
            {
                z = x;
                x = y;
                y = z;
            }
            else if (x == 0 && y == 0)
            {
                break;
            }
            Console.WriteLine(x + " " + y);
        }
    }
}


Measured memory_bytes: 9256
#include <iostream>
#include <string>

using namespace std;
 
int main()
{
    int num, count = 0;
    string ans;
    cin >> num >> ans;
    while(--num >= 0){
        string S;
        cin >> S;
        int flag = 0;
        //全探索
        for(int i = 0; i < S.size()-ans.size()+1; i++){
        	//j文字飛ばしで見る
            for(int j = 1; j < S.size(); j++){
                string L;
                //おんなじ文字列できたらflag立てる
                for(int k = i; k < S.size(); k += j){
                    L += S[k];
                    if(L == ans){
                        flag = 1;
                        break;
                    }
                }
            }
        }
        if(flag == 1){count++;}
    }
 
    cout << count << endl;
 
    return 0;
}

Measured memory_bytes: 1216
N,K=map(int,input().split())
l=list(map(int,input().split()))
import math
def f(n):
   A=0
   for i in l:
      A+=math.ceil(i/n)-1
   return A<=K
def bis(ng,ok):
   while abs(ok-ng)>1:
      mid=(ok+ng)//2
      if f(mid):
         ok=mid
      else:
         ng=mid
   return ok
print(bis(0,max(l)))

Measured memory_bytes: 30716
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    ll n,L[110]={};
    cin >> n;
    L[0]=2;L[1]=1;
    if(n>1){
        rep2(i,2,n+1)L[i]=L[i-1]+L[i-2];
    }
    
    cout << L[n];
    
    
	return 0;
}

Measured memory_bytes: 3536
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

using namespace std;

char buf[110];

int main(void) {
  cin >> buf;
  int n = strlen(buf);
  int res = 0;
  REP(i, n) {
    if(i < n-i-1) {
      if(buf[i] != buf[n-i-1]) {
        ++res;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 888
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s,t;
    R(s,t);
    REP(i,SZ(s)){
        rotate(s.begin(),s.begin()+1,s.end());
        if(s==t){
            W("Yes");
            return 0;
        }
    }
    W("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int main() 
{
int X,A,B;
cin>>X>>A>>B;
cout<<(X-A)%B;
system("pause");
return 0;
}

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

int main(int argc, char *argv[])
{
  string s;
  cin >> s;

  int result = 0;
  int streak = 0;
  for (int i = 0; i < s.size(); ++i) {
    auto c = s[i];
    if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
      streak++;
      if (streak > result) {
        result = streak;
      }
    } else {
      streak = 0;
    }
  }

  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{	
  	
	int a[3];
  	cin >> a[0] >> a[1] >> a[2];
  	sort(a , a + 3);
  	cout << (a[0] * a[1])/2 << endl;
	return 0;
 }

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int X,A,B;
int main() {
	cin>>X>>A>>B;


	cout<<(X-A)%B<<endl;
 	return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)






N,A,B,C,D=l()
S=input()
if '##' in S[min(A, B)-1:max(D, C)]:
    print('No')
    quit()
 
if C < D:
    print('Yes')
else:
    if '...' in S[B-2:D+1]:
        print('Yes')
        quit()
    print('No')


Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int a[3];
set<int>st;
signed main(){
	rep(i,3){
		cin>>a[i];
		st.insert(a[i]);
	}
	cout<<st.size()<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a;
  cin >> a;
  int ma=-1, mz=-1;
  for(int i=0; i<a.length(); i++){
    if(a[i]=='A'&&ma==-1) ma = i;
    if(a[i]=='Z') mz = max(mz, i);
  }
  cout << mz-ma+1 << endl;
  return 0;
}

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

int main() {
    int x;
    cin >> x;
    int ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    ans += x / 5 * 5;
    cout << ans << endl;
}


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

int main () {
  double a, b;
  std::cin >> a >> b;
  std::cout << (int)(a / b) << " " << (int)a % (int)b << " " << std::fixed << std::setprecision(6) << a / b << std::endl;
  return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

map<ll,int> prime_factorize(ll a){
	map<ll,int> res; res.clear();
	for (ll p = 2LL; p * p <= a; ++p){
		if (a % p == 0LL){
			int cnt = 0;
			do{
				a /= p; ++cnt;
			}while(a % p == 0LL);
			res[p] = cnt;
		} // end if
	} // end for

	if (a > 1LL){
		res[a] = 1;
	} // end if
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll N, P; cin >> N >> P;
	map<ll,int> ans = prime_factorize(P);
	ll res = 1LL;
	map<ll,int>::iterator it = ans.begin();
	for (; it != ans.end(); ++it){
		ll p = (*it).first;
		ll c = (ll)((*it).second);
//		cerr << "p: " << p << " c: " << c << endl;
		res *= (c / N > 0LL ? pow(p, (c / N)) : 1LL);	
	} // end for

	cout << res << endl;
		
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
	cout.precision(10);
	cout << fixed;

    string s;
    cin >> s;
    int n = s.size();
    ll res = 0;
    ll tren = 0;
    for(int i=0; i<(1<<(n-1)); i++){
        for(int j=0; j<n; j++){
            tren = 10*tren + (s[j]-'0');
            if(j == n-1){
                res += tren;
                tren = 0;
                break;
            }
            if((1<<j) & i){
                //cout << tren << endl;
                res += tren;
                tren = 0;
            }
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int a, b;
    cin >> a >> b;
    cout << max({ a + b,a - b,a * b }) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<algorithm>
#include<iostream>
#define mod 998244353
#define ll long long
#define N 3000006
using namespace std;
int n,cnt,pre[N];
bool vis[N];
ll ji[N],inv[N],ans,a,b,k;
ll pow_mod(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return ans;
}
ll C(ll n,ll m)
{
	return ji[n]*inv[n-m]%mod*inv[m]%mod;
}
int main()
{
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	if(k==0) 
	{
		cout<<1;
		return 0;
	}
	ji[0]=1;
	inv[0]=1;
 	ji[1]=1;
 	for(int i=2;i<=n;++i) 
 	ji[i]=ji[i-1]*i%mod;
 	inv[n]=pow_mod(ji[n],mod-2);
 	for(int i=n-1;i>=1;--i) inv[i]=inv[i+1]*(i+1)%mod;
 	if(a>b) swap(a,b);
 	for(ll x=0;x<=n;++x)
 	{
 		ll y=(k-a*x)/b;
 		if(y*b+a*x==k&&y>=0&&y<=n) ans=(ans+C(n,x)*C(n,y))%mod;
	 }
 	//for(int i=1;i<=10;++i) cout<<inv[i]<<" ";
 	cout<<ans;
	return 0;
}

Measured memory_bytes: 8448
n=int(input())
x,y=map(int,input().split())
z=x+y
for i in range(n-1):
  a,b=map(int,input().split())
  k=max((x-1)//a,(y-1)//b)+1
  x=k*a
  y=k*b
print(x+y)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0;i<(int)n;i++)
ll mod=1e9+7;
#define PI acos(-1)
struct edge{int from, to;};

int main(){
    ll n;
    cin>>n;
    ll ans=1001001001;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ll x=n/i;
            ll keta=0;
            while(x>0){
                x/=10;
                keta++;
            }
            ans=min(ans, keta);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

void doc()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}

void solve() {
    string s;
    cin >> s;
    int n = (int)s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == 'U' || s[i] == 'D') continue;
        if (i % 2 == 0 && s[i] == 'L') {
            cout << "No";
            return;
        }
        if (i % 2 == 1 && s[i] == 'R') {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // doc();
    solve();
}


Measured memory_bytes: 256
(function() {
	var buf = require('fs').readFileSync('/dev/stdin');
	var S = 0, i, val;
	for (i in buf) {
		val = buf[i];
		if (val < 48) break;
		S = 10 * S + (val - 48);
	}
	var s = S % 60;
	var M = (S - s) / 60;
	var m = M % 60;
	var h = (M - m) / 60;
	console.log(h + ":" + m + ":" + s);
}) ();

Measured memory_bytes: 15580
#include<bits/stdc++.h>
using namespace std;
#define db double
#define ll long long
const int MX=100000;
const ll mod=1e9+7;
ll dp[105][MX+5];
ll a[105];
int n;
ll solve(int k)
{
  ++k;
  dp[n+1][1]=1;
  for(int i=2;i<=k;i++)dp[n+1][i]+=dp[n+1][i-1];
  for(int i=n;i>=1;i--)
  {
    int x=a[i];
    for(int j=1;j<=k;j++)
    {
      int y=max(1,j-x);
      y--;
      dp[i][j]=(dp[i+1][j]-dp[i+1][y])%mod;
    }
    for(int j=1;j<=k;j++)
    {
      dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
    }
  }
  return (dp[1][k]-dp[1][k-1]+mod)%mod;
}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int k;
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i];
  ll res=solve(k);
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 79360
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let _: i32 = read_as_vec()[0];
    let mut flowers: Vec<i32> = read_as_vec();
    let mut water = 0;

    while flowers.iter().any(|h| *h > 0){
        for h in flowers.iter_mut().skip_while(|h| **h == 0).take_while(|h| **h > 0){
            *h -= 1;
        }
        water += 1;
    }
    println!("{}", water);
}


Measured memory_bytes: 4352