akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n;
int m;
int tot;
int tim= 0;
int head[maxn];
int vis[maxn];
int dis[maxn];
int degree[maxn];
struct Node{
    int v , next , w;
}edge[maxn];
void init(){
    tot = 0; tim = 0;
    memset(vis,0,sizeof(vis));
    memset(head,-1,sizeof(head));
    memset(degree,0,sizeof(degree));
}
void add(int u , int v , int w){
    edge[tot].next = head[u];
    edge[tot].v = v;
    edge[tot].w = w;
    head[u] = tot++;
}
bool dfs(int root ,int u){
    vis[u]=  ++tim;
    bool flag = true;
    for(int i = head[u];~i;i=edge[i].next){
        int v = edge[i].v;
        int w = edge[i].w;
        if(vis[v] >= vis[root]&&dis[u]+w!= dis[v]) flag = false;
        if(vis[v] == 0){
            dis[v] = dis[u] + w;
            if(!dfs(root,v)){
                flag = false;
            }
        }
    }
    return flag;
}
int main(){
    while(~scanf("%d%d",&n,&m)){
        init();
        for(int i = 1; i <= m;i++){
            int u , v , w;
             scanf("%d%d%d",&u,&v,&w);
              add(u,v,w);
              if(w > 0){
                degree[v]++;
              }
        }
        bool flag = true;
        for(int i = 1; i <= n;i++){
            if(degree[i]==0){
                dis[i] = 0;
                if(!dfs(i,i)){
                    flag = 0;
                }
            }
        }
        for(int i = 1; i <= n;i++){
            if(!vis[i]){
                dis[i]= 0;
                if(!dfs(i,i)){
                    flag = 0;
                }
            }
        }
        if(flag){
            printf("Yes\n");
        }
        else printf("No\n");
    }
}


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

vector<vector<pair<int, int>>> g;
vector<int> ans;
int k;

void dfs(int v, int pr = -1, int up = -1) {
	int now = 0;
	for (auto& p : g[v]) {
		if (now == up) now = (now + 1) % k;
		int u = p.first;
		int id = p.second;
		if (u != pr) {
			ans[id] = now + 1;
			dfs(u, v, now);
			now = (now + 1) % k;
		}
	}
}

