akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
ll s[100005], t[100005];
int main() {
  int ns, nt, q;
  cin >> ns >> nt >> q;
  for (int i = 0; i < ns; i++) {
    cin >> s[i];
  }
  s[ns] = LLONG_MAX;
  for (int i = 0; i < nt; i++) {
    cin >> t[i];
  }
  t[nt] = LLONG_MAX;
  while (q--) {
    ll trg;
    cin >> trg;
    // case 1
    int los = -1, lot = -1, his = -1, hit = -1;
    // find los
    int lo = 0, hi = ns, mid;
    while (lo <= hi) {
      mid = (lo+hi)/2;
      if (s[mid] > trg) {
        los = mid;
        hi = mid-1;
      } else lo = mid+1;
    }
    los--;
    // find lot
    lo = 0, hi = nt;
    while (lo <= hi) {
      mid = (lo+hi)/2;
      if (t[mid] > trg) {
        lot = mid;
        hi = mid-1;
      } else lo = mid+1;
    }
    lot--;
    // find his
    lo = 0, hi = ns-1;
    while (lo <= hi) {
      mid = (lo+hi)/2;
      if (s[mid] >= trg) {
        his = mid;
        hi = mid-1;
      } else lo = mid+1;
    }
    // find hit
    lo = 0, hi = nt-1;
    while (lo <= hi) {
      mid = (lo+hi)/2;
      if (t[mid] >= trg) {
        hit = mid;
        hi = mid-1;
      } else lo = mid+1;
    }
    
    ll ans = LLONG_MAX;
    // if (trg == 899) {
    //   cout << trg << " " << s[los] << " " << t[hit] << el;
    //   cout << los << el;
    // }
    if (los != -1 && lot != -1) ans = min(ans, max(trg-s[los], trg-t[lot]));
    if (his != -1 && hit != -1) ans = min(ans, max(s[his]-trg, t[hit]-trg));
    if (los != -1 && hit != -1) ans = min(ans, 2*min(trg-s[los], t[hit]-trg) + max(trg-s[los], t[hit]-trg));
    if (lot != -1 && his != -1) ans = min(ans, 2*min(trg-t[lot], s[his]-trg) + max(trg-t[lot], s[his]-trg));
    cout << ans << el;
  }
  return 0;
}

