akhauriyash/Code-Regression huggingface dataset:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
# 全探索
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            tmp = i*500 + j*100 + k*50
            if tmp == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int c;
int n,s;

long hoge(int u,int d,int sum){
    //printf("%d %d %d\n",u,d,sum);

    if(u==n){
        if(s==sum){
            //puts("yay!");
            c++;
        }
        return;
    }
    if(d==10)
        return;

    hoge(u,d+1,sum);
    hoge(u+1,d+1,sum+d);
}
main(){
    while(scanf("%d %d",&n,&s)!=EOF){
        //puts("hoge");
        if(n==0)
            break;
        c=0;
        hoge(0,0,0);
        printf("%d\n",c);
    }
    return 0;
}

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

def main():
  xs = [int(input()) for i in range(5)]
  k = int(input())
  for i in range(len(xs)):
    for j in range(i+1, len(xs)):
      if xs[j] - xs[i] > k:
        print(':(')
        return
  print('Yay!')


if __name__=='__main__':
  main()



Measured memory_bytes: 2940
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

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

    int g = 0;
    for(int i=0; i<N; i++) {
        int val; cin >> val;
        g = __gcd(g, val);
    }
    cout << g << endl;
    return 0;
}


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

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

signed main(void)
{
	int n; cin >> n;
	long long ans = 1;
	for (int i = 1; i <= n; ++i)
	{
		long long num; cin >> num;
		ans = ans * num / gcd(ans, num);
	}
	cout << ans << endl;
}

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

int main() {
	int		a,b,c,i,j,k,n,s,m,x,y,ans = 0;
	string	str;
	
	cin >> n >> k >> s;
	
	if (s < 1000000000) {
		for(i=0;i<k;i++) {
			cout << s << ' ';
		}
		for(i=k;i<n;i++) {
			cout << s+1 << ' ';
		}
		cout << endl;
	} else {
		for(i=0;i<k;i++) {
			cout << s << ' ';
		}
		for(i=k;i<n;i++) {
			cout << 1 << ' ';
		}
		cout << endl;
	}


}


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

