akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define N 1050

int lcs(string X,string Y) {
  int c[N+1][N+1];
  int x=X.size();
  int y=Y.size();
  int maxl = 0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=x;i++) c[i][0]=0;
  for(int j=0;j<=y;j++) c[0][j]=0;
  for(int i=1;i<=x;i++){
    for(int j=1;j<=y;j++){
      if(X[i]==Y[j]) c[i][j]=c[i-1][j-1]+1;
      else c[i][j]=max(c[i-1][j],c[i][j-1]);
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main() {
  int q; cin>>q;
  while (q--) {
    string a,b;
    cin>>a>>b;
    cout<<lcs(a,b)<<endl;
  }
  return 0;
}


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

int main() {
   long long N;
   std::cin >> N;
   std::vector<long long> A(N);

   for (long long i = 0; i < N; i++) {
      std::cin >> A.at(i);
   }
   long long d = 0;
   int n;
   for (long long i = 1; i < N; i++) {
      if (A.at(i-1) > A.at(i)) {
         n = (A.at(i-1) - A.at(i));
         d += n;
         A.at(i) += n;
      }
   }
   std::cout << d << '\n';
   // for (long long i = 0; i < N; i++) {
   //    std::cout << A.at(i) << ' ';
   // }

   return 0;
}


Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;
 
int k;
ll a[100001];
bool test(ll d){
    rep(i,k){
        //if(d<a[i]) return false;
        d-=d%a[i];
    }
    if(d<=2) return true;
    else return false;
}
bool test2(ll d){
    rep(i,k){
        //if(d<a[i]) return false;
        d-=d%a[i];
    }
    if(d>=2) return true;
    else return false;
}
int main(){  
    cin>>k;
    ll mm=0;
    rep(i,k){
        cin>>a[i];
        mm=max(mm,a[i]);
    }
    if(a[k-1]!=2){
        cout<<-1<<endl;
        return 0;
    }
    ll lb=2,ub=mm*k+2;
    rep(i,80){
        ll mid=(ub+lb)/2;
        if(test(mid)) lb=mid;
        else ub=mid;
    }
    ll mx=lb;
    lb=2,ub=mm*k+2;
    rep(i,80){
        ll mid=(ub+lb)/2;
        if(test2(mid)) ub=mid;
        else lb=mid;
    }
    ll mn=ub;
    if(mn>mx) cout<<-1<<endl;
    else cout<<mn<<" "<<mx<<endl;
    return 0;
}

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

long long N, K;
long long sum;
long long A[200005];

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	long long sum = 1;
	for(long long i = 0; i < N; i++) {
		if(i <= K - 1) {
			sum *= A[i];
		} else {
			long long oldval = A[i - (K)];
			long long newval = A[i];
			if(newval > oldval) {
				cout << "Yes" << endl;
			} else {
				cout << "No" << endl;
			}
		}

	}

}

Measured memory_bytes: 5188
import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
import fractions, functools
 
def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)
 
lcm = lcm_list(A)
 
answer = 0
for i in range(N):
    answer += lcm//A[i]
 
print(answer % (10**9 + 7))

Measured memory_bytes: 5596
import collections
import math

def combinations_count2(n, memo):
    if n <= 1:
        return 0
    if n in memo.keys():
        return memo[n]
    else:
        memo[n]= math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
        return memo[n]


n = input()
li = input().split()
c = collections.Counter(li)
memo = dict()
Sum = 0
for cv in c.values():
    Sum += combinations_count2(cv,memo)
for l in li:
    print(Sum - c[l] +1)

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

long long x, y, tmp=1, arr[60], ans=1;

int main () {
	ios_base::sync_with_stdio(false);
	cin>>x>>y;
	
	for(long long i=0; true; i++){
		if(x>y){
			cout<<i<<endl;
			break;
		}
		else x*=2;
	}
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<Int, Int> mp;
    for (Int i = 0; i < n; i++) {
        mp[a[i]] = i + 1;
    }
    sort(rall(a));
    multiset<Int> st;
    st.insert(0);
    st.insert(0);
    st.insert(n + 1);
    st.insert(n + 1);
    st.insert(mp[a[0]]);
    Int res = 0;
    for (Int i = 1; i < n; i++) {
        Int index = mp[a[i]];
        auto itr = st.lower_bound(index);
        Int R1 = *itr; itr++;
        Int R2 = *itr; itr--; itr--;
        Int L1 = *itr; itr--;
        Int L2 = *itr;
        //dump(index);
        //cout << L2 << " " << L1 << " " << R1 << " " << R2 << endl;
        Int cnt = (R2 - R1) * (index - L1) + (L1 - L2) * (R1 - index);
        res += a[i] * cnt;
        st.insert(index);
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000000000000
int h,w,a,b;
int main(void){
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("%d",(i<b)==(j<a));
		}
		printf("\n");
	}
}


