akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;



ll n,m,s,t;
ll dista[100002],distb[100002];
vector<P> machia[100002],machib[100002];
priority_queue<P,vector<P>,greater<P>> quea,queb;
ll mini[100002];

int main(){
  cin>>n>>m>>s>>t;
  rep1(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    machia[u].push_back(make_pair(a,v));
    machia[v].push_back(make_pair(a,u));
    machib[u].push_back(make_pair(b,v));
    machib[v].push_back(make_pair(b,u));
  }
  rep1(i,n){
    dista[i]=longinf;
    distb[i]=longinf;
  }
  dista[s]=0;
  rep0(i,machia[s].size()){
    quea.push(machia[s][i]);
    dista[machia[s][i].second]=machia[s][i].first;
  }
  while(quea.size()){
    P p=quea.top();
    quea.pop();
    if(p.first>dista[p.second]) continue;
    for(int i=0;i<machia[p.second].size();i++){
      ll c=machia[p.second][i].first;
      ll ne=machia[p.second][i].second;
      if(c+dista[p.second]<dista[ne]){
        dista[ne]=c+dista[p.second];
        quea.push(make_pair(c,ne));
      }
    }
  }
   distb[t]=0;
  rep0(i,machib[t].size()){
    queb.push(machib[t][i]);
    distb[machib[t][i].second]=machib[t][i].first;
  }
  while(queb.size()){
    P p=queb.top();
    queb.pop();
    if(p.first>distb[p.second]) continue;
    for(int i=0;i<machib[p.second].size();i++){
      ll c=machib[p.second][i].first;
      ll ne=machib[p.second][i].second;
      if(c+distb[p.second]<distb[ne]){
        distb[ne]=c+distb[p.second];
        queb.push(make_pair(distb[ne],ne));
      }
    }
  }
  ll shozikin=1e15;
  mini[n]=dista[n]+distb[n];
  for(int i=n-1;i>=1;i--){
    mini[i]=min(mini[i+1],dista[i]+distb[i]);
  }
  rep1(i,n){
    printf("%ld\n",shozikin-mini[i]);
  }
    return 0;
}

Measured memory_bytes: 22256
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| push(a)}
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0
    parent_idx = parent_idx(target_idx)
    while (@data[parent_idx] > @data[target_idx])
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0
      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while (has_child?(target_idx))

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      if @data[b].nil?
        c = a
      else
        c = @data[a] < @data[b] ? a : b
      end

      if @data[target_idx] > @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end



class PriorityQueue
  attr_accessor :data, :size
 
  def initialize(array = [])
    @data = []
    array.each { |a| push(a) }
  end
 
  def push(element)
    current = @data.size
    while current > 0
      p = parent(current)
      break if @data[p] <= element
      @data[current] = @data[p]
      current = p
    end
    @data[current] = element
  end
 
  def pop
    ret = @data[0]
    x = @data[-1]
    current = 0
    while have_child?(current)
      a = left_child(current)
      b = right_child(current)
      a = b if b < @data.size - 1 && @data[b] <= @data[a]
      break if @data[a] >= x
      @data[current] = @data[a]
      current = a
    end
    @data[current] = x
    @data.pop
 
    ret
  end
 
  def size
    @data.size
  end
 
  def front
    @data[0]
  end
 
  def empty?
    @data.empty?
  end
 
  private
  def parent(num)
    (num - 1) / 2
  end
 
  def left_child(num)
    num * 2 + 1
  end
 
  def right_child(num)
    num * 2 + 2
  end
 
  def have_child?(num)
    left_child(num) < @data.size - 1
  end
end


N, M = gets.chomp.split(' ').map(&:to_i)

AB = []
N.times do |i|
  AB[i] = gets.chomp.split(' ').map(&:to_i)
end

group_by_day = Hash[AB.group_by{|v|v[0]}.sort]

day_fee = Array.new(M){[]}
group_by_day.each do |k,v|
  day_fee[k-1] = v.map{|j| j[1]}
end

# require 'pry'
# binding.pry

ans = 0
pq = PriorityQueue.new
day_fee.each_with_index do |fees, idx|
  break if idx > M - 1
  fees.each do |fee|
    pq.push(fee*(-1))
  end
  ans += pq.pop.to_i
  # p pq
  # p pq.pop*(-1)
end

