akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using namespace std;

int main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3, y3, x4, y4;
	x3 = x2 + y1 - y2;
	y3 = y2 - x1 + x2;
	x4 = x1 - y2 + y1;
	y4 = y1 + x2 - x1;
	cout << x3 << endl;
	cout << y3 << endl;
	cout << x4 << endl;
	cout << y4 << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 2e5 + 5;

int n, a[N];

struct P {
	int x, y;
	P(int _x = 0, int _y = 0) {
		x = _x, y = _y;
	}
};
P b[N]; int b0;

int pd(int m) {
	b[b0 = 1] = P(1, a[1]);
	fo(i, 2, n) {
		if(a[i] > a[i - 1]) {
			b[++ b0] = P(1, a[i] - a[i - 1]);
		} else {
			int s = a[i - 1] - a[i];
			while(s > 0) {
				if(b[b0].y > s) {
					b[b0].y -= s;
					s = 0;
				} else {
					s -= b[b0 --].y;
				}
			}
			if(b[b0].x < m) {
				if(b[b0].y > 1) {
					b[b0].y --;
					int x = b[b0].x;
					b[++ b0] = P(x + 1, 1);
				} else b[b0].x ++;
			} else {
				if(b0 == 1) return 0;
				if(b[b0 - 1].y > 1) {
					b[b0 + 1] = b[b0];
					b[b0] = P(b[b0 - 1].x + 1, 1);
					b[b0 - 1].y --;
					b0 ++;
					b[b0].x = 1;
				} else {
					b[b0 - 1].x ++;
					b[b0].x = 1;
					int t = b0 --;
					while(b0 > 1 && b[b0 - 1].x == b[b0].x) {
						b[b0 - 1].y += b[b0].y;
						b0 --;
					}
					b[++ b0] = b[t];
				}
			}
		}
		while(b0 > 1 && b[b0 - 1].x == b[b0].x) {
			b[b0 - 1].y += b[b0].y;
			b0 --;
		}
	}
	return 1;
}