void solve() {
	int n;
	cin >> n;
	
	g.resize(n);
	ans.resize(n - 1);

	for (int i = 0; i < n - 1; i++) {
		int from, to;
		cin >> from >> to;
		from--; to--;
		g[from].pb({ to, i });
		g[to].pb({ from, i });
	}

	k = 0;
	for (int i = 0; i < n; i++) {
		k = max(k, (int) g[i].size());
	}

	dfs(0);

	cout << k << '\n';
	for (int i : ans) cout << i << '\n';
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 9856
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<P, int> PP;
int main() {
	string s, t; cin >> s >> t;
	int sum1[100001], sum2[100001];
	int l1 = s.length(); int l2 = t.length();
	sum1[0] = 0;
	rep1(i, l1) {
		int c;
		if (s[i-1] == 'A')c = 1;
		else c = 2;
		sum1[i] = sum1[i - 1] + c;
	}
	sum2[0] = 0;
	rep1(i, l2) {
		int c;
		if (t[i-1] == 'A')c = 1;
		else c = 2;
		sum2[i] = sum2[i - 1] + c;
	}
	int q; cin >> q;
	rep(i, q) {
		int a, b, c, d; cin >> a >> b >> c >> d; a--; b--; c--; d--;
		int x = sum1[b + 1] - sum1[a];
		int y = sum2[d + 1] - sum2[c];
		if ((x - y) % 3 == 0)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
//??????????¨????????????????????¬¬??????????¢?
//BFS DP ?§£?????´??????
#include <iostream>
#include <stdio.h>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int dm[4]={1,-1,4,-4};
map<string,int> DP;

void BFS()
{
    queue<string> que;
    que.push("01234567");
    DP["01234567"]=0;
    while(que.size())
    {
        string now=que.front();
        que.pop();
        int p=0;
        for(int i=0;i<8;i++)
        {
            if(now[i]=='0')
            {
                p=i;
                break;
            }
        }

        for(int i=0;i<4;i++)
        {
            int d=p+dm[i];
            if(d>=0&&d<=7&&!(p==3&&i==0)&&!(p==4&&i==1))
            {
                string next=now;
                swap(next[p],next[d]);
                if(!DP[next])
                {
                    DP[next]=DP[now]+1;
                    que.push(next);
                }
            }
        }
    }
}

int main()
{
    BFS();
    int d;
    while(~scanf("%d",&d))
    {
        string temp;
        temp+=d+'0';
        for(int i=0;i<7;i++) {scanf("%d",&d); temp+=d+'0';}
        cout<<DP[temp]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5428
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;

ll N,ans;
multiset<ll> st;

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

	cin >> N;
	
	//st.insert(ll(1e9+1));

	FOR(i, 0, N) {

		ll A;
		cin >> A;


		auto it = st.lower_bound(A);
		if (it != st.begin())st.erase(--it);
		st.insert(A);
					/*
		if (*st.begin()>=A) {//すべてAより大きかったら
			ans++;

		}
		else {//Aより小さいものが存在したら

			auto ite = st.lower_bound(A);
			
			ite--;
			st.erase(*ite);

		}
		st.insert(A);
			*/

		
	}
	cout << st.size() << endl;
	//cout << ans << endl;



}

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

long long N, K;
vector<long long> A;


//X以下がKこ未満
bool check(long long X) {
	long long num = 0;
	long long me = 0;

	//cout << "X = " << X << endl;
	for(long long i = 0; i < N; i++) {
		long long a = A[i];
		//cout << endl;
		//cout << "a = " << a << endl;
		if(a == 0) {
			if(X >= 0) {
				num += N;
				//cout << "me++" << endl;
				me++;
			}
		} else if(a > 0) {
			//小さいのとかけた方が小さくなる
			long long start = -1;
			long long end = N;

			while(start + 1 < end) {
				long long mid = (start + end)/2;
				if(a * A[mid] <= X) {
					start = mid;
				} else {
					end = mid;
				}
			}
			num += start + 1;
			if(start >= i) {
				me++;
			}
		} else {
			//大きいのとかけた方が小さくなる
			long long start = -1;
			long long end = N;

			while(start + 1 < end) {
				long long mid = (start + end)/2;
				if(a * A[mid] <= X) {
					end = mid;
				} else {
					start = mid;
				}
			}
			num += (N - end);
			if(end <= i) {
				me++;
			}
			////border以上のものの数はかけた時に以下になる
			//long long border = X/a;
			//border -= 2;
			//while(border * a > X) {
			//	border++;
			//}
 
 
			////cout << "border = " << border << endl;
			//if(border <= a) {
			//	//自分が含まれちゃう
			//	//cout << "me++" << endl;
			//	me++;
			//}
			////border以降のものの数はかけた時に以下になる
			////border以下の物はNG
			////cout << "num = " << N - (lower_bound(A.begin(), A.end(), border) - A.begin()) << endl;
			//num += N - (lower_bound(A.begin(), A.end(), border) - A.begin());
		}
	}
	//cout << "last num = " << num << " me = " << me << endl;
	num -= me;
	num/=2;


	return num < K;
}

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	
	sort(A.begin(), A.end());


	long long start = - LONG_MAX;
	long long end = LONG_MAX;

	while(start + 1 < end) {
		long long mid = (start + end)/2;
		if(check(mid)) {
			start = mid;
		} else {
			end = mid;
		}
	}
	cout << end << endl;
}



Measured memory_bytes: 5284
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// template <class... Args>
// auto create(size_t n, Args &&... args)
// {
//     if constexpr (sizeof...(args) == 1)
//         return vector(n, args...);
//     else
//         return vector(n, create(args...));
// }

// template <typename... T>
// void read(T &... args)
// {
//     ((cin >> args), ...);
// }

// template <typename... T>
// void write(T &&... args)
// {
//     ((cout << args), ...);
// }

void solve()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<vector<int>> dp(n, vector<int>(n));
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = i; j < n; j++)
        {
            if (i == j)
            {
                dp[i][j] = arr[i];
            }
            else
            {
                dp[i][j] = max(arr[i] - dp[i + 1][j], arr[j] - dp[i][j - 1]);
            }
        }
    }
    cout << dp[0][n - 1];
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    solve();
    return 0;
}