puts ans*(-1)


Measured memory_bytes: 34572
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 4800
int a[N][27];
int a2[N][27];
int e[N][365];
int v[N][365];
int sz, sz2;

int main() {
	int n;
	int x, y;
	vector<pair<int, pair<int, int> > >b;
	int c[26];
	int d[365][26];
	bool dd[365][26];
	vector<int>ds;
	int ans[365];
	scanf("%d", &n);
	f(i, 26)scanf("%d", &c[i]);
	f(i, n) {
		f(j, 26)scanf("%d", &d[i][j]);
		ds.clear();
		f(j, 26)ds.push_back(-d[i][j]);
		sort(ds.begin(), ds.end());
		f(j, 26) {
			if ((d[i][j] + ds[13]) > 0)dd[i][j] = true;
			else dd[i][j] = false;
		}
	}
	sz = 1;
	f(i, 26)a[0][i] = -1;
	a[0][26] = 0;
	f(t, n) {
		b.clear();
		f(i, sz) {
			x = a[i][26];
			f(j, 26) {
				x -= ((t - a[i][j])*c[j]);
			}
			f(j, 26) {
				if (dd[t][j]) {
					y = x + d[t][j];
					y += ((t - a[i][j])*c[j]);
					b.push_back(make_pair(y, make_pair(i, j)));
				}
			}
		}
		sort(b.begin(), b.end(), greater<pair<int, pair<int, int> > >());
		sz2 = b.size();
		if (sz2 > N)sz2 = N;
		f(i, sz2) {
			x = b[i].second.first;
			y = b[i].second.second;
			a2[i][26] = b[i].first;
			f(j, 26)a2[i][j] = a[x][j];
			a2[i][y] = t;
			e[i][t] = x;
			v[i][t] = y;
		}
		f(i, sz2) {
			f(j, 27)a[i][j] = a2[i][j];
		}
		sz = sz2;
	}
	x = 0;
	for (int i = n - 1; i >= 0; i--) {
		ans[i] = v[x][i];
		x = e[x][i];
	}
	f(i, n)printf("%d\n", ans[i] + 1);

	return 0;
}


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


int main(){
    int n,k;
    cin >>n>>k;
    int A[n];
  	for(int i=0;i<n;i++) A[i] = 0;
    for(int i=0;i<k;i++){
        int d;
        cin >>d;
        for(int j=0;j<d;j++){
            int a;
            cin >>a;
            A[a-1]++;
        }
    }  
    int count=0;
    for(int i=0;i<n;i++){
        if(A[i]==0) count++;
    }
    cout <<count<<endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  
  if(a<=8 && b<=8){
    cout<<"Yay!";
  }else{
    cout<<":(";
  }
  return 0;
}

Measured memory_bytes: 256
#YYMM, MMYY
S = input()

mae = S[:2]
ato = S[-2:]

is_MM = (int(mae) >= 1 and int(mae) <= 12) * 10 + (int(ato) >= 1 and int(ato) <= 12)

if is_MM == 11:
  print('AMBIGUOUS')
elif is_MM == 10:
  print('MMYY')
elif is_MM == 1:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
int dp[110000];
signed main(){
  int n;
  cin>>n;
  lp(i,110000) dp[i]=INF;
  int a[110000];
  lp(i,n) cin>>a[i];
  queue<pair<int,int> > q;
  int next=0;
  int cnt=0;
  dp[0]=0;
  while(1){
    if(next==n-1){
      cout<<0<<endl;
      return 0;
    }
    dp[next]=cnt;
    if(a[next]==0) break;
    dp[next]=cnt;
    next+=a[next];
  }
  q.push({next,0});
  while(!q.empty()){
    int now=q.front().first;
    cnt=q.front().second;
    q.pop();
    for(int i=1;i<=6;i++){
      next=now+i;
      if(next>=n) break;
      int stat=0;
      if(dp[next]<=cnt+1) continue;
      dp[next]=cnt+1;
      while(1){
	if(a[next]==0) break;
	next+=a[next];
	if(dp[next]<=cnt+1){
	  stat=1;
	  break;
	}
	dp[next]=cnt+1;
      }
      if(stat==1) continue;
      
      q.push({next,cnt+1});
    }
  }
  /*lp(i,n) cout<<dp[i]<<" ";
    cout<<endl;*/
  cout<<dp[n-1]<<endl;
  return 0;
}