Measured memory_bytes: 1280
import collections

n = int(input())
blue = collections.defaultdict(lambda:0)
for _ in range(n):
  blue[input()] += 1

m = int(input())
red = collections.defaultdict(lambda:0)
for _ in range(m):
  red[input()] += 1

ans = 0
for i,v in blue.items():
  if i not in red:
    ans = max(ans, v)
  else:
    if v > red[i]:
      ans = max(ans, v - red[i])
      
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<pair<int,int>,string> item;
main(){
	int n,i,w,s,S;
	string f;
	for(;cin>>n,n;){
		vector<item> items,result;
		for(i=0;i<n;i++)cin>>f>>w>>s,items.push_back(make_pair(make_pair(w,s),f));
		sort(items.begin(),items.end());
		S=99999;
		do{
			for(s=w=0,i=n-1;~i;i--){
				if(items[i].first.second<w)break;
				w+=items[i].first.first;
				s+=(i+1)*items[i].first.first;
			}
			if(i<0&&s<S)S=s,result=items;
		}while(next_permutation(items.begin(),items.end()));
		for(i=0;i<n;i++)cout<<result[i].second<<endl;
	}
}

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int r, c, k; cin >> r >> c >> k;
  vector<vector<ll >> item(r, vector<ll>(c, -1));
  REP(i, k) {
    int r, c;
    ll v;
    cin >> r >> c >> v;
    r--; c--;
    item[r][c] = v;
  }

  vector<vector<vector<ll>>> dp(4, vvll(r, vll(c, -1)));
  dp[0][0][0] = 0;
  if(item[0][0] != -1) dp[1][0][0] = item[0][0];

  REP(nowr, r) {
    REP(nowc, c) {
      REP(cnt, 4) {
        ll val = dp[cnt][nowr][nowc];
        if(nowr < r-1 && dp[0][nowr+1][nowc] < val) {
          dp[0][nowr+1][nowc] = val;
        }

        if(nowr < r - 1 && item[nowr+1][nowc] != -1 && dp[1][nowr+1][nowc] < val + item[nowr+1][nowc]) {
          dp[1][nowr+1][nowc] = val + item[nowr+1][nowc];
        }

        if(nowc < c - 1 && dp[cnt][nowr][nowc+1] < val) {
          dp[cnt][nowr][nowc+1] = val;
        }

        if(nowc < c - 1 && cnt < 3 && dp[cnt+1][nowr][nowc+1] < val + item[nowr][nowc+1]) {
          dp[cnt+1][nowr][nowc+1] = val + item[nowr][nowc+1];
        }
      }
    }
  }

  ll ans = 0;
  REP(i, 4) {
    chmax(ans, dp[i][r-1][c-1]);
  }
  cout << ans << endl;




}








Measured memory_bytes: 425112
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i < n + 1; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    if (s[0]=='R') {
        if (s[1]=='R') {
            if (s[2]=='R') {
                cout << 3 << endl;
            }
            else cout<< 2 << endl;
        }
        else {
            cout<<1<<endl;
        }
    }
    else {
        if (s[1]=='R') {
            if (s[2]=='R') {
                cout<<2<<endl;
            }
            else cout<<1<<endl;
        }
        else {
            if (s[2]=='R') {
                cout<<1<<endl;
            }
            else {
                cout<<0<<endl;
            }
        }
    }
}


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

