akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    int a, b, c, d, e, f;
    int n = 3010;
    cin >> a >> b >> c >> d >> e >> f;
    vector<bool> makableWater(n, false);
    vector<bool> makableSugar(n, false);
    makableSugar[0] = true;
    makableWater[0] = true;
    rep(i, n)
    {
        if (i + a < n)
        {
            makableWater[i + a] = makableWater[i + a] || makableWater[i];
        }
        if (i + b < n)
        {
            makableWater[i + b] = makableWater[i + b] || makableWater[i];
        }
    }
    rep(i, n)
    {
        if (i + c < n)
        {
            makableSugar[i + c] = makableSugar[i + c] || makableSugar[i];
        }
        if (i + d < n)
        {
            makableSugar[i + d] = makableSugar[i + d] || makableSugar[i];
        }
    }
    int bestWater = 0;
    int bestSugar = 0;
    lld density = -1;
    rep(i, 1, n) rep(j, n)
    {
        if (makableWater[i] == false || makableSugar[j] == false)
            continue;
        if (100 * i + j <= f && i * e >= j)
        {
            lld tmp = ((lld)100 * j) / (100 * i + j);
            if (tmp > density)
            {
                density = tmp;
                bestWater = i * 100 + j;
                bestSugar = j;
            }
        }
    }
    cout << bestWater << " " << bestSugar << endl;
    return 0;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  long long h[n];
  for(int i=0;i<n;i++){
    long long l;
    cin>>l;
    h[i]=l;
  }
  bool a[n];
  for(int i=0;i<n;i++)a[i]=true;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    if(h[s-1]>h[t-1])a[t-1]=false;
    else if(h[s-1]<h[t-1])a[s-1]=false;
    else{
      a[t-1]=false;
      a[s-1]=false;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i])ans++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 4500
fun main(args: Array<String>) {
    abc107c()
}

fun abc107c() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val xList = readLine()!!.split(" ").map { it.toLong() }

    val moveLength = (0..n - k).map {
        val right = xList[it + k - 1]
        val left = xList[it]
        val between = Math.abs(right - left)
        Math.min(Math.abs(left) + between, Math.abs(right) + between)
    }

    val answer = moveLength.min()

    println(answer)
}


Measured memory_bytes: 56192
use std::io::Read;

pub fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut it = buf.split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut ret: usize = 0;
    let mut max_hotel: usize = 0;
    for _ in 0..n {
        let h: usize = it.next().unwrap().parse().unwrap();
        if max_hotel <= h {
            ret += 1;
            max_hotel = h;
        }
    }
    println!("{}", ret);
}



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

int main(void){
    string s, t, ss;
    bool ans = false;
    cin >> s;
    cin >> t;
    ss = s + s;
    int nagasa = s.size();
    for (int i = 0; i < nagasa; i++) {
        int itchi = 0;
        for (int j = 0; j < nagasa; j++) {
            if (ss[i + j] == t[j]) itchi++;
        }
        if (itchi == nagasa) ans = true;
    }
    if (ans) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cassert>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;


int main()
{
    cin.sync_with_stdio(0);

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int res = 0;
    if (A < K)
    {
        res += A;
        K -= A;
    }
    else
    {
        cout << K;
        return 0;
    }
    if (B < K)
    {
        K -= B;
    }
    else
    {
        cout << A;
        return 0;
    }

    assert(K <= C);
    cout << res - K;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        int target = 1;

        for (int i = 0; i < N; i++) {
            if (a[i] != target) {
                ans++;
                continue;
            }
            if (a[i] == target) {
                target++;
            }
        }
        if (target == 1) {
            System.out.println(-1);
            return;
        }
        System.out.println(ans);
    }

}

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

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >>tx >>ty;
    int dx = tx-sx;
    int dy = ty-sy;
    cout << string(dy,'U') << string(dx,'R');
    cout << string(dy,'D') << string(dx,'L');
    cout << string(1,'L') <<string(1+dy,'U') << string(1+dx,'R') << string(1,'D');
    cout << string(1,'R') << string(1+dy,'D') <<string(1+dx,'L') << string(1,'U') << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int N, K;