int main() {
	scanf("%d", &n);
	fo(i, 1, n) scanf("%d", &a[i]);
	int as = 0;
	for(int l = 1, r = n; l <= r; ) {
		int m = l + r >> 1;
		if(pd(m)) as = m, r = m - 1; else l = m + 1;
	}
	pp("%d\n", as);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int a, b, c, k;
    cin>>a>>b>>c>>k;
    int s = min(a, max(k, 0ll));
    k-=s;
    int p = min(b, max(k, 0ll));
    s+=p*0;
    k-=p;
    int t = min(c, max(k, 0ll));
    s+=(-t);
    cout<<s;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

void solve(){
  int n, m, x, c=1;
    cin >> n >> m >> x;
    int a[m];
    rep(i, m) cin >> a[i];
    for(int i = 0; i < m; i++){
      if(a[i] < x && a[i+1] > x){
        cout << min(c, m-c) << endl;
        return;
      }else if(x < a[0] | x > a[m-1]){
        cout << 0 << endl;
        return;
      }
      c++;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ull = unsigned long long;
using ll = long long;
using ld = long double;
int main(){
  char a[200000];
  cin>>a;
  int l=strlen(a);
  int S=0;
  for(int i=0;i<l;i++){
   a[i]=a[i]-'0';
   S=S+a[i];
  }
  
  if(S%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdio>

using namespace std;

int main()
{
    int n;

    while (1) {
        cin >> n;
        if (n == 0) break;
        int s[n];
        double mid = 0;
        double hensa = 0;
        for (int i = 0; i < n; i++) {
            cin >> s[i];
            mid += s[i];
        }
        mid /= n;
        for (int i = 0; i < n; i++) {
            hensa += pow(s[i] - mid, 2);
        }
        hensa /= n;

        printf("%.8lf\n", sqrt(hensa));
    }
}



Measured memory_bytes: 3232
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  long long n;
  cin >> n;
  vector<long long> monsters(n+1);
  long long sum = 0;
  for (long long i = 0; i < n+1; i++) {
    long long val;
    cin >> val;
    sum += val;
    monsters.at(i) = val;
  }
  vector<long long> heroes(n+1);
  for (long long i = 0; i < n; i++) {
    cin >> heroes.at(i);
  }
  for (long long i = 0; i < n; i++) {
    if (heroes.at(i) <= monsters.at(i)) {
      monsters.at(i) -= heroes.at(i);
      continue;
    }
    heroes.at(i) -= monsters.at(i);
    monsters.at(i) = 0;
    monsters.at(i+1) = max(monsters.at(i+1) - heroes.at(i), 0LL);
  }
  long long sum2 = 0;
  for (long long x : monsters) {
    sum2 += x;
  }
  cout << sum - sum2 << '\n';
  return 0;
}


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

#define for_(i,a,b) for (int i=(a);i<(b);++i)

int N, score[111], T, memo[4][4][1 << 16], id, num[111], dp[100010];
string word[111], grid[4];

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

inline int gridId(int x, int y) { return (y << 2) + x; }

int rec(int x, int y, int bit) {
	int s = __builtin_popcount(bit);
	
	if (s >= (int)word[id].size()) return 1;
	if (memo[y][x][bit] >= 0) return memo[y][x][bit];
	
	int& res = memo[y][x][bit];
	res = 0;
	
	for_(d,0,8) {
		int nx = x + dx[d], ny = y + dy[d];
		if (nx < 0 || 4 <= nx || ny < 0 || 4 <= ny) continue;
		if (bit >> gridId(nx, ny) & 1) continue;
		if (grid[ny][nx] == word[id][s]) res += rec(nx, ny, bit | (1 << gridId(nx, ny)));
	}
	
	return res;
}

void solve() {
	memset(num, 0, sizeof(num));
		
	for_(i,0,N) {
		id = i;
		memset(memo, -1, sizeof(memo));
		
		for_(y,0,4) for_(x,0,4)	{
			if (grid[y][x] != word[i][0]) continue;
			num[i] += rec(x, y, 1 << gridId(x, y));
		}
	}
	
	memset(dp, 0, sizeof(dp));
	
	for_(i,0,N) {
		int m = num[i], len = word[i].size();
		
		for (int k = 1; m > 0; k <<= 1) {
			int mul = min(k, m);
			for (int j = T; j >= len * mul; --j) {
				dp[j] = max(dp[j], dp[j - len * mul] + score[i] * mul);
			}
			m -= mul;
		}
	}
	
	cout << dp[T] << endl;
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> word[i] >> score[i];
	for_(i,0,4) cin >> grid[i];
	cin >> T;
	solve();
}

Measured memory_bytes: 7704
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int l[n],r[n];
    int ans = 0;
    for(int i = 0; i < n; i++){
        scanf("%d %d",&l[i],&r[i]);
        ans += r[i] - l[i] + 1;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(void)
{
    int a, b;
    int c, d;
 
 
    scanf("%d %d", &a, &b);
 
    c= a * b;
    d= 2 * a + 2 * b;
 
    printf("%d %d\n", c, d);
 
    return 0;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

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

    ll r = 0, g = 0, b = 0;
    rep(i, 0, n)
    {
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    ll con1 = r * g * b;

    ll notCon2 = 0;
    rep(i, 0, n)
    {
        if (s[i] != 'R') continue;
        rep(k, 0, n)
        {
            if (s[k] != 'G') continue;
            if ((k + i) % 2 == 0 && s[(k + i) / 2] == 'B') notCon2++;
            if (2 * k - i >= 0 && 2 * k - i < n && s[2 * k - i] == 'B') notCon2++;
            if (2 * i - k >= 0 && 2 * i - k < n && s[2 * i - k] == 'B') notCon2++;
        }
    }
    cout << con1 - notCon2 << endl;
}


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

int main() 
{
		int n; cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				ans+=a[i]*a[j];
			}
		}
		cout<<ans;
	
	
	
}

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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N+1);
    for(int i = 1;i <= N;i++)    cin >> a[i];
    vector<vector<int>> col(H+1, vector<int>(W+1));
    int color = 1;
    for(int i = 1;i <= H;i++){
        for(int j = 1;j <= W;j++){
            col[i][j] = color;
            a[color]--;
            if(!a[color])   color++;
        }
    }
    for(int i = 1;i <= H;i++){
        if(i&1)for(int j = 1;j <= W;j++)    cout << col[i][j] << " ";
        else    for(int j = W;j >= 1;j--)   cout << col[i][j] << " ";
        cout << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include<cmath>
#include<vector>
#include<tuple>
#include <ctime>
#include<algorithm>
#include <initializer_list>
#include <cstring> 
 
#define tii tuple<int,int>
#define vi vector<int>
#define vii vector<vi>
#define ll long long int
#define vl vector<ll>
#define vll vector<vl>
 
#define mymod 1000000007
#define mx 99999999
#define mn -99999999
#define sz 101
 
using namespace std;
 
int main() {
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // Start
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll t = x/d;
    ll ans;
    if(t>=k) {
        ans = abs(x - k*d);
    }
    else {
        x -= t*d;
        k -= t;
        k = k%2;
        if(k) {
            ans = min(abs(x+d),abs(x-d));
        }
        else {
            ans = abs(x);
        }
        
    }
    cout<<ans;
    // cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}
 

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++)cin >> a[i]; sort(a.begin(), a.end());

    int cur = a.front();
    vector<pair<int,int>> rs;

    for(int i = 1; i < n - 1; i++) {
        if(a[i] >= 0) {
            rs.emplace_back(cur, a[i]);
            cur -= a[i];
        }
    }
    rs.emplace_back(a.back(), cur);
    cur = a.back() - cur;

    for(int i = 1; i < n - 1; i++) {
        if(a[i] < 0) {
            rs.emplace_back(cur, a[i]);
            cur -= a[i];
        }
    }
    cout << cur << endl;
    for(auto i : rs)cout << i.first << " " << i.second << endl;
}

Measured memory_bytes: 4660
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    char s; cin >> s;
    cout << (char)(s+1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x=0,k=0,z=0,i=0;
    cin>>k>>x;
    if(k==1){
        cout<<x;
    }
    else{
        z=x+(k-1);
        k-=1;
        i=x-k;
        for(int i=x-k;i<=z;i++){
            cout<<i<<' ';
        }
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	H := readint()
	N := readint()
	for i := 0; i < N; i++ {
		H -= readint()
	}
	ans := "No"
	if H <= 0 {
		ans = "Yes"
	}
	fmt.Println(ans)
}

const (
	iobufsize = 1 * 1024 * 1024 // 1 MB
)

var stdinsc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, iobufsize), iobufsize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func readint() int {
	stdinsc.Scan()
	v, err := strconv.Atoi(stdinsc.Text())
	if err != nil {
		panic(err)
	}
	return v
}

func readstr() string {
	stdinsc.Scan()
	return stdinsc.Text()
}

func pow(x, y int) int {
	if y < 1 {
		return 1
	}
	return x * pow(x, y-1)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 1792
#if 1
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <set>
#include <map>
#include <numeric>
#include <cassert>

using namespace std;
#define int long long
#define uint unsigned long long
constexpr int MOD = 1000000007;
constexpr int INF = 1145141919810;

#define LOADVEC(type,name,N) std::vector<type>name(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name[nnn]; \
}

#define LOADVEC2(type,name0,name1,N) std::vector<type>name0(N),name1(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn]; \
}

#define LOADVEC3(type,name0,name1,name2,N) std::vector<type>name0(N),name1(N),name2(N); \
for (int nnn = 0; nnn < N; ++nnn) { \
	cin >> name0[nnn];cin >> name1[nnn];cin >> name2[nnn]; \
}

#define LOAD(type,name) type name; \
cin >> name;


void proc();

signed main() {
	ios::sync_with_stdio(false);
	proc();
	return 0;
}

/*
--------------------------------------------------------
--------------------------------------------------------
---------------    template      ----------------------
--------------------------------------------------------
--------------------------------------------------------
*/

void proc() {
	LOAD(int,N);
	std::string s;
	cin >> s;
	int r = 0, b = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == 'R')++r;
		if (s[i] == 'B')++b;
	}
	if (r > b) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


#endif


Measured memory_bytes: 256
K,S=map(int,input().split())

count=0

for x in range(K+1):
    for y in range(x+1):
        z=S-x-y
        if z<0 or z>y:
            pass
        else:
            #print(x,y,z)
            if x==y==z:
                count+=1
            elif x==y or x==z or y==z:
                count+=3
            else:
                count+=6
        
print(count)

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

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

  string s, t;
  cin >> s >> t;

  sort (std::begin (s), std::end (s));
  sort (std::begin (t), std::end (t), [&] (auto && x, auto && y) {
    return x > y;
  });

  auto ans = s < t;
  cout << (ans ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>

using namespace std;
#define mod 1000000007
#define ll long long


ll n,w, a[100009], b[100009];
ll dp[109][100009];

// map<int, map<ll, ll> > dp;

ll solve(ll val, ll idx) {
    if(idx == 0)
        return val==0?0:INT_MAX;

    if(dp[idx][val])
    	return dp[idx][val];

    ll ans = solve(val, idx - 1);
    if(b[idx-1] <= val)
    	ans = min(ans, a[idx-1] + solve(val - b[idx-1], idx - 1));

    return dp[idx][val] = ans;
}

int s(ll sm) {

	for(ll i = sm; i >= 0; i--) {
		if(solve(i, n) <= w)
			return i;
	}
	return 0;
}

int main() {
        cin>>n>>w;
        ll sm=0;
        for(ll i = 0; i < n; i++) {
            cin>>a[i]>>b[i];
            sm += b[i];
        }
        cout<<s(sm)<<endl;

}


Measured memory_bytes: 80888
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int n; cin >> n;
	vv(int, v, n + 1, n + 1, 0);
	int index, num, k;
	rep(i, 0, n) {
		cin >> index >> num;
		rep(j, 0, num) {
			cin >> k;
			++v[index][k];
		}
	}
	rep(i, 1, n + 1) {
		rep(j, 1, n + 1) {
			cout << v[i][j] << (j == n ? "\n" : " ");
		}
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(i,v) for (auto i=v.begin();i!=v.end();++i)
using namespace std;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}

bool operator<(const string&a,const string&b) {
   int n=a.size(),m=b.size();
   if(b[n-1]=='$')return false;
   if(n<m)return true;
   if(n>m)return false;
   if(a<=b)return true;
   return false;
}

signed main()
{
   int N, M; cin >> N >> M;
   set<int> A;
   REP(i, M) {
      int a; cin >> a;
      A.insert(a);
   }
   V<int> num{-1,2,5,5,4,5,6,3,7,6};

   V<string> dp(N+1, "$");   // dp[i]: the max string using i matches.
   dp[0] = "";
   REP(i, N) {
      EACH(j, A) {
         int a = *j;
         if (i + num[a] <= N) {
            chmax(dp[i + num[a]], dp[i]+to_string(a));
         }
      }
   }
   cout << dp[N] << endl;


   return 0;
}


Measured memory_bytes: 33024
#include<stdio.h>
int main(){
  int N,K,b,i,S=0,x;
  scanf("%d",&N);
  scanf("%d",&K);

  b=K/2;
  for(i=0;i<N;i++){
    scanf("%d",&x);
    if(x>b){
      S+=K-x;
    }else{
      S+=x;
    }
  }
  

  printf("%d",2*S);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int main()
{
	int num;
	scanf("%d", &num);
	set<int>se;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (se.find(z) == se.end())se.insert(z);
		else se.erase(z);
	}
	printf("%d\n", se.size());
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, H, W, h, w);
  out((H - h) * (W - w));
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
#define rep(i, n) for(i = 0; i < (n); i++)
#define rrep(i, n) for(i = (n - 1); i >= 0; i--)
using namespace std;

bool vis[200005]={0};
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
    return 0;
}
void solve1()
{
    int n,m,k;
    cin>>n>>m>>k;
    int arr[n],brr[m];
    int a=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];arr[i]+=a;
        a=arr[i];
    }
    a=0;
    for(int i=0;i<m;i++)
    {
        cin>>brr[i];brr[i]+=a;
        a=brr[i];
    }
    int i=0,j=0,ans=0;
    while(arr[i]<=k&&i<n)
    {
        ans++;i++;
    }
    i--;
    while(brr[j]<=k&&j<m&&i>=0)
    {
        if(arr[i]+brr[j]<=k)
        {
            ans=max(ans,i+j+2);j++;
        }
        else
        {
            i--;
        }
    }
    int ans2=0;
    j=0;
    while(brr[j]<=k&&j<m)
    {
        ans2++;j++;
    }
    ans=max(ans,ans2);
    cout<<ans<<endl;
}