int ans[100005];
int main(){
    int n,m;
    int a,b;
    cin >> n >> m;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    for(int i=1;i<m+1;i++){
        cin >> a >> b;
        if(h[a-1]<=h[b-1])ans[a-1]--;
        if(h[b-1]<=h[a-1])ans[b-1]--;
    }
    int answer=0;
    for(int i=0;i<n;i++)if(ans[i]>=0)answer++;
    cout << answer << endl;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n;
    string s;
    cin >> n;
    cin >> s;

    int index = 0;

    vector<int> h;

    while(index <= n - 1){
        if(index != n - 1 && s[index] == s[index + 1]){
            h.pback(2);
            index += 2;
        }else{
            h.pback(1);
            index++;
        }
    }

    ll ans;
    int state;

    if(h[0] == 1){
        ans = 3;
        state = 1;
    }else{
        ans = 6;
        state = 2;
    }

    for(int i = 1; i < h.size(); i++){
        if(state == 1){
            if(h[i] == 1){
                ans = (ans * 2) % MODN;
            }else{
                ans = (ans * 2) % MODN;
                state = 2;
            }
        }else{
            if(h[i] == 1){
                state = 1;
            }else{
                ans = (ans * 3) % MODN;
            }
        }
    }

    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmax(a,b) ((a<b)?a=b:a)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
using namespace std; 

const int N=2e5+50; 

int n,f[N],prt[N],mx[N],ans[N]; 
vector<int> g[N],TT[N];
 

	
void dfs(int v,int p){
	mx[v]=max(mx[p],p);
	prt[v]=p; 
	for(int d:g[v])if(d!=p)dfs(d,v); 
	//f[v]=calc(v,p,mx[v]); 
	//for(int d:g[v])if(d!=p)TT[v].pb(T[d]); 
}

set<int> *Cur;
void Del(int v,int w){
	Cur->erase(v); 
	for(int d:g[v])if(d!=prt[v]){
		if(d<w)Del(d,w);
	} 
}

void shrink(set<int> *st,int w){
	Cur=st;
	while(!st->empty()&& *st->rbegin()>w){
		Del(*st->rbegin(),w); 
	}
}

set<int> *S[N];
void sol0(int v,int p){
	for(int d:g[v])if(d!=p)sol0(d,v); 
	S[v]=nullptr; 
	for(int d:g[v])if(d!=p)if(!S[v]||S[d]->size()>S[v]->size())S[v]=S[d];
	if(!S[v]){ S[v]=new set<int>(); S[v]->insert(v); f[v]=S[v]->size(); return ; }
	for(int d:g[v])if(d!=p)shrink(S[d],mx[v]);
	for(int d:g[v])if(d!=p)TT[v].pb(S[d]->size());
	for(int d:g[v])if(d!=p&&S[d]!=S[v]){
		for(int x:*S[d])S[v]->insert(x);
	}
	S[v]->insert(v); f[v]=S[v]->size(); return;
}

void sol(int v,int p,int up){
	ans[v]=(up+=f[v]);int ptr=0;
	for(int d:g[v])if(d!=p)sol(d,v,up-TT[v][ptr++]); 
}

int main(int argc,char *argv[]){
	//freopen("d.in","r",stdin);
	scanf("%d",&n); 
	rep(i,2,n){
		int u,v; 
		scanf("%d%d",&u,&v); 
		g[u].pb(v); 
		g[v].pb(u); 
	}
	dfs(1,0);sol0(1,0);
	//rep(v,1,n)printf("%d:%d\n",v,f[v]);
	sol(1,0,0);
	rep(i,2,n)printf("%d ",ans[i]-1); puts(""); 
	return 0; 
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    lint H, W, K;
    cin >> H >> W >> K;
    vector<string> G(H);
    rep(i, H) cin >> G[i];
    int mi = 2e9;
    for (int bits = 0; bits < (1 << H - 1); bits++) {
        int NumOfLine = 0;
        vector<int> id(H);
        int color = 0;
        for (int i = 0; i < H; i++) {
            id[i] = color;
            if (bits & (1 << i)) {
                color++;
                NumOfLine++;
            }
        }
        int ans = NumOfLine;
        // dump(id);
        int blocks = NumOfLine + 1;
        vector<lint> numOfW(blocks, 0);
        int exit = 0;
        for (int j = 0; j <= W - 1; j++) {
            // d(j);
            // dump(numOfW);
            for (int i = 0; i < H; i++) {
                if (G[i][j] == '1') { numOfW[id[i]]++; }
            }
            // dump(numOfW);
            bool ok = true;
            for (int i = 0; i < blocks; i++) {
                if (numOfW[i] > K) { ok = false; }
            }
            if (!ok) {
                ans += 1;
                for (int i = 0; i < blocks; i++) {
                    numOfW[i] = 0;
                }
                for (int i = 0; i < H; i++) {
                    if (G[i][j] == '1') { numOfW[id[i]]++; }
                }
                bool okk = true;
                for (int i = 0; i < blocks; i++) {
                    if (numOfW[i] > K) { okk = false; }
                }
                if (!okk) {
                    exit = 1;
                    break;
                }
            }
            // dump(numOfW);
        }
        if (exit == 1) continue;
        // dump(numOfW);
        // d(ans);
        mi = min(mi, ans);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i,j;
    cin>>n>>k;
    int v[k];
    for(i=0; i<k; i++)
        cin>>v[i];
    long long int total1=0,total2=0,ans;
    total1 = v[k-1]-v[0];
    total2 = n-v[k-1]+v[0]  +  v[k-1]-v[1];
    ans = min(total1,total2);
    total1 = n-v[k-1]+v[0] + v[k-2]-v[0];
    ans=min(ans,total1);
    for(i=1; i<k-1; i++)
    {
        total1 = v[i] + n-v[i+1];
        total2 = n-v[i]+v[i-1];
        ans = min(ans,min(total1,total2));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "before", long, "after");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    long cnt;
    foreach (i; iota(n).map!(x => x + 1).array())
    {
        if (2 * i % k == 0)
        {
            auto a = (n + i) / k;
            auto b = i / k;
            cnt += (a - b) ^^ 2;
        }
    }
    cnt.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e6 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)

int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int n;
    ll k;
    cin >> n >> k;
    int v[n + 2];
    fore(i, 1, n + 1)
        cin >> v[i];
    int vis[n + 1];
    cls(vis, -1);
    int i = 1;
    while(vis[i] == -1){
        vis[i] = 1;
        i = v[i];
    }
    vis[i] = 1e5;
    i = 1;
    vi cycle, not_cycle;
    while(vis[i] != 1e5){
        not_cycle.pb(i);
        i = v[i];
    }
    cls(vis, -1);
    while(vis[i] == -1){
        cycle.pb(i);
        vis[i] = 1;
        i = v[i];
    }
    if(sz(not_cycle) > k)
        cout << not_cycle[k] << '\n';
    else{
        k -= sz(not_cycle);
        k %= sz(cycle);
        cout << cycle[k] << '\n';
    }
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}   

Measured memory_bytes: 5824
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        a=min(j-i,abs(i-x)+abs(j-y)+1,abs(j-x)+abs(i-y)+1)
        ans[a-1]+=1
for ai in ans:
    print(ai)


Measured memory_bytes: 3444
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    bool canCalc = false;
    for(int i=1;i<=9;i++){
        if(N%i==0 && N/i<=9){
            canCalc = true;
            break;
        }
    }
    if(canCalc)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	long long N, A, B;
	long long ans = 0;
	cin >> N >> A >> B;

	vector<long long> X(N);
	for (int i = 0;i < N;i++)
		cin >> X[i];

	for (int i = 0;i < N - 1;i++)
		ans += min((X[i + 1] - X[i]) * A, B);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec A(N);
    ll s = 0;
    Rep (i, N) {
        cin >> A[i];
        s += A[i];
    }

    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());

    s = A[0];

    ll tmp = 1;
    Rep (i, N-2) {
        s += A[tmp];
        if (i % 2 == 1) tmp++;
    }

    cout << s << "\n";

}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, M;
	cin >> N;
	string s[N];
	map<string, int> m;
	int ans = 0;
	rep(i, 0, N) {
		cin >> s[i];
		if(m.find(s[i]) == m.end()) m.insert(make_pair(s[i], 1));
		else m[s[i]]++;
	}

	map<string, int> m2;

	cin >> M;
	string t[M];
	rep(i, 0, M) {
		cin >> t[i];
		if(m.find(t[i]) == m2.end()) m2.insert(make_pair(t[i], 1));
		else m2[t[i]]++;
	}

	for(map<string, int>::iterator ite = m.begin(); ite != m.end(); ++ite) {
		int tmp = ite->second - m2[ite->first];
		ans = max(ans, tmp);
	}
	cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int d=n%10;
        if(d==2 || d==4 || d==5 || d==7 || d==9) cout<<"hon"<<endl;
        else if(d==3) cout<<"bon"<<endl;
        else cout<<"pon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Pine1999
 */

