akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int A,B,C;
	cin>>A>>B>>C;
	if(A>C)
	cout<<"NO"<<endl;
	else if(A+B>=C)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var text = StringBuilder(readLine()!!)
    val listStr = listOf("dream","dreamer", "erase", "eraser")
    
   var result = false
   while(text.isNotEmpty()){
        val erase = listStr.find { text.endsWith(it) }
        if (erase == null) {
            println("NO")
            return
        } else {
            text.delete(text.length-erase.length , text.length)
        }
    }
    println("YES")
}

Measured memory_bytes: 38696
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		ULL K; cin >> K;
		ULL NK = N * K;
		vector<UL> S(N); rep(i, N) { cin >> S[i]; S[i]--; }
		vector<UL> Nx(N);
		{
			vector<UL> P; P.assign(200000, (UL)-1);
			rep(i, N) {
				if (P[S[i]] != (UL)-1) Nx[P[S[i]]] = i + 1;
				P[S[i]] = i;
			}
			rep(i, N) {
				if (P[S[i]] != (UL)-1) if (P[S[i]] < N) Nx[P[S[i]]] = N + i + 1;
				P[S[i]] = i + N;
			}
		}
		ULL p = 0;
		do { p += (Nx[p % N] - p % N); } while (p % N);
		ULL q = NK - NK % p;
		vector<UL> ans;
		while (q < NK) {
			ULL nxq = q + (Nx[q % N] - q % N);
			if(nxq <= NK) q += (Nx[q % N] - q % N);
			else {
				ans.push_back(S[q % N] + 1); q++;
			}
		}
		rep(i, ans.size()) {
			if (i != 0) cout << " ";
			cout << ans[i];
		}cout << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 4848
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    string s;cin>>s;
    ll k=in();

    vector<pair<char,ll>>blocks;blocks.emplace_back(s[0],1);
    for(ll i=1;i<s.length();++i){
        if(s[i]==blocks.back().first)++blocks.back().second;
        else blocks.emplace_back(s[i],1);
    }

    if(blocks.size()==1){
        cout<<s.length()*k/2<<endl;
        return 0;
    }

    ll ans=0;for(ll i=1;i<blocks.size()-1;++i)ans+=blocks[i].second/2*k;
    if(blocks[0].first!=blocks.back().first)
        ans+=blocks[0].second/2*k+blocks.back().second/2*k;
    else
        ans+= blocks[0].second/2
             +(blocks[0].second+blocks.back().second)/2*(k-1)
             +blocks.back().second/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