Measured memory_bytes: 4796
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, k = M()
x = ans = 0
for i in range(101, 0, -1):
    if a%i == 0 and b%i == 0:
        x += 1
    if k == x:
        ans = i
        break
print(ans)

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

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> x(n);
	for (auto &e : x) {
		std::cin >> e;
	}
	
	int sum;
	int min = 1145141919;
	auto sq = [](int x) { return x * x; };
	for (int i = 1; i <= 100; i++) {
		sum = 0;
		for (auto e : x) {
			sum += sq(e - i);
		}
		if (sum < min) min = sum;
		else break;
	}
	
	std::cout << min << std::endl;
	
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> ff(N, vector<bool> (N, false));
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b; a--; b--;
    ff.at(a).at(b) = true;
    ff.at(b).at(a) = true;
  }
  vector<int> num(N);
  for(int i = 0; i < N ; i++) {
    num.at(i) = i;
  }
  int count = 0;
  do {
    bool judge = true;
    /*for(int i = 0; i < num.size(); i++) {
      cout << num.at(i) << " ";
    }*/
    for(int i = 0; i < num.size() - 1; i++) {
      //cout << i;
      if(num.at(0) != 0) {
        judge = false;
        break;
      } else if(ff.at(num.at(i)).at(num.at(i + 1)) == false) {
        judge = false;
        break;
      }
    }
    //cout << endl;
    if(judge) {
      count++;
    }
  } while (next_permutation(num.begin(), num.end()));
  cout << count << endl;
}

Measured memory_bytes: 256
//============================================================================
// Name        : abc110c.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	map<char, char> ma, ima;
	bool ok = true;

	for (int i = 0; i < S.length(); ++i) {
		char s = S[i], t = T[i];
		if(ma.count(s)) if(ma[s] != t) ok = false;
		if(ima.count(t)) if(ima[t] != s) ok = false;

		ma[s] = t;
		ima[t] = s;
	}

	if(ok)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define INF 10000000000000LL
#define DIM 100007
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update> myset;
typedef  pair< long long, pair<long long, long long> > ppll;
ll n,m,c,x,x2,y2,e,h,k,res1,a1,a2,w,a3,y,z,a4,a5,a6,last,dist,LL,timer,start,finish,maxmask,newmax,reslast,tests,police,brothers;
string s,s1;
ld res;
ll dp[3007][3007];
ll mas[3007];
ll l,r;
int main(){


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

    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>mas[i];
    }
    for(int i=1;i<=n;i++){
        //if(n%2==1)mas[i]*=-1;
        dp[1][i]=mas[i];
    }
    for(int i=2;i<=n;i++){
        for(int j=1;j<=n-i+1;j++){
            l=j;
            r=j+i-1;
            //if((n-i)%2==0)
            dp[i][j]=max(mas[r]-dp[i-1][j],mas[l]-dp[i-1][j+1]);
            //cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
            //else
            //dp[i][j]=max(+dp[i-1][j]-mas[r],+dp[i-1][j+1]-mas[l]);

        }
    }
    cout<<dp[n][1]<<endl;
}


Measured memory_bytes: 70016
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n, k = nm()
mod = 10**9 + 7
ans = 1
for i in range(k, n+1):
    ans += (n*2-i+1)*i//2 - i*(i-1)//2 + 1
    ans %= mod
print(ans)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back

#define N 100010
#define MOD 1000000007

ll n, m;


ll gcd(ll i, ll j)
{
	if(j == 0)
		return i;
	return gcd(j, i % j);
}
ll lcm(ll i, ll j)
{
	return (i * j)/gcd(i , j);
}


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

	cin >> n;
	pair<ll, ll> ab[n];
	for (int i = 0; i < n; ++i)
 	{
 		cin >> ab[i].ff >> ab[i].ss;
 	} 	
 	sort(ab, ab + n, [](pair<ll, ll> a, pair<ll, ll> b){
 		return a.ss < b.ss;
 	});
 	ll time = 0;
 	int f = 1;
 	for (int i = 0; i < n; ++i)
 	{
 		if(time + ab[i].ff > ab[i].ss)
 		{
 			f = 0;
 			break;
 		}
 		time += ab[i].ff;
 	}
 	
 	if(f)
 		cout << "Yes\n";
 	else
 		cout << "No\n";
	return 0;
}

