akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

fn main() {
    input! {
        nn: chars
    }
    let n = nn.len();
    let nums = nn.into_iter().map(|c| (c as u8 - b'0') as usize) .collect::<Vec<_>>();
    let mut dp = vec_md![false;n+1;146;2];
    dp[0][0][0] = true;
    for i in 0..n {
        for j in 0..146 {
            for less in 0..2 {
                for d in 0..(if less == 1 {10} else {nums[i] + 1}) {
                    if j + d < 146 {
                        dp[i+1][j + d][less | (less == 0 && d < nums[i]) as usize]
                            |= dp[i][j][less];
                    }
                }
            }
        }
    }
    let mut max = 0usize;
    for j in 0..146 {
        if dp[n][j][0] || dp[n][j][1] {
            max = std::cmp::max(max, j);
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int m,n,a[1001],b[1001],f[10001];
int main()
{
	ios::sync_with_stdio(false);
	cin>>m>>n;
	for(res i=1;i<=n;++i) cin>>a[i]>>b[i];
	memset(f,0x3f,sizeof(f)),f[0]=0;
	for(res i=1;i<=n;++i)
	  for(res j=0;j<=m;++j) chkmin(f[min(j+a[i],m)],f[j]+b[i]);
	cout<<f[m]<<'\n';
	cout<<flush;	 
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n, greater<int>());
    bool flag = true;
    for (int i = 0; i < m; i++) {
        if (a[i] * 4 * m < sum) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N = gets.to_i
a = N.times.map{gets.split.map(&:to_i)}

NONE = -1
root = 0
$t = {}
$d = []
$h = []

def set_depth(u, d)
  return if u == NONE
  $d[u] = d
  set_depth($t[u][:l], d + 1)
  set_depth($t[u][:r], d + 1)
end

def set_height(u)
  h1, h2 = 0, 0
  h1 = set_height($t[u][:l]) + 1 unless $t[u][:l] == NONE
  h2 = set_height($t[u][:r]) + 1 unless $t[u][:r] == NONE
  $h[u] = (h1 > h2) ? h1 : h2
end

def get_sibling(u)
  return NONE if $t[u][:p] == NONE
  return $t[$t[u][:p]][:l] if $t[$t[u][:p]][:l] != u && !$t[$t[u][:p]][:l] != NONE
  return $t[$t[u][:p]][:r] if $t[$t[u][:p]][:r] != u && !$t[$t[u][:p]][:r] != NONE
  NONE
end

def type(u)
  if $t[u][:p] == NONE
    'root'
  elsif $t[u][:l] == NONE && $t[u][:r] == NONE
    'leaf'
  else
    'internal node'
  end
end

def degree(u)
  deg = 0
  deg += 1 unless $t[u][:l] == NONE
  deg += 1 unless $t[u][:r] == NONE
  deg
end

def print()
  (0...N).each do |u|
    puts "node #{u}: parent = #{$t[u][:p]}, sibling = #{get_sibling(u)}, degree = #{degree(u)}, depth = #{$d[u]}, height = #{$h[u]}, #{type(u)}"
  end
end

(0...N).each do |i|
  $t[i] = {p: NONE, l: NONE, r: NONE}
end

a.each do |a|
  v, l, r = a

  $t[v][:l] = l
  $t[v][:r] = r
  $t[l][:p] = v unless l == NONE
  $t[r][:p] = v unless r == NONE
end

(0...N).each do |i|
  root = i if $t[i][:p] == NONE
end

set_depth(root, 0)
set_height(root)
print()


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

  int A, B;
  std::cin >> A >> B;

  int C = 6 - (A + B);
  std::cout << C << std::endl;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int A, B, T;
    cin >> A >> B >> T;

    int time = A;
    int sum = 0;
    while (time < T + 0.5) {
        sum += B;
        time += A;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define  NUM  100

int ans[220];

/* ??\??????????????°????¶??????????????????°????±??????? */

int main(void)
{
  int num = 0;
  int count = 0;
  int i;
  int a, b, c;

  while ((scanf("%d", &a)) != EOF) {   

    scanf("%d", &b);
    num = 0;
    c = a + b;

    /* ?????°??? */
    while (1) {
      if (c == 0) break;    
      c = c / 10;
      num++;
    }

    /* ??????????????? */
    ans[count++] = num;   
  }
  
  /* ??????????????? */
  for(i = 0; i < count; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, T; cin >> A >> B >> T;
  cout << T/A * B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

int main() {
   int N; cin >> N;
   vector<int> G[N];
   rep(i,N) rep(j,N){
      char a; cin >> a;
      if(a=='1') G[i].push_back(j);
   }
   int ans=-1;
   rep(i,N){
      queue<int> q;
      vector<int> visited(N,-1);
      q.push(i);
      visited[i]=1;
      bool can=true;
      while(!q.empty()){
         int a=q.front(); q.pop();
         rep(j,G[a].size()){
            if(visited[G[a][j]]==-1){
               visited[G[a][j]]=visited[a]+1;
               q.push(G[a][j]);
            }
            else if(visited[G[a][j]]==visited[a]+1||visited[G[a][j]]==visited[a]-1);
            else {can = false;  break;} 
         }
         if(can == false) break;
      }
      if(!can) continue;
      if(can){
         sort(visited.begin(),visited.end(),greater<int>());
         ans=max(ans,visited[0]);
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int k,a,b;
    while(cin>>k)
    {
        cin>>a>>b;
        int cnt=0;
        for(int i=a;i<=b;i++)
        {
            if(i%k==0)
            {
                cnt=1;
                break;
            }
        }
        if(cnt==1)
        {
            cout<<"OK"<<endl;
        }
        else
        {
            cout<<"NG"<<endl;
        }
    }
}


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

int main() { 	
 int N,M,R,L,mR,mL;
 cin >>N>>M;
  mR=0;
  mL=N; 
  for(int i=0;i<M;i++){
  cin >>R>>L;
    if(mR<=R){
    mR=R;
    }
    
    if(mL>=L){
    mL=L;
    }

  }
  if(mL-mR> -1){
  cout << mL-mR+1<<endl;}else{
  cout << 0<<endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n,k;
  cin>>n>>k;
  vector<ll>v(n);
  for(auto &x:v) cin>>x;
  sort(v.begin(),v.end());
  ll sum=0;
  for(int i=0;i<n-k;i++) sum+=v[i];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
	long long a , b , x , ans;
	scanf("%lld %lld %lld",&a,&b,&x);
	long long a1 = (a - a%x)/x;
	long long b1 = (b - b%x)/x;
	ans = b1 - a1;
	if(a % x == 0) ans++;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main() {
		int cost; cin >> cost;
	do{
		int ten,fifty,hund,fivehund;
		cin >> ten >> fifty >> hund >> fivehund;
		int first_ten = ten;;
		ten = ten + fifty * 5 + hund * 10 + fivehund * 50;
		ten -= cost / 10;
		int ans_ten = 0;
		int ans_fifty = 0;
		int ans_hund = 0;
		int ans_fivehund = 0;
		ans_fivehund = (ten * 10) / 500;
		ten -= ans_fivehund * 50;
		ans_hund = (ten * 10) / 100;
		ten -= ans_hund * 10;
		ans_fifty = (ten * 10) /50;
		ten -= ans_fifty * 5;
		ans_ten = ten;

		if (first_ten - ans_ten > 0){
			cout << 10 << " " << first_ten - ans_ten << endl;
		}
		if (fifty - ans_fifty > 0){
			cout << 50 << " " << fifty - ans_fifty << endl;
		}
		if (hund - ans_hund > 0){
			cout << 100 << " " << hund - ans_hund << endl;
		}
		if (fivehund - ans_fivehund > 0){
			cout << 500 << " " << fivehund - ans_fivehund << endl;
		}
		cin >> cost;
		if (cost != 0){
		cout << endl;
		}
	}while(cost != 0);

	return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<int, int, ll> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[200100], b[200100];

ll solve() {
    ll min_b = inf;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > b[i] && min_b > b[i]) {
            min_b = b[i];
        }
        sum += a[i];
    }
    if (min_b >= inf) return 0;

    return sum - min_b;
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second 
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define pp pair<ll,ll> 
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t = 1 ;
void solve()
{
    ll n ;cin>>n;cout<<(n*n*n);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin >> t ;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int hill[100001];
vector<int> v[100001];
int ans = 0;
int main(){
	int N, M;
	cin >> N >> M;
	for(int i=1; i<=N; i++){
		cin >> hill[i];
	}
	int A, B;
	for(int i=1; i<=M; i++){
		cin >> A >> B; 
		v[A].push_back(B);
		v[B].push_back(A);
	}
	for(int i=1; i<=N; i++){
		if(v[i].size() == 0) {
			ans++;
			continue;	
		}
		int flag = 0;
		for(int j=0; j<v[i].size(); j++){
			if(hill[i] <= hill[v[i][j]]){
				flag = 1;
				break;	
			} 	
		}
		if(!flag) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 8664
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    val n = sc.nextInt()
    val p = (0 until n).map { sc.next().toInt() }
    println(problem170c(x, n, p))
}

fun problem170c(x: Int, n: Int, p: List<Int>): Int {
    if (n == 0) return x
    val p = p.toHashSet()
    var min = Integer.MAX_VALUE
    var minI = 0
    for (i in -100 until 200) {
        if (p.contains(i)) continue
        if (min > Math.abs(i - x)) {
            min = Math.abs(i - x)
            minI = i
        }
    }
    return minI
}

Measured memory_bytes: 38124
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc  = new Scanner(System.in);
			System.out.println(Math.abs(sc.nextLong() - sc.nextLong()) <= 1 ? "Brown" : "Alice");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 23760
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n,m,x;
    cin >> n >> m >> x;
    int a[110];
    REP(i,0,m){
        cin >> a[i];
    }
    //処理
    int ansa=0;
    int ansb=0;
    REP(i,0,m){
        if(a[i]<x) ansa++;
        if(a[i]>x) ansb++;
    }
    //出力
    cout << min(ansa,ansb) << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L,x;cin>>N>>L;
  x=N*L+N*(N-1)/2;
  if(N+L-1<0)x-=N+L-1;
  if(L>0)x-=L;
  cout<<x<<endl;
}

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

typedef complex<double> P;
const double eps = 1e-10;
const double inf = 1e10;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

P project(P s1, P s2, P p) {
  P base = s2 - s1;
  double t = dot(p - s1, base)/norm(base);
  return s1 + base*t;
}

P reflect(P s1, P s2, P p) {
  return p + (project(s1, s2, p) - p)*2.0;
}

int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a,b) > eps) return 1;
  if(cross(a,b) < -eps) return -1;
  if(dot(a,b) < -eps) return 2;
  if(norm(b)-norm(a) > eps) return -2;
  return 0;
}

bool isIntersect(P a1, P a2, P b1, P b2) {
  return ( ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 &&
           ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0 );
}

P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 -a1)/cross(b, a);
}

int main() {
  int N;
  P s;
  vector<P> g;
  while(cin >> N && N) {
    g.resize(N);
    cin >> s.real() >> s.imag();
    for(int i = 0; i < N; ++i) {
      cin >> g[i].real() >> g[i].imag();
    }

    vector<pair<P,P> > seg;
    for(int i = 0; i < N; ++i) {
      seg.push_back(make_pair(g[i], g[(i+1)%N]));
    }
    sort(seg.begin(), seg.end());
    int res = 0;
    do {
      try {
        vector<pair<P,P> > t = seg;
        P A, B;
        for(int i = 0; i < N; ++i) {
          P a = t[i].first;
          P b = t[i].second;
          // if(abs(ccw(s,a,b)) != 1) throw 0;
          if(ccw(s,a,b) == -1) swap(a, b);
          if(i == 0) {
            A = a;
            B = b;
          } else {
            if(ccw(s,A,a) ==  1) A = a;
            if(ccw(s,B,b) == -1) B = b;
            if(!(cross(A-s,B-s) > eps)) throw 0;
          }
          for(int j = i+1; j < N; ++j) {
            P p = reflect(a, b, t[j].first);
            P q = reflect(a, b, t[j].second);
            t[j] = make_pair(p, q);
          }
        }
        if(cross(A-s,B-s) > eps) ++res;
      } catch(...) {}
    } while(next_permutation(seg.begin(), seg.end()));
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#
# abc060 b
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7 5 1"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 2 1"""
        output = """NO"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 100 97"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """40 98 58"""
        output = """YES"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """77 42 36"""
        output = """NO"""
        self.assertIO(input, output)


def resolve():
    A, B, C = map(int, input().split())

    for i in range(A, A*B+1):
        if A*i % B == C:
            print("YES")
            break
    else:
        print("NO")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16308
N,x=map(int,input().split())
A=list(map(int,input().split()))
def solve(arr,sup):
    ans=0
    a=arr[:]
    for i in range(len(a)-1):
        tmp = a[i]+a[i+1]-sup
        if tmp>0:
            a[i+1]-=min(tmp,a[i+1])
            ans+=tmp
    return ans
print(min(solve(A,x), solve(A[::-1],x)))


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

int main() {
    long long n, ma, mb;
    const long long inf = 10000000000;
    auto ret = inf;
    std::cin >> n >> ma >> mb;
    std::vector<long long> a(n), b(n), c(n);
    for (auto i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i] >> c[i];
    }

    std::vector<std::vector<long long>> p(410, std::vector<long long>(410, inf));
    p[a[0]][b[0]] = c[0];
    for (auto i = 1; i < n; i++) {
        auto ptmp = p;
        for (auto j = 0; j < 400; j++) {
            for (auto k = 0; k < 400; k++) {
                if (p[j][k] == inf) continue;
                ptmp[j + a[i]][k + b[i]] = std::min(p[j + a[i]][k + b[i]], p[j][k] + c[i]);
            }
        }
        ptmp[a[i]][b[i]] = std::min(c[i], p[a[i]][b[i]]);
        ptmp.swap(p);
    }

    for (auto i = 1; std::max(ma, mb) * i <= 400; i++) {
        ret = std::min(ret, p[ma * i][mb * i]);
    }

    if (ret == inf) std::cout << -1 << std::endl;
    else std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 2960
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		int m=1<<n;
		var h=new int[n][];
		for(int i = 0;i<n;i++) {
			var p=sc.I;
			h[i]=new int[2];
			for(int j = 0;j<p;j++) {
				var e=sc.Ia;
				h[i][e[1]]|=1<<(e[0]-1);
			}
		}
		int ans=0;
		for(int i = 0;i<m;i++) {
			var bo=true;
			int p=0;
			for(int j = 0;j<n;j++) {
				if(((1<<j)&i)!=0){
					if((h[j][0]&i)!=0||(h[j][1]|i)!=i){
						bo=false;
						break;
					}
					p++;
				}
			}
			if(bo){
				ans=Max(ans,p);
			}
		}
		Console.WriteLine("{0}",ans);
	}
	static string Binary(long a,int b){
		string s=Convert.ToString(a,2);
		return (b>s.Length?new string('0',b-s.Length):"")+s;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
int main(){
	map<int,vector<int> > data;
	for(int i=150-1;i>0;i--){
		for(int j=i-1;j>0;j--){
			data[i*i+j*j].push_back(j);
		}
	}
	int h,w;
	while(cin>>h>>w&&(h!=0||w!=0)){
		bool f=false;
		int s=h*h+w*w;
		sort(data[s].begin(),data[s].end());
		for(int i=0;i<data[s].size();i++){
			if(data[s][i]>h){
				f=true;
				cout<<data[s][i]<<" "<<sqrt(s-data[s][i]*data[s][i])<<endl;
				break;
			}
		}
		if(f)continue;
		while(1){
			s++;
			if(data[s].size()){
				sort(data[s].begin(),data[s].end());
				cout<<data[s][0]<<" "<<sqrt(s-data[s][0]*data[s][0])<<endl;
				break;
			}
		}
	}
}

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


int64_t gcd(int64_t a, int64_t b) {
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main() {
	int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    cout<< b - (a-1) - b/c + (a-1)/c - b/d + (a-1)/d + b/lcm(c, d) - (a-1)/lcm(c, d) <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll dp[3000][3000][4];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int r, c, k;
    cin >> r >> c >> k;
    vector<vector<ll>> a(r, vector<ll>(c, 0));
    int y, x; ll v;
    for(int i=0;i<k;++i) {
        cin >> y >> x >> v;
        --y; --x;
        a[y][x] = v;
    }

    fill_n((ll *)dp, r*c*4, 0LL);
    for(int i=0;i<r;++i) {
        for(int j=0;j<c;++j) {
            for(int l=0;l<=3;++l) {
                if(j < c-1) dp[i][j+1][l] = max(dp[i][j+1][l], dp[i][j][l]);
                if(j < c-1 && l < 3 && a[i][j]) dp[i][j+1][l+1] = max(dp[i][j+1][l+1], dp[i][j][l] + a[i][j]);
                if(i < r-1) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l]);
                if(i < r-1 && l < 3  && a[i][j]) dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][l] + a[i][j]);
            }
        }
    }
    if(a[r-1][c-1]) for(int l=0;l<=2;++l) dp[r-1][c-1][l] += a[r-1][c-1];
    

    cout << *max_element(dp[r-1][c-1], dp[r][0]) << endl;
}


Measured memory_bytes: 354728
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
const ll MAX = 402020;
ll fac[MAX], finv[MAX], inv[MAX];
void cinit() { // O(nlogn)
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    reps(i, 2, MAX){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll c(int n, int k){ // 二項係数計算
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//--MAIN-----------------------------------
void Main() {
    ll N,K; cin>>N>>K;
    ll anss=0;
    cinit();
    rep(i,min(N,K+1)){
       ll ans=1;
       ans*=c(N-1,i);
       ans%=MOD;
       ans*=c(N,i);
       anss+=ans;
       anss%=MOD;
    }
    cout<< anss<<"\n";


}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    double N; cin >> N;
    double a=N/3.0;
    cout << a*a*a << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
mList=set([int(input()) for _ in range(m)])

dp=[0]*(n+1)
dp[0]=1
if 1 not in mList:
  dp[1]=1

for i in range(2,n+1):
  if i in mList: continue
  dp[i]+=dp[i-1]
  dp[i]+=dp[i-2]
  dp[i]%=1000000007

print(dp[n])


Measured memory_bytes: 13216
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n;
    n = sc.nextInt();

    int[] arr = new int[n];
    int[] sorted = new int[n];

    for (int i = 0; i < n; i++) {
      int num = sc.nextInt();
      arr[i] = num;
      sorted[i] = num;
    }

    Arrays.sort(sorted);
    int upper = n / 2;
    int lower = n / 2 - 1;
    double median = (sorted[upper] + sorted[lower]) / 2.0;
    for (int i = 0; i < n; i++) {
      int removed = arr[i];
      if (removed < median) {
        System.out.println(sorted[upper]);
      } else {
        System.out.println(sorted[lower]);
      }
    }
  }
}


Measured memory_bytes: 84936
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int Maxn=2e5+5;
int n,m,v,p,a[Maxn];
bool check(int pos){
	int kill=n-p;ll sum=0;
	for(int i=n;i>=1&&kill;i--){
		if(i!=pos){
			if(a[pos]-a[i]>m)return false;
			sum+=max(a[pos]-a[i],0),kill--;
		}
	}
	return sum<=(ll)m*v;
}
int main(){
	cin>>n>>m>>v>>p;
	v=n-v;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]=1e9-a[i];
	}
	sort(a+1,a+n+1);
	int l=1,r=n;
	while(l<r){
		int mid=(l+r+1)/2;
		if(check(mid))l=mid;
		else r=mid-1;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int m, n, total, br;
int main() {
    IOS; cin >> n >> m;
    vector<int> v(n);
    for(int i=0; i<n; ++i) {cin >> v[i]; total+=v[i];}
    double vr = 0.25 / (double)(m) * (double)(total);
    int la = ceil(vr);
    for(int i=0; i<n; ++i) {
        if(v[i]>=la) ++br;
    }
    if(br>=m) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[10000]={1,1};
int kaishi(int n){
    if(a[n])return a[n];
    a[n]=kaishi(n-1)+kaishi(n-2);
    return a[n];
}
int main(){
    int n;
    scanf("%d",&n);
    printf("%d\n",kaishi(n));
    return 0;
}

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

void solve(long long X){
	for(int i = 1;; i++) {
		if(i * (i + 1) / 2 >= X) {
			cout << i << endl;
			return;
		}
	}
}

int main(){	
	long long X;
	scanf("%lld",&X);
	solve(X);
	return 0;
}



Measured memory_bytes: 256
//let's do it
 #include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1000000000000
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define boost1 ios::sync_with_stdio(false);
#define boost2 cin.tie(0);
#define mem(a,val) memset(a,val,sizeof a)
#define endl "\n"
#define maxn 100001

ll dp[310][310][310],n,minl[310][4],maxl[310][4];

ll add(ll x,ll y)
{
	return (x+y)%mod;
}
int valid(int c1,int c2,int c3,int ind)
{
	if(c2>=minl[ind][1])
	return 0;
	if(c2<maxl[ind][2])
	return 0;
	if(c1>=minl[ind][2])
	return 0;
	if(c1<maxl[ind][3])
	return 0;
	if(c3<maxl[ind][1])
	return 0;
	return 1;
}
ll solve(int c1,int c2,int c3)
{
	ll last_ind=c3+1;
	if(last_ind>n)
	return 1;
	ll ans=dp[c1][c2][c3];
	if(ans!=-1)
	return ans;
	ans=0;
	ll nc1,nc2,nc3;
	//paint c1
	nc1=c2;
	nc2=c3;
	nc3=last_ind;
	if(valid(nc1,nc2,nc3,last_ind))
	ans=add(ans,solve(nc1,nc2,nc3));
	//paint c2
	nc1=c1;
	nc2=c3;
	nc3=last_ind;
	if(valid(nc1,nc2,nc3,last_ind))
	ans=add(ans,solve(nc1,nc2,nc3));
	//paint c3
	nc1=c1;
	nc2=c2;
	nc3=last_ind;
	if(valid(nc1,nc2,nc3,last_ind))
	ans=add(ans,solve(nc1,nc2,nc3));

	dp[c1][c2][c3]=ans;
	return ans;
}
int main()
{
	boost1;boost2;
	ll i,j,m,x,y,l,r;
	mem(dp,-1);
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		{
			minl[i][j]=inf;
			maxl[i][j]=-inf;
		}
	}
	while(m--)
	{
		cin>>l>>r>>x;
		minl[r][x]=min(minl[r][x],l);
		maxl[r][x]=max(maxl[r][x],l);
	}
	cout<<solve(0,0,0);
	return 0;
}


Measured memory_bytes: 233088
#include <iostream>
using namespace std;
#define MAX 2019
int n;
int array[30];
int exists[MAX];

void solve(int pos, int sum) {
  sum += array[pos];
  if (sum >= MAX) return;
  exists[sum] = 1;
  for (int i = pos+1; i < n; i++) {
    solve(i, sum);
  }
}

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

  int q, m;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> m;
    cout << (exists[m] ? "yes" : "no") << endl;
  }
}




Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define MAX 1000000

bool prime[MAX];
bool order[MAX+1];
int menu[30];
int n,money;

void init(){
	fill(prime,prime+MAX,true);
	prime[0]=prime[1]=false;
	for(int i=2;i<MAX;i++){
		if(prime[i]){
			for(int j=2;j*i<MAX;j++)
				prime[j*i]=false;
		}
	}
}
int main(){
	init();
	while(cin>>n>>money,n|money){
		for(int i=0;i<n;i++)cin>>menu[i];
		fill(order,order+(MAX+1),false);
		order[0]=true;
		for(int i=0;i<=money;i++){
			for(int j=0;j<n;j++){
				if(order[i] && i+menu[j]<=money)
					order[i+menu[j]] = true;
			}
		}
			
		int ans=-1;
		for(int i=money;i>1;i--){
			if(prime[i] && order[i]){
				ans=i;
				break;
			}
		}
		if(ans!=-1)cout<<ans<<endl;
		else cout<<"NA"<<endl;
	}
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    int N, K;
    scanf("%d %d", &N, &K);
    double probability = 0;
    int i = 0;
    for(i = 0; i < N; i ++)
    {
        if((ceil(log((double)K / (double)(i + 1)) / log(2.0))) > 0.1){
            probability += 1.0 / pow(2, (ceil(log((double)K / (double)(i + 1)) / log(2.0))));
        }else{
            probability += 1.0;
        }
           
    }
    probability = probability / N;
    printf("%.10lf", probability);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

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

	for (int i = 0; i < q; ++i) {
		int c, a, n;
		std::cin >> c >> a >> n;
		int step = 1;
		int count = 0;
		while (step != 4) {
			switch (step) {
			case 1:
				if (c > 0 && n > 0 && a > 0)
					--c, --a, --n, ++count;
				else
					++step;
				break;
			case 2:
				if (c >= 2 && a > 0)
					c -= 2, --a, ++count;
				else
					++step;
				break;
			case 3:
				if (c >= 3)
					c -= 3, ++count;
				else
					++step;
				break;
			}
		}

		std::cout << count << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
int n;
string s;

void solve() {
	cin >> n;
	cin >> s;
	//'E'の累積和を求める
	int k = count(s.begin(), s.end(), 'E');
	int ans = k;
	for (char c : s) {
		//今見ている場所の文字がEであれば向きを変更する必要がある人数を減らす
		//次の文字以降も向きを変更する必要は発生しない
		if (c == 'E') k--;
		ans = min(ans, k);
		//今見ている場所の文字がWであれば次の文字以降向きを変更する必要があるので、人数をカウントアップ
		if (c == 'W') k++;
	}
	cout << ans << endl;
	return;
}

int main(int args, char* argv[]) {
	solve();
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int maN = 1e6+5;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    
    for(int i = 0; i< n; ++i)
    {
        cin >> a[i];
    }
    ll sum = 0;
    for(int i = 1; i < n; ++i)
    {
        if(a[i] < a[i-1] )
        {
            sum += a[i-1]-a[i];
            a[i] += a[i-1]-a[i];
        }
    }
    cout << sum;
	return 0;
}

Measured memory_bytes: 4780
#include <cassert>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int main() {
  long N, L;
  cin >> N >> L;
  assert(2 <= N && N <= 200);
  assert(-100 <= L && L <= 100);

  const auto orig = (L + L + N - 1) * N / 2;
  auto min = L + 1;
  for (auto i = 0u; i < N; ++i) {
    if (L + i < abs(min))
      min = L + i;
  }
  cout << (orig - min);
}


Measured memory_bytes: 256
import java.util.*;

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

        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        String[] sElementArray=sc.nextLine().split(" ");
        int[] array=Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();
        sc.close();

   
            int q=partition(array,0,n-1);
            String[] ss=Arrays.stream(array).mapToObj(Integer::toString).toArray(s->new String[s]);
            for(int i=0;i<n;i++){
                if(q==i){
                    System.out.print("["+ss[i]+"]"+" ");
                }else if (i!=n-1){
                    System.out.print(ss[i]+" ");
                }else{
                    System.out.println(ss[i]);
                }
            }
        
            
        }
public static int partition(int[] array,int startIndex,int endIndex){
        // int n=array.length;
        int i=startIndex-1;
        for(int j=startIndex;j<endIndex;j++){
            if(array[j]<=array[endIndex]){
                i++;
                swap(array,i,j);
            }
        }
        i++;
        swap(array,i,endIndex);
        return i;
    }

    public static void swap(int[] array,int i, int j){
                int tmp=array[i];
                array[i]=array[j];
                array[j]=tmp;
    }
    }
    


Measured memory_bytes: 79596
'''input
5 5
.#.#.
#.#.#
.#.#.
#.#.#
.#.#.
'''

import sys
import math
from collections import Counter

debug = 0
readln = sys.stdin.readline
#sys.setrecursionlimit(1000000)

def write(s):
    sys.stdout.write(str(s))

def writeln(s):
    sys.stdout.write(str(s))
    sys.stdout.write('\n')

def readint():
    return int(readln().strip())

def readints():
    return map(int, readln().split())

def readstr():
    return readln().strip()

def readstrs():
    return readln().split()

def dbg(*args):
    if debug: print(' '.join(map(str, args)))


h,w = readints()
mat = []
dp = [[0] * w for _ in xrange(h)]
for _ in xrange(h):
    mat.append(readstr())

def getdp(r, c, cur):
    if r < 0 and c == 0 or c < 0 and r == 0:
        old = 0
        oldc = '.'
    elif r < 0 or c < 0:
        return 2**31
    else:
        old = dp[r][c]
        oldc = mat[r][c]

    if cur == '#' and oldc == '.':
        return old + 1
    else:
        return old

def solve(h, w):
    global dp
    for r in xrange(h):
        for c in xrange(w):
            cur = mat[r][c]
            dp[r][c] = min(getdp(r-1, c, cur), getdp(r, c-1, cur))
    dbg(dp)
    return dp[h-1][w-1]

print solve(h, w)

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

int main(){
    int a, b;
    while(1)
    {
    cin>>a>>b;
    if(a==0 && b==0)break;
    else if(a>b)cout<<b<<' '<<a<<endl;
    else cout<<a<<' '<<b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.nextLine();
		char[] b = new char[1010];
		b=a.toCharArray();
		for(int i=0;i<b.length;i++){
			if(b[i]=='a'&&b[i+1]=='p'&&b[i+2]=='p'&&b[i+3]=='l'&&b[i+4]=='e'){
				b[i]='p';
				b[i+1]='e';
				b[i+2]='a';
				b[i+3]='c';
				b[i+4]='h';
			}
			else if(b[i]=='p'&&b[i+1]=='e'&&b[i+2]=='a'&&b[i+3]=='c'&&b[i+4]=='h'){
				b[i]='a';
				b[i+1]='p';
				b[i+2]='p';
				b[i+3]='l';
				b[i+4]='e';
			}
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vi a(n);
        REP(i, n) {
            string s; cin >> s;
            a[i] = s.size();
        }

        vi nums = { 5, 7, 5, 7, 7};
        REP(i, n) {
            int cnt = 0;
            int idx = 0;
            bool valid = false;
            FOR(j, i, n) {
                cnt += a[j];
                if (cnt > nums[idx]) break;
                if (cnt == nums[idx]) {
                    cnt = 0;
                    if (++idx == 5) {
                        valid = true;
                        break;
                    };
                }
            }
            if (valid) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3176
#include<stdio.h>

int main(void){
  int n,a,b,c,d[101],i,j,t;

  scanf("%d %d %d %d",&n,&a,&b,&c);

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

  for(i=n-1;i>0;i--)
    for(j=0;j<i;j++)
      if(d[j]<d[j+1])
	t=d[j],d[j]=d[j+1],d[j+1]=t;
      
  for(i=0;i<n;i++)
    if((c + d[i])/(a+b)>=c/a)c+=d[i],a+=b;
    else break;
  
  printf("%d\n",c/a);

  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;

int main(){
  int n;
  cin>>n;
  for(int k=0;k<n;k++){
    vector<int> a(10);
    for(int i=0;i<10;i++)cin>>a[i];
    int x=a[0];
    int y=0;
    int fl=1;
    for(int i=1;i<10;i++){
      if(x>a[i]&&y>a[i]){
        fl=0;
        cout<<"NO"<<endl;
        break;
      }
      if(x>=y){
        if(x<a[i]){
          x=a[i];
        }else{
          y=a[i];
        }
      }else{
        if(y<a[i]){
          y=a[i];
        }else{
          x=a[i];
        }
      }
    }
    if(fl)cout<<"YES"<<endl;
  }
}



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

using namespace std;

typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	set <string> s;
	for(int i = 0; i <n; i++)
	{
		string s1;
		cin >> s1;
		s.insert(s1);
	}
	cout << s.size() << "\n";
}

int main()
{
	int t = 1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 19252
from collections import Counter
N = int(input())
d = dict()

ans = 0
for i in range(N):
  s = str(input())
  s = ''.join(sorted(s))
  if s in d:
    ans += int(d[s])
    d[s] = int(d[s]) + 1
  else:
    d[s] = 1
    
print(ans)

Measured memory_bytes: 22636
/* competitive programming circle traP */
/* template */
#include <stdio.h>
#include <queue>
using namespace std;

int h,w,n;
int px[11];
int py[11];
int mp[1000][1000];
bool used[1000][1000];
int dy[4] = {1,0,-1,0};
int dx[4] = {0,1,0,-1};

int bfs(int sy,int sx,int gy,int gx){
  for(int i=0;i<h;i++)for(int j=0;j<w;j++){
    used[i][j] = false;
  }
  queue<int> qy,qx,qd;
  used[sy][sx] = true;
  qy.push(sy); qx.push(sx); qd.push(0);
  while(!qy.empty()){
    int y,x,d;
    y = qy.front(); qy.pop();
    x = qx.front(); qx.pop();
    d = qd.front(); qd.pop();
    if(y==gy && x==gx)return d;
    for(int i=0;i<4;i++){
      int ny = y+dy[i];
      int nx = x+dx[i];
      int nd = d+1;
      if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
      if(used[ny][nx])continue;
      if(mp[ny][nx] == 1)continue;
      used[ny][nx] = true;
      qy.push(ny); qx.push(nx); qd.push(nd);
    }
  }
  return -1;
}

int main(){
  scanf("%d%d%d",&h,&w,&n);
  for(int i=0;i<h;i++){
    char s[1001];
    scanf("%s",&s);
    for(int j=0;j<w;j++){
      char c = s[j];
      if(c=='X'){
        mp[i][j] = 1;
      }else{
        mp[i][j] = 0;
        if(c=='S'){
          py[0] = i;
          px[0] = j;
        }else if(c!='.'){
          py[c-'0'] = i;
          px[c-'0'] = j;
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    ans += bfs(py[i],px[i],py[i+1],px[i+1]);
  }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    double val = (double)N / 1.08;
    if ((int)((int)val * 1.08) == N)
    {
        cout << (int)val << endl;
    }
    else if ((int)(((int)val + 1) * 1.08) == N)
    {
        cout << (int)val + 1 << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c;
  cin>>a>>b>>c;
  if(a>=c){a-=c;cout<<a<<' '<<b<<endl;return 0;}
  else{c-=a;a=0;}
  if(b>=c){b-=c;}
  else{b=0;}
  cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int h, w, n;
  cin >> h >> w >> n;
  cout << (n + max(h, w) - 1) / max(h, w) << '\n';
  return 0;
}

Measured memory_bytes: 256