const ll MOD = 1000000007;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;

    vll S(N + 2);
    rep(i, N + 1) S[i + 1] = S[i] + ll(i);
    
    ll ans = 1;

    REP(i, K, N + 1) {

        ans += S[N + 1] - S[N - i + 1] - (S[i] - S[0]) + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int n,m;
int table[1001][1001];
int g[1001][1001];

void putg(){
    REP(i,m+1){
        REP(j,n+1){
            g[i][j]=INT_MAX;
        }
    }
    g[0][0]=0;
}

int check(int i,int j){
    if(i>0&&j>0){
        return 0;
    }else if(j>0){
        return 1;
    }else {
        return 2;
    }
}

int solve(){
    REP(i,m){
        REP(j,n+1){
            if(i+1<j)continue;
            int ch=check(i,j);
            if(ch==0){
                g[i][j]=min(g[i-1][j],g[i-1][j-1]+table[i][j]);
            }else if(ch==1){
                g[i][j]=table[i][j];
            }else{
                g[i][j]=0;
            }
        }
    }
    return g[m-1][n];
}

int main(){
    cin >> n >> m;
    putg();
    vector<int> d(n),c(m);
    REP(i,n)cin >> d[i];
    REP(i,m){
        cin >> c[i];
        REP(j,n){
            table[i][j+1]=c[i]*d[j];
        }
    }

    int ans=solve();
//    REP(i,m){
//        REP(j,n+1){
//            cout << table[i][j] <<" ";
//        }
//        cout << endl;
//    }

//    REP(i,m){
//        REP(j,n+1){
//            cout << g[i][j] << " ";
//        }
//        cout << endl;
//    }
    cout << ans << endl;

}



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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin >> n;
    vi a(n+2,0);rep(i,n)cin >> a[i+1];
    a.push_back(0);

    int sum = 0;
    for(int i=1;i<n+2;i++){
        sum += abs(a[i] - a[i-1]);
    }

    for(int i=1;i<n+1;i++){
        ll ans = sum - abs(a[i] - a[i-1]) - abs(a[i] - a[i+1]) + abs(a[i+1] - a[i-1]);
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
        int h,w; cin>>h>>w;
        vector<string> s(h);
        for(int i=0; i<h; i++) cin>>s[i];

        int maxDist = 0;
        // マップも大きくないので、全ての道をスタート地点として調べてしまって良い
        for(int i=0; i<h; i++) {
                for(int j=0; j<w; j++) {
                        if(s[i][j]=='.') {
                                vector<vector<int> > dist(h,vector<int>(w,-1));
                                queue<pair<int,int> > que;
                                pair<int,int> start(i,j);

                                dist[i][j]=0;
                                que.push(start);
                                while(!que.empty()) {
                                        pair<int,int> pos=que.front();
                                        que.pop();
                                        // 上下左右4方向についてチェック
                                        int dx[4] = {1,0,-1,0};
                                        int dy[4] = {0,1,0,-1};
                                        for(int i=0; i<4; i++) {
                                                int nh = pos.first+dx[i];
                                                int nw = pos.second+dy[i];
                                                if(nh<0 || nh>=h || nw<0 || nw>=w) continue;
                                                if(s[nh][nw] == '#') continue;
                                                if(dist[nh][nw]!=-1) continue;

                                                dist[nh][nw]=dist[pos.first][pos.second]+1;
                                                maxDist=max(maxDist,dist[nh][nw]);
                                                que.push(make_pair(nh,nw));
                                        }
                                }
                        }
                }
        }
        cout << maxDist << endl;
}


Measured memory_bytes: 3600
program sample
    implicit none
  
    integer(8) :: i,j,k,m,n,x,y
    real(8)::b
    integer(8),allocatable :: a(:)
  
    read(*,*) n
    allocate(a(n))
    read(*,*)a
    k=sum(a)/n
    m=k+1
    x=0
    y=0
    do i=1,n
        x=x+(a(i)-k)**2
        y=y+(a(i)-m)**2
        
    end do
    if (x<=y)then
        write(*,*) x
    
    else
        write(*,*) y
    end if
  

    deallocate(a)
    stop
end program sample
  



Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();
		BigDecimal x = a.add(b) ;
		BigDecimal c = new BigDecimal("2");
		x = x.divide(c,0,BigDecimal.ROUND_UP) ;

		System.out.println(x);
	}
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S.at(i);

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S.at(i).at(j) == '.') {
                int count = 0;
                for (int k = max(i - 1, 0); k <= min(i + 1, H - 1); k++) {
                    for (int l = max(j - 1, 0); l <= min(j + 1, W - 1); l++) {
                        if (S.at(k).at(l) == '#') count++;
                    }
                }
                S.at(i).at(j) = '0' + count;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << S.at(i).at(j);
            if (j == W - 1) cout << endl;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<string>
#include<list>
using namespace std;

int main(){
	int a, b;
	list<int> digit;
	
	while(!(cin>>a>>b).eof()){
		if((a+b)>0){
			int c=a+b;
			stringstream ss;
			ss << c;
			digit.push_back(ss.str().size());
		}
		
	}
	list<int>::iterator it = digit.begin();
	while(it != digit.end()){
		cout << *it << endl;
		it++;		
	}
	
 	return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
int main(void){
	int n,x;
	int i,j,k;
	int num = 0;
	
	while(1){
		scanf("%d %d",&n,&x);
		if(n == 0&&x == 0)break;
		if(n >= 3&&n <= 100){
			for(i = 1;i < n-1;i++){
				for(j = i + 1;j < n;j++){
					for(k = j + 1;k < n+1;k++){
							if(i + j + k == x){
								num++;
							}
						}
					}
				}
			
			}
			printf("%d\n",num);
			num = 0;
		}
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cout << (s[i] == '?' ? 'D' : s[i]);
    }
    cout << '\n';
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double mi=INF;
    double ma=0;
    double n;
    while(cin>>n){
        mi=min(mi,n);
        ma=max(ma,n);
    }
    cout<<ma-mi<<endl;
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){

  string a, b;
  cin >> a >> b;
  int x = stoi(a+b);
  int flag = 0;
  for(long p = 1; p < 10000; p++){
    if(p*p == x){
      flag = 1;
      break;
    }
  }
  if(flag == 1)
    printf("Yes");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 256
// http://algorithms.blog55.fc2.com/blog-entry-66.html

#include <iostream>
using namespace std;
#include <stdio.h>

#define MAX 100
#define INFTY (1 << 21)

int SIZE;
int R[MAX + 2];
int C[MAX+1][MAX+1]; // cost table
int B[MAX+1][MAX+1]; // best table

void compute(){
	int i=0,j,k;
    for (; i <= SIZE; i++ )
    for (j = 0; j <= SIZE; j++ ) C[i][j] = INFTY;
    
    for (i = 0; i <= SIZE; i++ ) C[i][i] = 0;
    
    for (j = 1; j < SIZE; j++ ){
        for (i = 0; i < SIZE - j; i++ ){
            for (k = i; k < i + j; k++ ){
                // C[i][i+j] = min( C[i][i+j], 
                //                  C[i][k-1] + C[k][i+j] + R[i]*R[k]*R[i+j+1]);
                int cost = C[i][k] + C[k+1][i+j] + R[i]*R[k+1]*R[i+j+1];
                if ( cost < C[i][i+j] ){
                    C[i][i+j] =  cost;
                    B[i][i+j] = k;
                }
                
            }
        }
    }
}

void order( int i, int j ){
    if ( i == j ) cout << "M" << i;
    else{
        cout << "(";
        order( i, B[i][j]-1 ); order(B[i][j], j);
        cout << ")";
    }
}

void input(){
    cin >> SIZE;
	int z,i=0;
    for (; i < SIZE; i++ ) cin >> R[i]>>z;
	R[i]=z;
	//SIZE++;
}

void output(){
    cout <<  C[0][SIZE-1] << endl;
    //order(1, SIZE);
    //cout << endl;
}

main(){
    input();
    compute();
    output();
}

Measured memory_bytes: 1236
((input: string): void => {
    const hoge: number[] = input.split(" ").map(Number);
    const fuga: number = 10 ** 10;
    const piyo: number = Math.round((hoge[0]/hoge[1]) * fuga);
    console.log((piyo / fuga).toFixed(10));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
from collections import deque


def first_cut(links, colors):
    tmp_links = links.copy()
    for v, neighbors in tmp_links.items():
        while len(neighbors) == 1 and colors[v]:
            del links[v]
            par = neighbors.pop()
            links[par].remove(v)
            v = par
            neighbors = links[par]
    return links


def diameter(links, flags):
    def dfs(s):
        fs = flags[s]
        d, v = 0, 0
        q = deque(sorted((fs + flags[v], v, s) for v in links[s]))
        while q:
            d, v, a = q.popleft()
            for u in links[v]:
                if u == a:
                    continue
                fu = flags[u]
                if fu:
                    q.append((d + 1, u, v))
                else:
                    q.appendleft((d, u, v))
        return d, v

    s = next(iter(links))
    _, t = dfs(s)
    d, _ = dfs(t)
    return d


def solve(links, colors):
    if all(colors):
        return 0

    links = first_cut(links, colors)
    k = len(links)

    if k == 1:
        return 1

    flags = {v: colors[v] ^ (len(link) % 2 == 0) for v, link in links.items()}
    euler_tour = 2 * (k - 1) + sum(flags.values())
    return euler_tour - 2 * diameter(links, flags)


n = int(input())
links = {i: set() for i in range(n)}
for _ in range(n - 1):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    links[x].add(y)
    links[y].add(x)
colors = [c == 'B' for c in input()]

print(solve(links, colors))


Measured memory_bytes: 65632
def present(n):
  if n%2 == 0:
    return n/2
  else:
    return (n-1)/2

s = input()
a, b, k = s.split()
a = int(a)
b = int(b)
for i in range(int(k)):
  if i % 2 == 0:
    a = present(a)
    b = b + a
  else:
    b = present(b)
    a = a + b

print("{} {}".format(int(a),int(b)))


Measured memory_bytes: 3060
#include<stdio.h>

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

int main(void){
	int i;
	int n, a[10];
	int ans;

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

	ans = a[0];
	for (i = 1; i < n; i++)
		ans = lcm(ans, a[i]);

	printf("%d\n", ans);

	return 0;
}

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

int N;
int square[20][20] = {} ;

void search( int x , int y , int cnt ){
	if( cnt == N*N+1 ) return ;
	
	if( square[y][x]==0 ){
		square[y][x] = cnt ;
		search( (x+1)%N , (y+1)%N , cnt+1 );
	}else {
		search( (x+N-1)%N , (y+N+1)%N , cnt );
	}
	
}

int main(){
	
	while( cin >> N , N ){
		
		for( int i=0 ; i<N ; i++ )
			for( int j=0 ; j<N ; j++ )
				square[i][j] = 0;
		
		search( N/2 , N/2+1 , 1 );
		
		for( int i=0 ; i<N ; i++ ){
			for( int j=0 ; j<N ; j++ ){
				if( square[i][j] < 1000 ) cout << ' ';
				if( square[i][j] < 100  ) cout << ' ';
				if( square[i][j] < 10   ) cout << ' ';
				cout << square[i][j] ;
			}
			cout << endl ;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>

int main()
{
	int n;
	double d,x,ans=0;
	
	scanf("%d%lf%lf",&n,&d,&x);
	for(int i=n;i>=1;i--)
	{
		ans+=d+(i-0.5)*x;
		d=((2*i+2)*d+5*x)/(2*i);
		x=(2*i+4)*x/(2*i);
	}
	
	printf("%.9f\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
   int i, h , m , s;
   cin >> i ;
   h = i / 3600 ;
   m = i % 3600 / 60;
   s = i % 3600 % 60;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#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 eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<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 tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int F[100][10];
ll Point[100][11];

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

  rep(i,n){
    rep(j,10){
      cin>>F[i][j];
    }
  }
  rep(i,n){
    rep(j,11){
      cin>>Point[i][j];
    }
  }
  ll ans = -1000000000;
  rep(k,1<<10){
    ll tmp = 0;
    if(k==0)continue;
    bitset<10> b(k);
    vi c(n,0);
    rep(i,n){
      rep(j,10){
        c[i]+=(b[j]&& F[i][j]);
      }
    }
    rep(i,n){
      tmp+=Point[i][c[i]];
    }
    maxs(ans,tmp);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
function floor_sum(n, m, a, b)
  ans::BigInt = 0
  n,m,a,b=BigInt.([n,m,a,b])
  if a >= m
    ans += (n - 1) * n * (a ÷ m) / 2
    a %= m
  end
  if b >= m
    ans += n * (b ÷ m)
    b %= m
  end
  y_max = (a * n + b) ÷ m
  x_max = (y_max * m - b)
  if y_max == 0; return ans; end
  ans += (n - (x_max + a - 1) ÷ a) * y_max
  ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
  return ans
end
p()=parse.(Int,split(readline()))
function main()
  for i=1:parse(Int,readline())
    floor_sum(p()...) |> println
  end
end
main()

Measured memory_bytes: 287980
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0
for i in range(n):
    count += min(a[i], b[i])
    b[i] = max(b[i]-a[i], 0)

    count += min(a[i+1], b[i])
    a[i+1] = max(a[i+1] - b[i], 0)

print(count)


Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

vector<vector<ll>> edge;
ll aoki[100008];
ll taka[100008];

void dfs(ll at, ll t){
	aoki[at] = t;
	rep(i, 0, edge[at].size()){
		ll next = edge[at][i];
		if(aoki[next] == -1){
			dfs(next, t+1);
		}
	}
}

ll dfs2(ll at, ll t){
	if(aoki[at] == t){return t;}
	if(aoki[at] == t-1){return t-1;}
	
	ll keep = t+((aoki[at]-t)/2)*2;
	ll taihi = 0;
	rep(i, 0, edge[at].size()){
		ll next = edge[at][i];
		taihi = max(aoki[next], taihi);
	}
	keep = min(t+((taihi-t)/2)*2, keep);
	
	ll res = keep;
	taka[at] = keep;
	rep(i, 0, edge[at].size()){
		ll next = edge[at][i];
		if(aoki[next] >= t+1 && taka[next] == -1){
			ll buf = dfs2(next, t+1);
			res = max(buf, res);
		}
	}
	return res;
}


int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, u, v;
	cin >> n >> u >> v;
	edge.resize(n+1);
	ll a, b;
	rep(i, 0, n){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}
	
	rep(i, 1, n+1){aoki[i] = -1;}
	dfs(v, 0);
	//rep(i, 1, n+1){print(aoki[i])}
	rep(i, 1, n+1){taka[i] = -1;}
	ll ans = dfs2(u, 0);
	//rep(i, 1, n+1){print(taka[i])}
	print(ans)
	return 0;
}

Measured memory_bytes: 10496
<?php
    /*
        Problem URL : http://agc012.contest.atcoder.jp/tasks/agc012_a

        Score  :
        Result :
        Time   : ms
        Memory : KB
     */

    ini_set('error_reporting', E_ALL & ~E_NOTICE);

    // define('DEBUG', true);
    define('DEBUG', false);

    if (DEBUG) {
        $start = microtime(true);
    }
    echo solve() . PHP_EOL;
    if (DEBUG) {
        $t = microtime(true) - $start;
        printf ("Elapsed time: %7.3f sec\n", $t);
    }

    function solve() {
        $idx = array();
        $maxavg = 0;
        fscanf(STDIN, "%d\n", $N);
        $a = explode(" ", trim(fgets(STDIN)));
        rsort($a);
        // var_dump($a);
        for ($i = 0; $i < $N * 2; $i++) {
            if ($i % 2 == 1) {
                $ans += $a[$i];
            }
        }
        return $ans;
    }


Measured memory_bytes: 36544
#include <iostream>

using namespace std;

int main(){
  char a, b;

  cin >> a >> b;

  if(a == 'H'){
    if(b == 'H'){
      cout << 'H';
    } else {
      cout << 'D';
    }
  } else {
    if(b == 'H'){
      cout << 'D';
    }else {
      cout << 'H';
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, ans = 0; cin >> n;
    rep(i, n){
        ll l, r; cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int N,k;
int day[101]={0};
long long int tem[101][4][3]={0};

long long int cal(int n,int p,int d ){
		if(tem[n][p][d]>0)
			return tem[n][p][d];
		else if(d>=3)
			return 0;
		else if(n>=N)
			return 1;
		else if(day[n+1]>0){
			tem[n][p][d] =cal(n+1,day[n+1],(p==day[n+1])?d+1:1);
			tem[n][p][d] %= 10000;
			return tem[n][p][d];
		}else{
			tem[n][p][d]= cal(n+1,1,(p==1)?d+1:1)+cal(n+1,2,(p==2)?d+1:1)+cal(n+1,3,(p==3)?d+1:1);
			tem[n][p][d] %= 10000;
			return tem[n][p][d];
		}
}

int main(void){
	int a,b;
	int total;
	scanf("%d %d",&N,&k);
	for(int i=0;i<k;i++){
		scanf("%d %d",&a,&b);
		day[a]=b;
	}
	total=cal(0,0,0);
	total %=10000;
	printf("%lld\n",total);
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}





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

int main(void) {
  int N;
  cin >> N;
  
  int64_t prev = 2, res = 1;
  for(int i = 2; i <= N; i++) {
    int64_t temp = res;
    res += prev;
    prev = temp;
  }
  cout << res << endl;
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair< int, int > P;
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

int k, n, a[100000];

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

    cin >> n >> k;
    REP(i, n) {
        cin >> a[i];
    }

    cout << (n - 1 + (k - 2)) / (k - 1) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>

const int N=100005;
int fst[N],id[N],cnt[N],n,D,tot=0;
bool u[N];
long long X[N],Y[N],ans=0;
struct Edge{int to,nxt;}e[N*8];

void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
	e[++tot].to=x;e[tot].nxt=fst[y];fst[y]=tot;
}

bool cmp(int i,int j){
	return X[i]!=X[j]?X[i]<X[j]:Y[i]<Y[j];
}

bool check(int i,int j,int x){
	return X[i]<X[j]+D || (X[i]==X[j]+D && Y[i]<Y[j]+x);
}

void work(int d){
	std::sort(id+1,id+n+1,cmp);
	for (int i=1,j=1,l=1,r=1;i<=n;i++){
		for (;l<=n && check(id[l],id[i],-d);l++);
		for (;r<=n && check(id[r],id[i],d+1);r++);
		cnt[id[i]]+=r-l;
		j=std::max(l,j);
		if (j==r) continue;
		addedge(id[i],id[j]);
		for (;j+1<r;j++) addedge(id[j],id[j+1]);
	}
}

void dfs(int x){
	if (u[x]) return;
	u[x]=1;ans+=cnt[x];
	for (int i=fst[x];i;i=e[i].nxt) dfs(e[i].to);
}

int main(){
	int a,b;
	scanf("%d%d%d\n",&n,&a,&b);
	for (int i=1;i<=n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		X[i]=x+y;Y[i]=x-y;
	}
	D=std::max(abs(X[a]-X[b]),abs(Y[a]-Y[b]));
	for (int i=1;i<=n;i++) id[i]=i;
	work(D);
	for (int i=1;i<=n;i++) std::swap(X[i],Y[i]);
	work(D-1);
	for (int i=1;i<=n;i++) u[i]=0;
	dfs(a);
	printf("%lld\n",ans);
}

Measured memory_bytes: 10624
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int p[1000000];
int main()
{
	for (int i = 2; i < 1000000; ++i)
	{
		if (!p[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				p[j] = 1;
		}
	}

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; i += 2)
			if (!p[i] && !p[n-i])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

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

	multiset<int> S;

	int query, x;
	int L, R;

	for (int i = 0; i < q; i++) {
		cin >> query;
		if (query == 0) {
			cin >> x;
			S.insert(x);
			cout << S.size() << endl;
		}
		else if (query == 1){
			cin >> x;
				cout << S.count(x) << endl;	
		}
		else if(query == 2){
			cin >> x;
			S.erase(x);		
		}
		else {
			cin >> L >> R;
			for (auto itr = S.lower_bound(L); itr != S.upper_bound(R); itr++) {
				cout << *itr << endl;
			}
		}
	}
}


Measured memory_bytes: 12356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0134
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt(); long sum = 0;
            for (int i = 0 ; i < n ; i++) sum += RLong();
            Console.WriteLine(sum / n);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 15920
#include<stdio.h>
int main(void)
{
	int price=700,i;
	char s[3];
	
	scanf("%4s",s);
	
	for(i=0;i<3;i++){
		if(s[i]=='o') price+=100;
	}
	
	printf("%d",price);
	
	return 0;
}


Measured memory_bytes: 128
from collections import Counter
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

def cnt(num):
    i=1
    co=0
    while num>=0:
        num-=i
        co+=1
        i+=1
    return co-1

n=int(input())
c=Counter(prime_factorize(n))
l=list(c.values())
r=0
for x in l:
    r+=cnt(x)
print(r)

Measured memory_bytes: 9368
package main

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

func main() {
	d, t, s := readI(), readI(), readI()
	if d <= t*s {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 1784
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

const double PI  =3.141592653589793238463;

int main()
{
    double R;
    cin >> R;

    double res = R*2*PI;
    printf("%.10f\n", res);
    return 0;
}


Measured memory_bytes: 3776
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int n;
  char A[100];
  int S[100];
  int a,v;
  int p=0;

  while( scanf("%s", A) != EOF){ 
    // printf("%s\n",A);
    a = atoi(A);
    if(a!=0){
      S[p] = a;
      // printf("S[%d] = %d\n",p,S[p]);
      p++;
    }else{
      if(A[0]=='+')
	S[p-2] = S[p-2] + S[p-1];
      if(A[0]=='-')
	S[p-2] = S[p-2] - S[p-1];
      if(A[0]=='*')
	S[p-2] = S[p-2] * S[p-1];
      // printf("S[%d] = %d\n",p-2,S[p-2]);
      p--;
    }
  }
  printf("%d\n",S[0]);
  return 0;
}

Measured memory_bytes: 1824
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int n;
    scan(n);

    auto rb = redBlackTree!(string)();

    foreach (i ; 0 .. n) {
        string si;
        scan(si);
        rb.insert(si);
    }

    auto ans = rb.length;
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 26024
#include<stdio.h>
int main(void)
{
	int n,t,a,h,i,ans,max,c,b;
	scanf("%d %d %d",&n,&t,&a);
	a=a*1000;
	max=1000000000;
	for(i=1;i<=n;i++){
		scanf("%d",&h);
		c=1000*t-h*6;
		ans=c-a;
		if(ans<0){
			ans=-ans;
		}
		if(ans<max){
			max=ans;
			b=i;
		}
	}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,a[1000],i,sum=0;
  cin>>n>>k;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<k;i++)
  {
    sum=sum+a[i];
  }
  cout<<sum;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  ll n,m;cin>>n>>m;
  vector<ll> v;
  REP(i,n){
    ll t;cin>>t;
    v.pb(t);
  }
  VSORT(v);

  vector<LP> vlp;
  REP(i,m){
    ll b,c;cin>>b>>c;
    LP lp;
    lp.first = c;
    lp.second = b;
    vlp.pb(lp);
  }

  sort(vlp.begin(),vlp.end());

  ll vlpCounter = m-1;
  ll vCounter = 0;
  bool bo = false;

  while(vlpCounter>=0){
    ll c = vlp[vlpCounter].first;
    ll b = vlp[vlpCounter].second;

    for(int i=vCounter;i<vCounter + b;i++){
      if(i==n){
        bo = true;
        break;
      }
      if(v[i]<=c){
        v[i] = c;
      }else{
        bo = true;
        break;
      }
    }
    if(bo)break;
    vCounter += b;
    vlpCounter--;
    /*vector<ll>::iterator it = lower_bound(v.begin(),v.end(),c);
    if(it==v.begin())break;

    ll num = it - v.begin();
    if(num<=b){
      REP(i,num){
        v[i] = c;
      }
      break;
    }else{
      for(int i = num-1;i>=num - b;i--){
        v[i] = c;
      }
    }
    vlpCounter--;

    REP(i,n){
      cout<<v[i]<<"    ";
    }
    cout<<endl;*/
  }

  ll ans = 0;
  REP(i,n){
    ans += v[i];
  }
  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 3188
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

double log(double base, double value) {
	return std::log2(value) / std::log2(base);
}

///素因数分解をする関数。計算量はO(√n)
std::unordered_map<Int, Int> Factorize(Int n) {

	std::unordered_map<Int, Int> res;
	for (Int i = 2; i * i <= n; ++i) {
		if (n % i != 0)continue;
		res[i] = 0;
		while (n % i == 0) {
			n /= i;
			res[i]++;
		}
	}
	if (n != 1)res[n] = 1;
	return res;

}

void calc() {

	Int X; std::cin >> X;
	Int max = 1000;
	for (Int i = -max; i <= max; ++i) {
		Int num = pow(i, 5) + X;
		for (Int j = -max; j <= max; ++j) {
			if (num == pow(j, 5)) {
				std::cout << std::max(i, j) << " " << std::min(i, j);
				return;
			}
		}
	}

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 4060
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cfloat>
using namespace std;
bool visited[100000];
vector <int> edges[100000];
void dfs(int cur){
  visited[cur] = true;
  for(int i = 0; i < edges[cur].size(); i++){
    int next = edges[cur][i];
    if(!visited[next]){
      dfs(next);
    }
  }
}

int main(){
  int N;
  int M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int A;
    int B;
    cin >> A >> B;
    edges[A - 1].push_back(B - 1);
    edges[B - 1].push_back(A - 1);
  }

  int cc_no = 0;
  for(int i = 0; i < N; i++){
    if(!visited[i]){
      cc_no ++;
      dfs(i);
    }
  }
  cout << cc_no - 1 << endl;
  return 0;
}


Measured memory_bytes: 9652
from collections import Counter

mod = 998244353

n = int(input())
d = list(map(int, input().split()))
c = Counter(d)
if not(c[0] == 1 and d[0] == 0):
    print(0)
    exit()

k = sorted(c.keys())
prev = -1
ans = 1
for ki in k:
    if prev+1 != ki:
        ans = 0
        break
    a = c[ki-1] if ki != 0 else 1
    ans *= pow(a, c[ki], mod)
    ans %= mod
    prev = ki
print(ans)


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

using namespace std;

int a,b;

int main()
{
    scanf("%d%d",&a,&b);
    if(a >= 13)
        printf("%d\n",b);
    else if(a > 5)
        printf("%d\n",b / 2);
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();

    if k > 1000 {
        let ans = vec![n; n];
        put!(..ans);
        return;
    }

    let mut xs: Vec<usize> = sc.vec(n);
    for _ in 0..k {
        let mut ds = vec![0i64; n];
        for i in 0..n {
            if i >= xs[i] {
                ds[i - xs[i]] += 1;
            } else {
                ds[0] += 1;
            }
            if i + xs[i] + 1 < ds.len() {
                ds[i + xs[i] + 1] -= 1;
            }
        }
        let mut ac = 0;
        for i in 0..n {
            ac += ds[i];
            xs[i] = ac as usize;
        }
    }

    put!(..xs);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 14292
#include <bits/stdc++.h>
using namespace std;
int n, x, y, t;
vector<pair<int, int> > a[100020];
long long s[100020];
long long z[100020];
long long sum;
int dfs(int x, int y) {
	int sz = 1;
	for (pair<int, int> u: a[x]) {
		if (u.first == y) {
			continue;
		}
		int r = dfs(u.first, x);
		if (r * 2 != n) {
			z[u.second] = (s[u.first] - s[x]) / (n - r * 2);
			sum -= z[u.second] * r * (n - r) * 2;
		} else {
			t = u.second;
		}
		sz += r;
	}
	return sz;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &x, &y);
		a[x].push_back(make_pair(y, i));
		a[y].push_back(make_pair(x, i));
	}
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &s[i]);
		sum += s[i];
	}
	dfs(1, 0);
	if (t) {
		z[t] = sum * 2 / n / n;
	}
	for (int i = 1; i < n; i++) {
		printf("%lld\n", z[i]);
	}
	return 0;
}

Measured memory_bytes: 15744
x,y = map(int, input().split())
money = 0
if x == 1:
    money += 300000
    if y == 1:
        money += 400000
elif x == 2:
    money += 200000
elif x == 3:
    money += 100000
if y == 1:
    money += 300000
elif y == 2:
    money += 200000
elif y == 3:
    money += 100000
print(money)


Measured memory_bytes: 3060
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 , LG = 20 , inf = 1e9 + 20 ;
int n , l , q , x[N] , nxt[LG][N] ;

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

	cin >> n ;
	for (int i = 0 ; i < n ; i ++) cin >> x[i] ;

	cin >> l ;

	for (int i = n - 1 , p = n - 1 ; i >= 0 ; i --) {
		while (x[p] - x[i] > l) p -- ;
		nxt[0][i] = p ;
	}

	for (int i = 1 ; i < LG ; i ++)
		for (int j = 0 ; j < n ; j ++)
			nxt[i][j] = nxt[i - 1][nxt[i - 1][j]] ;

	cin >> q ;

	while (q --) {
		int a , b , ans = inf , cur = 0 ;
		cin >> a >> b ;
		a -- , b -- ;

		if (a > b) swap(a , b) ;

		for (int i = LG - 1 ; i >= 0 ; i --) {
			if (nxt[i][a] >= b) {
				ans = min(ans , cur + (1 << i)) ;
			}
			else {
				cur += (1 << i) ;
				a = nxt[i][a] ;
			}
		}

		cout << ans << '\n' ;
	}
}


Measured memory_bytes: 9088
MOD = 10 ** 9 + 7

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

S = []
T = []

for a in A:
    if a < 0:
        T.append(a)
    else:
        S.append(a)

lenS = len(S)
lenT = len(T)

ok = False
if lenS > 0:
    if N == K:
        ok = lenT % 2 == 0
    else:
        ok = True
else:
    ok = K % 2 == 0

ans = 1
if not ok:
    A.sort(key=lambda x: abs(x))
    for i in range(K):
        ans *= A[i]
        ans %= MOD
else:
    S.sort()
    T.sort(reverse=True)
    if K % 2 == 1:
        ans *= S.pop()
    P = []
    while len(S) >= 2:
        x = S.pop()
        x *= S.pop()
        P.append(x)
    while len(T) >= 2:
        x = T.pop()
        x *= T.pop()
        P.append(x)
    P.sort(reverse=True)
    for i in range(K//2):
        ans *= P[i]
        ans %= MOD

print(ans)


Measured memory_bytes: 31736
<?php
define('N', 1000);

function trace(array $A, $n) {
  for ($i=0; $i<$n; $i++) {
    if($i > 0) printf(" ");
    printf("%d", $A[$i]);
  }
  printf("\n");
}

$n = intval(trim(fgets(STDIN)));
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$count = 0;
$flag = 1;
while($flag) {
  $flag = 0;
  for($j=$n-1; $j>0; $j--) {
    if($A[$j] < $A[$j-1]) {
      $tmp = $A[$j];
      $A[$j] = $A[$j-1];
      $A[$j-1] = $tmp;
      $flag = 1;
      $count++;
    }
  }
}
trace($A, $n);
printf("%d", $count);
?>



Measured memory_bytes: 9332