Measured memory_bytes: 3328
import numpy as np
def check(x):
    x=abs(x)
    n=int(x**(float(0.2)))
    return n**5==x
def sol(x):
    for i in range(1,1001):
        if (check(i**5-x)):
            print (i,int(np.sign(i**5-x)*abs(i**5-x)**(float(0.2))))
            return

if __name__=='__main__':
    x=int(input())
    sol(x)

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

int main(){
    int a,b;
    int d,r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    printf("%d %d %.8lf\n",d,r,f);
    
    return 0;
}


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

int main() {
int n,q; cin>>n>>q;
  string s; cin>>s;
  char mfor[q+1];
  char vec[q+1];
  for(int i=1;i<=q;i++){
    cin>>mfor[i]>>vec[i];}
  char masu[n+1];
  for(int i=1;i<=n;i++){
    masu[i]=s[i-1];}
  
  int pol=0;
  int por=n+1;
  int point[n+1]={0};
  for(int i=q;i>=1;i--){
    
    if(vec[i]=='L'){
      if(masu[pol+1]==mfor[i]){
        point[pol+1]=1;
      pol++;}
        if(masu[por]==mfor[i]){
          if(por<=n){point[por]=0;
                     por++;}
        }
      
    }
          
    if(vec[i]=='R'){
      if(masu[por-1]==mfor[i]){
        point[por-1]=1;
        por--;}
      if(masu[pol]==mfor[i]){
        if(pol>=1){point[pol]=0;
        pol--;}
      }
     }
          
      if(por==pol+1) break;
  }
  
  int cou=0;
  for(int i=1;i<=n;i++){
    if(point[i]==0)cou++;}
  
  cout<<cou<<endl;
    
  
}


Measured memory_bytes: 1924
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int R, G, B, N;
    int ans = 0;
    cin >> R >> G >> B >> N;
    for (int r=0; r <= N; r++){
        for (int g = 0; g <= N; g++){
            if ((N - r*R - g*G) % B == 0 && (N - r*R - g*G) >= 0){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    combination c(2*n);
    mint ans = c(2*n-1,n);
    for(int i = k+1; i < n+1; i++) {
        ans -= c(n,i)*c(n-1,i);
    }
    cout << ans << endl;
}


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

#define MAX 5000000
#define KEYMAX 2000000000

void maxHeapify(int i);
void swap(int*, int*);

int H, A[MAX+1];

int main(){
  int i;
  scanf("%d",&H);
  if(H < 1 || H > (MAX/10))
    exit(1);

  for(i = 1; i <= H; i++){
    scanf("%d",&A[i]);
    if(A[i] < (KEYMAX * (-1)) || A[i] > KEYMAX)
      exit(1);
  }

  for(i = H/2; i >= 1; i--)
    maxHeapify(i);

  for(i = 1; i <= H; i++)
    printf(" %d",A[i]);

  printf("\n");

  return 0;
}

void maxHeapify(int i){
  int l, r, largest;
  int temp;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= H && A[l] > A[i])
    largest = l;
  else
    largest = i;
  if(r <= H && A[r] > A[largest])
    largest = r;

  if(largest != i){
    swap(&A[i],&A[largest]);
    maxHeapify(largest);
   }
}

void swap(int *a, int *b){
  int temp;

  temp = *a;
  *a = *b;
  *b = temp;
  }



Measured memory_bytes: 3660
#include <iostream>
#include <vector>

using namespace std;

void abc_150a();

void abc_151a();

void abc_152a();

void abc_154a();

void abc_156a();

void abc_157a();

void abc_158a();

void abc_159a();

int main()
{
  //abc_150a();
  //abc_151a();
  //abc_152a();
  //abc_154a();
  //abc_156a();
  //abc_157a();
  //abc_158a();
  abc_159a();
}

void abc_150a()
{
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) cout << "Yes\n";
  else cout << "No\n";
}

void abc_151a()
{
  char C;
  cin >> C;

  cout << (char)((int)C + 1) << "\n";
}

void abc_152a()
{
  int N, M;
  cin >> N >> M;
  if (N == M) cout << "Yes\n";
  else cout << "No\n";
}