#include <bits/stdc++.h>
//#include "../library/dsu.hpp"
//#include "../library/fenwicktree.hpp"
//#include "../library/modint.hpp"
//#include "../library/segtree.hpp"
//#include "../library/string.hpp"
//#include "../library/math.hpp"

using namespace std;
//using namespace atcoder;

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

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int inf = (int) (1e9);

void EDistMax(std::istream& in, std::ostream& out) {
    int n;
    in >> n;
    vector<int> x(n), y(n);
    rep(i, n) in >> x[i] >> y[i];
    int mx = -inf, mn = inf;
    for (int i = 0; i < n; ++i) {
        uax(mx, x[i] + y[i]);
        uin(mn, x[i] + y[i]);
    }
    int ans = mx - mn;
    mx = -inf, mn = inf;
    for (int i = 0; i < n; ++i) {
        uax(mx, -x[i] + y[i]);
        uin(mn, -x[i] + y[i]);
    }
    uax(ans, mx - mn);
    mx = -inf, mn = inf;
    for (int i = 0; i < n; ++i) {
        uax(mx, x[i] - y[i]);
        uin(mn, x[i] - y[i]);
    }
    uax(ans, mx - mn);
    mx = -inf, mn = inf;
    for (int i = 0; i < n; ++i) {
        uax(mx, -x[i] - y[i]);
        uin(mn, -x[i] - y[i]);
    }
    uax(ans, mx - mn);
    out << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    EDistMax(in, out);
    return 0;
}