Measured memory_bytes: 73688
/*
[agc033] A - Darker and Darker
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_H = 1000;
const int MAX_W = 1000;

const int dh[4] = {-1, 0, 1, 0};
const int dw[4] = {0, 1, 0, -1};

int H, W;
string A[MAX_H];

ll solve() {
    queue<pair<int, pii>> q;
    bool visited[MAX_H][MAX_W];
    memset(visited, false, sizeof(visited));

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                q.push({0, {i, j}});
            }
        }
    }

    int ans = 0;
    while (!q.empty()) {
        auto thw = q.front();
        q.pop();
        int t = thw.first;
        int h = thw.second.first;
        int w = thw.second.second;
        if (h < 0 || H <= h || w < 0 || W <= w) {
            continue;
        }
        if (visited[h][w]) {
            continue;
        }
        visited[h][w] = true;
        ans = max(ans, t);

        for (int i = 0; i < 4; i++) {
            q.push({t + 1, {h + dh[i], w + dw[i]}});
        }
    }

    return ans;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 50632
n,a,b = map(int,input().split())
s = list(input())
count = 0
count1 = 0
for i in range(n):
    if count < a+b:
        if s[i] == "a":
            count += 1
            print("Yes")
        elif s[i] == "b":
            if count1 < b:
                count += 1
                count1 += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4704
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

A,B,C=nm()
K=int(input())

count=0
while(B<=A):
    B*=2
    count+=1
while(C<=B):
    C*=2
    count+=1

print('No' if K<count else 'Yes')



    


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

class Main {
  public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String[] list = new String[3];
      list[0] = String.valueOf(sc.nextInt());
      list[1] = String.valueOf(sc.nextInt());
      list[2] = String.valueOf(sc.nextInt());

      Arrays.sort(list);

      System.out.println(String.join(" ",  list));
      sc.close();
  }
}


Measured memory_bytes: 26256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int N;
	cin>>N;
	string P,Q;
	rep(i,0,N){
		char c;
		cin>>c;
		P.pb(c);
	}
	rep(i,0,N){
		char c;
		cin>>c;
		Q.pb(c);
	}
	string A;
	rep(i,1,N+1){
		A.pb((char)('0'+i));
	}
	ll a=0,b=0,cnt=0;
	do{
		cnt++;
		if(P==A) a=cnt;
		if(Q==A) b=cnt;
		//DBG(a,b,A,P);
		if(a>0&&b>0) break;
	}while(next_permutation(all(A)));
	cout<<abs(a-b)<<endl;
	return 0;
}


Measured memory_bytes: 3528
# -*- coding: utf-8 -*-
import numpy as np
import types
import copy
import math

# Input
l = list(map(int, input().split()))
N = l[0]
K = l[1]
win_rate = 0

def calcNeedCount(d, k):
    point = d
    count = 0
    while point < k:
        point = point * 2
        count += 1

    return count


n = copy.deepcopy(N)
while n > 0:
    dice = n

    # Calc need count
    need = calcNeedCount(dice, K)
    #print("need", need)

    win_rate += (1/N) * math.pow(1/2, need)

    n += -1

# Print
print(win_rate)


Measured memory_bytes: 19364
n = int(input())
p = [[] for _ in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    p[i].append(list(map(int,input().split())))
ans = 0
for i in range(2**n):
  a = [(i >> j) & 1 for j in range(n)]
  flag = 1
  for k in range(n):
    if a[k]*flag == 1:
      for l in p[k]:
        if a[l[0]-1] != l[1]:
          flag = 0
  ans = max(ans,flag*sum(a))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int h,w,a[1501][1501],ls,s[1501][1501];
main(){
	cin>>h>>w;
		r(i,h)r(j,w)cin>>s[i][j];
		memset(a,0,sizeof(a));
		r(i,h)r(j,w){
			if(!i&&!s[i][j])a[i][j]++;
			if(i&&!s[i][j])a[i][j]=a[i-1][j]+1;
		}
		int ans=0;
		r(i,h){
			stack<P>st;
			r(j,w+1){
				if(st.empty())st.push(P(a[i][j],j));
				if(st.top().fi==a[i][j])continue;
				else if(st.top().fi<a[i][j])st.push(P(a[i][j],j));
				else{
					while(!st.empty()&&st.top().fi>a[i][j]){
						ans=max(ans,(j-st.top().se)*st.top().fi);
						ls=st.top().se;
						st.pop();
					}
					st.push(P(a[i][j],ls));
				}
			}
		}
		cout<<ans<<endl;
	
}

Measured memory_bytes: 20104
package main

import "fmt"

func GCM(a, b int) int {
	if a < b {
		a, b = b, a
	}
	if b == 0 {
		return a
	}
	return GCM(b, a % b)
}

func LCM(a, b int) int {
	return a*b/GCM(a, b)
}

func main() {

	for {
		var a, b int
		var G, L int
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			break
		}
		G = GCM(a, b)
		L = LCM(a, b)
		fmt.Printf("%d %d\n", G, L)
	}
}


Measured memory_bytes: 1100
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 998244353;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int powmod(int a, int b) {
    if (b == 0)
        return 1;
    int res = powmod(a, b / 2);
    res = res * res % MOD;
    if (b & 1)
        res = res * a % MOD;
    return res;
}


int f[MX];
int f1[MX];
int C(int n, int k) {
    if (k < 0 || k > n)
        return 0;
    return f[n] * f1[k] % MOD * f1[n - k] % MOD;
}



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

    f[0] = 1;
    fi(1, MX)
        f[i] = f[i - 1] * i % MOD;
    f1[MX - 1] = powmod(f[MX - 1], MOD - 2);
    fi1(MX - 1, 0) 
        f1[i] = f1[i + 1] * (i + 1) % MOD;

    int n, m, k;
    cin >> n >> m >> k;

    int sum = 0;
    fi(0, k + 1) {
        sum += C(n - 1, i) * m % MOD * powmod(m - 1, n - i - 1) % MOD;
    }   
    cout << sum % MOD << '\n';
}

Measured memory_bytes: 6824
#include <iostream>
#include <algorithm>
#include <map>
#include <memory.h>
#include <cstdlib>
#include <cmath>
using namespace std;

struct C{
  int x, y, r;
};

bool operator<(const C &c1, const C &c2){
  return c1.r < c2.r;
}

bool away(const C &c1, const C &c2){
  int dx = abs(c1.x - c2.x);
  int dy = abs(c1.y - c2.y);
  return dx * dx + dy * dy > (c1.r + c2.r) * (c1.r + c2.r);
}

bool PinCircle(int x, int y, const C &c2){
  int dx = abs(x - c2.x);
  int dy = abs(y - c2.y);
  return dx * dx + dy * dy < c2.r * c2.r;
}

bool CircleinCircle(const C &c1, const C &c2){
  int dx = abs(c1.x - c2.x);
  int dy = abs(c1.y - c2.y);
  return c2.r > c1.r && dx * dx + dy * dy < (c2.r - c1.r) * (c2.r - c1.r);
}

C circles[2000];
int dp[2][2000];

int main(){
  int n;
  int x[2], y[2]; 
  while(cin >> n && n){
    int res = 0;
    memset(dp, 0, sizeof(dp));
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    for(int i = 0; i < n; i++)
      cin >> circles[i].x >> circles[i].y >> circles[i].r;
    sort(circles, circles + n);
    for(int type = 0; type < 2; type++){
      for(int i = 0; i < n; i++){
	if(PinCircle(x[type], y[type], circles[i]) &&
	   !PinCircle(x[(type+1)%2], y[(type+1)%2], circles[i])){
	  dp[type][i] = 1;
	  for(int j = 0; j < i; j++){
	    if(CircleinCircle(circles[j], circles[i]))
	      dp[type][i] = max(dp[type][i], dp[type][j] + 1);
	  }
	}
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	res = max(res, max(dp[0][i], dp[1][j]));
	res = max(res, max(dp[0][j], dp[1][i]));
	if(away(circles[i], circles[j]))
	  res = max(res, max(dp[0][i] + dp[1][j], dp[1][i] + dp[0][j]));
      } 
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N, M, C;
	cin >> N >> M >> C;
	int B[25], A[25][25];
	int i, j, l = 0;
	for (i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (i = 0; i < N; i++){
		for (j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	for (i = 0; i < N; i++) {
		int k = 0;
		for (j = 0; j < M; j++) {
			k += A[i][j] * B[j];
		}
		if (k + C > 0) {
			l++;
		}
	}
	cout << l;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

const int INF=1e9;
const ll INFF=1e17;
const double EPS=1e-9;
const ll MOD=1e9+7;
const int MAXN=1e5+10;
ll fact[MAXN],fact_i[MAXN];
ll mod_exp(ll b,ll e){
	ll r=1LL;
	while(e>0){
		if(e&1LL)r=(r*b)%MOD;
		b=(b*b)%MOD;
		e>>=1LL;
	}
	return r;
}
ll mi(ll n_f){return mod_exp(n_f,MOD-2LL)%MOD;}
ll nck(ll n,ll k){if(k>n)return 0;return (fact[n]*((fact_i[k]*fact_i[n-k])%MOD))%MOD;}
ll mod(ll a){return (a+MOD)%MOD;}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a[MAXN],d,rep,l=-1;
	bool pre[MAXN];
	cin >> n;
	REP(i,n+1)pre[i]=0;
	REP(i,n+1){cin >> a[i];if(pre[a[i]])rep=a[i];else pre[a[i]]=1;}
	REP(i,n+1)if(a[i]==rep){if(l==-1)l=i;else d=i-l-1;}
	fact[0]=1;for(ll i=1;i<=n+1;i++)fact[i]=(fact[i-1]*i)%MOD;
	fact_i[0]=1;for(ll i=1;i<=n+1;i++)fact_i[i]=(fact_i[i-1]*mi(i))%MOD;
	FOR(i,1,n+2){
		cout << mod(nck(n+1,i)-nck(n+1-(d+2),i-1)) << '\n';
	}
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main() {
  int a, c, d, e, gou = 0;
  cin >> a;
  int b[a];
  for(int i = 0; i < a; i++) {
    cin >> b[i];
    gou += b[i];
  }
  cin >> c;
  for(int i = 0; i < c; i++) {
    cin >> e >> d;
    cout << gou - (b[e - 1] - d) << endl;
  }
}


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

namespace ConsoleApplication24 {
    class Program {
        static void Main(string[] args) {

            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            
            var result = Method(n,s);
            Console.WriteLine(result);
        }

        private static int Method(int n, string s) {
            int max = 0;
            int x = 0;
            for (int i = 0; i < s.Length; i++) {
                if(s[i] == 'I') {
                    x++;
                    if(max < x) {//maxの値を取得
                        max = x;
                    }
                }
                else if (s[i] == 'D') {
                    x--;
                }
            }

            return max;
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
#define mod 1000000007
int main()
{	
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int w=1;
	// cin>>w;
	while(w--){
		string s,t;
		cin>>s>>t;
		int n=s.size(),m=t.size();
		int arr[n+1][m+1];
		F(i,0,n+1){
			F(j,0,m+1){
				if(i==0||j==0)arr[i][j]=0;
				else{
					if(s[i-1]==t[j-1])arr[i][j]=arr[i-1][j-1]+1;
					else arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
				}
			}
		}
		string ans="";
		int i=n,j=m;
		while(i>0&&j>0){
			if(s[i-1]==t[j-1]){ans=t[j-1]+ans;
			i--;j--;}
			else if(arr[i][j-1]>arr[i-1][j])j--;
			else i--;
		}
		cout<<ans;
	}
}

Measured memory_bytes: 38740
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = arr_data[0][0]


print("Yes"   if "9"  in n else "No")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll len = (1 << N);
    ll S[len];
    REP(i, 0, len) {
        cin >> S[i];
    }
    sort(S, S + len);
    reverse(S, S + len);
    ll smod[len];
    ll modnum = 0;
    smod[0] = 0;
    REP(i, 1, len) {
        if (S[i] != S[i - 1]) {
            modnum++;
        }
        smod[i] = modnum;
    }
    bool ok = true;
    if (smod[1] == 0) {
        ok = false;
    }
    ll gen[N];
    fill(gen, gen + N, 0);
    ll newgen[N];
    fill(newgen, newgen + N, 0);
    fill(gen, gen + N, 1);
    ll maxgen = N - 1;
    REP(i, 1, len) {
        if (smod[i] != smod[i - 1]) {
            REP(j, 0, N) {
                newgen[j] += gen[j];
                gen[j] = newgen[j];
                newgen[j] = 0;
            }
            maxgen = -1;
            PER(j, N - 1, -1) {
                if (gen[j] != 0) {
                    maxgen = j;
                    break;
                }
            }
        }
        if (maxgen == -1) {
            ok = false;
            break;
        }
        REP(j, 0, maxgen) {
            newgen[j]++;
        }
        gen[maxgen]--;
        if (gen[maxgen] == 0) {
            maxgen--;
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		long num = sc.nextInt();
		long total = 1;

		for(int i = 1; i <= num; i++){

			total *= i;
		}

		System.out.println(total);
	}

}

Measured memory_bytes: 26152
#include <bits/stdc++.h>
#define val(a) ((a)>=0?(a):0)
using namespace std;
typedef long long LL;
const int MAX_N=105;
int h[MAX_N];
int n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=n;i++)ans+=val(h[i]-h[i-1]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        
        cin>>n>>m;
        cout<<(n)*(n-1)/2 + (m)*(m-1)/2;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(4);

            int start = Math.max(a[0], a[2]);
            int end = Math.min(a[1], a[3]);

            out.println(Math.max(end - start, 0));
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
#include<bits/stdc++.h>
typedef long long ll;
const int MOD = 1e9+7, MK=1e6+1, MS = 1e6+1;
int K, L;
ll ans, F[MK+MS], IF[MK+MS];
inline ll exp(ll b, ll e) {
    ll ret = 1;
    while(e) {
        if(e&1) ret = (ret * b) % MOD;
        b = (b * b) % MOD;
        e /= 2;
    }
    return ret;
}
inline ll nCr(int n, int r) {
    return (((F[n] * IF[r]) % MOD) * IF[n - r]) % MOD;
}
int main() {
    scanf("%d\n", &K);
    scanf("%*s%n", &L);
    F[0] = IF[0] = 1;
    for(int i=1;i<=K+L;++i) {
        F[i] = (F[i-1] * i) % MOD;
        IF[i] = (IF[i-1] * exp(i, MOD - 2)) % MOD;
    }
    for(int i=0;i<=K;++i) {
        ans = (ans + (((nCr(i + L - 1, L - 1) * exp(25, i)) % MOD) * exp(26, K - i)) % MOD) % MOD;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 34972
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut a: Vec<i64> = (0..n).map(|_| sc.ne()).collect();
    a.sort();
    let (mut lb, mut ub) = (-1, (n - 1) as i32);
    while ub - lb > 1 {
        let mid = ((lb + ub) / 2) as usize;
        let mut cur = 0;
        let mut ok = true;
        for i in 0..n {
            if a[i] <= a[mid] * 2 {
                cur += a[i];
            } else {
                if a[i] <= cur * 2 {
                    cur += a[i];
                } else {
                    ok = false;
                    break;
                }
            }
        }
        if ok {
            ub = mid as i32;
        } else {
            lb = mid as i32;
        }
    }
    println!("{}", n - ub as usize);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 14588
#include<bits/stdc++.h>
using namespace std;
void fin(int a,int b,int v){
    if(a==b){
        printf("%d ",a);
        return;
    }
    int x=(a^b)&(-(a^b));
    v^=x;
    int y=v&(-v);
    fin(a,a^y,v);
    fin(a^y^x,b,v);
}
int main(){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(__builtin_popcount(a^b)&1){
        printf("YES\n");
        fin(a,b,(1<<n)-1);
    }
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll  long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define f(i,n)   for(long long i=0;i<n;i++)
#define INF 1e9+5
#define LINF 1e18L+5;
#define pb push_back
#define mk make_pair
using namespace std;
/************************BELIAL**********DEVIL*********BELIAL***********DEVIL*************************/
void min_self(long long &a,long long b)
{
  a= min(a,b);
  return;

}
int main()
{
    int n,w;

    cin>>n>>w;


    vector<int> wt(n),val(n);

     for(int i=0;i<n;i++)
     {
        cin>>wt[i]>>val[i];	
     }
   
   int tval=0;

   for(int i=0;i<n;i++)
   	 tval+= val[i];

  vector<ll> dp(tval+1, INF);  // dp[i] stores min wt having value exactly equal to i,INF initialisn makes that sure.
  dp[0]=0;                     // if its not possible to make val i then dp[i] will have inf
   	for(int item =0;item<n;item++)
   	{
        
       for(int value_already=tval-val[item];value_already>=0;value_already--)
       {

             min_self(dp[value_already+ val[item]],dp[value_already]+wt[item]);



       }
   	}

  int ans=0;

  for(int i=0;i<=tval;i++)
  {
     if(dp[i]<=w)
     	  ans= max(ans,i);

  } 

  cout<<ans;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll a,b,c;cin>>a>>b>>c;
  string ans= a+b+c<=21 ? "win":"bust";
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  string s;
  int k;
  cin>>s>>k;
  int n=s.size();
  int one=0;
  char ans;
  for(int i=0;i<n;i++){
    if(s[i]=='1') one++;
    else{
      ans=s[i];
      break;
    }
  }
  if(one>=k) cout<<1<<endl;
  else cout<<ans<<endl;
}


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