void abc_154a()
{
  string S, T;
  cin >> S >> T;
  int a, b;
  cin >> a >> b;
  string U;
  cin >> U;

  if (S == U) cout << a - 1 << " " << b << "\n";
  else cout << a << " " << b - 1 << "\n";

}


void abc_156a()
{
  int N, R;
  cin >> N >> R;

  if (N >= 10) cout << R << "\n";
  else cout << R + 100 * (10 - N) << "\n";
}

void abc_157a()
{
  int N;
  cin >> N;

  if (N % 2 == 0) cout << N / 2 << "\n";
  else cout << N / 2 + 1 << "\n";
}

void abc_158a()
{
  vector<char> s(3);
  for (int i = 0; i < 3; ++i) cin >> s[i];
  for (int i = 0; i < 3; ++i)
  {
    for (int j = i + 1; j < 3; ++j)
    {
      if (s[i] != s[j])
      {
        cout << "Yes\n";
        return;
      }
    }
  }
  cout << "No\n";

}

int combination2(int n)
{
  return n * (n - 1) / 2;
}

void abc_159a()
{
  int N, M;
  cin >> N >> M;

  cout << combination2(N) + combination2(M) << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>

int main(void){
    std::string str;
    int N;
    std::cin >> N;
    std::cin.ignore();
    for(int i = 0; i < N; ++i){
        getline(std::cin, str);
        int pos;
        while((pos = str.find("Hoshino")) != -1){
            str.replace(pos, 7, "Hoshina");
        }
        std::cout << str << std::endl;
    }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        signed main() {
 
   
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        string s,t;
        cin>>s>>t;
        int fl=0;
        for(int i=0;i<s.length()&&t.length();i++)
            if(s[i]!=t[i])
                fl=1;

        if(fl || s.length()>=t.length())
            cout<<"No\n";
        else
            cout<<"Yes\n";
        return 0;
    }

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

void main_()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << setprecision(10) << static_cast<double>(W) * H / 2 << " " << (x * 2 == W && y * 2 == H ? 1 : 0) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, const T& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T> bool chmax(T& a, const T& b){ if(a < b){ a = b; return 1; } return 0; }
const int INF = 0x3fffffff;

vector<int> bfs(const vector<vector<int>>& g, int s){
  vector<int> d(g.size(), INF);
  queue<int> q;
  d[s] = 0;
  q.push(s);
  while(q.size()){
    int at = q.front();
    q.pop();
    for(int i : g[at]) if(chmin(d[i], d[at] + 1)) q.push(i);
  }
  return d;
}
int main(){
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector<vector<int>> g(n);
  for(int i = 0; i < n - 1; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> d_taka = bfs(g, u), d_aoki = bfs(g, v);
  int ans = 0;
  for(int i = 0; i < n; i++) if(d_taka[i] < d_aoki[i]) chmax(ans, d_aoki[i] - 1);
  cout << ans << endl;
}

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

using namespace std;

int main() {
long long n,r;

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

long long na=0;
for(int i=0;i<n;i++)
{
    if(i%2==1)
    na-=a[i];
    else
    na+=a[i];
}

long long  b[n];
b[0]=na;
cout<<b[0]<<" ";
for(int i=1;i<n;i++){
b[i]=2*a[i-1]-b[i-1];
    cout<<b[i]<<" ";
}





    return 0;
}


Measured memory_bytes: 2816
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	int i,j,n;ll s=0;cin>>n;vi v(n);for(i=0;i<n;i++) cin>>v[i],s+=v[i];
	vvpi d(n+1,vpi(n+1));for(i=1;i<=n;i++) d[i][i].fs=v[i-1],d[i][i].se=0;
	for(i=1;i<n;i++){
		for(j=1;j<=n-i;j++){
			int a=j,b=i+j;
			d[a][b].fs=max(v[a-1]+d[a+1][b].se,v[b-1]+d[a][b-1].se);
			if(v[a-1]+d[a+1][b].se>v[b-1]+d[a][b-1].se) d[a][b].se=d[a+1][b].fs; else d[a][b].se=d[a][b-1].fs;
		}
	}cout<<2*d[1][n].fs-s<<endl;
//	for(i=1;i<=n;i++){
//		for(j=1;j<=n;j++) cout<<d[i][j].fs<<" "<<d[i][j].se<<"   ";cout<<endl;
//	}
}


Measured memory_bytes: 141184
import numpy as np
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, m, k = geta(int)
    ca = np.array([0] + list(geta(int))).cumsum()
    cb = np.array([0] + list(geta(int))).cumsum()

    ans = 0
    for i in range(n+1):
        if ca[i] > k:
            break
        j = np.searchsorted(cb, k-ca[i], side="right") - 1
        if ans < i + j:
            ans = i + j

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 50204
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();

    if(x > 29){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
    return;

  }
}

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

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<int>> ans(h, vector<int>(w));
    for (int i = 0; i < b; i++) {
        for (int j = a; j < w; j++) {
            ans.at(i).at(j) = 1;
        }
    }
    for (int i = b; i < h; i++) {
        for (int j = 0; j < a; j++) {
            ans.at(i).at(j) = 1;
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = -1;
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];
    }
};


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int N, M;
    cin >> N >> M;
    UnionFind u(N);
    vector<int> A(M), B(M);
    REP (i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        u.unite(A[i],B[i]);
    }
    REP(i,N) {
        ans = max(ans, u.size(i));
    }

    cout << ans << endl;

    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc177/abc177_d && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc177/abc177_d && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc177/abc177_d && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 7900
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))
ta=10000
pos=1
for i in range(0,n):
  x = h[i]
  temp=abs(t-x*0.006-a)
  if temp < ta:
    pos = i+1
    ta = temp


