akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

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

  if (A == 1) A+=13;
  if (B == 1) B+= 13;

  if (A == B) cout << "Draw" << endl;
  else if (A > B) cout << "Alice" << endl;
  else cout << "Bob" << endl;

  return 0;
}

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

int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A <= X && X <= A + B) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const int INF = 1E09;
const int MAX_N = 200;

struct edge {
    int to, cost;
};

vector<edge> G[MAX_N + 1];
int d[MAX_N + 1];

void dijkstra(int s);

int N, M, R;

int dp[8][1 << 8], cmin[8][8];
int rt[8];

int getmin(int i, int s);

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

    cin >> N >> M >> R;

    for (int i = 0; i < R; i++) {
        cin >> rt[i];
    }

    for (int i = 0; i < M; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        edge es = { t, c };
        G[s].push_back(es);
        edge et = { s, c };
        G[t].push_back(et);
    }

    for (int i = 0; i < R; i++) {
        fill(d, d + N + 1, INF);
        dijkstra(rt[i]);
        for (int j = 0; j < R; j++) {
            cmin[i][j] = d[rt[j]];
            cmin[j][i] = d[rt[j]];
        }
    }

    memset(dp, -1, sizeof(dp));
    int ans = INF;
    for (int i = 0; i < R; i++) {
        ans = min(ans, getmin(i, (1 << R) - 1));
    }

    cout << ans << "\n";

    return 0;
}

int getmin(int i, int s)
{
    if (dp[i][s] != -1) {
        return dp[i][s];
    }
    int t = s & ~(1 << i);
    if (t == 0) {
        return dp[i][s] = 0;
    }
    int ans = INF;
    for (int k = 0; k < R; k++) {
        if (t & (1 << k)) {
            ans = min(ans, getmin(k, t) + cmin[i][k]);
        }
    }
    return dp[i][s] = ans;
}