Measured memory_bytes: 2816
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod7=1000000007LL;
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add(LL _x, LL _y, LL _mod=mod7){
  _x+=_y;
  return _x>=_mod ? _x-_mod : _x;
}
inline LL sub(LL _x, LL _y, LL _mod=mod7){
  _x-=_y;
  return _x<0 ? _x+_mod : _x;
}
inline LL mul(LL _x, LL _y ,LL _mod=mod7){
  _x*=_y;
  return _x>=_mod ? _x%_mod : _x;
}
LL mypow(LL _a, LL _x, LL _mod){
  if(_x == 0) return 1LL;
  LL _ret = mypow(mul(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=mul(_ret, _a, _mod);
  return _ret;
}
LL mymul(LL _a, LL _x, LL _mod){
  if(_x == 0) return 0LL;
  LL _ret = mymul(add(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=add(_ret, _a, _mod);
  return _ret;
}
void sleep(double sec = 1021){
  clock_t s = clock();
  while(clock() - s < CLOCKS_PER_SEC * sec);
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
void build(){

}
string s;
int k;
void init(){
  cin>>s>>k;
}
void solve(){
  vector<string> v;
  int len=s.length();
  for(int i=0; i<len; i++)
    for(int j=1; j<=5; j++)
      v.push_back(s.substr(i, j));
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end())-v.begin());
  cout<<v[k-1]<<endl;
}
int main(){
  build();
  //__ = getint();
  while(__ --){
    init();
    solve();
  }
}


Measured memory_bytes: 1660
mod = 10**9+7
mod2 = 998244353
rng = 200001
fctr = [1]
finv = [1]
for i in range(1,rng):
    fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
    finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
    if n<0 or k<0:
        return 0
    else:
        return fctr[n]*finv[n-k]*finv[k]%mod
h,w,a,b = map(int, input().split(' '))
ans = cmb(h+w-2,h-1)
x = h-a+b-1
for i in range(1,min(a,b)+1):
    ans = (ans-(cmb(x,b-i)*cmb(h+w-2-x,w-b+i-1))%mod)%mod
print(ans)

Measured memory_bytes: 55664
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1

a,b,c,d,e,f = list(map(int, input().split()))

waVa = maxValue(a*100,b*100,f)
suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
maxR = 0

anw = waVa
ans = suVa

while 1:
	waVa = maxValue(a*100,b*100,waVa-1)
	suVa = maxValue(c,d,min(f-waVa,waVa*e//100))
	if waVa == 0:
		break
	if maxR<100*suVa/(suVa+waVa):
		maxR = 100*suVa/(suVa+waVa)
		anw = waVa
		ans = suVa

print(anw+ans,ans)

Measured memory_bytes: 40176
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
long k;

int main(){
    scanf("%ld%ld", &n, &k);
    long ans = 0;
    for(int i = 0; i < n; i++){
        long a;
        scanf("%ld", &a);
        if(a >= k){
            ans++;
        }
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 256
if __name__ == '__main__':
	sx, sy, tx, ty = map(int, input().split())
	u1 = ty - sy
	r2 = tx - sx

	root = 'U' * u1 + 'R' * r2 + 'D' * u1 + 'L' * (r2+1)
	root2 = 'U' * (u1+1) + 'R' * (r2+1) + 'D' + 'R' + 'D' * (u1+1) + 'L' * (r2+1) + 'U'
	print(root + root2)

Measured memory_bytes: 3060
import sys

n = int(raw_input())
s = raw_input()
s += s[0]

first = ['SS', 'SW', 'WS', 'WW']

for f in first:
    ans = f
    for i in [i+1 for i in range(n)]:
        if ans[-1] == 'S':
            if ans[-2] == 'S':
                if s[i] == 'o':
                    ans += 'S'
                else:
                    ans += 'W'
            else:
                if s[i] == 'o':
                    ans += 'W'
                else:
                    ans += 'S'
        else:
            if ans[-2] == 'S':
                if s[i] == 'o':
                    ans += 'W'
                else:
                    ans += 'S'
            else:
                if s[i] == 'o':
                    ans += 'S'
                else:
                    ans += 'W'
    if ans[0] == ans[-2] and ans[1] == ans[-1]:
        print ans[0:n]
        sys.exit(0)

print -1


Measured memory_bytes: 9160
X, N = [int(v) for v in input().strip().split(" ")]
ps = input().strip()

if str(X) not in ps:
    print(X)
else:
    ps = [int(v) for v in ps.split(" ")]
    ps = sorted(ps)

    pointer = None
    for i in range(len(ps)):
        if ps[i] == X:
            pointer = i

    pre = X
    left_best = ps[0] - 1
    for i in range(pointer - 1, -1, -1):
        now = ps[i]
        if pre - now > 1:
            left_best = pre - 1
            break
        else:
            pre = now

    pre = X
    right_best = ps[-1] + 1
    for i in range(pointer, len(ps)):
        now = ps[i]
        if now - pre > 1:
            right_best = pre + 1
            break
        else:
            pre = now

    if abs(left_best - X) <= abs(right_best - X):
        print(left_best)
    else:
        print(right_best)

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
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;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int S;
  cin >> S;
  int f = S / 100;
  int b = S % 100;
  bool yymm = true;
  bool mmyy = true;
  if(b == 0) {
    yymm = false;
  }
  
  if(f == 0) {
    mmyy = false;
  }

  if(b < 1 || b > 12) {
    yymm = false;
  }

  if(f < 1 || f > 12) {
    mmyy = false;
  }

  if(mmyy && yymm) {
    cout << "AMBIGUOUS" << endl;
  } else if(!mmyy && !yymm) {
    cout << "NA" << endl;
  } else if(mmyy) {
    cout << "MMYY" << endl;
  } else {
    cout << "YYMM" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long lcm(long long a,long long b)
{
	long long t=0,x=0;
	if(a<b)
	{
		t=a;a=b;b=t;
	}
	for(int i=1;i<=a;i++)
	{
		if((a*i)%b==0)
		{
			x=a*i;
			break;
		}
	}
	return x;
}

long long n,x,y,t;
int main()
{
	scanf("%lld%lld",&n,&x);
	n--;
	while(n--)
	{
		scanf("%lld",&y);
		x=lcm(x,y);
	}
	printf("%lld\n",x);
}

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

const int Maxn = 305;
const int mod = 998244353;

string S;
bool pos[Maxn][Maxn][Maxn];
int dp[Maxn][Maxn][Maxn];
int res;

int main()
{
    cin >> S;
    pos[0][0][0] = true;
    for (int i = 0; i <= S.length(); i++)
        for (int a = Maxn - 1; a >= 0; a--)
            for (int b = Maxn - 1; b >= 0; b--) if (pos[i][a][b]) {
                if (a + b >= 2) {
                    if (a > 0) pos[i][a - 1][b] = true;
                    if (b > 0) pos[i][a][b - 1] = true;
                }
                if (i < S.length()) {
                    pos[i + 1][a][b] = true;
                    if (a > 0) pos[i + 1][a - 1 + (S[i] == '0')][b + (S[i] == '1')] = true;
                    if (b > 0) pos[i + 1][a + (S[i] == '0')][b - 1 + (S[i] == '1')] = true;
                }
                if (i + 1 < S.length()) {
                    pos[i + 2][a + (S[i] == '0')][b + (S[i] == '1')] = true;
                    pos[i + 2][a + (S[i + 1] == '0')][b + (S[i + 1] == '1')] = true;
                }
            }
    dp[S.length()][0][0] = 1;
    for (int i = S.length(); i > 0; i--)
        for (int a = 0; a < Maxn; a++)
            for (int b = 0; b < Maxn; b++) if (dp[i][a][b]) {
                if (pos[i][a][b]) res = (res + dp[i][a][b]) % mod;
                if (S[i - 1] == '0') dp[i - 1][a][b] = (dp[i - 1][a][b] + dp[i][a][b]) % mod;
                else if (a + 1 < Maxn) dp[i][a + 1][b] = (dp[i][a + 1][b] + dp[i][a][b]) % mod;
                if (S[i - 1] == '1') dp[i - 1][a][b] = (dp[i - 1][a][b] + dp[i][a][b]) % mod;
                else if (b + 1 < Maxn) dp[i][a][b + 1] = (dp[i][a][b + 1] + dp[i][a][b]) % mod;
            }
    printf("%d\n", res);
    return 0;
}


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

int a[100000];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int v = 0;
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (v > a[i] + 1) {
			flag = false;
			break;
		}
		v = max(v, a[i]);

	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 640
import Control.Monad

main = do
  (n:x:xs) <- map read . words <$> getLine
  ns <- forM [1..n] $ \t -> do
    read <$> getLine
  putStrLn . show $ solve x ns

solve :: Int -> [Int] -> Int
solve x ns = (length ns) + (x - (sum ns)) `div` (minimum ns)

Measured memory_bytes: 892
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[20];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int row=0;
		int col=0;
		int dir=0;
		while(1){
			scanf("%s",str);
			if(str[0]=='S')break;
			if(str[0]=='F'){
				int c;scanf("%d",&c);
				for(int i=0;i<c;i++){
					row+=dx[dir];
					if(row<0)row=0;
					if(row>=a)row=a-1;
					col+=dy[dir];
					if(col<0)col=0;
					if(col>=b)col=b-1;
				}
			}
			if(str[0]=='B'){
				int c;scanf("%d",&c);
				for(int i=0;i<c;i++){
					row-=dx[dir];
					if(row<0)row=0;
					if(row>=a)row=a-1;
					col-=dy[dir];
					if(col<0)col=0;
					if(col>=b)col=b-1;
				}
			}
			if(str[0]=='L')dir=(dir+3)%4;
			if(str[0]=='R')dir=(dir+1)%4;
		}
		printf("%d %d\n",row+1,col+1);
	}
}

Measured memory_bytes: 1032
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int union_find[200000];
int union_search(int now) {
	if (union_find[now] == now) return now;
	return union_find[now] = union_search(union_find[now]);
}
int union_merge(int a, int b) {
	a = union_search(a);
	b = union_search(b);
	union_find[a] = b;
	return 0;
}
long long cnt[200000];
set<int> gogo[200000];
int main() {

	int n;
	cin >> n;
	REP(i, 200000) {
		union_find[i] = i;
	}
	vector<pair<int, int>> inputs;
	REP(i,n){
		int a, b;
		cin >> a >> b;
		inputs.push_back(make_pair(a, b));
	}
	sort(inputs.begin(), inputs.end());
	for (int i = 1; i < inputs.size(); ++i) {
		if (inputs[i].first == inputs[i - 1].first) {
			union_merge(inputs[i].second, inputs[i - 1].second);
		}
	}
	for (int i = 0; i < inputs.size(); ++i) {
		gogo[union_search(inputs[i].second)].insert(inputs[i].first);
	}
	for (int i = 1; i < 200000; ++i) {
		cnt[union_search(i)]++;
	}
	long long ans = 0;
	for (int i = 1; i < 200000; ++i) {
		long long pre_ans = gogo[i].size();
		pre_ans *= cnt[i];
		ans += pre_ans;
	}
	cout << ans-n << endl;
}

Measured memory_bytes: 10356
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    ll m = n;
    vector<int> pf;
    for(int i = 2; i*i <= n; ++i) {
        if(n % i == 0){
            while(n % i == 0) {
                n /= i;
                pf.push_back(i);
            }
        }
    }
    if(n!=1) pf.push_back(n);
    cout << m << ':';
    REP(i,pf.size()) cout << " " << pf[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int n,d;
  cin>>d>>n;
  int x;
  if(d==0) x =1;
  else if(d==1) x=100;
  else if(d==2) x=10000;
  if(n==100){
    if(x==1) {cout<<101;return 0;}
    else if(x==100){cout<<10100;return 0;}
    else if(x==10000){cout<<1010000;return 0;}
  }else{
    x*=n;
  }
  cout<<x<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef unsigned long long ull;
typedef pair<ull,int> pi;
ull tmp,sum=0,tmp2;
pi s[100005];
int tmp1,n,m;
priority_queue< int , vector<int> , greater<int> > q;
int main()
{
    cin>>n>>m;
    for (int i=1;i<=n;++i)
    {
        cin>>tmp;
        q.push(tmp);
    }
    for (int j=1;j<=m;++j)
        cin>>s[j].fi>>s[j].se;
    sort(s+1,s+m+1);
    for (int i=m;i>0;--i)
    {
        tmp1=s[i].fi; tmp2=s[i].se;
        while (tmp1>0&&tmp2>q.top())
        {
            q.pop();
            q.push(tmp2);
            --tmp1;
        }
    }
    for (int i=1;i<=n;++i)
    {
        sum+=q.top();
        q.pop();
    }
    cout<<sum;
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
   string s;
   cin >> s;
   if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
   }
   else {
    cout << "No" << endl;
   }
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void){

    
    int n;
    cin>>n;
    vi l(2*n);
    rep(i,2*n)cin>>l[i];
    Sort(l);
    int ans=0;
    rep(i,2*n){
        ans+=l[i];
        i++;
    }
    fin(ans);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;


     signed main(){
         cout << std::fixed << std::setprecision(15);
int n,k,c;
cin>>n>>k>>c;
string s;
cin>>s;
if(n==1){
     cout<<1<<endl;
     return 0;
}
int p=0;
int t[n]={},t2[n]={};
while(p<n){
     while(p<n&&s[p]=='x')p++;
     if(p<n){
          t[p]=1;
          p+=c+1;
     }
}
p=n-1;
while(p>=0){
     while(p>=0&&s[p]=='x')p--;
     if(p>=0){
          t2[p]=1;
          p-=c+1;
     }
}
for(int i=1;i<n;i++)t[i]+=t[i-1];
for(int i=n-2;i>=0;i--)t2[i]+=t2[i+1];
if(t2[1]<k)cout<<1<<endl;
for(int i=1;i<n-1;i++)if(t2[i+1]+t[i-1]<k)cout<<i+1<<endl;
if(t[n-2]<k)cout<<n<<endl;
     }

 


 






    





      

        


Measured memory_bytes: 6876
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


A, B, C, D = na()

mod = 998244353

dp = [[0] * (D + 1) for _ in range(C + 1)]

dp[A][B] = 1
for a in range(A + 1, C + 1):
    dp[a][B] = (dp[a - 1][B] * B) % mod

for b in range(B + 1, D + 1):
    dp[A][b] = (dp[A][b - 1] * A) % mod

for a in range(A + 1, C + 1):
    for b in range(B + 1, D + 1):
        dp[a][b] = (dp[a - 1][b] * b + dp[a][b - 1] * a -
                    dp[a - 1][b - 1] * (a - 1) * (b - 1)) % mod

print(dp[C][D])


Measured memory_bytes: 136724
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

		int R;
		cin >> R;
		cout << R / 3 << endl;
	
}

Measured memory_bytes: 256
import numpy

A = list(map(int, input().split()))

K = A[1]
N = A[0]

P = list(map(float, input().split()))

EP = list(map(lambda x: (1+x)/2, P))

cumEP = list(numpy.cumsum(EP))

new_list = []

if N>K:
    for val in range(N-K):
        new_list.append(cumEP[val+K]-cumEP[val])
    print(max(new_list))
else:
    print(sum(EP))


Measured memory_bytes: 40392
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

    string s;
    cin >> s;

    for(int i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
        if(s[i]==s[i+2]){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll n;

struct Rect {
	ll left;
	ll right;
	ll top;
	ll bottom;
};

void dfs(P p, vector<vector<bitset<50>>>& stat, vector<vector<bool>>& used, bitset<50>& tgt) {
	used[p.first][p.second]=true;
	ll dx[]={1,0,-1,0};
	ll dy[]={0,1,0,-1};
	REP(i,4) {
		ll nx=p.first+dx[i];
		ll ny=p.second+dy[i];
		if(nx>=0&&nx<used.size()&&ny>=0&&ny<used[0].size()&&!used[nx][ny]
		   &&stat[nx][ny].to_ullong()==tgt.to_ullong()) dfs(P(nx,ny),stat,used,tgt);
	}
}

ll solve() {
	vector<Rect> rec(n);
	vector<ll> x;
	vector<ll> y;
	REP(i,n) {
		ll l,t,r,b;
		cin>>l>>t>>r>>b;
		x.pb(l); x.pb(r);
		y.pb(t); y.pb(b);
		rec[i]={l,r,t,b};
	}
	x.pb(-1); x.pb(1000001);
	y.pb(-1); y.pb(1000001);
	UNIQUE(x);
	UNIQUE(y);
	REP(i,n) {
		rec[i].left=find(ALL(x),rec[i].left)-x.begin();
		rec[i].right=find(ALL(x),rec[i].right)-x.begin();
		rec[i].top=find(ALL(y),rec[i].top)-y.begin();
		rec[i].bottom=find(ALL(y),rec[i].bottom)-y.begin();
	}
	vector<vector<bitset<50>>> stat(x.size()-1,vector<bitset<50>>(y.size()-1,bitset<50>(0)));
	REP(k,n) {
		FOR(i,rec[k].left,rec[k].right) {
			FOR(j,rec[k].bottom,rec[k].top) stat[i][j][k]=1;
		}
	}
	vector<vector<bool>> used(x.size()-1,vector<bool>(y.size()-1,false));
	ll ret=0;
	REP(i,x.size()-1) REP(j,y.size()-1) {
		if(!used[i][j]) {
			ret++;
			dfs(P(i,j),stat,used,stat[i][j]);
		}
	}
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin>>n;
		if(n==0) break;
		cout<<solve()<<endl;
	}
}



Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005,p=1000000007,INV2=(p+1)/2;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,a[N],b[N],las[N],h[N],f[N],g[N],invf[N],invg[N],ans;
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
struct BIT{
	int f[N];
	void clear(){memset(f,0,sizeof(f));}
	int lowbit(int x){return x&(-x);}
	void add(int x,int val){for (;x<=n;x+=lowbit(x)) check(f[x],val);}
	int que(int x){
		int t=0;
		for (;x;x-=lowbit(x)) check(t,f[x]);
		return t;
	}
}s,cnt;
int main(){
	n=read();
	for (int i=1;i<=n;i++) a[i]=read(),h[a[i]]++;
	for (int i=n;i;i--) h[i]+=h[i+1];
	f[0]=g[0]=1;
	for (int i=1;i<=n;i++){
		b[i]=h[i]-(n-i);
		f[i]=(ll)f[i-1]*b[i]%p;
		las[i]=(b[i]==1) ? i : las[i-1];
		g[i]=(ll)g[i-1]*max(1,b[i]-1)%p;
	}
	if (!f[n]){puts("0");return 0;}
	invf[n]=qpow(f[n],p-2);
	invg[n]=qpow(g[n],p-2);
	for (int i=n;i;i--) invf[i-1]=(ll)invf[i]*b[i]%p,invg[i-1]=(ll)invg[i]*max(b[i]-1,1)%p;
	for (int i=1;i<=n;i++){
		int t=(ll)f[n]*invf[a[i]]%p*g[a[i]]%p*(s.que(a[i])-s.que(las[a[i]])+p)%p*INV2%p;
		check(ans,t);
		s.add(a[i],(ll)f[a[i]]*invg[a[i]]%p);
	}
	s.clear();
	for (int i=n;i;i--){
		int t=(ll)f[n]*cnt.que(a[i]-1)%p;
		if (las[a[i]]!=a[i]) check(t,p-(ll)f[n]*invf[a[i]]%p*g[a[i]]%p*(s.que(a[i]-1)-s.que(las[a[i]])+p)%p*INV2%p);
		check(ans,t);
		s.add(a[i],(ll)f[a[i]]*invg[a[i]]%p);cnt.add(a[i],1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8064
n, x = map(int, input().split())
bli = []
pli = []
z = 2 ** (n + 2) - 3
count = 0
for i in range(n + 1):
    y = 2 ** (i + 2) - 3
    bli.append(y // 2 + 1)
    pli.append(y // 2)
for i in range(n, -1, -1):
    if x == 0:
        break
    elif i == 0:
        count += 1
        break
    elif x > (2 ** (i + 2) - 3) // 2 + 1:
        count += bli[i - 1] + 1
        x -= (2 ** (i + 2) - 3) // 2
    elif x == (2 ** (i + 2) - 3) // 2 + 1:
        count += bli[i - 1] + 1
        break
    x -= 1
print(count)

Measured memory_bytes: 3064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int X = in.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = in.nextInt();
            }

            int jumpNum = 1;
            int distance = 0;
            for (int i = 0; i < N; i++) {
                distance += L[i];
                if (distance <= X) {
                    jumpNum++;
                } else {
                    break;
                }
            }
            out.println(jumpNum);
        }

    }
}



Measured memory_bytes: 23508
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))

using namespace std;

int main(void){
    int n;
    cin >> n;
    if(n <= 599){
        cout << "8" << endl;
    } else if(n <= 799){
        cout << "7" << endl;
    } else if(n <= 999){
        cout << "6" << endl;
    } else if(n <= 1199){
        cout << "5" << endl;
    } else if(n <= 1399){
        cout << "4" << endl;
    } else if(n <= 1599){
        cout << "3" << endl;
    } else if(n <= 1799){
        cout << "2" << endl;
    } else {
        cout << "1" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

string string_add(string a, string b) 
{

	string new_str = "";
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	string long_s;
	string short_s;
	if (a.size() >= b.size()) {
		long_s = a;
		short_s = b;
	}
	else {
		long_s = b;
		short_s = a;
	}
	int carry = 0;
	int dif = long_s.size() - short_s.size();
	for (int i = 0; i < dif; i++)
			short_s += "0";
	for(int i=0;i<long_s.size();i++)
	{
		int hab = stoi(long_s.substr(i, 1)) + stoi(short_s.substr(i, 1)) + carry;
		if (hab > 9) {
			carry = 1;
			hab -= 10;
		}
		else carry = 0;

		new_str += to_string(hab);
	}
	if (carry != 0) new_str += to_string(carry);
	reverse(new_str.begin(), new_str.end());
	return new_str;
}


string string_multi(string a, string b) 
{
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	string acc = "0";
	for (int i = 0; i < a.size();i++)
	{
		int carry = 0;
		string gob = "";
		for(int j=0;j<b.size();j++)
		{
			int gob_1 = stoi(a.substr(i, 1)) * stoi(b.substr(j, 1)) + carry;
			gob += to_string(gob_1 % 10);
			carry = gob_1 / 10;
		}
		if (carry != 0) gob += to_string(carry);
		for(int j=0;j<i;j++)
			gob = "0" + gob;
		reverse(gob.begin(), gob.end());
		acc = string_add(acc, gob);
	}
	return acc;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	string now = "1", maxN = "1";
	for (int i = 0; i < 18; i++)maxN += "0";
	cin >> N;
	vector<string>v(N);
	for (auto &i : v)
	{
		cin >> i;
		if (i == "0")
		{
			cout << 0;
			return 0;
		}
	}

	for (auto tmp : v)
	{
		now = string_multi(now, tmp);
		if (now.size() >= 19 && now != maxN)
		{
			cout << -1;
			return 0;
		}
	}

	cout << now;

}


Measured memory_bytes: 10956
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    int a, b, C;
    double c, S, L, h;

    cin >> a >> b >> C;

    S = 0.5 * a * b * sin(C * M_PI / 180);
    c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C * M_PI / 180));
    L = a + b + c;
    h = S * 2 / a;


    cout << fixed << setprecision(5);
    cout << S << "\n";
    cout << L << "\n";
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 3444
val aToZ = ('a'..'z')
val countMap  = HashMap<Char, Int>().withDefault { 0 }

fun main(args: Array<String>) {
    while (true){
        val chars = readLine()?.map { when{ it.isUpperCase() -> it.toLowerCase() else -> it} } ?: break
        if (chars.isEmpty()) break
        chars.forEach {
            val count = countMap.getValue(it)
            countMap[it] = count + 1
        }
    }
    aToZ.forEach {
        println("$it : ${countMap.getValue(it)}")
    }
}


Measured memory_bytes: 28348
/* 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define INF 1000000000
#define EPS 1e-20
#define pb push_back
constexpr double pi = 3.14159265358979323846;
/* 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ 乁(ᴗ ͜ʖ ᴗ)ㄏ */

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    vector<int> v(5);
    int lst(INT_MAX), val(0);
    for (int i(0); i < 5; ++i) {
        cin >> v[i];
        if (v[i]%10 < lst && v[i]%10 != 0) {
            lst = v[i] % 10;
            val = v[i];
        }
    }
    ll sum(0);
    bool done = false;
    for (int i(0); i < 5; ++i) {
        if (v[i] == val && done == false) {
             done = true;
            continue;
        }
        if (v[i]%10 != 0)
            sum += v[i] + 10 - v[i]%10;
        else sum += v[i];
    }
    cout << sum + val;
    cout << "\n"; /* new-line for VS code */
    return 0;
}

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

int main() {
  int N,i;
  cin >> N;
  int h[100000];
  int d[100000];
  
  for(i=0;i<N;i++)
    cin >> h[i];
  
  d[0] = 0;
  d[1] = abs(h[1] - h[0]);
  for (i=2;i<N;i++)
    d[i] = min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));
  cout << d[N-1] << endl;
  return 0;
}

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

struct Graph
{
    int N;
    struct Edge { int source, target, weight; };
    vector<vector<Edge>> adjacency_list;

    Graph(int N) : N(N), adjacency_list(N) {}

    int add_vertex()
    {
        adjacency_list.push_back({});
        return N++;
    }

    void add_edge(int a, int b, int w) { adjacency_list[a].push_back({a, b, w}); }

    int distance(const int start, const int finish) const
    {
        auto seen = vector<bool>(N);
        auto distances = vector<int>(N, -1);

        struct State { int v, distance; };
        auto deque = std::deque<State>({{start, 0}});

        while (!deque.empty())
        {
            auto s = deque.front(); deque.pop_front();
            if (seen[s.v]) continue;
            seen[s.v] = true;
            distances[s.v] = s.distance;

            for (const auto e : adjacency_list[s.v])
            {
                const auto next = State{e.target, s.distance + e.weight};
                if (e.weight == 0) deque.push_front(next);
                else deque.push_back(next);
            }
        }

        return distances[finish];
    }
};

struct Subway { int source, target, company; };

int solve(const int N, const vector<Subway>& subways)
{
    auto graph = Graph(N);

    auto ids = map<pair<int, int>, int>();
    const auto id = [&](int station, int company)
    {
        if (ids.count({station, company})) return ids[{station, company}];
        else
        {
            const auto substation = ids[{station, company}] = graph.add_vertex();
            graph.add_edge(station, substation, 1);
            graph.add_edge(substation, station, 0);
            return substation;
        }
    };

    for (const auto s : subways)
    {
        const auto v = id(s.source, s.company), w = id(s.target, s.company);
        graph.add_edge(v, w, 0);
        graph.add_edge(w, v, 0);
    }

    return graph.distance(0, N-1);
}

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

    auto subways = vector<Subway>();
    for (auto i = 0; i < M; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        subways.push_back({a, b, c});
    }

    cout << solve(N, subways) << endl;
}


Measured memory_bytes: 62680
import glob

#IS_TEST = 1

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\136\\B'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            return self.problem[self.index]
            self.index += 1
        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                self.initialize(path)
                self.resolve()
        except NameError:
            self.resolve()


class B(Common):

    def resolve(self):

        n = int(self.input_data())
        digits = len(str(n))
        result = 0
        if digits % 2 != 0:
            result += n - (10 ** (digits-1)) + 1
        for i in range(1, digits):
            if i % 2 == 0:
                continue
            else:
                result += 10 ** (i-1) * 9

        print(str(result))



solver = B(REL_PATH)
solver.exec_resolve()

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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		//?´???°?±???????
		boolean[] search = new boolean[10000000];
        Arrays.fill(search, true);
        for(int i = 2; i < 10000000; i++){
            // ?´???°????????°?????????????????????
            if(!search[i]){
                continue;
            }

            // ?´???°????????°?????????????????¨???
            for(int j = i * 2; j < 10000000; j += i){
                search[j] = false;
            }
        }

        while(true) {
			int num = sc.nextInt();
			int sum = 0; //????¨????????´???¨
			int count = 0;
			if(num == 0) {
				break;
			}

			for(int i = 2; count < num; i++) {
				if(search[i]){
	                sum += i;
	                count++;
	            }
			}
			System.out.println(sum);
		}
	}

}