Measured memory_bytes: 6684
import java.util.*

fun main(args: Array<String>) {
    abc045b()
}

fun abc045b() {
    val abcList = (1..3).map { readLine()!!.toCharArray().map { it.toInt() - 97 } }
        .map { ArrayDeque(it) }

    var nextTurn = 0
    while (true) {
        nextTurn = abcList[nextTurn].pollFirst() ?: return println((nextTurn + 65).toChar())
    }
}


Measured memory_bytes: 31772
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 

 
#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define itt iterator
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define isvowel(a) (a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001


#define int ll

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

int n,k;
std::vector<int> a;
int dp[maxn][2];

int find(int rem,int turn)
{
	if(!rem) return !turn;
	if(dp[rem][turn]!=-1) return dp[rem][turn];
	
	int x=0,y=0;
	int f=1;

	for(int i:a)
	{
		if(rem>=i)
		{
			f=find(rem-i,!turn);
			if(f) y++;
			else x++;
			f=0;
		}
	}

	if(f) return dp[rem][turn]=!turn;
	if(turn) return dp[rem][turn]=(y!=0);
	return dp[rem][turn]=(x==0);
}


signed main()
{

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

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

	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int h;
		cin>>h;
		a.pb(h);
	}
	initialise(dp,-1);

	if(find(k,1)) cout<<"First\n";
	else cout<<"Second\n";

	return 0;
}