Measured memory_bytes: 4776
size = gets.chomp.to_i
nums = gets.strip.split(' ').map(&:to_i)

count = 1
nums.each_with_index do |num, i|
  next if i == 0
  
  west_nums = nums[0...(i)]
  east_nums = nums[(i+1)...(size)]
  if west_nums.max <= num
    count += 1
  end
  if east_nums.size > 0 && east_nums.max < num
    break
  end
end

puts count


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <tuple>

using namespace std;

int main() {
  int n,k;
  int ans = 0;
  string s;
  cin >> n >> k;
  cin >> s;

  int start = 0;
  int i = 0;
  int cnt = 0;
  while(i<n) {
    if (cnt >= 2*k+1) start = i;
    char c = s[i];
    while(i<n && c==s[i]) i++;
    if (i>=n) {
      ans += (i-start)-1;
      break;
    }
    cnt++;
    if (cnt < 2*k+1) continue;
    else ans += (i-start)-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 888
n = input()
k = int(input())

def case1(x):
    return (len(x) - 1) * 9 + int(x[0])

def case2(x):
    if (len(x) < 2):
        return 0
    ret = (len(x) - 1) * (len(x) - 2) // 2 * 81
    ret += case1('9' * (len(x) - 1)) * (int(x[0]) - 1)
    for i in range(1, len(x)):
        if x[i] != '0':
            ret += case1(x[i:])
            break
    return ret

def case3(x):
    if (len(x) < 3):
        return 0
    ret = (len(x) - 1) * (len(x) - 2) * (len(x) - 3) // 6 * 729
    ret += case2('9' * (len(x) - 1)) * (int(x[0]) - 1)
    for i in range(1, len(x)):
        if x[i] != '0':
            ret += case2(x[i:])
            break
    return ret

if k == 1:
    print(case1(n))
elif k == 2:
    print(case2(n))
else:
    print(case3(n))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  i64 N, P;
  cin >> N >> P;

  if (N == 1) {
    cout << P << endl;
    return 0;
  }

  i64 ans = 1;
  for (i64 i = 2; i*i <= P; ++i) {
    i64 cnt = 0;
    while(P % i == 0) {
      ++cnt;
      P /= i;
    }

    cnt /= N;
    for (i64 j = 0; j < cnt; ++j) ans *= i;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	n, k := readInt(), readInt()

	prime := n % k
	if abs(prime-k) < prime {
		fmt.Println(abs(prime - k))
	} else {
		fmt.Println(prime)
	}
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,an=0,ex=0;cin>>n;
	for(int u=2;u<n;u++){
		for(int v=1;v*v<=u;v++){
			if(v*v==u) ex++;
			else if(u%v==0) an++;}
			}
		cout<<2*an+ex+1;
}		




Measured memory_bytes: 3684
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s;
    cin >> s;
    long int a = 0;
    for(int i = 0; i < s.size(); ++i){
        a = (a + s[i] - '0') % 9;
    }
 
    if(a == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3728
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define MOD1 1000000007

inline void inp( long long int  &n ){n=0;int ch=getchar();int sign=1;while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}while( ch >= '0' && ch <= '9' )n = (n<<3)+(n<<1) + ch-'0', ch=getchar();n=n*sign;}
#define pi acos(-1)
#define iil pair<int,int>
#define vii vector<ii>
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define ll  long long int
#define LL long long int
#define loop2(i,n) for(ll i=1;i<=n;i++)
#define MIN(a,b) (a) < (b) ? (a) : (b)
#define MAX(a,b) (a) > (b) ? (a) : (b)
#define ABS(a) (a) > 0 ? (a) : -(a)
#define rep1(i,a,n) for(i=a;i<(n);i++)
#define pii pair< ll, ll >
#define pb push_back
#define mp make_pair
#define all(x)                  (x).begin(),(x).end()
#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
#define EPS 1e-7
using namespace std;
//find the holy grail in an  adventure frought with danger
//The bigger the occasion, the better the response.
// Never giving in, fighting to the end
// Look at  the limits ; Check if it is binary search
//Code till the end of contest
const int MAXN = (ll)1e5+11;
ll array1[MAXN];
bool check[MAXN] = {false};
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m;
    cin>>n>>m;
    loop2(i, n)
    {
        array1[i]+=1;
    }
    check[1] = true;
    loop2(i, m)
    {
        ll a,b;
        cin>>a>>b;
        //cout<<a<<"---"<<b<<" "<<array1[a]<<" "<<array1[b]<<endl;
        if(array1[a]>0){
        array1[a]--;
        array1[b]+=1;
            if(check[a]==true){
                
                check[b] = true;
                
            }
            
            if(array1[a]==0)
            {
                check[a] = false;
            }
       
            
        }
    }
    ll ans  =0  ;
   
    loop2(i, n)
    {
        if(array1[i]&&check[i]){
            ans++;
        }
        
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    set<int> st;
    vector<ll> v;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (st.count(a)) {
            st.erase(a);
            v.push_back(a);
        } else {
            st.insert(a);
        }
    }

    sort(v.begin(), v.end(), greater<ll>());

    ll ans = v[0] * v[1];
    if (2 <= v.size()) cout << ans << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
	
	int a,b,c[101],d[1001],i,min=1001;
	scanf("%d %d",&a,&b);
	for(i=0;i<a;i++){
		scanf("%d %d",&c[i],&d[i]);
		if(d[i]>b)c[i]=10000;
	}
	for(i=0;i<a;i++){
		if(min>c[i])min=c[i];
	}
	if(min==1001){
		printf("TLE\n");
	}else{
		printf("%d\n",min);
	}
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include<random>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;



int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    cout << 180 * n - 360;


    return 0;
}

Measured memory_bytes: 256
/*******************************
 * written by Koki Riho
 * Rih0z https://github.com/Rih0z
 *******************************/

#include<iostream>
#include<map>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<cmath>

#define DEBUG false

#define FOR(i , a, b) for(size_t i = a ; i < b ; i++ )
#define REP(i,b) FOR(i , 0 , b)
#define RFOR(i,a,b) for(size_t i = a-1 ; i >= b ; i--)
#define RREP(i,a) RFOR(i,a,0)



typedef long long ll;
using namespace std;

int scanInt(void);
string scanString(void);

void scanLlArr(ll *a , int n);
void scanCharArr(char *string);

void printInt(int p);
void printLlArr(ll *a);
void printCharArr(char *string);


void perSum(ll *a , ll *sum ,int n);

/*************Global variable  **************/
int N ;
char str[26];
std::map<char,int> M ;
/*******************************/

int main(){
  if (DEBUG){
    std::printf("******debug mode********\n");
  }
  int ans ; 
  int a[3];
  REP(i,3){
    cin >> a[i];
  }
  int K ;
  cin >> K ;
  int max = 0 ;
  int j ; 
  REP(i,3){
    if(a[i] > max)
      {
        max = a[i] ;
        j = i ;
      }
  }
  REP(i,K){
    a[j] *= 2 ;
  }
  REP(i,3){
    ans += a[i];
  }
  cout << ans << endl;



  if (DEBUG){
    std::printf("******debug********\n");

    std::printf("******debug********\n");
  }
  return 0 ;
}

//各地点までの部分和を計算する
void perSum(ll *a , ll *sum ,int n){
  int i ;
  sum[0] = a[0];
  for(i = 1 ; i < n ; i++){
    sum[i] = a[i] + sum[i-1];
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<vector<int>> g(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  deque<int> ans;
  set<int> now;
  ans.push_back(0);
  now.insert(0);
  while(true){
    int left=ans.front(),right=ans.back();
    bool flag=false;
    for(auto itr:g[left]){
      if(!now.count(itr)){
        ans.push_front(itr);
        now.insert(itr);
        flag=true;
        break;
      }
    }
    for(auto itr:g[right]){
      if(!now.count(itr)){
        ans.push_back(itr);
        now.insert(itr);
        flag=true;
        break;
      }
    }
    if(!flag) break;
  }
  cout<<ans.size()<<endl;
  for(auto itr:ans) cout<<itr+1<<endl;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

template< int mod >
struct Combination {
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  vector< pair< int, int > > ev;
  Combination< mod > uku(H + W);
  ev.emplace_back(0, 0);
  for(int i = 0; i < N; i++) {
    int y, x;
    cin >> y >> x;
    --y, --x;
    ev.emplace_back(y, x);
  }
  ev.emplace_back(H - 1, W - 1);

  sort(begin(ev), end(ev));
  N += 2;
  vector< int64 > dp1(N);
  vector< int64 > dp2(N);
  dp2[0] = 1;
  for(int i = 1; i < N; i++) {
    for(int j = i - 1; j >= 0; j--) {
      if(ev[i].second >= ev[j].second) {
        auto c = uku.C(ev[i].first - ev[j].first + ev[i].second - ev[j].second, ev[i].first - ev[j].first);

        dp1[i] += dp2[j] * c % mod;
        dp2[i] += dp1[j] * c % mod;
        dp1[i] %= mod;
        dp2[i] %= mod;
      }
    }
  }

  cout << (dp1.back() + mod - dp2.back()) % mod << endl;
}



Measured memory_bytes: 3456
from collections import Counter
from math import sqrt
n,m = (int(i) for i in input().split())
if m==1: ans = 1
else:
	m2,k,x,mod,ans = m,2,[],10**9+7,1
	while k**2<=m2:
		for i in range(k,int(sqrt(m2))+1):
			if m2%i==0:
				x.append(i)
				k,m2 = i,m2//i
				break
			elif i==int(sqrt(m2)): k = i+1
	x.append(m2)
	c,d = Counter(x).most_common(),[]
	for i,j in c: d.append(j)
	n2 = max(d)+n
	fn,fk = [1]*(n2),[1]*(n2)
	for i in range(n2-1): fn[i+1] = (fn[i]*(i+2))%mod
	def power(n,k):
		if k==1: return n
		elif k%2==0: return power((n**2)%mod,k//2)
		else: return (n*power(n,k-1))%mod
	def comb(n,k):
		if n==0 or k==0 or n==k: return 1
		else: return (((fn[n-1]*fk[n-k-1])%mod)*fk[k-1])%mod
	fk[-1] = power(fn[-1],mod-2)
	for i in range(2,n2+1): fk[-i] = (fk[-i+1]*(n2+2-i))%mod
	for i in d: ans = (ans*comb(i+n-1,i))%mod
print(ans)

Measured memory_bytes: 11252
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int sum_dig(i64 num){
    int sum =0;
    while(num){
        sum += (num%10);
        num /= 10;
    }

    return sum;
}
int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    i64 n;
    cin>>n;
    //i64 x;
    
    int num_digits = int(log10(n))+1;
    

    int max_sum=sum_dig(n);
    
    i64 expo = i64(pow(10,num_digits-1));
    i64 p = ((n/expo)*expo) - 1;

    max_sum = max(max_sum, sum_dig(p));


    /*
    for(i64 i=1;i<=n;i++){
        int sum = 0;
        i64 num=i;
        while(num){
            sum += (num%10);
            num /= 10;
        }
        if(sum>max_sum){
            max_sum = sum;
            x = i;
        }
       // max_sum = max(sum, max_sum);
    }*/
    cout<<max_sum<<endl;
    return 0;
}



Measured memory_bytes: 512
while True:
    a, b = map(int,input().split())
    if a == 0 and b == 0:
        break
    if a < b:
        a, b = b, a
    C = 0
    while True:
        C  = C + 1
        a = a % b
        if a == 0:
            break
        a, b = b, a
    print(b, C)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> x(n),y(n);
  rep(i,n){
    cin >> x[i] >> y[i];
  }
  map<pair<ll,ll>,int> mp;
  rep(i,n)rep(j,n)if(i!=j){
    ll p = x[i]-x[j];
    ll q = y[i]-y[j];
    mp[{p,q}]++;
  }
  int tmp=0;
  for(auto it:mp){
    tmp = max(tmp,it.S);
  }
  int ans = n-tmp;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
a, b, c = map(int, input().split())
k = int(input())

while k > 0:
    if b <= a:
        b *= 2
    elif c <= b:
        c *= 2
    k -= 1
if b < c:
    if a < b:
    	print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 61604
s=input()
N=len(s)
A=0
B=0
for i in range(0,N,2):
    if s[i]=='0':
        A+=1
    if i+1==N:
        break
    if s[i+1]=='1':
        B+=1
if A+B<=N/2:
    print(A+B)
else:
    print(N-(A+B))


Measured memory_bytes: 3188
K=gets.to_i
as=gets.split.map(&:to_i).reverse
l,r=2,3
as.each do |e|
    l=(l+e-1)/e
    r=(r+e-1)/e
    l*=e
    r*=e
end
puts l==r ? -1 : "#{l} #{r-1}"


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

public class Main {
	public static void main(String[] args) throws IOException {
     Scanner sc = new Scanner(System.in);
     String s = sc.nextLine(); 
     for(int i = 0; i<s.length(); i++) {
    	 System.out.print("x");
     }
     System.out.println(); 
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
using namespace std;
int n;
int a[100005];
map<int,int> mp;
set<int> S;
priority_queue<int> q;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		mp[a[i]]++;
		S.insert(a[i]);
	}
	for (set<int>::iterator it=S.begin();it!=S.end();it++){
		if (mp[*it]>=2){
			q.push(*it);
		}
	}
	int x=0,y=0;
	if (!q.empty()){
		x=q.top();
		q.pop();
	}
	if (mp[x]>=4){
		long long ans=(long long)x*(long long)x;
		printf("%lld",ans);
		return 0;
	}
	if (!q.empty()){
		y=q.top();
	}
	
	long long ans=(long long)x*(long long)y;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9984
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i < j and j < k:
                if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
                    if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                        ans += 1

print(ans)

Measured memory_bytes: 68396
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<pair<int,int> >g[110000];
int t[110000];
void dfs(int a,int b,int c){
	t[a]=c;
	for(int i=0;i<g[a].size();i++){
		if(g[a][i].first==b)continue;
		dfs(g[a][i].first,a,(c+g[a][i].second)%2);
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);p--;q--;
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	dfs(0,-1,0);
	for(int i=0;i<a;i++)printf("%d\n",t[i]);
}

Measured memory_bytes: 9344
#include<cstdio>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=100000+5;
int vec[maxn];
int main()
{

	int t,cnt,temp;
	while(scanf("%d",&t)==1)
	{
		cnt=0;
		for(int i=1;i<=t;i++)
		{
			scanf("%d",&vec[i]);
		}
			for(int i=1;i<t;i++)
		{
			if(i==vec[i])
			{
				cnt++;
				swap(vec[i],vec[i+1]);
			}
	    }
	    if(vec[t]==t) cnt++;
	    printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int N;
  int i, j;
  int count = 1;
  int flag;
  cin >> N ;
  vector<int> H(N);

  for(i=0; i<N; i++)
    cin >> H[i];

  for(i=1; i<N; i++){
    flag = 1;
    for(j=0; j<i; j++)
      if(H[j] > H[i]){
	flag = 0;
	break;
      }
    if(flag == 1)
      count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    string S,T,U;
    ll A,B;
    cin >> S >> T >> A >> B >> U;
    if (S == U){
        A--;
    }else{
        B--;
    }

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted(int(input()) for TN in range(0,N))
if N%2==0:
    S = A[:(N//2)]
    B = A[(N//2):]
    SS = -2*sum(S)+S[-1]
    BS = 2*sum(B)-B[0]
    PT = SS+BS
    print(PT)
else:
    S = A[:(N//2)]
    B = A[(N//2):]
    SS1 = -2*sum(S)
    BS1 = 2*sum(B)-B[0]-B[1]
    PT1 = SS1+BS1
    
    SS2 = -2*sum(S)+S[-1]
    BS2 = 2*sum(B)-3*B[0]
    PT2 = SS2+BS2
    print(max(PT1,PT2))

Measured memory_bytes: 13596
#include<bits/stdc++.h>
using namespace std;
//vector<vector<long long int> > dp(100001,vector<long long int>(4));
long long int dp[100001][4];
long long int n;
long long int gen(int i,int p,vector<vector<long long int> >&arr)
{
    long long int ans=INT_MIN;
    if(i>=n)
        return 0;
    if(dp[i][p]!=-1)
        return dp[i][p];
    if(p==0)
    {
        ans=max(ans,arr[i][1]+gen(i+1,1,arr));
        ans=max(ans,arr[i][2]+gen(i+1,2,arr));
    }
    else if(p==1)
    {
        ans=max(ans,arr[i][0]+gen(i+1,0,arr));
        ans=max(ans,arr[i][2]+gen(i+1,2,arr));
    }
    else if(p==2)
    {
       ans=max(ans,arr[i][0]+gen(i+1,0,arr));
       ans=max(ans,arr[i][1]+gen(i+1,1,arr));

    }
    else{
        ans=max(ans,arr[i][0]+gen(i+1,0,arr));
        ans=max(ans,arr[i][1]+gen(i+1,1,arr));
        ans=max(ans,arr[i][2]+gen(i+1,2,arr));
    }
    return dp[i][p]=ans;

}
int main()
{
    //int n;
    cin>>n;
    vector<vector<long long int>> arr(n,vector<long long int>(3));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    //input part has been done
    memset(dp,-1,sizeof(dp));

    long long ans=gen(0,3,arr);
    cout<<ans;

}


Measured memory_bytes: 21196
function main(input) {                                                                                                                                                                                 
    const args = input.split(' ');                                                                                                                                                                     
    const a = parseInt(args[0], 10);                                                                                                                                                                   
    const b = parseInt(args[1], 10);                                                                                                                                                                   
                                                                                                                                                                                                       
    if ((a * b) % 2 === 0) {                                                                                                                                                                           
        console.log('Even');                                                                                                                                                                           
    } else {                                                                                                                                                                                           
        console.log('Odd');                                                                                                                                                                            
    }                                                                                                                                                                                                  
}                                                                                                                                                                                                      
                                                                                                                                                                                                       
main(require('fs').readFileSync('/dev/stdin', 'utf8'))   

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;

/*/
  ll a, b;
  cin >> a >> b;
  puts((a * b == 2016) ? "Yes" : "No");

/*/
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;

//*/


  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vlli vector<long long int>
#define pb push_back
#define mp make_pair
#define all(c)  ((c).begin()), ((c).end())
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> t;
	t.pb(1);
	int i=1;
	vector<int> dp(n+1);
	dp[1]=1;
	while(pow(6,i)<=n){
		int x=pow(6,i);
		dp[x]=1;
		t.pb(x);
		i++;
	}
	i=1;
	while(pow(9,i)<=n){
		int x=pow(9,i);
		dp[x]=1;
		t.pb(x);
		i++;
	}
	int m=t.size();
	FOR(i,2,n+1){
		if(!dp[i]){
			int min_change=INT_MAX;
			FOR(j,0,m){
				if(t[j]<i)
					min_change=min(min_change,dp[i-t[j]]);
			}
			dp[i]=min_change+1;
		}
		//cout<<i<<" "<<dp[i]<<"\n";
	}
	cout<<dp[n]<<"\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,A,B,tot,q[100010],ans[100010];
char s[100010];
void query(int x,int y){
	printf("? %d %d\n",x,y);fflush(stdout);
	scanf("%s",s);
}
int main(){
	int i;
	scanf("%d%d",&A,&B);
	n=A+B;
	if(A<=B)return puts("Impossible"),0;
	for(i=0;i<n;i++){
		if(!tot)q[++tot]=i;
		 else{
		 	query(q[tot],i);
		 	if(s[0]=='Y')q[++tot]=i;
		 	 else tot--;
		 }
	}
	for(i=0;i<n;i++){
		query(q[tot],i);
		if(s[0]=='Y')ans[i]=1;
	}
	printf("! ");
	for(i=0;i<n;i++)printf("%d",ans[i]);puts("");
}
/*
要想到无解的情况是A<=B，不然没的做 
*/

Measured memory_bytes: 724
#include<iostream>
using namespace std;
int main(){
  int a,i,ans,l,k;ans = 0;l = 10;
  for (i=0;i<5;i++){
    cin >> a;
    ans += (a/10)*10;
    k = a%10;
    if(k != 0) ans += 10; 
    else k = 10;
    if (k < l) l = k;
  }
  cout << ans-(10-l) << endl;
}

Measured memory_bytes: 256