Measured memory_bytes: 36784
from collections import Counter
N, P = map(int, input().split())

def prime_factorize(N):
    prime_list = []
    while N % 2 == 0:
        prime_list.append(2)
        N //= 2
    f = 3
    while f**2 <= N:
        if N % f == 0:
            prime_list.append(f)
            N //= f
        else:
            f += 2
    if N != 1:
        prime_list.append(N)
    return prime_list

res = prime_factorize(P)
l = Counter(res).items()
ans = 1
for l in Counter(res).items():
    ans *= l[0]**(l[1]//N)
print(ans)

Measured memory_bytes: 66180
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int k,a,b;
    cin>>k>>a>>b;
    FOR(i,a,b+1){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}


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

int main()
{
    string s, p, doubleS;
    cin >> s >> p;
    doubleS = s + s;
    if (doubleS.find(p) != string::npos)
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cctype>
#include <iterator>
using namespace std;

vector<string> parseL(string s) {
    const int L = s.length();
    int i = 0, j = 0;
    vector<string> res;
    while(true) {
        if(L <= j) break;
        j++;
        while(j < L && islower(s[j])) j++;
        res.push_back(s.substr(i, j - i));
        i = j;
    }
    return res;
}

vector<string> parseU(string s) {
    s[0] = tolower(s[0]);
    vector<string> res = parseL(s);
    res[0][0] = toupper(res[0][0]);
    return res;
}

vector<string> parseD(string s) {
    const int L = s.length();
    int i = 0;
    vector<string> res;
    while(true) {
        string t;
        while(i < L && s[i] != '_') {
            t.push_back(s[i]);
            i++;
        }
        res.push_back(t);
        if(i == L) break;
        i++;
    }
    return res;
}

void tr(vector<string> vec) {
    copy(vec.begin(), vec.end(), ostream_iterator<string>(cerr, "_"));
}

int main() {
    for(string text, type; cin >> text >> type, type != "X"; ) {
        vector<string> vec;
        if(find(text.begin(), text.end(), '_') != text.end()) {
            vec = parseD(text);
        }
        else if(isupper(text[0])) {
            vec = parseU(text);
        }
        else {
            vec = parseL(text);
        }

        if(type == "L") {
            for(int j = 0; j < (int)vec[0].size(); j++) cout << (char)tolower(vec[0][j]);
            for(int i = 1; i < (int)vec.size(); i++) {
                cout << (char)toupper(vec[i][0]);
                for(int j = 1; j < (int)vec[i].size(); j++) {
                    cout << (char)tolower(vec[i][j]);
                }
            }
        }
        else if(type == "U") {
            for(int i = 0; i < (int)vec.size(); i++) {
                cout << (char)toupper(vec[i][0]);
                for(int j = 1; j < (int)vec[i].size(); j++) {
                    cout << (char)tolower(vec[i][j]);
                }
            }
        }
        else {
            for(int j = 0; j < (int)vec[0].size(); j++) cout << (char)tolower(vec[0][j]);
            for(int i = 1; i < (int)vec.size(); i++) {
                cout << '_';
                for(int j = 0; j < (int)vec[i].size(); j++) {
                    cout << (char)tolower(vec[i][j]);
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vi h(n); rep(i,n) cin >> h[i];
	int ans = 0;
	int cnt = 0;
	rep2(i,1,n){
		if(h[i-1]>=h[i])cnt++;
		else cnt = 0;
		ans = max(ans,cnt);
	}
	out(ans);
}




Measured memory_bytes: 640
#include<math.h>
#include<stdio.h>

int main(void)
{
	int a, b, C;
	double csquare,Carc,c, S, L, h, pi = 3.141592654;

	scanf("%d %d %d", &a,&b,&C);
	Carc = C*pi / 180;
	csquare = (a*a) + (b*b) - (2 * a*b*cos(Carc));
	c = sqrt(csquare);
	S = (a*b*sin(Carc))/2, L = a + b + c, h = (2 * S) / a;
	printf("\n%f\n", S);
	printf("%f\n", L);
	printf("%f\n", h);

	return 0;
}


Measured memory_bytes: 2036
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] s = new String[n];
		for(int i = 0; i < n; i++){
			s[i] = sc.next();
		}
		long ans = 0;
		TreeMap<String,Integer> map = new TreeMap<String,Integer>();
		for(int i = 0; i < n; i++){
			int[] a = new int[10];
			for(int j = 0; j < 10; j++){
				a[j] = s[i].charAt(j);
			}
			Arrays.sort(a);
			String b = "";
			for(int j = 0; j < 10; j++){
				b=b + a[j];
			}
			if(map.containsKey(b)){
              map.put(b,map.get(b)+1);
              ans+=map.get(b);
			}else{
				map.put(b,0);
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 93012
N=int(input())
a=list(map(int,input().split()))
h=a[:]
cnt=0
while sum(h)!=0:
  mae=False
  for i in range(N):
    if h[i]>0:
      if mae==False:
        cnt+=1
      mae=True
      h[i]-=1
    else:
      mae=False

print(cnt)

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

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

  if (N % 2 == 0)
    cout << N << endl;
  else
    cout << 2 * N << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define ll long long
int n;
ll a[111111],b[111111],c[111111];
ll ans=0;
ll rui[3][111111];

int main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n);

	rep(i,n){
		int pos=upper_bound(b,b+n,a[i])-b;

		if(pos<n){
			rui[0][pos]++;
			rui[0][n]--;
		}
	}
	for(int i=1;i<n;i++)rui[0][i]+=rui[0][i-1];

	rep(i,n){
		int pos=upper_bound(c,c+n,b[i])-c;
		if(pos<n){
			rui[1][pos]+=rui[0][i];
			rui[1][n]-=rui[0][i];
		}
	}
	for(int i=1;i<n;i++)rui[1][i]+=rui[1][i-1];
	
	rep(i,n)ans+=rui[1][i];
	cout<<ans<<endl;
	
	
	return 0;
}


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


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

    int A,B;
    cin >> A >> B;
    int ans=0;
    int i0,i1,i3,i4;

    for(int i=A;i<=B;i++){
        string s=to_string(i);
        if(s.at(0)==s.at(4) && s.at(1)==s.at(3)) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256