int main(){
    int x1,x2,x3,x4,x5;
    int result;
    cin >>x1>>x2>>x3>>x4>>x5;
    if(x1==0){
        result = 1;
    }else if(x2==0){
        result = 2;
    }else if(x3==0){
        result =3;
    }else if(x4==0){
        result = 4;
    }else{
        result = 5;
    }
    cout <<result << endl;
    

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

const ll INF = 1e18;
ll ans = INF;

void f(map<int, vector<P>> X, int d1, int d2){
    for(auto [x, mp] : X) {
        sort(all(mp));
        ll tmp = INF;
        for(auto [y, d] : mp){
            if(d == d1) tmp = y;
            if(tmp == INF) continue;
            if(d == d2) {
                tmp = y - tmp;
                ans = min(ans, tmp);
                // cout << x << ", " << y << ", " << d << ": " << ans << endl;
                tmp = INF;
            }
        }
    }
    return;
}

void g(map<int, vector<P>> X, int d1, int d2){
    for(auto [x, mp] : X) {
        sort(all(mp));
        ll tmp = INF;
        for(auto [y, d] : mp){
            if(d == d1) tmp = y;
            if(tmp == INF) continue;
            if(d == d2) {
                tmp = y - tmp;
                ans = min(ans, tmp * 2);
                // cout << x << ", " << y << ", " << d << ": " << ans << endl;
                tmp = INF;
            }
        }
    }
    return;
}

void Main() {
    int n; cin >> n;
    map<int, vector<P>> X, Y, YpX, YmX;
    
    rep(i, n){
        int x, y; char u; cin >> x >> y >> u;
        int d;
        if(u == 'U') d = 0;
        else if(u == 'R') d = 1;
        else if(u == 'D') d = 2;
        else if(u == 'L') d = 3;
    
        X[x].eb(y, d);
        Y[y].eb(x, d);
        YpX[y+x].eb(y, d);
        YmX[y-x].eb(y, d);
    }

    
    // cout << "X" << endl;
    f(X, 0, 2);
    // cout << "Y" << endl;
    f(Y, 1, 3);    
    // cout << "Y+X" << endl;
    g(YpX, 0, 1);
    g(YpX, 3, 2);
    // cout << "Y-X" << endl;
    g(YmX, 0, 3);    
    g(YmX, 1, 2);    

    if(ans == INF) cout << "SAFE" << endl;
    else cout << ans * 5 << endl;
    return;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 91440
x = int(input())

if 400 <= x < 600:
    print(8)
elif 600 <= x < 800:
    print(7)
elif 800 <= x < 1000:
    print(6)

elif 1000 <= x < 1200:
    print(5)

elif 1200 <= x < 1400:
    print(4)

elif 1400 <= x < 1600:
    print(3)
elif 1600 <= x < 1800:
    print(2)
elif 1800 <= x < 2000:
    print(1)


Measured memory_bytes: 61648
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll fact[400003];
ll ifact[400003];
ll Combination(ll a,ll b) {
  ll s = (fact[a] * ifact[b]) % Mod;
  return (s * ifact[a-b]) % Mod;
}

int main() {
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i < 400003; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= Mod;
    ifact[i] = modinv(fact[i],Mod);
  }
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  ll ans = 0;
  for (ll i = 0; i < H-A; i++) {
    ll res = Combination(B-1+i,i) * Combination(W+H-B-2-i,W-B-1);
    res %= Mod;
    ans += res;
    ans %= Mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9864
use proconio::input;

fn prime_factorization(n: usize) -> Vec<(usize, usize)> {
    let mut p = vec![];
    if n < 2 {
        return p;
    }
    let mut n = n; // shadowing
    for i in 2.. {
        if i * i > n {
            break;
        }
        let mut c = 0;
        while n % i == 0 {
            c += 1;
            n /= i;
        }
        if c > 0 {
            p.push((i, c));
        }
    }
    if n != 1 {
        p.push((n, 1));
    }
    p
}

fn main() {
    input! {
        n: usize,
        p: usize,
    };
    let mut x = 1_usize;
    for (p_i, q_i) in prime_factorization(p) {
        x *= p_i.pow((q_i / n) as u32);
    }
    let ans = x;
    println!("{}", ans);
}


Measured memory_bytes: 2124
#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx2,tune=native")
#include<bits/stdc++.h>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv1(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
template<typename a, typename b>
void minq(a& x, b y) {
	if (x > y)
		x = y;
}
template<typename a, typename b>
void maxq(a& x, b y) {
	if (x < y)
		x = y;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
//WHEN DOING MODULAR SUBTRACTION ALWAYS **ALWAYS** ADD MOD
//no AVX on ATCoder
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int c[] = { 11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051, 1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451, 1471, 1481, 1511, 1531, };
int main() {
	doin();
	int n;
	cin >>n;
	for(int i = 0; i < n; i++) cout << c[i] << " ";
	return 0;
}


Measured memory_bytes: 256
def c_pyramid():
    N = int(input())
    Pos = [[int(i) for i in input().split()] for j in range(N)]
    # 与えられた情報から頂点座標を一意に得られるので、h=0にならない
    x, y, h = sorted(Pos, key=lambda x: x[2])[-1]
    # 中心座標を全探索
    for cx in range(101):
        for cy in range(101):
            # 頂点の高さ height を決めたとき、すべての座標の情報と一致するか？
            height = h + abs(x - cx) + abs(y - cy)  # 定義式から逆算
            if all(h_i == max(height - abs(x_i - cx) - abs(y_i - cy), 0)
                   for x_i, y_i, h_i in Pos):
                return '{} {} {}'.format(cx, cy, height)  # すべて一致した。これが解
    return None

print(c_pyramid())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	 long long ans=0;
	if(k==0){
		ans=(long long)n*n;
	}else{
			for(int i=k;i<=n;i++){
				
				ans+=(long long)(i-k)*(n/i);
				if(n%i>=k){
					ans+=n%i-k+1;
				}
			}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, X, min_m = INF, res = 0; cin >> N >> X;
    rep (i, 0, N) {
        int m; cin >> m;
        min_m = min(m, min_m);
        X -= m;
        res++;
    }
    cout << res + X/min_m << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

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

  if (n%2 != 0) {
    puts("No");
    return 0;
  }

  if (s.substr(0,n/2) == s.substr(n/2)) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll ans=0x3f3f3f3f3f3f,tmp=0;
int a[N],sum[N];
int n;

void get(int x) {
	tmp=0;
	memset(sum,0,sizeof(sum));
	if(a[0]==0)tmp++,sum[0]=x;
	else{
		if(x*a[0]<0){
			if(x==1){
				sum[0]=1;
				tmp = tmp + x - a[0];
			}else{
				sum[0]=-1;
				tmp = tmp + a[0] - x;
			}
		}else sum[0] = a[0];
	}

	for(int i=1;i<n;i++){
		if(sum[i-1]>0){
			if(sum[i-1]+a[i]<0){
				sum[i]=sum[i-1]+a[i];
				continue;
			}else{
				sum[i]=-1;
				tmp=tmp+sum[i-1]+a[i]+1;
				continue;
			}
		}else{
			if(sum[i-1]+a[i]>0){
				sum[i]=sum[i-1]+a[i];
				continue;
			}else{
				sum[i]=1;
				tmp=tmp+1-sum[i-1]-a[i];
				continue;
			}
		}
	}

	ans = min(ans,tmp);
}
int main(int argc, char** argv) {
	cin>>n;
	//cout<<ans<<endl;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	get(1);
	get(-1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String ans = "x";
    if((a + b) == 15) ans = "+";
    if((a * b) == 15) ans = "*";
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int N;
	cin >> N; 

	vector<P>A(N);
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		A[i] = make_pair(a,i+1);
	}
	sort(A.begin(),A.end());

	for (int i = 0; i < N; ++i) {
		cout << A[i].second << " ";
	}
	cout << endl;
}


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

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll h,w,k;
	cin>>h>>w>>k;
	string s[h],mp[h];
	for(int i=0;i<h;i++)
		cin>>mp[i],s[i]=mp[i];
	ll ans=0;
	for(int i=0;i<(1<<h);i++){
		for(int j=0;j<(1<<w);j++){
			for(int i1=0;i1<h;i1++){
				for(int j1=0;j1<w;j1++){
					s[i1][j1]=mp[i1][j1];
				}
			}
			int bl=0;
			for(int i1=0;i1<h;i1++){
				for(int j1=0;j1<w;j1++){
					if((i>>i1)%2 || (j>>j1)%2) s[i1][j1]='.';
					if(s[i1][j1]=='#') bl++;
				}
			}
			if(bl==k) ans++;
			//cout<<i<<"\n";
		}
	}
	cout<<ans;
}

Measured memory_bytes: 3596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.StringTokenizer;

public class Main{
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		int N = Integer.parseInt(br.readLine());
		
		int[] a = new int[N];
		st = new StringTokenizer(br.readLine());
		for(int i=0; i<N; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		
		long[][] dp = new long[N+1][N+1];
		
		for(int i=N-1; i>=0; i--) {
			for(int j=i; j<N; j++) {
				if(i==j) {
					dp[i][j] = a[i];
				}else {
					dp[i][j] = Math.max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
				}
			}
		}
		System.out.println(dp[0][N-1]);
		
	}
}


Measured memory_bytes: 104152
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i=0;i<n;i++) a[i] = sc.nextLong();
        Arrays.sort(a);
        long sum = 0;
        for(long w:a) sum += w;
        long ans = n%2==0?solveEven(a,sum,n):solveOdd(a,sum,n);
        System.out.println(ans);
    }
    // when n is odd
    static long solveOdd(long[] a, long sum, int n){
        long sum1 = 0;
        for(int i=n/2+1;i<=n-1;i++) sum1 += a[i];
        long ans1 = 2*sum1-2*(sum-sum1)+a[n/2]+a[n/2-1];
        long sum2 = 0;
        for(int i=n/2;i<n;i++) sum2 += a[i];
        long ans2 = 2*sum2-a[n/2]-a[n/2+1]-2*(sum-sum2);
        return Math.max(ans1,ans2);
    }
    static long solveEven(long[] a, long sum, int n){
        if(n==2) return a[1]-a[0];
        long sum1 = 0;
        for(int i=n/2;i<n;i++) sum1 += a[i];
        long ans1 = 2*sum1-a[n/2]-2*(sum-sum1)+a[n/2-1];
        return ans1;
    }
}


Measured memory_bytes: 62876
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int p=0,i;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            p++;
        }
    }
    cout<<p<<endl;
    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	string s1,s2;
	cin>>s1>>s2;
	int len=0;
	rep(i,0,SZ(s1)){
		if(s1[i]!=s2[i]){
			len++;
		}
	}
	printf("%d",len);
} 