int main() {
	long long N;
	string S[500];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> S[i];
	bool check = false;
	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (S[i][j] == '#') check = true;
	if (!check) {
		cout << -1 << endl;
		return 0;
	}
	long long MIN = 1000;
	for (int i = 0; i < N; i++) {
		check = false;
		long long COUNT = 0;
		for (int j = 0; j < N; j++) {
			if (S[j][i] == '#') check = true;
		}
		if (!check) COUNT++;
		for (int j = 0; j < N; j++) {
			if (S[i][j] == '.') COUNT++;
		}
		MIN = min(MIN, COUNT);
	}
	long long ANS = MIN;
	for (int i = 0; i < N; i++) {
		bool check = true;
		for (int j = 0; j < N; j++) {
			if (S[j][i] == '.') check = false;
		}
		if (!check) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




int main()
{

	string S;
	vector<string> Ss;
	int ans;

	cin >> S;

	Ss.push_back(string(1,S[0]));
	int ssi = 0;
	for (int si = 1; si < S.length(); si++){
		if(Ss[ssi].length() > 1 || Ss[ssi] != string(1,S[si])){
			Ss.push_back(string(1,S[si]));
			ssi++;
		}else{
			if (si == S.length() - 1) {
				if (Ss[ssi] != string(1, S[si])) {
					Ss.push_back(string({ S[si] , S[si + 1] }));
					ssi++;
				}
				else {
					Ss[ssi] = Ss[ssi] + string(1, S[si]);
				}
			}
			else {
				Ss.push_back(string({ S[si] , S[si + 1] }));
				ssi++;
			}
			si++;
		}
	}

	ans = ssi+1;

	printf("%d",ans);


	return 0;
}



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

vector<pair<ll, ll>> prime_factor(ll n) {
    vector<pair<ll, ll>> res;
    for (ll a =2; a * a <= n; a++) {
        if (n % a != 0) continue;
        ll ex = 0; // 指数

    // 割れる限り割り続ける
        while (n % a == 0) {
        ex++;
        n /= a;
       }
    // その結果を push
        res.push_back({a, ex});
    }
  
    if (n != 1) res.push_back({n, 1});
    return res;
} 

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

    auto fact = prime_factor(P);
    ll ans = 1;
    for (auto p : fact) {
        for (int j = 0; j < p.second/N; j++) ans *= p.first;
    }
    cout << ans << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if (A>=13) {
    cout << B;
  }
  else if (6<=A&&A<=12) {
    cout << B/2;
  }
  else {
    cout << 0;
  }
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto S = rs.to!(dchar[]);
	S[K-1] = S[K-1].toLower;
	S.writeln;
}
// =======================111=1===========

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii : toLower;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

int main() {
	string b;
	int i, c = 0, d = 0;
	stack<char> a;
	bool e;
	while (1) {
		getline(cin,b);
		for (i = 0; i<(int)b.size(); i++) {
				/*if (b[i] == '(') { c += 1; 
				e = true;
				}
				if (b[i] == ')') {
					c -= 1;
					e = false;
					if (c < 0||e==false) {
						c = 1;
						break; }
				}
				if (b[i] == '[') { d += 1; 
				e = false;
				}
				if (b[i] == ']') { d -= 1;
				d = true;
				if (d < 0||e==true) { 
					d = 1;
					break;
				}
				}
		*/
			if (b[i] == '(' || b[i] == '[') {
				a.push(b[i]); }
			if (a.empty())if (b[i] == ')' || b[i] == ']') { 
				a.push(b[i]);
				break; }
			if (b[i] == ')'&&a.top() == '(') { a.pop(); }
			else if (b[i] == ']'&&a.top() == '[') { a.pop(); }
			else if (b[i] == ')'&&a.top() == '[') { break; }
			else if (b[i] == ']'&&a.top() == '(') { break; }

		}

		if (b[0] == '.') { break; }
		//if (c == 0 && d == 0) 
		if(a.empty()){cout << "yes"<<endl; }
			else { cout << "no"<<endl; }
			//c = 0, d = 0;
			while (!a.empty()) { 
			a.pop();
			};
	};
	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int h,n;
int dp[1001];
int v[4000],cost[4000];
int ans = 1e-9;
/*
int go(int i,int sum){

        if(dp[i][sum]!=-1) return dp[i][sum];

       dp[i][sum] =min(val[i]+go(i+1,W-a[i]),go(i+1,W));
       return dp[i][sum];
}
*/
void go(int i,int x, int y ){

     ans = max(ans,x-y);
    if(i>n){
      return ;
    }
    go(i+1,v[i]+x,cost[i]+y);
    go(i+1,x,y);
    return;
}
 int main()
{
   // fast;

    int n,k,q;
  string s;
     cin >> s;
     stack<char>st;
     int cnt = 0;
     for(int i = 0; i<s.size() ; i++){
        if(i==0){
            st.push(s[i]);continue;
        }
        if(!st.empty()){

            if(abs(st.top())=='1' && s[i]=='0' || st.top()=='0' && s[i]=='1'){
                cnt++;
                st.pop();
            } else{
             st.push(s[i]);
            }
        }
        else st.push(s[i]);
     }

     cout << cnt*2 << endl;

   return 0;
}


Measured memory_bytes: 512
import heapq


def main():
    X, Y, Z, K = map(int, input().split())
    A = sorted(list(map(int, input().split())),reverse=True)
    B = sorted(list(map(int, input().split())),reverse=True)
    C = sorted(list(map(int, input().split())),reverse=True)

    used = set()
    candidate = []
    heapq.heappush(candidate, (-A[0]-B[0]-C[0], 0, 0, 0))

    for _ in range(K):
        value, x, y, z = heapq.heappop(candidate)
        print(-value)

        if x+1 < X and (x+1, y, z) not in used:
            heapq.heappush(candidate, (-A[x+1]-B[y]-C[z], x+1, y, z))
            used.add((x+1, y, z))

        if y+1 < Y and (x, y+1, z) not in used:
            heapq.heappush(candidate, (-A[x]-B[y+1]-C[z], x, y+1, z))
            used.add((x, y+1, z))

        if z+1 < Z and (x, y, z+1) not in used:
            heapq.heappush(candidate, (-A[x]-B[y]-C[z+1], x , y, z+1))
            used.add((x, y, z+1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 4976
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    set<char> mth={'M','A','R','C','H'},fnd;
    map<char,ll> f;
    string s;
    for (i=0;i<n;i++)
    {
        cin>>s;
        if (mth.find(s[0])!=mth.end())
        {
            fnd.insert(s[0]);
            f[s[0]]++;
        }
    }
    if (fnd.size()<3)
        cout<<"0\n";
    else if (fnd.size()==3)
    {
        ll ans=1;
        for (auto e: f)
            ans*=e.ss;
        cout<<ans<<endl;
    }
    else if (fnd.size()==4)
    {
        ll ans=0;
        vector<ll> np;
        for (auto e: f)
            np.pb(e.ss);
        for (i=0;i<16;i++)
        {
            if (__builtin_popcount(i)==3)
            {
                ll tp=1;
                int g=i,ctr=3;
                while (ctr>=0)
                {
                    if (g&1)
                        tp*=np[ctr];
                    g>>=1;
                    ctr--;
                }
                ans+=tp;
            }
        }
        cout<<ans<<endl;
    }
    else
    {
        ll ans=0;
        vector<ll> np;
        for (auto e: f)
            np.pb(e.ss);
        for (i=0;i<32;i++)
        {
            if (__builtin_popcount(i)==3)
            {
                ll tp=1;
                int g=i,ctr=4;
                while (ctr>=0)
                {
                    if (g&1)
                        tp*=np[ctr];
                    g>>=1;
                    ctr--;
                }
                ans+=tp;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256