Measured memory_bytes: 9600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int n;
  double y, v, t;

  while(cin >> v) {
    t = v/9.8;
    y = 4.9 * t * t;

    int i = 1;
    while(1) {
      if(5*i-5 > y) {
	n = i;
	break;
      }
      i++;
    }
    cout << n << endl;
  }
}

Measured memory_bytes: 1228
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: i64,
        m: i64,
        d: i64,
    }
    println!(
        "{}",
        ((m - 1) * (min(2 * d, n) + min(d + 1, 2) * max(n - 2 * d, 0))) as f64 / (n * n) as f64
    );
}


Measured memory_bytes: 4352
// finish date: 2019/11/24

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    vi deme;
    vi max_progress(N + 1, 0);
    FOR(i, 1, N + 1) {
        if (S[i] == '0'){
            max_progress[i] = i;
        } else{
            max_progress[i] = max_progress[i - 1];
        }
    }
    int pos = 0;
    while (pos != N) {
        int nextpos = min(pos + M, N);
        if (pos == max_progress[nextpos]) {
            cout << -1 << endl;
            return 0;
        }
        deme.push_back(max_progress[nextpos] - pos);
        pos = max_progress[nextpos];
    }

    reverse(deme.begin(), deme.end());
    rep(i, deme.size()) {
        cout << deme[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1528
N, A, B, C, D = map(int, input().split())

def foo():
    for i in range(N):
        hoge = C * (N - 1 - i) - D * i <= B - A
        fuga = B - A <= -C * i + (N - 1 - i) * D
        
        yield hoge and fuga

print('YES' if any(foo()) else 'NO')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 



int main(){
    int n,q;cin >> n >> q;
    vector<LL> s(n),t(n),x(n),d(q);
    vector<pair<LL,P>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> x[i];
        v[i]=mp(x[i],mp(s[i],t[i]));
    }
    sort(ALL(v));
    for (int i = 0; i < q; i++) {
        cin >> d[i];
    }
    vector<vector<P>> vp(q+1),vm(q+1);
    for (int i = n-1; i >= 0; i--) {
        int l = lower_bound(ALL(d),v[i].sc.fs-v[i].fs)-d.begin();
        int r = lower_bound(ALL(d),v[i].sc.sc-v[i].fs)-d.begin();
        vp[l].pb(mp(v[i].fs,i));
        vm[r].pb(mp(v[i].fs,i));
    }
    set<P> st;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < vp[i].size(); j++) {
            st.insert(vp[i][j]);
        }
        for (int j = 0; j < vm[i].size(); j++) {
            st.erase(vm[i][j]);
        }
        if(st.empty()) cout << -1 << endl;
        else cout << st.begin()->fs << endl;
    }
    return 0;
}