print(pos)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  vl a(n), b(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vl ts;
  int res = 0;
  ll sum = 0, sumpos = 0;
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    if (b[i] > a[i]) {
      ++res;
      sum += b[i] - a[i];
      a[i] = b[i];
    } else {
      sumpos += a[i] - b[i];
      ts.emplace_back(a[i] - b[i]);
    }
  }
  sort(ts.rbegin(), ts.rend());
  if (sumpos < sum) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < ts.size() && sum > 0; ++i) {
    ++res;
    sum -= ts[i];
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

vector<bool> seen;
void dfs(VVI &G, int v){
    seen[v] = true;
    for (int nv:G[v]){
        if (seen[nv]) continue;
        dfs(G, nv);
    }
}

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

int N, M; cin>> N >> M;
VI a(M), b(M); rep(i, 0, M) cin >> a[i] >> b[i];

int ans = 0;
rep(i, 0, M){
    seen.assign(N+1, false);
    VVI G(N+1);
    rep(j, 0, M)
        if (i != j){
            G[a[j]].push_back(b[j]);
            G[b[j]].push_back(a[j]);
        }
    dfs(G, 1);
    if (count(RANGE(seen, 1, N+1), false)) ++ans;
} 
cout << ans << endl;



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, cnt;	

	while(cin >> n){
		bool prime[1000000] = {false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

Measured memory_bytes: 4048
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int n;
struct Point{
    int x, y, id;
};
struct Edge{
    int v, u, w;
};
int root[500000];
int sz[500000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    vector<Point> a(n);
    vector<Edge> e(2 * n - 2);
    for (int i = 0; i < n; i++) root[i] = i;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].x >> a[i].y;
        a[i].id = i;
    }
    sort(all(a), [&](Point a, Point b){
         return a.x < b.x;
         });
    for (int i = 0; i + 1 < n; i++)
    {
        e[i] = {a[i].id, a[i + 1].id, a[i + 1].x - a[i].x};
    }
    sort(all(a), [&](Point a, Point b){
         return a.y < b.y;
         });
    for (int i = 0; i + 1 < n; i++)
    {
        e[i + n - 1] = {a[i].id, a[i + 1].id, a[i + 1].y - a[i].y};
    }
    sort(all(e), [&](Edge a, Edge b){
         return a.w < b.w;
         });
    ll ans = 0;
    std::function<int(int)> Root = [&](int x)
    {
        return (x == root[x]) ? x : (root[x] = Root(root[x]));
    };
    for (int i = 0; i < 2 * n - 2; i++)
    {
        int a = Root(e[i].v);
        int b = Root(e[i].u);
        if (a == b)
        {
            continue;
        }
        if (sz[a] == sz[b])
            sz[a]++;
        if (sz[a] < sz[b])
        {
            root[a] = b;
        }
        else
        {
            root[b] = a;
        }
        ans += e[i].w;
    }
    cout << ans;
}


Measured memory_bytes: 4608
import copy
h,w=map(int,input().split())
c=[]
for _ in range(10):
    c.append(list(map(int,input().split())))

a=[]
for _ in range(h):
    a.append(list(map(int,input().split())))


d=copy.copy(c)

for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])