Measured memory_bytes: 3936
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 110, M = N * N;

int Map[N][N];
int n, m, k, val[M];

int main(){
	scanf("%d%d%d", &n, &m, &k);
	For(i, 1, k) scanf("%d", &val[i]);
	int now = 1;
	For(i, 1, n){
		if(i & 1){
			For(j, 1, m){
				Map[i][j] = now;
				if(!--val[now]) ++now;
			}
		}
		else
			Forr(j, m, 1){
				Map[i][j] = now;
				if(!--val[now]) ++now;
			}
	}
	For(i, 1, n) For(j, 1, m) printf("%d%c", Map[i][j], j == m ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


#define ll long long
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
const ll inf=1e9;


ll a[maxn];
ll b[maxn];
multiset<ll> st;
map<ll,vector<ll> > ger;
map<ll,bool> vis;

void dfs(ll a){
	vis[a]=1;
	FOR(i,ger[a]){
		ll v=ger[a][i];
		if(vis[v]==0){
			dfs(v);
		}
	}
}
int main(){
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		a[n]^=a[i];
		st.insert(a[i]);
	}
	st.insert(a[n]);
	for(ll i=0;i<n;i++){
		cin>>b[i];
		if(st.find(b[i])==st.end()){
			cout<<-1;
			return 0;
		}
		st.erase(st.find(b[i]));
	}
	b[n]=(*st.begin());
	st.erase(b[n]);
	ll ans=0;
	for(ll i=0;i<=n;i++){
		if(a[i]!=b[i]){
			ger[a[i]].pb(b[i]);
			ger[b[i]].pb(a[i]);
		}
		ans+=(a[i]!=b[i]);
	}
	if(ans==0){
		cout<<0;
		return 0;
	}
	for(ll i=0;i<=n;i++){
		if(a[i]!=b[i] && vis[a[i]]==0){
			dfs(a[i]);
			ans++;
		}	
	}
	if(b[n]==a[n]){
		bool ntanha=1;
		/// ans-1 
		for(ll i=0;i<n;i++){
			if(a[i]==b[n]){
				ntanha=0;
			}
		}
		if(ntanha){
			cout<<ans;
		}
		/// ans
		else{
			cout<<ans-1;
		}
		return 0;
	}
	cout<<ans-2;
}













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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;
int main()
{
	fastIO;
	ll x,y;cin>>x>>y;cout<<x+y/2;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,i;
  cin >> N >> i;
  cout << N-i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < int > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vll vector < ll >
# define pii pair < int , int >
# define mp make_pair
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    const string N = "CODEFESTIVAL2016";
    string s;
    int ans = 0;
    fi>>s;
    for (int i = 0;i < s.length();++i)
        ans += N[i] != s[i];
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}

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

long long int n;

void solve(){
	cin>>n;
	int p= n%10;
	if(p==3)
		cout<<"bon";
	else if(p==0 ||p==1 ||p==6 ||p==8  )
		cout<<"pon";
	else 
		cout<<"hon";
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 0; i < 3; i++){
    int temp = 0;
    temp = n % 10;
    if(temp == 7){
      cnt++;
    }
    n = n / 10;
  }
  if(cnt == 0){
  	cout << "No";
  }else{
  	cout << "Yes";
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    int n;
    cin>>n;
    pair<int,int>a[n];
    rep(i,n){
        cin>>a[i].first;
        a[i].second = i+1;
    }
    sort(a,a+n);
    rep(i,n){
        cout<<a[i].second<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int dg[N];
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		dg[x]++, dg[y]++;
	}
	for (int i = 0; i < n; i++) {
		if (dg[i] % 2) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}


Measured memory_bytes: 640
S=input()
n=len(S)
A=[0]*(n+1)
for i in range(n):
    if(S[i]=='<'):
        A[i+1]=A[i]+1
for i in reversed(range(n)):
    if(S[i]=='>'):
        A[i]=max(A[i],A[i+1]+1)
print(sum(A))

Measured memory_bytes: 46792
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

struct Edge {
    int to, id ;
};

vector<vector<Edge>> to ; 
vector<int> ans ;

void dfs (int v, int c = -1, int p = -1){
    int k = 1 ;
    rep(i, to[v].size()){
        int u = to[v][i].to ;
        int ei = to[v][i].id ;
        if(u == p) continue ;
        if(k == c) ++k ;
        ans[ei] =  k;
        k++  ;
        dfs(u,ans[ei], v) ;
    }
}

int main() {
    int n ;
    cin >> n ;
    to.resize(n) ;
    ans.resize(n) ;
    rep(i, n - 1){
        int a, b ;
        cin >> a >> b ;
        a-- ;
        b-- ;
        to[a].push_back((Edge){b, i}) ;
        to[b].push_back((Edge){a, i}) ;
    }
    dfs(0) ;
    int mx = 0;
    rep(i, n) mx = max(mx, int(to[i].size())) ;
    cout << mx << endl ;
    rep(i, n - 1){
        cout << ans[i] << endl ;
    }
    return 0 ;
}  

Measured memory_bytes: 11092
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	pp := make([]P, 2)
	for i := 0; i < 2; i++ {
		pp[i].x = getNextFloat64(scanner)
		pp[i].y = getNextFloat64(scanner)
		pp[i].r = 0.0
	}
	n := getNextInt(scanner)

	for i := 0; i < n; i++ {
		x := getNextFloat64(scanner)
		y := getNextFloat64(scanner)
		r := getNextFloat64(scanner)
		pp = append(pp, P{
			x: x,
			y: y,
			r: r,
		})
	}

	costs := make([][]float64, n+2)
	for i := 0; i < n+2; i++ {
		costs[i] = make([]float64, n+2)
	}
	for i := 0; i < n+2; i++ {
		for j := i + 1; j < n+2; j++ {
			cost := math.Sqrt(math.Pow(pp[i].x-pp[j].x, 2)+math.Pow(pp[i].y-pp[j].y, 2)) - pp[i].r - pp[j].r
			if cost < 0 {
				cost = 0
			}
			costs[i][j] = cost
			costs[j][i] = cost
		}
	}

	dd := make([]float64, n+2)
	for i := 1; i < n+2; i++ {
		dd[i] = math.MaxFloat64
	}

	visited := make([]int, n+2)
	hp := &HH{}
	heap.Init(hp)

	heap.Push(hp, HP{
		i:    0,
		cost: 0,
	})
	for hp.Len() > 0 && visited[1] == 0 {
		p := heap.Pop(hp).(HP)
		if visited[p.i] == 1 {
			continue
		}
		visited[p.i] = 1
		for i := 0; i < n+2; i++ {
			if visited[i] == 1 {
				continue
			}
			if dd[i] < p.cost+costs[p.i][i] {
				continue
			}
			dd[i] = p.cost + costs[p.i][i]
			heap.Push(hp, HP{
				i:    i,
				cost: p.cost + costs[p.i][i],
			})
		}
	}

	fmt.Fprintln(writer, dd[1])
	writer.Flush()
}

type HP struct {
	i    int
	cost float64
}
type HH []HP

func (h HH) Len() int           { return len(h) }
func (h HH) Less(i, j int) bool { return h[i].cost < h[j].cost }
func (h HH) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *HH) Push(x interface{}) {
	*h = append(*h, x.(HP))
}
func (h *HH) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