Measured memory_bytes: 43488
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;

int N, K, ans=0;
vector<int> e[2005];
bool dead[2005];

int far(int c, int d, int k){
	dead[c] = true;
	int ret = 1;
	if( d == k ) return ret;
	for(auto t: e[c]) if(dead[t] == false){
		ret += far(t, d+1, k);
	}
	return ret;
}


int main(){
	ans = INF;

	cin >> N >> K;
	rep(i, N-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}

	rep(i,N){
		if( K%2 == 0 ){
			Fill(dead, false);
			chmin( ans, N - far(i,0,K/2) );
		}else{
			for(auto j: e[i]){
				Fill(dead, false);
				dead[i] = true;
				dead[j] = true;
				chmin( ans, N - far(i,0,(K-1)/2) - far(j,0,(K-1)/2) );
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
#include <cstring>


int main() {
    int n; std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::map<int, int> minid, cnt;
    for (int i = 0; i < n; i++) {
        if (!minid.count(a[i])) minid[a[i]] = i;
        cnt[a[i]]++;
    }
    std::sort(a.rbegin(), a.rend());
    a.erase(std::unique(a.begin(), a.end()), a.end());
    std::vector<long long> ans(n);
    int m = a.size();
    a.push_back(0);
    long long c = 0;
    int mi = 1e9;
    for (int i = 0; i < m; i++) {
        c += cnt[a[i]];
        mi = std::min(mi, minid[a[i]]);
        ans[mi] += c*(a[i] - a[i + 1]);
    }
    for (int i = 0; i < n; i++) std::cout << ans[i] << std::endl;
    return 0;
}


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

using namespace std;

struct sushi {
	long long int pos;
	long long int cal;
	long long int best_cal;
};

int main() {
	int N;
	long long int C;
	cin >> N >> C;

	vector<sushi> sushi_forward;
	vector<sushi> sushi_backward;
	sushi_forward.resize(N);
	sushi_backward.resize(N);
	for (int ii = 0; ii<N; ii++) {
		long long int pos;
		long long int cal;
		cin >> pos >>cal;
		sushi_forward[ii].pos = pos;
		sushi_forward[ii].cal = cal;
		sushi_backward[ii].pos = C - pos;
		sushi_backward[ii].cal = cal;
	}

	sort(sushi_forward.begin(), sushi_forward.end(),
		[](const auto& item1, const auto& item2) {return item1.pos < item2.pos; });
	sort(sushi_backward.begin(), sushi_backward.end(),
		[](const auto& item1, const auto& item2) {return item1.pos < item2.pos; });

	{
		long long int sum_cal = 0;
		long long int best_cal = 0;
		for (auto& sushi : sushi_forward) {
			sum_cal += sushi.cal;
			best_cal = max(best_cal, sum_cal - sushi.pos);
			sushi.best_cal = best_cal;
		}
	}

	{
		long long int sum_cal = 0;
		long long int best_cal = 0;
		for (auto& sushi : sushi_backward) {
			sum_cal += sushi.cal;
			best_cal = max(best_cal, sum_cal - sushi.pos);
			sushi.best_cal = best_cal;
		}
	}

	long long int best_cal = 0;
	for (int ii = 0; ii < N; ii++) {
		best_cal = max(best_cal, sushi_forward[ii].best_cal);
		best_cal = max(best_cal, sushi_backward[ii].best_cal);
		if (ii < N - 1) {
			best_cal = max(best_cal, sushi_forward[ii].best_cal + sushi_backward[N - ii - 2].best_cal - sushi_forward[ii].pos);
			best_cal = max(best_cal, sushi_forward[ii].best_cal + sushi_backward[N - ii - 2].best_cal - sushi_backward[N - ii - 2].pos);
		}
	}

	cout << best_cal;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;
int v[4];
int main()
{
    long long a,b,c,d,n,m1,m2,m3;
    long long c1;
    cin>>a>>b>>c>>d>>n;
    m1=a*4;
    m2=b*2;
    if(m1>m2)
        m1=m2;
    if(m1>c)
        m1=c;
    m2=2*m1;
    if(d<m2)
        m2=d;
    if(n%2==0)
        c1=(n/2)*m2;
    else
        c1=(n/2)*m2+m1;
    cout<<c1;



    return 0;
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i; 
    os << " ]";
    return os;
}


const int INF = 1e8;

const ll MOD = 1e9+7LL;

ll num[10000];

// 5 5
// 101
//  5 * (5 * 5) * (5 * 5)

template<typename T>
T xpow(T x, T n, T M) {
    T ret = 1;
    T val = x;
    for(; n != 0; n >>= 1) {
        if(n & 1) {
            ret *= val;
            ret %= M;
        }
        val *= val;
        val %= M;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    ll N, K;

    cin >> N >> K;

    vector<ll> divs;

    for(ll i = 1; i*i <= N; i++) {
        if(N % i == 0) {
            divs.emplace_back(i);
            if(i*i < N) divs.emplace_back(N/i); 
        }
    }

    sort(ALL(divs));

    ll ans = 0;

    // d:cyclic
    for(int i = 0; i < divs.size(); i++) {
        ll d = divs[i];
        ll val = xpow<ll>(K, (d+1)/2, MOD);
        for(int j = 0; j < i; j++) {
            if(divs[i] % divs[j] == 0) {
                val = (val - num[j] + MOD) % MOD;
            }
        }
        num[i] = val;
        if(d & 1) { // odd
            ans += num[i] * d;
        } else { // even
            ans += num[i] * d / 2;
        }
        ans %= MOD;
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    rep(i, k) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 3620
#!/usr/bin/env python3


import array
import collections
import math


def sieve_of_eratosthenes(end, typecode="L"):
    assert end > 1
    is_prime = array.array("B", (True for i in range(end)))
    is_prime[0] = False
    is_prime[1] = False
    primes = array.array(typecode)
    for i in range(2, end):
        if is_prime[i]:
            primes.append(i)
            for j in range(2 * i, end, i):
                is_prime[j] = False
    return primes


def factorize_trial_division(n, typecode="Q"):
    factors = array.array(typecode)
    if n < 2:
        return factors
    for p in sieve_of_eratosthenes(math.ceil(math.sqrt(n)) + 1):
        if p * p > n:
            break
        while n % p == 0:
            factors.append(p)
            n //= p
    if n > 1:
        factors.append(n)
    return factors


def solve(n, p):
    factors_counter = collections.Counter(factorize_trial_division(p))
    res = 1
    for k, v in factors_counter.most_common():
        d = v // n
        if d == 0:
            break
        else:
            res *= k ** d
    return res


def main():
    n, p = (int(z) for z in input().split())
    print(solve(n, p))


if __name__ == "__main__":
    main()

Measured memory_bytes: 5112
#include<stdio.h>

#define N 100

int selectionSort(int *,int);

int main()
{
  int a[N],n,i,cnt;

  scanf("%d",&n);

  for(i = 0; i < n; i++)
  {
    scanf("%d",&a[i]);
  }

  cnt = selectionSort(a,n);

  for(i = 0; i < n; i++)
  {
    if(i > 0)printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

int selectionSort(int *A, int n)
{
  int minj,j,i,temp,cnt=0;

  for(i = 0; i < n; i++)
  {
    minj = i;
    for(j = i; j < n; j++)
    {
      if(A[j] < A[minj])
      {
	minj = j;
      }
    }
    if(i != minj){
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      cnt++;
    }
  }
  
    return cnt;
}



Measured memory_bytes: 2048
// 1 21 ABC b
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  string s,t;
  cin>>s>>t;
  int x=stoi(s+t);
  for(int i=1;i<=1000;i++){
    if(i*i==x){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void)
 {
     int A,B,C,D;

     scanf("%d%d%d%d",&A,&B,&C,&D);

     while((A>0)&&(C>0)){
       C+=-B;
       if(C<=0) { printf("Yes\n"); return 0; }
       A+=-D;
       if(A<=0) { printf("No\n");  return 0; }
    }
 }



Measured memory_bytes: 1644
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(aov(a),x)-a.begin())
#define UB(a,x) (upper_bound(aov(a),x)-a.begin())
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1;
        vi aa;
        rep(i,3)
        {
            vp(aa,x);
        }
        sort(all(aa));
        int a=aa[0],b=aa[1],c=aa[2];
        s=0;
        x=b-a;
        s+=(x/2);
        a+=((x/2) *2);
        if(x%2) a++,c++,s++;
        s+=c-a;
        cout<<s<<en;
}



Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	ll a[N];

	/*
	ll min = MOD;
	ll max = -MOD;

	rep(i, N)
	{
		cin >> a[i];
		if (a[i] - i > max)
		{
			max = a[i] - i;
		}

		if (a[i]-i < min)
		{
			min = a[i] - i;
		}
	}

	ll min_total;

	for(int b = min; b <= max; b++)
	{
		ll total = 0;

		rep(i, N)
		{
			total += abs(a[i]-b-i);
		}

		if (total < min_total)
		{
			min_total = total;
		}
	}

	cout << min_total << endl;
	*/
	ll b[N];
	rep(i, N)
	{
		cin >> a[i];
		b[i] = a[i] - i - 1;
	}
	
	sort(b, b+N);

	if (N & 0x01)
	{
		ll bb = b[N / 2];
		ll total = 0;

		rep(i, N)
		{
			total += abs(a[i]- bb - i - 1);
		}

		cout << total << endl;
	}
	else
	{
		ll bbl = b[N / 2 - 1];
		ll bbr = b[N / 2 ];
		ll l_total = 0;
		ll r_total = 0;

		rep(i, N)
		{
			l_total += abs(a[i]- bbl - i - 1);
		}

		rep(i, N)
		{
			r_total += abs(a[i]- bbr - i - 1);
		}

		cout << ((l_total < r_total) ? l_total : r_total) << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {

    private static Map<Integer, Integer> m_mapBossId = new LinkedHashMap<Integer, Integer>();

    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        final int iEmployeeNum = Integer.parseInt(sc.next());
        initBossId(iEmployeeNum);

        // 社員番号1が固定でいるため。
        for (int i = 1; i <= iEmployeeNum - 1; i++) {
            final int iBossId = Integer.parseInt(sc.next());
            int iSub = m_mapBossId.get(iBossId);
            iSub++;
            m_mapBossId.put(iBossId, iSub);
        }
        output();
    }

    private static void initBossId(final int iEmploy) {
        for (int id = 1; id <= iEmploy; id++) {
            m_mapBossId.put(id, 0);
        }
    }

    private static void output() {
        for (Entry entry : m_mapBossId.entrySet()) {
            System.out.println(entry.getValue());
        }
    }
}


Measured memory_bytes: 73228
#include <stdio.h>
 
int main(void){
 
  char date[10];
  
  scanf("%s",date);
  
  if(date[5] == '1')
    printf("TBD");
  
  if(date[5] == '0'){
    if(date[6] == '1')
      printf("Heisei");
    else if(date[6] == '2')
      printf("Heisei");
    else if(date[6] == '3')
      printf("Heisei");
    else if(date[6] == '4')
      printf("Heisei");
       
    else
    printf("TBD");
  }
  
 
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    int h = 0,u = 1;
    int ok = 1;
    REP(i,S.size()){
        if(h == 0 &&u == 1&& S[i] == 'h'){
            h = 1;
            u = 0;
        }else if(u == 0 && h == 1&&S[i] == 'i'){
            u = 1;
            h = 0;
        }else{
            ok = 0;
        }
    }
    cout << (ok == 1 && u == 1? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256