ans=0

for hi in range(h):
    for ahi in a[hi]:
        if(ahi != -1):
            ans+=d[ahi][1]
print(ans)

Measured memory_bytes: 3956
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdint>
using namespace std;

int_fast8_t d;
uint_fast32_t M = 0;
uint_fast64_t c, sd = -1, sc = -1;
constexpr int buff_size = 1 << 18;
char buff[buff_size], *ci = buff + buff_size, *ce = ci, ct;

inline char read_input() {
    if (ci == ce) { fread_unlocked(buff, 1, buff_size, stdin); ci = buff; }
	return *ci++;
}

int main() {
    while((ct=read_input()) > 47) M = (M<<1) + (M<<3) + ct - 48;
    while(M--) {
        if(ci + 18 > ce) {
            d = read_input() - 48;
            read_input();
            for(c=0; (ct=read_input()) > 47;) c = (c<<1) + (c<<3) + ct - 48;
        } else {
            d = *ci - 48;
            ci += 2;
            for(c=0; *ci > 47;) c = (c<<1) + (c<<3) + *ci++ - 48;
            ci++;
        }
        sc += c;
        sd += c * d;
    }
    printf("%lld", sc + sd / 9);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
    int n, k; cin >> n >> k;
    vector<ll> h(n+1);
    rep(i, n) cin >> h.at(i+1);

    sort(h.begin(), h.end());
    ll ans = INF;
    for(int i=1; i<=n-k+1; i++){
        ans = min(h.at(i+k-1)-h.at(i), ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = in.nextIntArray(n);
            int[] b = in.nextIntArray(n);

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

            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, a[i] + b[i]);
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

int main()
{
    ll N,x;
    cin >> N >> x;
    vector<ll> a(N);
    for(ll i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    ll count = 0;

    for(ll i = 0; i < N-1; i++)
    {
        ll d = a.at(i)+a.at(i+1) - x;
        if(a.at(i)+a.at(i+1) > x)
        {
            count += d;
            if(d <= a.at(i+1))
            {
                a.at(i+1) -= d;
            }
            else
            {
                a.at(i) -= (d - a.at(i+1)); 
                a.at(i+1) = 0;
            }
            
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    vector<vector<bool>> ch(h, vector<bool>(w, 0));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w - 1; j++) {
            if(g[i][j] == '#' && g[i][j + 1] == '#') {
                ch[i][j] = ch[i][j + 1] = 1;
            }
        }
    }
    for(int j = 0; j < w; j++) {
        for(int i = 0; i < h - 1; i++) {
            if(g[i][j] == '#' && g[i + 1][j] == '#') {
                ch[i][j] = ch[i + 1][j] = 1;
            }
        }
    }
    bool ok = 1;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(!ch[i][j] && g[i][j] == '#') {
                ok = 0;
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{ int A,B,C;
scanf("%d%d%d",&A,&B,&C);
if(A==B&&A!=C)
    printf("Yes\n");
else if(A==C&&A!=B)
    printf("Yes\n");
else if(B==C&&B!=A)
    printf("Yes\n");
else
        printf("No\n");
return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
	int x,i,s;
	s = 0;
	while(1){
		scanf("%d",&x);
		if(x==0){
			break;
		}else{
			i = s + 1;
			s = i;
			printf("Case %d: %d\n",i,x);
		}


	}


	return 0;
}

Measured memory_bytes: 600
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

INF = 10**12
N, M, L = map(int, readline().split())

ABCQST = np.array(read().split(), dtype=np.int64)
ABC = ABCQST[:3*M]
A = ABC[::3]; B = ABC[1::3]; C = ABC[2::3]

Q = ABCQST[3*M]

ST = ABCQST[3*M + 1:]
S = ST[::2]; T = ST[1::2]

graph = csr_matrix((C, (A, B)), (N + 1, N + 1))
d = floyd_warshall(graph, directed=False)

d[d <= L] = 1
d[d > L] = INF

d = floyd_warshall(d, directed=False).astype(int)
d[d == INF] = 0

d -= 1
print('\n'.join(d.astype(str)[S, T]))


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t dfs(vector<vector<pair<int64_t, pair<int64_t, int64_t>>>>& edges,
            vector<bool>& visited, int64_t v, int64_t goal, int64_t c) {
    visited[v] = true;

    if (v == goal) {
        return c;
    }

    for (auto&& edge : edges[v]) {
        auto u = edge.first;
        if (visited[u]) {
            continue;
        }

        auto&& cap = edge.second.first;

        if (cap == 0) {
            continue;
        }

        c = min(c, cap);

        auto ret = dfs(edges, visited, u, goal, c);
        if (ret > 0) {
            cap -= ret;
            edges[u][edge.second.second].second.first += ret;
            return ret;
        }
    }

    return 0L;
}

int main() {
    int64_t h, w;
    cin >> h >> w;

    vector<string> table(h);
    int64_t s, t, ss, tt;
    for (auto i : irange(0L, h)) {
        string line;
        cin >> line;
        table[i] = line;
        for (auto j : irange(0L, w)) {
            if (line[j] == 'S') {
                s = i;
                ss = j + h;
            } else if (line[j] == 'T') {
                t = i;
                tt = j + h;
            }
        }
    }

    if (s == t || ss == tt) {
        cout << -1 << endl;
        return 0;
    }

    int64_t n = h + w;
    vector<vector<pair<int64_t, pair<int64_t, int64_t>>>> edges(n);
    for (auto i : irange(0L, h)) {
        for (auto j : irange(0L, w)) {
            if (table[i][j] == '.') {
                continue;
            }

            auto v = i;
            auto u = h + j;
            if (u == ss) {
                u = s;
            } else if (u == tt) {
                u = t;
            }
            if (v == u) {
                continue;
            }

            edges[v].emplace_back(u, make_pair(1L, edges[u].size()));
            edges[u].emplace_back(v, make_pair(1L, edges[v].size() - 1));
        }
    }

    int64_t ans = 0;
    while (true) {
        vector<bool> visited(n);
        auto f = dfs(edges, visited, s, t, 100L);
        ans += f;
        if (f == 0) {
            break;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<long long> a(n + 1), b(m + 1), asum(n + 1, 0), bsum(m + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        asum[i] = asum[i - 1] + a[i];
        if (asum[i] <= k) {
            ans = max(ans, i);
        }
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i];
        bsum[i] = bsum[i - 1] + b[i];
        if (bsum[i] <= k) {
            ans = max(ans, i);
        }
    }
    for (int i = 1; i <= n; i++) {
        if (asum[i] > k) {
            break;
        }
        int cnt = i, L = 1, R = m;
        while (L <= R) {
            int mid = L + R >> 1;
            if (bsum[mid] <= k - asum[i]) {
                cnt = max(cnt, i + mid);
                L = mid + 1;
            } else {
                R = mid - 1;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9592
N = int(input())
dp = [0]*(100010)
dp[0] = 0
#dp[N] : N円払うのに必要な最小枚数
#dp[N] = min{1+dp[N-1],1+dp[N-6],1+dp[N-9],1+dp[N-6^2],...}

for i in range(1,100010):
  dp[i] = float('inf')
  power = 1
  while(power <= i):
    dp[i] = min(dp[i],dp[i-power]+1)
    power = power*6
  power = 1
  while(power <= i):
    dp[i] = min(dp[i],dp[i-power]+1)
    power = power*9
print(dp[N])

Measured memory_bytes: 3828
n, m = map(int, input().split())
d = {}
for _ in range(m):
    x, y, _ = map(int, input().split())
    if x in d:
        d[x].append(y)
    else:
        d[x] = [y]
    if y in d:
        d[y].append(x)
    else:
        d[y] = [x]
s = {i for i in range(1, n+1)}
a = 0
ts = set()
while s:
    cur = [s.pop()]
    ts = set(cur)
    a += 1
    while cur:
        nextp= []
        for i in cur:
            for j in d.get(i, []):
                if j not in ts:
                    ts.add(j)
                    nextp.append(j)
        cur = nextp
    s -= ts
print(a)


Measured memory_bytes: 41168
#include<iostream>
using namespace std;
int main(){
  int n,h,max_n=0,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h;
    if(max_n<=h)ans++;
    max_n=max(max_n,h);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256