type P struct {
	x, y, r float64
}


Measured memory_bytes: 32000
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
typedef long long ll;
const int MAXN = 1e6 + 10 ;
const int MAX = 1e7 + 1 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
ll mod = 500500507;
ll powr(ll a , ll b){ if(b==0) return 1LL ; ll x = powr(a,b/2) ; x = (x*x)%mod ; if(b%2) return ((a%mod)*x)%mod ; return x ;}
ll gcd(ll a , ll b){if(a==0) return b ; return gcd(b%a,a);}

vector<int> prm ;
bool p[MAXN] ;
void seive() {
    
    for(int i = 0; i < MAXN;i++) p[i] = true ;
    p[0] = p[1] = false ;
    for(int i = 4 ; i < MAXN;i+=2) p[i] = false ;
    for(int  i = 3 ; i <= sqrt(MAXN);i+=2)
        if(p[i])
            for(int j = 2*i ; j < MAXN;j+=i)
                p[j] = false ;
    prm.pb(2) ;
    for(int i  =3 ; i< MAXN;i+=2)
        if(p[i]) prm.pb(i) ;
}
int main () {
    
    seive();
    
    ll N , P ;
    cin >> N >> P ;
    if(P==1 || N==1) {
        cout<<P<<endl;
        return 0 ;
    }
    map<ll,ll> mp ;
    for(int i = 0; i < prm.size() && prm[i] <= P ;i++){
        int cnt =0 ;
        while(P%prm[i]==0){
            P/=prm[i] ;
            cnt++ ;
        }
        if(cnt) mp[prm[i]]=cnt ;
        if(P < MAXN && p[P]==true){
            mp[P]+= 1 ;
            break ;
        }
    }
    ll g = 1LL;
    for(auto it = mp.begin();it!=mp.end();it++)
        if(it->S >= N) g=g*(pow(it->F , (it->S/N))) ;
    cout<<g<<endl;
    
    return 0 ;
}
//