vector<VI> G(10000);
int dist[2010];

void dfs(int v, int p, int cur) {
	dist[v] = cur;
	for (int nv : G[v]) {
		if (nv == p)continue;
		dfs(nv, v, cur + 1);
	}
}


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


	cin >> N >> K;

	REP(i, N-1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	int ans = INF;

	if (K % 2 == 0) {
		REP(i, N) {
			dfs(i, -1, 0);
			int cnt = 0;
			REP(j, N)if (dist[j] > K / 2)cnt++;
			ans = min(ans, cnt);
		}
	}
	else {
		REP(u, N) {
			for (int v : G[u]) {
				dist[v] = 0;
				dfs(u, v, 0);
				dfs(v, u, 0);
				int cnt = 0;
				REP(a, N)if (dist[a] > K / 2)cnt++;
				ans = min(ans, cnt);
			}
		}
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a[100005],sum=1,ans=0;
	cin>>n;
	for(register int i=0; i<n; i++) {
		cin>>a[i];
	}
	sort(a,a+n);
	if(n==1) {
		cout<<1<<endl;
		return 0;
	}
	for(int i=1; i<n; i++) {
		if(a[i]==a[i-1]) {
			sum++;
		} else {
			ans+=(sum%2);
			sum=1;
		}
	}
	if(sum%2){
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int H=in(),W=in(),A=in(),B=in();
	REP(i,H){
		REP(j,W){
			if((i<B && j<A) ||(i>=B && j>=A)) cout << 0;
			else cout << 1;
		}
		out();
	}
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin >> N;
	vector<string> s(N);
	vector<int64> t(N);
	string X;
	REP(i, N) cin >> s[i] >> t[i];
	cin >> X;
	int64 sum = accumulate(all(t), 0LL);
	int64 sum2 = 0;
	REP(i, s.size()) {
	  sum2 += t[i];
	  if (s[i] == X) break;
	}
	cout << sum - sum2 << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(a+1):
    for j in range(b+1):
      for k in range(c+1):
        if i*500 + j *100 + k*50 == x:
          cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
N = int(input())
a = list(map(int, input().split()))

a.sort()

import collections
c = collections.Counter(a)

ans = 0
for i in c.most_common():
    if i[0] <= i[1]:
        ans += i[1] - i[0]
    else:
        ans += i[1]

print(ans)

Measured memory_bytes: 26496
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,m;std::cin>>n>>m;
    std::map<lint,lint,std::greater<>>map;
    for(lint i=0;i<n;i++){
        lint x;std::cin>>x;
        map[x]++;
    }
    while(m--){
        lint x,y;std::cin>>x>>y;
        map[y]+=x;
    }
    lint ans=0,count=0;
    for(auto&&p:map){
        lint x,y;std::tie(x,y)=p;
        if(n<=count+y){
            ans+=(n-count)*x;
            break;
        }
        count+=y;
        ans+=x*y;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=10000;i++)
	{
		if(i*2/25==a&&i/10==b)
		{
			cout<<i;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

ll solve(vector<int> vec){
    int n=vec.size();
    int num0=0;
    rep(i,n){
        if(vec[i]==0) num0++;
    }
    int nownum=0;
    ll ans=0;
    rep(i,n){
        if(vec[i]==1){
            ans+=num0-nownum;
        }else nownum++;
    }
    return ans;
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll ans=0;
    vector<int> vec;
    rep(i,n){
        if(s[i]=='A') vec.push_back(1);
        else if(i<n-1 && s[i]=='B' && s[i+1]=='C') {
            vec.push_back(0);
            i++;
        }else{
            ans+=solve(vec);
            vec.clear();
        }
    }
    ans+=solve(vec);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2168
from collections import deque
N=int(input()) 
Graph=[[] for _ in range(N)]
for _ in range(N-1):
  u,v,w=map(int,input().split())
  Graph[u-1].append((v-1,w))
  Graph[v-1].append((u-1,w))
used=[0]*N
ans=[0]*N
used[0]=1
que=deque([0])
while que:
  node=que.popleft()
  color=ans[node]
  for point,dist in Graph[node]:
    if used[point]:
      continue;
    if dist%2==0:
      ans[point]=color
    else:
      ans[point]=color^1
    que.append(point)
    used[point]=1
print(*ans, sep='\n')

Measured memory_bytes: 41620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
typedef long long ll;
struct Point{int x,y,id;};
bool linkx(Point &p1,Point &p2){
	return p1.y==p2.y ? p1.x<p2.x : p1.y<p2.y;
}
bool linky(Point &p1,Point &p2){
	return p1.x==p2.x ? p1.y<p2.y : p1.x<p2.x;
}
typedef pair<ll,int> edge;//cost,id(<2K+2)
int xid(Point &p){return p.id*2;}
int yid(Point &p){return p.id*2+1;}

int main(void){
	int M,N,K,X,Y;
	cin>>M>>N>>K;
	vector<edge> g[2*(K+1)];
	vector<Point> vp(K+1);
	vector<ll> dp(2*(K+1));
	rep(i,K){
		cin>>X>>Y;
		vp[i]={X,Y,i};
	}
	vp[K]={M,N,K};

	//switch
	rep(i,K){
		g[xid(vp[i])].push_back({1,yid(vp[i])});
		g[yid(vp[i])].push_back({1,xid(vp[i])});
	}

	//linkx
	sort(all(vp),linkx);
	rep(i,K){
		if(vp[i].y==vp[i+1].y){
			Point p1=vp[i],p2=vp[i+1];
			int cost=abs(p1.x-p2.x);
			g[xid(p1)].push_back({cost,xid(p2)});
			g[xid(p2)].push_back({cost,xid(p1)});
		}
	}

	//linky
	sort(all(vp),linky);
	rep(i,K){
		if(vp[i].x==vp[i+1].x){
			Point p1=vp[i],p2=vp[i+1];
			int cost=abs(p1.y-p2.y);
			g[yid(p1)].push_back({cost,yid(p2)});
			g[yid(p2)].push_back({cost,yid(p1)});
		}
	}

	fill(all(dp),LLONG_MAX);
	priority_queue<edge,vector<edge>,greater<edge>> q;
	if(vp[0].x==1){
		dp[yid(vp[0])]=vp[0].y-1;
		q.push({dp[yid(vp[0])],yid(vp[0])});
	}
	
	while(q.size()){
		edge u=q.top(); q.pop();
		int id=u.second;
		if(id>=2*K){
			cout<<u.first<<endl;
			return 0;
		}
		if(dp[id] < u.first)continue;
		for(auto to:g[id]){
			if(dp[to.second] > dp[id]+to.first){
				dp[to.second] = dp[id]+to.first;
				q.push({dp[to.second],to.second});
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 51864
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 1;
	while(s.size() != 0 && ans == 1){
		if(s[s.size()-1] != 'r' && s[s.size()-1] != 'm' && s[s.size()-1] != 'e') ans = 0;
		else{ 
			if(s[s.size()-1] == 'r'){
				string s1 = "dreamer";
				string s2 = "eraser";
				if(s.size() >= 7 && s1 == s.substr(s.size()-7)) s = s.substr(0, s.size()-7);
				else if(s.size() >= 6 && s2 == s.substr(s.size()-6)) s = s.substr(0, s.size()-6);
				else ans = 0;
			}
			else if(s[s.size()-1] == 'm'){
				string s1 = "dream";
				if(s.size() >= 5 && s1 == s.substr(s.size()-5)) s = s.substr(0, s.size()-5);
				else ans = 0;
			}
			else if(s[s.size()-1] == 'e'){
				string s1 = "erase";
				if(s.size() >= 5 && s1 == s.substr(s.size()-5)) s = s.substr(0, s.size()-5);
				else ans = 0;
			}
		}
	}
	if(ans == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 596
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}


// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main(){
    int N,Q;
    string S;
    cin >> N >> Q;
    cin >> S;

    vector<int>a(S.size()+4,0);
    for(int i=0; i<S.length()-1; i++){
        if(S[i]=='A' && S[i+1]=='C'){
            a[i+1]+=a[i]+1;
        }else{
            a[i+1]=a[i];
        }
    }

    for(int i=0; i<Q; i++){
        int l,r;
        cin >> l >> r;
        cout << a[r-1]-a[l-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int sum = accumulate(a.begin(), a.end(), 0);
    int cnt = 0;
    for(auto x : a){
        if(x * 4 * m >= sum)cnt++;
    }
    if(cnt < m){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
}


Measured memory_bytes: 3600
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;

int main(){
     
    int N;
    
    cin>>N;
    cout<<800*N-200*(N/15)<<endl;
     
    return 0;
}
 

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NX = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NX[0];
            var X = NX[1];
            var LList = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var preD = 0;
            for (var i = 2; i <= N + 1; i++)
            {
                var D = preD + LList[i - 1 - 1];

                if (D > X)
                {
                    Console.WriteLine(i - 1);
                    return;
                }

                preD = D;
            }

            Console.WriteLine(N + 1);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,sum=0,temp;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	if(a.size()%2){
		for(int i=a.size()-1;i>=(a.size()/2);i--){
			sum+=a[i]*2;
		}
		sum-=a[a.size()/2];
	}
	else {
		for(int i=a.size()-1;i>=(a.size()/2);i--){
			sum+=a[i]*2;
		}
	}
	sum-=a[a.size()-1];
	cout<<sum<<endl;
}

Measured memory_bytes: 4028
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
#define YN(f) cout<<((f)?"Yes":"No")<<endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000; 

int main(){
	int n,m,a[100000],b[100000]={};
	cin>>n>>m;
	REP(i,m){
		int c,d;
		cin>>c>>d;
		b[c-1]++,b[d-1]++;
	}
	REP(i,n){
		cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int N, K;
	cin >> N >> K;
	if (K <= (N + 1) / 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
macro_rules! read_line {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let input: Vec<i32> = read_to_vec();
    let (w, h, n) = (input[0], input[1], input[2]);
    let mut input: Vec<Vec<i32>> = vec![Vec::new(); 4];
    let zero: i32 = 0;

    for _ in 0..n {
        let line: Vec<i32> = read_to_vec();
        
        match line[2] {
            a @ 1...4 => input[(a-1) as usize].push(line[(a/3) as usize]),
            _ => panic!(),
        }
    }

    let (bottom, top, left, right) =
        (input[0].iter().max().unwrap_or(&zero),
        input[1].iter().min().unwrap_or(&w),
        input[2].iter().max().unwrap_or(&zero),
        input[3].iter().min().unwrap_or(&h));

    println!("{}",
        std::cmp::max(0, top - bottom) *
        std::cmp::max(0, right - left));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; ++i){
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    auto f = factorize(g);
    cout << f.size()+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)

void Main()
{
    string s;
    cin >> s;
    int list[1000] = {0};

    rep(i, s.size())
    {
        char a = s[i];
        list[(int)a]++;
    }

    rep(i, 1000)
    {
        if (list[i] % 2 == 1)
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
	int N, max = 0;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; ++i){
		cin >> A.at(i);
	}
	sort(A.begin(),A.end());
	cout << A.back() - A.front() << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    count = 0
    for i in range(1,N):
        if A[i]<A[i-1]:
            count += A[i-1] - A[i]
            A[i] = A[i-1]
    print(count)




if __name__ == '__main__':
    main()


Measured memory_bytes: 30852
import math

def cmb(n, r,MOD=10**9+7):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) % MOD
 
    return result % MOD

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

from collections import Counter
def main():
    n,m  = map(int,input().split())
    c = Counter(prime_factorize(m))
    ans = 1
    for i in c.values():
        ans *= cmb(n+i-1,i)
        ans %= 10**9+7
    print(ans%(10**9+7))
if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
A, B, K = map(int, input().split())
for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A = A - 1
        A = int(A / 2)
        B += A

    if i % 2 == 1:
        if B % 2 == 1:
            B -= 1
        B = int(B / 2)
        A += B

print(A, B)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> G(N,vector<int>(N,0));
    rep(i,N) G[i][i]=1;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        --a,--b;
        G[a][b]=G[b][a]=1;
    }
    vector<int> color(N,0);
    queue<int> que;
    bool ok=true;
    int now=1;
    rep(i,N){
        if (color[i]==0){
            que.push(i);
            color[i]=now;
            while(!que.empty()){
                int v=que.front();
                que.pop();
                rep(nv,N){
                    if (!G[v][nv]){
                        if (color[nv]==0){
                            color[nv]=-color[v];
                            que.push(nv);
                        }
                        else if (color[nv]==color[v]) ok=false;
                    }
                }
            }
            ++now;
        }
    }
    if (!ok){
        cout << -1 << endl;
        return 0;
    }
    vector<int> cnt(now*2,0);
    rep(i,N){
        int c=color[i];
        if (c>0) ++cnt[(c-1)*2];
        else ++cnt[(-c-1)*2+1];
    }
    bitset<1000> bit(1);
    rep(i,now){
        bitset<1000> bitc=bit;
        bitc<<=cnt[2*i];
        bit<<=cnt[2*i+1];
        bit|=bitc;
    }
    int t,h;
    rep(i,N/2+1){
        if (bit.test(i)) t=i,h=N-i;
    }
    int ans=t*(t-1)/2+h*(h-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 2304
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
import math

def run():
    A,B = map(int, input().split())
    print(A*B)




if __name__ == "__main__":
    run()

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	ll a[n],b[n],c[n];
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>b[i];
	rep(i,0,n-1) cin>>c[i];
	rep(i,0,n) a[i]-=1;
	ans=b[a[0]];
	ll pr=a[0];
	rep(i,1,n){
		ans+=b[a[i]];
		if(a[i]-pr==1){
			ans+=c[pr];
		}
		pr=a[i];
	}	
	ret(ans)
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
struct node{
	int a,b;
}N[maxn];
bool cmp(node x,node y)
{
	if(x.b==y.b) return x.a<y.a;
	else return x.b<y.b;
}
int main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&N[i].a,&N[i].b);
	}
	sort(N,N+n,cmp);ll tmp=0;
	int flag=1;
	for(int i=0;i<n;i++)
	{
		if(N[i].a+tmp<=N[i].b)
		{
			tmp+=N[i].a;
		}
		else
		{
			flag=0;break;
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    S[K-1] = tolower(S[K-1]);
//    transform(S[K], S[K], S[K], ::toupper);
    cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int cnt=0;
	for(int i=1;i<=5;i++)
	{
		int x;
		cin>>x;
		cnt++;
		if(x==0)
		{
			cout<<cnt<<endl;
			return 0;
		}
	}	
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			char[] t = stdIn.nextLine().toCharArray();
			for(int i=0;i<t.length;){
				if(t[i]!='@'){
					System.out.print(t[i]);
					i++;
				}
				else{
					i += 2;
					int f = t[i-1] - '0';
					for(int j=0;j<f;j++){
						System.out.print(t[i]);
					}
					i++;
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>
#include<deque>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define eps 1e-6
#define mem(n,a) memset(n,a,sizeof(n))
#define rep(i,be,en) for(int i=be;i<=en;++i)
#define pre(i,be,en) for(int i=en;i>=be;--i)
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lowbit(int x) { return x & -x; }


using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 300010;

int main() {
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	LL res = -INFL;
	res = max(res, a * c);
	res = max(res, a * d);
	res = max(res, b * c);
	res = max(res, b * d);


	cout << res << endl;











	return 0;
}

Measured memory_bytes: 3232
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner input = new Scanner(System.in);
    	while(true){
    		int num = input.nextInt();
    		if(num == 0)break;
    		System.out.println(fact(num));
    	}
    }
    
    public static int fact(int num){
    	int two_count = 0;
    	int five_count = 0;
    	for(int i = 1 ; i <= num ; i++){
    		int ban = i;
    		while(true){
    			if(ban % 2 == 0){
    				two_count++;
    				ban /= 2;
    			}else if(ban % 5 == 0){
    				five_count++;
    				ban /= 5;
    			}else{
    				break;
    			}
    		}
    	}
    	return Math.min(two_count, five_count);
    }
}

Measured memory_bytes: 18700
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	if(b%a==0){cout<<a+b;}
	else{cout<<b-a;}



	cout<<endl;
} 


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	ll K, A, B;
	cin >> K >> A >> B;
	if (A >= B - 2 || A + 1 > K) {
		cout << K + 1 << "\n";
		return 0;
	}
	ll res = B;
	K -= A + 1;
	if (K % 2 == 0) res += (B - A)*K / 2;
	else res += (B - A)*(K - 1) / 2 + 1;
	cout << res << "\n";
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int a, int B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, int B) {return (a + (B - 1)) / B;}
long long divCeil(int a, long long B) {return (a + (B - 1)) / B;}
long long divCeil(long long a, long long B) {return (a + (B - 1)) / B;}

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int ans = (X - Z) / (Y + Z);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
 
 
int main() {
    int64_t n,ans;
    ans =0;
    string s;
    cin>>n;
    cin>>s;
    
    for(int i=0;i<n-2;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

void solve() {
   ll n,k;
   cin >> n >> k;
   vector<ll> q;
   ll ans = 0;

   for(int i = 0;i<n;i++){
       int t;
       cin >> t;
       q.push_back(t);
   }

   for(int i = 0;i < min(n,k)+1;i++){
       for(int j = 0;j < min(n,k)-i+1;j++){
        vector<ll> s = q;
        s.erase(s.begin()+i,s.end()-j);
        sort(s.begin(),s.end());
        if(k-i-j < 0) continue;
        for(int p = 0;p < min((ll)k-i-j,(ll)s.size());p++){
            s[p] = max((ll)0,s[p]);
        }
        ll tmp = accumulate(s.begin(),s.end(),0);          
        ans = max(ans,tmp);
       }      
    }
  
   cout << max(ans,(ll)0) << endl;   
   
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    ($t : ty) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().parse().unwrap(); 
        buf.clear();
        tmp_var
    }};
    ($t : ty, $size : expr) => {{
        use std::io::BufRead;
        let tmp_handle = std::io::stdin();
        let mut handle = tmp_handle.lock();
        let mut buf = String::new();
        handle.read_line(&mut buf).unwrap();
        let tmp_var: $t = buf.trim().split_whitespace()
            .map(|a| a.parse().unwrap()).collect();
        buf.clear();
        tmp_var
    }};
}
fn main() {
    let config = input!(Vec<usize>, 3);
    let mut total: usize = 0;
    for n in 1..config[0]+1 {
        let tmp = apart_num(n).iter().sum::<usize>();
        if config[1] <= tmp && tmp <= config[2] {
            total += n;
        }
    }
    println!("{}", total);
}

fn apart_num(mut n: usize) -> Vec<usize> {
    let mut v = vec![];
    while n != 0 {
        v.push(n % 10);
        n /= 10;
    }
    return v;
}


Measured memory_bytes: 4352
package main

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

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

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

var to = make([][]int, 200000)
var ret = make([]int, 200000)

func dfs(v int, p int) {
	u := to[v]
	for i := 0; i < len(u); i++ {
		if u[i] == p {
			continue
		}
		ret[u[i]] += ret[v]
		dfs(u[i], v)
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	Q := nextInt()

	for i := 0; i < N-1; i++ {
		a := nextInt()
		b := nextInt()
		a--
		b--
		to[a] = append(to[a], b)
		to[b] = append(to[b], a)
	}
	p := make([]int, Q)
	x := make([]int, Q)
	for i := 0; i < Q; i++ {
		p[i] = nextInt()
		x[i] = nextInt()
	}

	// calc
	for i := 0; i < Q; i++ {
		ret[p[i]-1] += x[i]
	}
	dfs(0, -1)

	// output
	for i := 0; i < N-1; i++ {
		fmt.Printf("%d ", ret[i])
	}
	fmt.Println(ret[N-1])
}


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

int main() {
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b&&b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

vector<int> prime;

int main(void) {
	for(int i = 2;i < 60000;i++) {
		bool isPrime = true;
		for(auto e:prime) {
			if(i % e == 0) {
				isPrime = false;
				break;
			}
		}
		if(isPrime) prime.push_back(i);
	}
	int n;
	while(cin >> n) {
		auto eq = equal_range(prime.begin(),prime.end(),n);
		cout << *(eq.first-1) << " " << *(eq.second) << endl;
	}
}



Measured memory_bytes: 3048
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100


struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_cost,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		cost = arg_cost;
		rev_index = arg_rev_index;
	}

	int to,capacity,cost,rev_index;
};

int V;
vector<Edge> G[NUM];
int dist[NUM];
int pre_node[NUM],pre_edge[NUM];


void add_edge(int from,int to,int capacity,int cost){
	G[from].push_back(Edge(to,capacity,cost,G[to].size()));
	G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

int min_cost_flow(int source,int sink,int flow){
	int ret = 0;
	while(flow > 0){

		for(int i = 0; i < V; i++)dist[i] = BIG_NUM;
		dist[source] = 0;
		bool update = true;
		while(update){
			update = false;
			for(int node_id = 0; node_id < V; node_id++){
				if(dist[node_id] == BIG_NUM)continue;
				for(int i = 0; i < G[node_id].size(); i++){
					Edge &e = G[node_id][i];
					if(e.capacity > 0 && dist[e.to] > dist[node_id]+e.cost){
						dist[e.to] = dist[node_id]+e.cost;
						pre_node[e.to] = node_id;
						pre_edge[e.to] = i;
						update = true;
					}
				}
			}
		}

		if(dist[sink] == BIG_NUM){
			return -1;
		}

		int tmp_flow = flow;
		for(int node_id = sink; node_id != source; node_id = pre_node[node_id]){
			tmp_flow = min(tmp_flow,G[pre_node[node_id]][pre_edge[node_id]].capacity);
		}
		flow -= tmp_flow;
		ret += tmp_flow*dist[sink];
		for(int node_id = sink; node_id != source; node_id = pre_node[node_id]){
			Edge &e = G[pre_node[node_id]][pre_edge[node_id]];
			e.capacity -= tmp_flow;
			G[node_id][e.rev_index].capacity += tmp_flow;
		}
	}
	return ret;
}

int main(){

	int E,F;
	scanf("%d %d %d",&V,&E,&F);

	int from,to,capacity,cost;
	for(int loop = 0; loop < E; loop++){
		scanf("%d %d %d %d",&from,&to,&capacity,&cost);
		add_edge(from,to,capacity,cost);
	}

	printf("%d\n", min_cost_flow(0,V-1,F));

	return 0;
}



Measured memory_bytes: 3252