void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    d[s] = 0;
    while (!que.empty()) {
        P p = que.top();
        int v = p.second;
        que.pop();
        if (d[v] < p.first)
            continue; 
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

Measured memory_bytes: 3920
#include <stdio.h>
#define MOD 1000000007
typedef long long ll;
ll a[300000];
int main() {
	int n;
	ll sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < 60; i++) {
		int c0 = 0, c1 = 0;
		for (int j = n - 1; j >= 0; j--) {
			if ((a[j] >> i) & 1) {
				c1++;
			} else {
				c0++;
			}
		}
		sum += (1LL << i) % MOD * c0 % MOD * c1 % MOD;
		sum %= MOD;
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 4000
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)

if x > a:
	x_a = x - a
else:
	x_a = a - x

if x > b:
	x_b = x - b
else:
	x_b = b - x
	
if x_a > x_b:
	print("B")
else:
	print("A")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
int main(){
    int N; cin >> N;
    vector<int> a(N+1);
    REP(i,N) cin >> a[i+1];
    vector<int> b(N+1);

    for(int i = N; i>=1; i--){
        int tmp = 0;
        for(int j = i+i; j<=N; j += i){
            tmp += b[j];
        }
        if(tmp % 2 == a[i] % 2){b[i] = 0;}
        else{b[i] = 1;}
    }

    vector<int> ans;
    for(int i = 1;i<=N;i++){
        if(b[i]) ans.push_back(i);
    }
    cout <<ans.size() <<endl;

    REP(i,ans.size()){
         printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
    }
    
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	double R;
	cin >> R;
	cout << 2*R*M_PI << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3804
D, G = map(int, input().split())
grid = [[0,0]]#インデックス合わせとく
for i in range(D):
    p,c = map(int, input().split())
    grid.append([p,c])

import itertools
kumi = list(itertools.product([0,1], repeat=D))
anls = []
fans = float('inf')
for item in kumi:
    count = 0
    ans = 0
    k = 0
    score = 0
    for i in item:
        count += 1
        if i == 1:
            score += grid[count][0]*100*count + grid[count][1]
            ans += grid[count][0]
        else:
            k = count

    if G <= score :
        fans = min(fans,ans)
    elif score+(k*100)*(grid[k][0]-1) >= G :
        a = int((G-score)/(k*100))
        if score+a*k*100==G:
            ans += a
        else:
            ans += (a+1)
        fans = min(fans,ans)
if fans != float('inf'):
    fans = int(fans)
print(fans)



Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define N 2019

int main(void){
    int L,R;
    scanf("%d %d",&L, &R);

    int ans;
    if((R-L)>=N){
        ans=0;
    }
    else{
        int l,r;
        l=L%N;
        r=R%N;
        if(r<l){
            ans=0;
        }
        else{
            ans=N;
            for(int i=l;i<r;i++){
                for(int j=i+1;j<=r;j++){
                    int tmp=i*j%N;
                    if(tmp<ans) ans=tmp;
                }
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

#define f first
#define s second
#define INF (1<<29)
using namespace std;

typedef pair<int,int>pii;
typedef pair<int,pii>piii;
typedef pair<double,int>pid;

vector<pid> g[101];
pid pre[101];
double d[101];

bool dijkstra(int S, int G){
  priority_queue<pid,vector<pid>,greater<pid> > que;
  que.push(pid(0.0,S));
  for(int i=0;i<101;i++)pre[i]=pid(-1,-1);
  fill(d,d+100,INF);
  d[S]=0;
  while(!que.empty()){
    pid now = que.top();
    que.pop();
    
    if(now.s==G)return true;

    for(int i=0;i<g[now.s].size();i++){
      pid nx = g[now.s][i];
      if(d[nx.s] > now.f+nx.f){
	pre[nx.s]=now;
	d[nx.s]=now.f+nx.f;
	que.push(pid(now.f+nx.f,nx.s));
      }
    }
  }
  return false;
}

int main(void){

  int n,m;
  while(cin >> n,n>0){

    vector<piii>v(n);
    for(int i=0;i<n;i++){
      g[i].clear();
      cin >> v[i].f >> v[i].s.f >> v[i].s.s;
      v[i].f--;
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	double a = v[i].s.f-v[j].s.f;
	double b = v[i].s.s-v[j].s.s;
	double d = a*a+b*b;
	if(d <= 2500){
	  g[v[i].f].push_back(pid(sqrt(d),v[j].f));
	  g[v[j].f].push_back(pid(sqrt(d),v[i].f));
	}
      }
    }

    cin >> m;
    for(int i=0;i<m;i++){
      int S,G;
      cin >> S >> G;
      if(!dijkstra(S-1,G-1))cout << "NA" << endl;
      else {
	vector<int>res;
	int now = G-1;
	while(pre[now].s>=0){
	  res.push_back(now+1);
	  now=pre[now].s;
	}
	res.push_back(S);
	reverse(res.begin(),res.end());
	for(int i=0;i<res.size();i++)
	  cout << res[i] << (i<res.size()-1?" ":"\n");
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3116
#include <stdio.h>

int main(){
	int A[4], B[4];
	int a, b;
	int hit, blow;

	while( scanf("%d%d%d%d",&A[0],&A[1],&A[2],&A[3]) != EOF ){
		scanf("%d%d%d%d",&B[0],&B[1],&B[2],&B[3]);

		hit=blow=0;

		for( a=0; a<4; a++ ){
			for( b=0; b<4; b++ ){
				if( A[a] == B[b] ){
					(a==b)? hit++ : blow++;
				}
			}
		}

		printf("%d %d\n", hit, blow);
	}

	return 0;
}
	

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

#define ll long long

using namespace std;

int n, a[100000+4];

int main() {
    cin >> n;
    for (int i=0;i<n;++i)
        cin >> a[i];
    sort(a, a+n);
    cout << a[n/2]-a[n/2-1];

    return 0;
}


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

using namespace std;
 
int main() {
  int A, B, C;
  string op;
  cin >> A >> B;

  C = A % 500;
  if (C <= B){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
const int I = 1001001001001ll;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll x[20];
int main(){
    ll r,d; cin >> r >> d >> x[0];
    for(int i = 1; i <= 10; i++){
        x[i] = x[i-1]*r - d;
    }
    for(int i = 1; i <= 10; i++){
        cout << x[i] << endl;
    }
}


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

void solve(int p,string S,vector<int> &ans){
	if(p==0){
		bool p7,p5,p3;
		p7=false;
		p5=false;
		p3=false;
		for(int i=0;i<S.size();i++){
			if(S.at(i)=='7'){
				p7=true;
			}
			else if(S.at(i)=='5'){
				p5=true;
			}
			else if(S.at(i)=='3'){
				p3=true;
			}
		}
		if(p7 && p5 &&p3){
			istringstream ss;
			ss=istringstream(S);
			int A;
			ss>>A;
			ans.push_back(A);
		}
	}
	
	else{
		for(char i='3';i<='7';i+=2){
			solve(p-1,S+i,ans);
		}
	}
}


int main() {
	int N;
	cin >> N;
	int tmp =N;
	int p=3;
	while(tmp>1){
		tmp=tmp/10;
		p++;
	}
	vector<int> ans(0);
	for(int j=0;j<=p;j++){
		solve(j,"",ans);
	}
	sort(ans.begin(),ans.end());
	int sum=0;
	for(int i=0;i<ans.size();i++){
		if(ans.at(i)<=N){
			sum++;
		}
		else{
			break;
		}
	}
	// cout<<ans.at(ans.size()-1)<<endl;
	cout<<sum<<endl;
}

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

int main() {
	//cout<<"GfG!";
    int n;
    cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
	    if(s[i]+n>90)
	    {
	        s[i]=s[i]+(n-26);
	    }
	    else
	    {
	        s[i]=s[i]+n;
	    }
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=1e9;
int main(){
      int n;
      while(cin>>n&&n){
            int fld[n][n],cnt[n][n];
            memset(cnt,0,sizeof(cnt));
            REP(i,n)REP(j,n)cin>>fld[j][i];
            REP(i,n){
                  int ma=-1;
                  REP(j,n)ma=max(ma,fld[i][j]);
                  REP(j,n)if(fld[i][j]==ma)cnt[i][j]++;
            }
            REP(i,n){
                  int mi=INF;
                  REP(j,n)mi=min(mi,fld[j][i]);
                  REP(j,n)if(fld[j][i]==mi)cnt[j][i]++;
            }
            REP(i,n){
                  REP(j,n){
                        if(cnt[j][i]==2){
                              cout<<fld[j][i]<<endl;
                              goto exit;
                        }
                  }
            }
            cout<<0<<endl;
            exit:;
      }
}

Measured memory_bytes: 1168
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
ll M;
ll S;
vl U;
vl V;
vl A;
vl B;
vl C;
vl D;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> M;
    cin >> S;
    U = vl(M);
    V = vl(M);
    A = vl(M);
    B = vl(M);
    for(int i = 0; i < M; ++i){
        cin >> U[i];
        cin >> V[i];
        cin >> A[i];
        cin >> B[i];
    }
    C = vl(N);
    D = vl(N);
    for(int i = 0; i < N; ++i){
        cin >> C[i];
        cin >> D[i];
    }
    solve();
}

// 2 <= N <= 50
// N-1 <= M <= 100
// 0 <= S <= 10^9
// 1 <= A_i <= 50
// 1 <= B_i,C_i,D_i <= 10^9
// U_i < V_i
// (U_i,V_i)=(U_j,V_j) なる i,j(i != j) は存在しない
// 都市 1 から都市 t=2,...,N にいくつかの鉄道路線を使って移動することができる。
// 入力はすべて整数である。

template<typename T>
struct edge{
    int src,to;
    T cost;
    edge(int from,int to,T cost):src(src),to(to),cost(cost){}
    edge(int to,T cost):edge(-1,to,cost){}
    operator int()const{return to;}
};

template<typename T>
using Edges=vector<edge<T>>;

template<typename T>
using Graph=vector<Edges<T>>;

// ll N, ll M, ll S, vl U, vl V, vl A, vl B, vl C, vl D
// t=2,...,Nについて、都市 1 から都市 t への移動にかかる最小の時間を順番に一行ずつ出力せよ。
void solve(){
    rep(i,M)--U[i],--V[i];
    const ll MX=2600;
    Graph<ll> g(N*MX);
    rep(i,M){
        rep(j,MX){
            if(j-A[i]<0)continue;
            g[U[i]*MX+j].emplace_back(V[i]*MX+j-A[i],B[i]);
            g[V[i]*MX+j].emplace_back(U[i]*MX+j-A[i],B[i]);
        }
    }
    rep(i,N){
        rep(j,MX){
            ll to=min(j+C[i],MX-1);
            g[i*MX+j].emplace_back(i*MX+to,D[i]);
        }
    }

    pq<pl> q;
    chmin(S,MX-1);
    q.emplace(0,S);
    vl d(N*MX,LINF);
    d[S]=0;
    while(q.size()){
        ll cost,src;
        tie(cost,src)=q.top();q.pop();
        if(d[src]<cost)continue;
        for(auto &e:g[src]){
            if(d[e.to]<=d[src]+e.cost)continue;
            d[e.to]=d[src]+e.cost;
            q.emplace(d[e.to],e.to);
        }
    }

    rep(i,1,N){
        ll ans=LINF;
        rep(j,MX)chmin(ans,d[i*MX+j]);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 24616
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    vector<ll> d(n);
    rep(i, n)cin >> d[i];
    ll ans = 0;
    rep(i, n)for(ll j = i+1; j < n; ++j)ans+=d[i]*d[j];
    cout << ans << endl;
}

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

char A,B;
cin>>A>>B;
if(A=='H'&&B=='H')
    cout<<"H"<<endl;
if(A=='D'&&B=='D')
    cout<<"H"<<endl;

    if(A=='D'&&B=='H')
    cout<<"D"<<endl;

    if(A=='H'&&B=='D')
    cout<<"D"<<endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#define INF 0x3f3f3f3f
#define LL long long
#define pii pair<int,int>
using namespace std;
const double pi = 2*acos(0.0);
const int maxn = 1e5 + 30;
const int inf=2e9;
const int maxm = 1e7 + 10;
const int mod = 1000007;
const int MZ = 333;

bool notprime[maxn];
int prime[maxn];
map<LL,int> cnt;
map<LL,bool> vis;
LL a[maxn],b[maxn];

void init()
{
    int k = 0;
    for(int i=2;i<=100000;i++) {
        if(!notprime[i]) {
           prime[++k] = i;
           for(int j=i;j<=100000;j+=i) notprime[j] = true;
        }
    }
}

int main()
{
    init();
    int n;
    cin >> n;
    for(int i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++) {
        LL x = a[i];
        LL numx = 1,numy = 1;
        //printf("x=%lld\n",x);
        for(int j=1;j<=MZ&&x!=1;j++) {
            int p = 0;
            if(x%prime[j]==0) {
                while(x%prime[j]==0) {
                    p++;
                    x /= prime[j];
                }//printf("x=%lld prime[%d]=%d\n",x,j,prime[j]);
                p %= 3;
                if(!p) continue;
                //printf("p=%d\n",p);
                for(int k=1;k<=p;k++) numx *= prime[j];
                for(int k=3;k>p;k--) numy *= prime[j];
                //printf("numx=%lld numy=%lld\n",numx,numy);
            }

        }
        LL tmp = sqrt(x);
        if(tmp*tmp==x) {
            numx *= x;
            numy *= tmp;
        }
        else {
            numx *= x;
            numy *= x*x;
        }
        a[i] = numx; b[i] = numy;
        //printf("a[%d]=%lld b[%d]=%lld\n",i,a[i],i,b[i]);
        cnt[a[i]]++;
    }
    int ans = 0;
    for(int i=1;i<=n;i++) {
        if(vis.count(a[i])||vis.count(b[i])||a[i]==1) continue;
        ans += max(cnt[a[i]],cnt[b[i]]);
        vis[a[i]] = 1; vis[b[i]] = 1;
    }
    if(cnt.count(1)) ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 27008
function Main (input) {
  input = input.split("\n");
  var S = input[0];
  var T = input[1];
  if (S == T.slice(0, T.length-1)) {
    console.log("Yes");
  }
  else {
    console.log("No");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

string field[25];
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
int sh;
int sw;
map<i_i, int> dust;
int numdust;
int dist[1050][22][22];

struct query {
    int state, h, w;
    query(int a, int b, int c) {
        state = a;
        h = b;
        w = c;
    }
};

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int H, W;
        cin >> W >> H;
        if(W == 0) break;
        dust.clear();
        numdust = 0;
        for(int h = 1; h <= H; h++) {
            cin >> field[h];
            field[h] = "&" + field[h];
            for(int w = 1; w <= W; w++) {
                if(field[h][w] == 'o') {
                    sh = h;
                    sw = w;
                }
                if(field[h][w] == '*') {
                    dust[{h, w}] = numdust;
                    numdust++;
                }
            }
        }
        for(int h = 0; h <= H; h++) {
            for(int w = 0; w <= W; w++) {
                for(int bit = 0; bit < (1 << numdust); bit++) {
                    dist[bit][h][w] = INF;
                }
            }
        }
        dist[(1 << numdust) - 1][sh][sw] = 0;
        queue<query> queries;
        queries.emplace((1 << numdust)-1, sh, sw);
        bool clear = false;
        while(!queries.empty()) {
            query now = queries.front();
            queries.pop();
            if(now.state == 0) {
                cout << dist[now.state][now.h][now.w] << endl;
                clear = true;
                break;
            }
            for(int k = 0; k <= 3; k++) {
                int newh = now.h + dh[k];
                int neww = now.w + dw[k];
                int newbit = now.state;
                int newdist = dist[now.state][now.h][now.w] + 1;
                if(newh <= 0 || newh > H || neww <= 0 || neww > W) continue;
                if(field[newh][neww] == 'x') continue;
                if(field[newh][neww] == '*') {
                    newbit &= ~(1 << dust[{newh, neww}]);
                }
                if(dist[newbit][newh][neww] <= newdist) continue;
                dist[newbit][newh][neww] = newdist;
                queries.emplace(newbit, newh, neww);
            }
        }
        if(!clear) cout << -1 << endl;
    }
    return 0;
}


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

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

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

    return arr

n=int(input())

a=factorization(n)
ans=0


#print(a)

for i in a:
  temp=1
  for j in range(1,41):
    if temp<=i:
      ans+=1
      temp+=j+1
      #print(temp)
    if temp>i:
      break

print(ans)

Measured memory_bytes: 9476
import math
# def myAnswer(argv:list) -> int:


def modelAnswer(argv:list) -> int:
   return math.ceil(argv.pop(0) / min(argv)) + 4
def main():
   argv = [int(input()) for _ in range(6)]
   print(modelAnswer(argv))

if __name__ == '__main__':
   main()

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
double P[3005], DP[3005][3005];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> P[i];

  DP[0][0] = 1;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j <= N; j++){
      DP[i][j] = DP[i-1][j] * (1-P[i]);
      if (j > 0) DP[i][j] += DP[i-1][j-1] * P[i];
    }
  }

  double ans = 0;
  for (int i = N / 2 + 1; i <= N; i++){
    ans += DP[N][i];
  }
  printf("%.16lf\n", ans);

  return 0;
}


Measured memory_bytes: 74184
from collections import deque

n, m = map(int, input().split())

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

ans = [-1] * (n - 1)

q = deque()
q.append(0)
used = {0}
while q:
  node = q.popleft()
  for next_node in graph[node]:
    if next_node in used:
      continue
    q.append(next_node)
    used.add(next_node)
    ans[next_node - 1] = node + 1

print('Yes')
print(*ans, sep='\n')

Measured memory_bytes: 42652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    ll N;
    cin>>N;
    ll ans = N*(N-1)/2;
    
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const mxn = 5e5+10;
long long dp[mxn], h[mxn],inf =1e16;
int main(){
	int n,k;
	cin>>n>>k;
	fill(dp,dp+mxn,inf);
	for (int i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	for (int i =1 ;i<n;i++){
		for (int j =1;j<=k;j++){
			if (i-j>=0)
				dp[i]=min(dp[i],dp[i-j]+ abs(h[i]-h[i-j]) );
		}
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 6784
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        char[]ss = S.toCharArray();

        int cou = 0;
        int C = 0;
        for(int i=2; i<S.length()-1; i++) {
        	if(ss[i] == 'C') {
        		C++;
        	}
        }
        for(int i=0; i<S.length(); i++) {
        	if(ss[i]>96) {
        		cou++;
        	}
        }
        
        if(ss[0]=='A' && C==1 && cou==S.length()-2){
            System.out.println("AC");    
        }else{
            System.out.println("WA");
    }
}
}


Measured memory_bytes: 35640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
  ll N, Q;
  cin >> N >> Q;
  string S; cin >> S;
  
  VL a(N,0);
  ll cnt = 0;
  rep(i,1,N){
    if(S[i-1] == 'A' && S[i] == 'C'){
      cnt++;
    } 
    a[i] = cnt;
  }
  
  ll l,r;
  rep(i,0,Q){
    cin >> l >> r;
    l--; r--;
    cout << a[r] - a[l] << endl;
  }
  return 0;
}

Measured memory_bytes: 4304
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,H,W;
  cin>>N>>H>>W;
  
  cout<<(N-H+1)*(N-W+1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=n;i>=1;i-=2){
        cout<<s[i-1]<<" ";
    }
    for(int i=(n%2==1)+1;i<=n;i+=2){
        cout<<s[i-1]<<" ";
    }
    cout<<endl;
}


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

int main(){
    
    int n;
    
    cin >> n;
    
    int num[n];
    
    for (int i = 0; i < n; i++ ) {
        cin >> num[i];
        
    }
    
    for (int j = 0; j < n; j++ ) {
        cout << num[n - 1 - j] ;
        if (j != n-1) {
            cout <<" ";
        }
        
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 4001
int n,p,q,a,b,c,dp[404][405],i,j,ans=INF,l;
int main(void){
    cin>>n>>p>>q;
    for(i=0;i<401;i++)for(j=0;j<401;j++)dp[i][j]=INF;
    dp[0][0]=0;
    for(l=0;l<n;l++){
        cin>>a>>b>>c;
        for(i=400;i>=a;i--)for(j=400;j>=b;j--)dp[i][j]=min(dp[i][j],dp[i-a][j-b]+c);
    }
    for(i=1;i<=n;i++)ans=min(ans,dp[p*i][q*i]);
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int n = 0;
		long sum = 0;

		// ????????£????????¨?????????
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();

		// ??\???????????°????????°????????¶
		if (n <= 0 || n > 10000) {
			sc.close();
			return;
		}

		// ??\???????????°????????°??????????????????
		int[] a_i = new int[n];

		// n????????????????????\?????????????????¶?????????????????????break???
		boolean a = false;
		for (int i = 0; i < a_i.length; i++) {
			a_i[i] = sc.nextInt();
			if (a_i[i] > 1000000 || a_i[i] < -1000000)
				a = true;
		}
		sc.close();
		if (a)
			return;

		int max = a_i[0]; // ??¨?????????????????§??????a_i[0]????¨???????????????°max?????£??\
		int min = a_i[0]; // ??¨????????????????°???????a_i[0]????¨???????????????°min?????£??\
		// ?????§?????¨????°????????±???????
		for (int i = 0; i < a_i.length; i++) {
			if (max < a_i[i]) {
				max = a_i[i];
			}
			if (min > a_i[i]) {
				min = a_i[i];
			}

		}
		// ????¨????????±???????
		for (int value : a_i) {
			sum = sum + value;
		}

		// ????????????
		System.out.println(min + " " + max + " " + sum);

		// ????????£???????????????
		sc.close();
	}
}

Measured memory_bytes: 41420
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
int main()
{
	ll N;
  	cin>>N;
  	
	cout<<N%2+N/2;
  
	return 0;
}  

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

using namespace std;

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

	long long n;
	cin >> n;
	if (n % 2 == 0)
		cout << n;
	else
		cout << (n * 2);
	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> check(N+1);
    vector<int> WA_count(N+1);
    int P;
    string S;
    int ac = 0;
    int wa = 0;
    for(int i=0;i<M;i++){
        cin >> P >> S;

        if (check[P]) continue;

        if (S == "AC"){
            check[P] = 1;
            ac++;
            wa += WA_count[P];
        }else{
            WA_count[P]++;
        }
    }
    cout << ac << " " << wa << endl;
}

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

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

    int n;
    cin >> n;
    multiset<int> mada;
    for (int i = 0; i < 1 << n; i++) {
        int a;
        cin >> a;
        mada.insert(a);
    }

    auto it = mada.end();
    it--;
    vector<int> dekita = {*it};
    mada.erase(it);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 1 << i; j++) {
            int a = dekita[j];
            auto it = mada.lower_bound(a);
            if (it == mada.begin()) {
                cout << "No" << endl;
                return 0;
            }
            it--;
            dekita.push_back(*it);
            mada.erase(it);
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 13688
#include <stdio.h>
#include <string.h>

#include <cstdlib>
#include <iostream>
#include <istream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

using lint = long long;
using namespace std;

int main() {
    lint N, M;

    std::cin >> N >> M;
    std::vector<lint> H(N, 0);
    std::vector<lint> A(M, 0), B(M, 0);
    std::vector<lint> ans(N, 0);

    for (lint i = 0; i < N; i++) {
        std::cin >> H[i];
    }

    for (lint i = 0; i < M; i++) {
        std::cin >> A[i] >> B[i];
        if (H[A[i] - 1] > H[B[i] - 1]) {
            ans[B[i] - 1]++;
        } else if (H[A[i] - 1] == H[B[i] - 1]) {
            ans[A[i] - 1]++;
            ans[B[i] - 1]++;
        } else {
            ans[A[i] - 1]++;
        }
    }

    lint res = 0;

    for (lint i = 0; i < N; i++) {
        if (ans[i] == 0) {
            res++;
        }
    }

    printf("%lld", res);

    return 0;
}


Measured memory_bytes: 6036
from sys import stdin
n,m = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]
a = []
for i in range(m):
    a.append([int(x) for x in stdin.readline().rstrip().split()])
b = [0] * n
for i in range(m):
    if h[a[i][0]-1] > h[a[i][1]-1]:
        b[a[i][1]-1] = 1
    elif h[a[i][0]-1] == h[a[i][1]-1]:
        b[a[i][1]-1] = 1
        b[a[i][0]-1] = 1
    else:
        b[a[i][0]-1] = 1
ans =0
for i in range(n):
    if b[i] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 93776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;


int main() {
    string S; cin >> S;
    ll ans = 0;
    for(auto ch : S) if(ch == '2') ans++;
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a + b > c + d)
            puts("Left");
    else if (a + b < c + d)
            puts("Right");
    else
            puts("Balanced");
    return 0;
}


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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({int32_t x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

int32_t main(){
  int n = RI;
  int C = RI;
  int K = RI;

  int t[n];
  for(int i = 0; i < n; i++){
    t[i] = RI;
  }

  sort(t, t+n);

  int ans = 0;
  int ptr = 0;
  while(ptr < n){
    int limit = t[ptr]+K;
    int sz = 0;

    while(ptr < n && sz < C && t[ptr] <= limit){
      ptr++, sz++;
    }

    ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i).sort.reverse

pre = a[0]
max1 = 0
max2 = 0
1.upto(n-1) do |i|
  if a[i] == pre && max1 == 0
    max1 = a[i]
    pre = 0
  elsif
    a[i] == pre && max1 != 0
    max2 = a[i]
    puts max1 * max2
    exit
  else
    pre = a[i]
  end
end
puts 0

Measured memory_bytes: 23244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

vector <ll> factorials;
ll mod=1e9+7;

ll modExp(ll x, ll n)
{
    if (n==0) return 1;
    if (n==1) return x%mod;
    ll ans = modExp(x,n/2);
    ans = (ans*ans)%mod;
    if (n%2) ans*=x;
    return ans%mod;
}

ll modInv(ll a)
{
    return modExp(a, mod-2);
}

ll choose(ll n, ll k) 
{
    if (k==0) return 1;
    if (k>n) return 0;
    ll num = factorials[n];
    ll den = (factorials[n-k]*factorials[k])%mod;
    den = modInv(den);
    return (num*den)%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    factorials.resize(3e6+1, 1);
    loop(i,2, 3e6+1)
    {
        factorials[i]=(factorials[i-1]*i)%mod;
    }
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans=0;
    for (ll j=c1; j<=c2; ++j)
    {
        ll temp = (choose(r2+j+1, j+1)-choose(r1+j, j+1)+mod)%mod;
        ans = (ans+temp)%mod;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 23680
gets.to_i.times do
  n,k = gets.chomp.split.map(&:to_i)
  xs = gets.chomp.split.map(&:to_i).sort!
  d = Array.new(n-1) do |i|
    xs[i+1]-xs[i]
  end
  d.sort!.reverse!
  ans = xs[-1]-xs[0]
  p = [k,n].min-1
  if p>0
    ans -= d[0,p].inject(:+)
  end
  puts [ans,0].max
end

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N,M,X;
  cin>>N>>M>>X;
  vector<int>C(N);
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    cin>>C[i];
    for(int j=0;j<M;j++)cin>>A[i][j];
  }
  int bit=pow(2,N);
  int ans=INT_MAX;
  for(int b=0;b<bit;b++){
    vector<int>R(M,0);
    int res=0;
    for(int i=0;i<N;i++){
      if((b>>i)%2){
        res+=C[i];
        for(int j=0;j<M;j++)R[j]+=A[i][j];
      }
    }
    bool ok=true;
    for(int i=0;i<M;i++)if(R[i]<X)ok=false;
    if(ok)ans=min(ans,res);
  }
  if(ans==INT_MAX)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
#define EPS (double)1e-6;
int N;
int A[200005],B[200005];
map<P,int>mp;
signed main(){
	cin>>N;
	int za=0,zb=0,memo=0;
	rep(i,N){
		cin>>A[i]>>B[i];
		if(A[i]&&B[i]){
			int g=gcd(A[i],B[i]);
			A[i]/=g;
			B[i]/=g;
			mp[{A[i],B[i]}]++;
		}else {
			if(!A[i]&&B[i])za++;
			if(A[i]&&!B[i])zb++;
			if(!A[i]&&!B[i])memo++;
		}
	}
	int ans=1;
	map<P,bool>used;
	for(auto p:mp){
		if(used[p.first])continue;
		int i=p.second+mp[{-p.first.first,-p.first.second}];
		int j=mp[{-p.first.second,p.first.first}]+mp[{p.first.second,-p.first.first}];
		ans*=(mod_pow(2,i)+mod_pow(2,j)+mod-1)%mod;
		ans%=mod;
		used[p.first]=true;
		used[{-p.first.first,-p.first.second}]=true;
		used[{-p.first.second,p.first.first}]=true;
		used[{p.first.second,-p.first.first}]=true;
	}
	ans*=(mod_pow(2,za)-1+mod_pow(2,zb)+mod)%mod;
	ans%=mod;
	cout<<(ans+memo+mod-1)%mod<<endl;
}


Measured memory_bytes: 106624
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  string S, T;
  cin >> S >> T;

  vvl ss(26), tt(26);

  rep(i, S.size()){
    ss[S[i] - 'a'].push_back(i);
    tt[T[i] - 'a'].push_back(i);
  }

  stable_sort(ss.begin(), ss.end());
  stable_sort(tt.begin(), tt.end());

  rep(i, 26){
    if(!(ss[i] == tt[i])){
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  
  return 0;
}


Measured memory_bytes: 7628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>

char buf[1<<24];
int nextint(){
	static int id = 0;
	if(id == 0)read(0, buf, 1<<24);
	int res = 0;
	while(buf[id]<'0' || '9'<buf[id])id++;
	while(id<1<<24 && '0'<=buf[id] && buf[id]<='9'){
		res *= 10;
		res += buf[id++] - '0';
	}if(id>=1<<24)return -1;
	return res;
}

int getint(){
	register char c = getchar();
	int res = 0;
	while(48<=c && c<=57){
		res *= 10;
		res += c - 48;
		c = getchar();
	}
	return res;
}

#define sz 1<<20
#define mod 998244353
#define pr 3

long modpow(long x, long y, long m){
	long res = 1l, tmp = x;
	while(y){
		if(y&1)res = res * tmp % m;
		tmp = tmp * tmp % m;
		y >>= 1;
	}
	return res;
}
int bit_rev(int x, int h){
	int res = 0;
	for(int i=0; i<h; i++){
		res <<= 1;
		res |= x&1;
		x >>= 1;
	}
	return res;
}
void dft(long a[], int h, bool sign){
	for(int i=0; i<1<<h; i++){
		int j = bit_rev(i, h);
		if(i < j){
			long tmp = a[i];
			a[i] = a[j];
			a[j] = tmp;
		}
	}
	for(int s=1; s<=h; s++){
		int m = 1<<s;
		long zeta = modpow(pr, (mod-1)>>s, mod);
		if(!sign)zeta = modpow(zeta, mod-2, mod);
		for(int k=0; k<1<<h; k+=m){
			long pow_zeta = 1;
			for(int j=0; j<m/2; j++){
				long t = pow_zeta * a[k+j+m/2] % mod,
					 u = a[k+j];
				a[k+j] = (u + t) % mod;
				a[k+j+m/2] = (mod + u - t) % mod;
				pow_zeta = zeta * pow_zeta % mod;
			}
		}
	}
}
int N, M;
long A[sz], B[sz];
int main(){
	//scanf("%d%d", &N, &M);
	N = nextint(); M = nextint();
	//for(int i=0; i<N; i++)scanf("%ld", &A[i]);
	//for(int i=0; i<M; i++)scanf("%ld", &B[i]);
	for(int i=0; i<N; i++)A[i] = nextint();
	for(int i=0; i<M; i++)B[i] = nextint();
	dft(A, 20, true); dft(B, 20, true);
	for(int i=0; i<sz; i++)A[i] = A[i] * B[i] % mod;
	dft(A, 20, false);
	long inv = modpow(sz, mod-2, mod);
	for(int i=0; i<N+M-1; i++){
		if(i)putchar(32);
		printf("%ld", A[i] * inv % mod);
	}putchar(10);
	return 0;
}

Measured memory_bytes: 37388
n, p = map(int, input().split())

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

from collections import Counter

ctr = Counter(prime_factorize(p))

for k, v in ctr.items():
    ctr[k] = v // n

ans = 1
for k, v in ctr.items():
    ans *= k ** v
print(ans)

Measured memory_bytes: 38640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<pll>> G(N);
    rep(i,N-1) G[i+1].emplace_back(0,i);
    rep(i,M) {
        int L,R; ll C; cin >> L >> R >> C;
        L--; R--;
        G[L].emplace_back(C,R);
    }

    priority_queue<pll, vector<pll>, greater<pll>> pq;
    pq.emplace(0,0);
    vector<ll> dist(N,1e18);
    vector<bool> c(N);
    dist[0] = 0;
    while (!pq.empty()) {
        ll v,C;
        tie(C,v) = pq.top(); pq.pop();
        c[v] = true;
        if (C > dist[v]) continue;
        for (auto i : G[v]) {
            ll nv,d;
            tie(d,nv) = i;
            if (c[nv]) continue;
            if (chmin(dist[nv],dist[v] + d)) pq.emplace(dist[nv],nv);
        }
    }

    if (dist[N-1] == 1e18) cout << -1 << endl;
    else cout << dist[N-1] << endl;
} 

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

int main()
{
	long int a,n,array[10001],sum=0,i;
	cin>>a>>n;
	for(i=0;i<n;i++)
	{
		cin>>array[i];
		sum=sum+array[i];
	}
	if(sum<=a)
	{
		cout<<a-sum<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int n,m;
int id[100000];
bool used[100000];
vector<int> p[100000];
bool f[100000];
void dfs(int now,int mem){
	f[now]=1;
	id[now]=mem;
	for(int i=0;i<p[now].size();i++){
		if(f[p[now][i]]){
			continue;
		}else{
			dfs(p[now][i],mem);
		}
	}
	return;
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		x--;
		y--;
		used[x]=1;
		used[y]=1;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		id[i]=1e9+7;
		if(!used[i]){
			ans++;
			f[i]=1;
		}
	}
	int now=0;
	for(int i=0;i<n;i++){
		if(!f[i]){
			dfs(i,now);
			now++;
		}
	}
	cout<<ans+now<<endl;
	return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

vector<int> primes;
bool isNotPrime[200100];

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

    primes.emplace_back(2);
    for(int i=4;i<=200000;i+=2){
        isNotPrime[i] = true;
    }

    for(int i=3;i<=200000;i+=2){
        if(isNotPrime[i]){continue;}

        primes.emplace_back(i);

        for(int j=2*i;j<=200000;j+=i){
            isNotPrime[j] = true;
        }
    }

    while(true){
        int n, p;
        std::cin >> n >> p;
        if(n == -1){break;}

        vector<int> v;
        auto it = upper_bound(primes.begin(), primes.end(), n);
        // std::cout << "*it: " << *it << std::endl;
        for(int i=0;i<100;++i){
            for(int j=i;j<100;++j){
                v.emplace_back(*(it+i) + *(it+j));
            }
        }

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

        // for(int i : v){
        //     std::cout << i << std::endl;
        // }
        // std::cout << "----------" << std::endl;
        
        std::cout << v[p-1] << std::endl;
    }
}



Measured memory_bytes: 3412
# coding: utf-8
# Your code here!

def solve(n, m, q, arrays):
    from itertools import combinations_with_replacement
    pattern = list(combinations_with_replacement(range(1, m+1), n))

    maxp = 0
    for x in pattern:
        get = 0
        for array in arrays:
            if x[array[1]-1] - x[array[0]-1] == array[2]:
                get += array[3]

        maxp = max(maxp, get)

    print(maxp)

n, m, q, *aa = map(int, open(0).read().split())

arrays = []
loop = 0
array = []
for x in aa:
    array.append(x)
    loop += 1
    if loop % 4 == 0:
        arrays.append(array)
        array = []

solve(n, m, q, arrays)


Measured memory_bytes: 21540