Measured memory_bytes: 1916
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int w,n,a,b,ans[50];
	for(int i=0 ; i < 50 ; i++ ){
		ans[i] = i;
	}
	scanf("%d %d", &w, &n);
	for(int i=0 ; i < n ; i++ ){
		scanf("%d,%d", &a, &b );
		swap( ans[a] , ans[b] );
	}
	for(int i=1 ; i <= w ; i++ ){
		printf("%d\n", ans[i] );
	}
}

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

int main()
{
	long long int n, num, sum = 0;
	scanf("%lld", &n);
	
	num = n;
	while(num != 0)
	{
		sum += num % 10;
		num /= 10;
	}
	
	if(n % sum == 0) printf("Yes\n");
	else printf("No\n");
}

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

int main() {
  int M, D;
  cin >> M >> D;

  int ans = 0;

  for (int i = 4; i <= M; i++){
    for (int j = 1; j <= D; j++){
      if (j%10 < 2 || (j/10%10) < 2){
        continue;
      }

      if (j%10 * (j/10%10) == i){
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

nums = [[0, 0] for _ in range(n)]

for i in range(n):
  nums[i][0], nums[i][1] = map(int, input().split())
  
if n % 2 == 0:
  # even
  nums.sort(key=lambda x: x[0])
  a = (nums[(n+1)//2 - 1][0] + nums[(n+1)//2][0]) / 2
  nums.sort(key=lambda x: x[1])
  b = (nums[(n+1)//2 - 1][1] + nums[(n+1)//2][1]) / 2
  print(int((b-a) * 2 + 1))
  
else:
  # odd
  nums.sort(key=lambda x: x[0])
  a = nums[(n+1)//2 - 1][0]
  nums.sort(key=lambda x: x[1])
  b = nums[(n+1)//2 - 1][1]
  print(b-a + 1)


Measured memory_bytes: 42268
#include<iostream>
#include<utility>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n,m;cin>>n>>m;
  vector<pair<int,int> > pii(n);

  for(int i=0;i<n;i++)
    cin>>pii[i].first>>pii[i].second;
  sort(pii.begin(),pii.end());
  for(int i=0;i<m;i++){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int cnt=0;
    for(int j=0;j<n;j++){
      if(x1<=pii[j].first&&pii[j].first<=x2&&y1<=pii[j].second&&pii[j].second<=y2)
	cnt++;
    }
    printf("%d\n",cnt);
  }
  // cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3232
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
m = max(a)



flag = True

for i in range(1, m+1):
    if i<m//2:
        if c[i]!=0:
            flag = False
    elif i==m//2:
        if m%2 == 0:
            if c[i]!=1:
                flag = False
                break
        else:
            if c[i]!=0:
                flag = False
                break
    elif i == m//2+1:
        if m%2 == 0:
            if c[i]<2:
                flag = False
                break
        else:
            if c[i]!=2:
                flag = False
                break
    else:
        if c[i]<2:
            flag = False
            break

print('Possible' if flag else 'Impossible')

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

int main()
{
    int n;
    cin>>n;
    int *a=new int [n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int SortDone=0;
    int times=0;
    while(SortDone<n){
        for(int i=n-1;i>SortDone;i--){
            if(a[i]<a[i-1]){
                swap(a[i],a[i-1]);
                times++;
            }
        }
        SortDone++;
    }
    for(int i=0;i<n-1;i++)
        cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
    cout<<times<<endl;
    return 0;
}



Measured memory_bytes: 3100
N = int(input())
A = list(map(int, input().split()))

count = 0
min = abs(A[0])
sum = 0
for i in A:
    # 0と負の数をカウント
    if i<=0:
        count += 1
    # 最小更新
    if min > abs(i):
        min = abs(i)
    # 合計
    sum += abs(i)
#print('count:'+str(count))
#print('min:'+str(min))
#print('sum:'+str(sum))
if count%2 == 0:
    print(sum)
else:
    print(sum-(min*2))


Measured memory_bytes: 19972
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")

#include<bits/stdc++.h>

#define pb push_back
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f(i, a ,b) for(int i = (int)a; i <=(int)(b);i++)
#define endl "\n"
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define int long long
using namespace std;

const int N = 1e5+5,MOD = 1000000007;
const long long INF = 0xFFFFFFFFFFFFFFFL;

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

void IOS()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
   	cout.precision(10);
   	cout << fixed;
}
	
int32_t main()
{
	IOS();
	int n,s;
	cin >> n >> s;
	vector<int> w(n+1),v(n+1);
	f(i,0,n-1)cin >> w[i] >> v[i];
	vector<int> dp(n*1000+1,INF);
	dp[0] = 0;
	for(int i = 0; i < n; i++)
	{
		for(int j = n*1000; j >= v[i]; j--)
		{
			dp[j] = min(dp[j], dp[j-v[i]]+w[i]);
		}
	}
	int ans = 0;
	for(int i = 0;i < 1000*n+1; i++)if(dp[i] <= s)ans = i;
	cout << ans;		
	return 0;
}

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

int main() {
  int D,N; cin >> D >> N;
  int answer = 0;
  
  if (D == 0) {
    if (N != 100) answer = N;
    else answer = 101;
  } else if (D == 1) {
    if (N != 100) answer = 100 * N;
    else answer = 10100;
  } else if (D == 2) {
    if (N != 100) answer = 100 * 100 * N;
    else answer = 1010000;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
h,w = [int(i) for i in readline().split()]
b = [input() for _ in range(h)]

dx4=[0, 1, 0,-1]
dy4=[1, 0,-1, 0]

from collections import deque


ans = 0
for sx in range(h):
    for sy in range(w):
        if b[sx][sy] == "#": continue
        
        c = 0    
        memo = [[-1]*w for _ in range(h)]
        q = deque()
        q.append((sx,sy)) #初期状態をキューに入れる
        memo[sx][sy] = 0 #初期状態を訪問済みにする
        while q: #キューが空になるまで
            x,y = q.popleft() #キューから情報を取り出す
            #(x,y)の各隣に対して処理-------------------------------------
            for i in range(4):
                nx = x + dx4[i]
                ny = y + dy4[i]
                #範囲外ならスキップ---------------------------------------------------
                if nx < 0 or nx>=h or ny <0 or ny>=w: continue
                #壁ならスキップ-------------------------------------------------------
                if b[nx][ny] == "#": continue
                #(nx,ny)が確認済みならスキップ----------------------------------------
                if memo[nx][ny] >= 0: continue
                #(nx,ny)が未確認のとき、確認済みにしてキューに入れる------------------
                memo[nx][ny] = memo[x][y]+1
                c = memo[x][y]+1
                q.append((nx,ny))

        if ans < c: ans = c

print(ans)

Measured memory_bytes: 45660