akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = 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; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

//E
ll n,k;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

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

    cin>>n>>k;

    vll a(k+1);
    FORR(i,k,1){
        a[i]=power(k/i,n);
        ll j=2*i;
        while(j<=k){
            a[i] -= a[j];
            j+=i;
        }
    }

    ll ans=0;
    FOR(i,1,k){
        ans += i * a[i];
        ans %= mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
#include <math.h>
int main(){
  int n,w[100],sum=0,i,min,s1,s2;
  fscanf(stdin,"%d\n",&n);
  for(i=0;i<n;i++){
  	fscanf(stdin,"%d",&w[i]);
    sum+=w[i];
  }
  s1=w[0];
  s2=sum-w[0];
  min=abs(s1-s2);
  for(i=1;i<n-1;i++){
  	s1+=w[i];
    s2-=w[i];
    if(min>abs(s1-s2))
      min=abs(s1-s2);
  }
  printf("%d",min);
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    double N;

    cin >> N;

    double count = 0;

    for(int i = 0; i < N; i++) {
        double x;
        cin >> x;
        count += 1 / x;
    }

    


    cout << 1 / count << endl;
}

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

const int MOD_VALUE = 1000000007;


int main(void){

	int h,w,k;

	int in[300][300];
	int out[300][300];

	int bot[300];
	int top[300];
	int non[300];

	int i,j;
	char buff;
	int l_flag;
	int n_line;

	int index;

	scanf("%d %d %d",&h,&w,&k);

	index = 1;

	for(i=0;i<h;i++){
		for(j=0;j<w;j++){

			//初期化
			out[i][j] = -1;

			scanf("%c",&buff);

			if(buff == '\n'){
				scanf("%c",&buff);
			}

			if(buff == '#'){
				in[i][j] = 1;
			}else{
				in[i][j] = 0;
			}
		}
	}

	// a,b[h][w]
	for(i=0;i<w;i++){
		bot[i] = -1;
		top[i] = -1;
		for(j=0;j<h;j++){
			if(in[j][i] == 1){

				// botの更新
				if(bot[i] == -1){ bot[i] = j; }

				// topの更新
				top[i] = j;
			}
		}
	}

	n_line = -1;
	for(i=0;i<w;i++){
		non[i] = -1;
		if(bot[i] != -1){
			if(n_line == -1){n_line = i;}
			non[i] = 1;
		}
	}
/*
	printf("\n===in===\n");
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			printf("%d ",in[i][j]);
		}
		printf("\n");
	}


	printf("\n===top===\n");
	for(i=0;i<w;i++){
		printf("%d ",top[i]);
	}

	printf("\n===bot===\n");
	for(i=0;i<w;i++){
		printf("%d ",bot[i]);
	}

	printf("\n===non===\n");
	for(i=0;i<w;i++){
		printf("%d ",non[i]);
	}

	printf("\nn_line : %d\n",n_line);
	*/

	for(i=n_line;i<w;i++){
		if(non[i] == 1){
			for(j=0;j<h;j++){
				if(in[j][i] == 1){
					if(j != bot[i]){
						index++;
					}
				}
				out[j][i] = index;
			}
			index++;
		}else{
			for(j=0;j<h;j++){
				out[j][i] = out[j][i-1];
			}
		}
	
	}
	for(i=n_line-1;i>=0;i--){
		for(j=0;j<h;j++){
			out[j][i] = out[j][i+1];
		}
	}

//	printf("\n===out===\n");
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			printf("%d ",out[i][j]);
		}
		printf("\n");
	}


	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define per(i,a,b) for(long long i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n;
	cin>>n;
	ll ans = 0;
	vector<ll> v;
	rep(i,0,n){
		ll a;
		cin>>a;
		v.pb(a);
	}
	while(1){
		sort(all(v));
		if(v[v.sz-1]<200)break;
		ll b = (v[v.sz-1]-100)/n;
		v[v.sz-1]-=n*b;
		rep(i,0,v.sz-1){
			v[i]+=b;
		}
		ans += b;
	}
	while(1){
		sort(all(v));
		if(v[v.sz-1]<n)break;
		v[v.sz-1]-=n;
		rep(i,0,v.sz-1){
			v[i]++;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>
#define abs(x) (x>0) ? x : -x
#define TRUE 1
#define FALSE 0

long long int psum( int pattern, long long int x, long long int y, long long int z){
  long long int sum=0;
  
  sum += ( pattern % 2 < 1 ) ? x : -x;
  sum += ( pattern % 4 < 2 ) ? y : -y;
  sum += ( pattern % 8 < 4 ) ? z : -z;
  
  return sum;
}

int main(void){
  
  int Is_swaped,h,i,j,p,n,m;
  long long int ans[8],x[1000],y[1000],z[1000],w[1000],temp[3];
  
  scanf("%d %d",&n,&m);
  for( i=0; i<n; i++) scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  
  for( p=0; p<8; p++){
    h = n;
    Is_swaped = FALSE;
    
    while( h>1 || Is_swaped == TRUE ){
      if( h>1 ){
        h = ( h * 10 ) / 13;
      }
      
      Is_swaped = FALSE;
      for( i=0; i<n-h; i++){
        if( psum(p,x[i],y[i],z[i]) < psum(p,x[i+h],y[i+h],z[i+h]) ){
          // swap
            temp[0] = x[i];   temp[1] = y[i];   temp[2] = z[i];
             x[i] = x[i+h];    y[i] = y[i+h];    z[i] = z[i+h];
          x[i+h] = temp[0]; y[i+h] = temp[1]; z[i+h] = temp[2];
          Is_swaped = TRUE;
        }
      }
    }
    
    for( ans[p]=0, i=0; i<m; i++) ans[p] += psum(p, x[i], y[i], z[i]);
  }
  
  h = 8;
  Is_swaped = FALSE;
  while( h>1 || Is_swaped == TRUE ){
    if( h>1 ){
      h = ( h * 10 ) / 13;
    }
    
    Is_swaped = FALSE;
    for( i=0; i<8-h; i++){
      if( ans[i] < ans[i+h] ){
        // swap
        p = ans[i];
        ans[i] = ans[i+h];
        ans[i+h] = p;
        Is_swaped = TRUE;
      }
    }
  }
  
  printf("%lld\n",ans[0]);
    
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 1000000
using namespace std;

int main(){
    int n;
    int fib[50];
    cin>>n;
    fib[0]=1;
    fib[1]=1;
    rep(i,2,n+1){
        fib[i]=fib[i-1]+fib[i-2];
    }
    cout<<fib[n]<<endl;
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <set>

int main(){
    int n, m;
    std::cin >> n >> m;

    std::multiset<double> a;
    for(int i = 0; i < n; ++i){
        double val;
        std::cin >> val;
        a.insert(val);
    }

    for(int i = 0; i < m; ++i){
        auto itr = a.end();
        --itr;
        a.insert(*itr / 2);
        a.erase(itr);
    }
    
    long long ans = 0;
    for(auto itr = a.begin(); a.end() != itr; ++itr){
        ans += *itr;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 4992
import numpy as np
N = int(input())
*W, = list(map(int, input().split()))

W_cumsum = np.cumsum(W)

D = []
for t in range(N-1):
  D.append(np.abs(W_cumsum[N-1] - 2*W_cumsum[t]))
ans = np.min(D)

print(ans)


Measured memory_bytes: 21496
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program3
    {
        private class Change
        {
            public int before;
            public int after;
        }

        static void Main(string[] args)
        {
            var inputArray1 = int.Parse(Console.ReadLine());
            var inputArray2 = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var inputArray3 = int.Parse(Console.ReadLine());

            var counterArray = new long[100001];

            for (var i = 0; i < inputArray2.Length; i++)
            {
                counterArray[inputArray2[i]]++;
            }
            var result = inputArray2.Sum();

            for (int i = 0; i < inputArray3; i++)
            {
                var inputArray4 = Console.ReadLine().Split().Select(long.Parse).ToArray();
                result += (inputArray4[1] - inputArray4[0]) * counterArray[inputArray4[0]];
                counterArray[inputArray4[1]] += counterArray[inputArray4[0]];
                counterArray[inputArray4[0]] = 0;
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 51084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {

    int n, m; cin >> n >> m;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> from(n, -1);

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int new_v : G[v]) {
            if (dist[new_v] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 new_v について距離情報を更新してキューに追加する
            dist[new_v] = dist[v] + 1;
            que.push(new_v);
            from[new_v] = v;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
        cout << from[i] + 1 << endl;
    }
    return 0;
}

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



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

	int N;
	cin >> N;
	vector<double>P(N+1,0.0);
	REP(i, N)cin >> P[i+1];
	double dp[3010][3010] = { 0.0 };
	//i番目まで見てj枚表である確率

	eFOR(i, 1, N) {

		double a = P[i], b = 1.0 - P[i];

		eFOR(j, 0, i) {

			if (i == 1) {
				dp[i][0] = b;
				dp[i][1] = a;
				break;
			}
			if (j == 0)dp[i][j] += dp[i - 1][j] * b;
			else dp[i][j] += dp[i - 1][j - 1] * a + dp[i - 1][j] * b;
		}
	}
	double ans = 0.0;
	eFOR(i,N/2+1, N) {
		ans += dp[N][i];
	}
	printf("%.10f", ans);

	/*eREP(i, N) {
		eREP(j, N) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/


	return 0;
}



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

using namespace std;

const int N = 1e5;

int n, h[N + 1], dp[N + 1];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%d", h + i);

	dp[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; ++i)
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

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


Measured memory_bytes: 4416
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int a;
    scanf("%d",&a);
    int f=a/100;
    int j=a%100;
    if((f>=13&&j==0)||(f==0&&j==0)||(f>=13&&j>=13)||(f==0&&j>=13))
        printf("NA\n");
    else if(f>0&&(j==0||j>=13))
        printf("MMYY\n");
    else if(j>0&&(f==0||f>=13))
        printf("YYMM\n");
    else 
        printf("AMBIGUOUS\n");
}

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

int main() {
 int r,d,x2000;
  cin>>r>>d>>x2000;
  int x[11];
  x[0]=x2000;
  
  for(int i=1;i<11;i++){
    x[i]=r*x[i-1]-d;
  cout<<x[i]<<endl;
}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;



int main(){
ll N;
  cin>>N;
  ll u[N],v[N],w[N];
  
  vector<vector<pair<ll,ll>>> brid(N+1,vector<pair<ll,ll>>(0,make_pair(0,0)));
  
  for(ll i=1;i<N;i++){
  cin>>u[i]>>v[i]>>w[i];
    brid[u[i]].push_back(make_pair(v[i],w[i]%2));
    brid[v[i]].push_back(make_pair(u[i],w[i]%2));
  }
  
  vector<ll> dist(N+1,-1);
  queue<ll> que;
  dist[1]=0;
  que.push(1);
  while(!que.empty()){
  ll num=que.front();
    que.pop();
    for(ll i=0;i<(ll)brid[num].size();i++){
     if(dist[brid[num][i].first]!=-1)continue;
      
      dist[brid[num][i].first]=(dist[num]+brid[num][i].second)%2;
      que.push(brid[num][i].first);
      
    }
  
  }
  
  for(ll i=1;i<N+1;i++){
  cout<<dist[i]<<endl;
  }
  
 
}


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

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

  vector<int> f(N + 1);
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) {
      f[j]++;
    }
  }

  ll ans = 0;
  for (ll k = 1; k <= N; k++) {
    ans += k * f[k];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 42276
def solution
  a, b, c, d = gets.chomp.split('').map(&:to_i)
  %w[+ -].repeated_permutation(3).each do |p|
    expression = "#{a}#{p[0]}#{b}#{p[1]}#{c}#{p[2]}#{d}"
    return "#{expression}=7" if eval(expression) == 7
  end
end

puts solution


Measured memory_bytes: 3836
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let mut a: Vec<Vec<usize>> = Vec::new();
    for i in 0..2 {
        a.push(read![[usize]]);
    }
    let mut ans = 0;
    for i in 0..n {
        let s: usize = a[0].iter().take(i + 1).sum::<usize>()
            + a[1].iter().by_ref().skip(i).take(n - i).sum::<usize>();
        if s > ans {
            ans = s;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

char trans(char t) {
	if (t == 'W')return 'B';
	else return 'W';
}
void solve() {
	ll ans = 1;
	int n; cin >> n;
	string s; cin >> s;
	if (s[0] == 'W') {
		cout << 0 << endl; return;
	}
	ll num = 1;
	for (int i = 1; i < 2 * n; i++) {
		char memo = s[i];
		if (num % 2)memo = trans(memo);
		if (memo == 'B') {
			num++;
		}
		else {
			if (num < 0) {
				cout << 0 << endl; return;
			}
			else {
				ans = ans * num%mod; num--;
			}
		}
	}
	if (num > 0) {
		cout << 0 << endl; return;
	}
	rep1(i, n) {
		ans = ans * i%mod;
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i <= n; i++)
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll m = a + b;
    cout << (n / m) * a + min(n % m, a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};


bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,a[100001],cnt=0,tmp=0,t,x,b[100001];
  cin >> N >> x;
  REP(i,N)cin >> a[i];
  REP(i,N-1){
    if(a[i] + a[i+1] > x){
      t = a[i+1];
      a[i+1] = max(x-a[i],0LL);
      tmp += t - a[i+1];
    }
  }
  if((a[0] + a[1]) > x){
    t = a[0];
    a[0] = max(x-a[1],0LL);
    tmp += t - a[0];
  }
  cout << tmp << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
const int MOD = 1000000007;
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 1024
# coding: utf-8

import collections

def main():
    N = int(input())
    a = map(int, input().split())

    c = collections.Counter()
    for i in a:
        c[i] += 1
        c[i-1] += 1
        c[i+1] += 1
    return c.most_common(1)[0][1]


print(main())


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

int main()
{
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u)
    a--;
  if (t == u)
    b--;
  printf("%d %d\n", a, b);
  return 0;
}

Measured memory_bytes: 256
S = input()

pos_list = []
for i in range(len(S)-1):
    s = S[i]
    next_s = S[i+1]
    if s == "R" and next_s == "L":
        pos_list.append(i)

l_list = [-1 for i in range(len(S))]
r_list = [-1 for i in range(len(S))]

pos_idx = 0
for i in range(len(S)):
    if i <= pos_list[pos_idx]:
        r_list[i] = pos_list[pos_idx]
    else:
        pos_idx += 1
        if pos_idx == len(pos_list):
            break
        r_list[i] = pos_list[pos_idx]

pos_idx = len(pos_list)-1
for i in range(len(S))[::-1]:
    if i >= pos_list[pos_idx]:
        l_list[i] = pos_list[pos_idx]
    else:
        pos_idx -= 1
        if pos_idx == -1:
            break
        l_list[i] = pos_list[pos_idx]

count_list = [0 for i in range(len(S))]
for i in range(len(S)):
    s = S[i]
    if s == "R":
        stop_idx = r_list[i]
    else:
        stop_idx = l_list[i]
    if (stop_idx - i) % 2 == 1:
        stop_idx += 1
    count_list[stop_idx] += 1

ans = ""
for i in range(len(count_list)):
    ans += str(count_list[i]) + " "
print(ans)



Measured memory_bytes: 8164
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=998244353;
long long fact[200010];
void pre(){
    fact[0]=1;
    for(long long i=1; i<200010; ++i){
        fact[i]=(fact[i-1]*i)%mod;
    }
}
long long pwr(long long x, long long e){
    if(e==0)
        return 1;
    long long tmp=pwr(x,e/2);
    tmp=(tmp*tmp)%mod;
    if(e%2)
        tmp=(tmp*x)%mod;
    return tmp;
}
long long cmb(long long x, long long y){
    long long res, tmp;
    tmp=pwr(fact[x-y], mod-2);
    res=(fact[x]*tmp)%mod;
    tmp=pwr(fact[y],mod-2);
    res=(res*tmp)%mod;
    return res;
}
int main(){
    ll n, m, k;
    pre();
    while(cin>>n>>m>>k){
        ll ans=0;
        for(int i=0; i<=k; ++i){
        	ans+=((pwr(m-1, n-i-1)*m)%mod)*cmb(n-1, i);
        	ans%=mod;
        	// cout<<ans<<endl;
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;



int main(){
    int A[200001];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    int mini = A[0];
    int maxcost = A[1]-A[0];
    
    for (int i = 1; i < n-1; i++) {
        mini = min(mini,A[i]);
        maxcost = max(maxcost,A[i+1]-mini);
    }
    
    cout << maxcost << endl;
    return 0;
}

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

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int ans = 0;
  rep(i, n) {
    if (h[i] < k) continue;
    ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
    string s; cin >> s;
    int K; cin >> K;
    int n = s.size();

    int cnt = 0;
    rep(i, n){
        int x = s[i] - 'a';
        if(x == 0)continue;
        x = 26 - x;
        if(cnt + x > K)continue;
        cnt += x;
        s[i] = 'a';
    }

    if(cnt < K){
        int y = (K - cnt) % 26;
        int k = s[n-1] - 'a';
        k += y;
        k %= 26;
        s[n-1] = 'a' + k;
    }

    cout << s << endl;

    return 0;
}

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

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, A;
	
	cin >> N >> A;
	
	if(N%500 <= A)
		cout << "Yes";
	else
		cout << "No";
	
	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;

int main(){
    int D; cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
        }
    }

    rep(z,D){
        int contest=-1;
        int score=-1;
        rep(i,26){
            if(score < s[z][i]){
                score = s[z][i];
                contest = i+1;
            }
        }
        cout << contest << endl;
    }
}


Measured memory_bytes: 3684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    double w,h,x,y;
    scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
    printf("%lf ",w*h/2);
    if (x*2==w && y*2==h){
        printf("1\n");
    } else {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int h[100005];
int main()
{
    int N,K;
    int i,c=0;
    scanf("%d%d",&N,&K);
    for(i=0;i<N;i++){
         scanf("%d",&h[i]);
    }
            for(i=0;i<N;i++)
          {
              if(h[i]>=K)
              c++;
          }
        printf("%d",c);
        return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

typedef long long LL;
int main()
{
    LL x;
    cin>>x;
    LL s=100;
    for(int i=1;;i++)
    {
        s=1.01*s;
        if(s>=x)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int X = sc.nextInt();
		for (int i=X-K+1;i<K+X;i++) {
			System.out.print(i);
			System.out.print(" ");
		}
	}
}


Measured memory_bytes: 36132
a = int(input())
b = int(input())
c = int(input())
x = int(input())
n=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j * 100 + k * 50 ==x:
                n+=1
print(n)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            string[] strs = line.Split(' ');

            int H = int.Parse(strs[0]); // H行
            int W = int.Parse(strs[1]); // W列
            int K = int.Parse(strs[2]); // K個残るような塗りつぶし方
            // 塗りつぶし方は何通り？
            char[,] map = new char[W,H];
            for (int i = 0; i < H; i++)
            {
                var data = Console.ReadLine();
                for(int j = 0; j < W; j++)
                {
                    map[j, i] = data[j];
                }
            }
            int count = 0;
            byte[] pow = new byte[7];
            for (int i = 0; i < 7; i++)
            {
                pow[i] = (byte)Math.Pow(2, i);
            }
            int maxW = pow[W];
            int maxH = pow[H];
            for (int i = 0; i < maxW; i++)
            {
                for(int j = 0; j < maxH; j++)
                {
                    var newmap = (char[,])map.Clone();
                    for(int k = 0; k < W; k++)
                    {
                        if ((i & pow[k]) > 0)
                        {
                            // ひっくり返す
                            for(int l = 0;l < H; l++)
                            {
                                newmap[k, l] = '$';
                            }
                        }
                    }
                    for (int k = 0; k < H; k++)
                    {
                        if ((j & pow[k]) > 0)
                        {
                            // ひっくり返す
                            for (int l = 0; l < W; l++)
                            {
                                newmap[l, k] = '$';
                            }
                        }
                    }
                    int mapcount = 0;
                    for(int k = 0; k < W; k++)
                    {
                        for(int l = 0; l < H; l++)
                        {
                            if (newmap[k, l] == '#') mapcount++;
                        }
                    }
                    if (mapcount == K) count++;
                }
            }


            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 28240
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint n;
llint d[1005];
set<llint> S;

int main(void)
{
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> d[i];

  for(int i = 1; i <= n; i++) S.insert(d[i]);
  for(int i = 1; i <= n-1; i++) {
    S.insert(d[i]*10 + d[i+1]);
  }
  for(int i = 1; i <= n-2; i++) {
    S.insert(d[i]*100 + d[i+1]*10 + d[i+2]);
  }
  for(int i = 1; i <= n-3; i++) {
    S.insert(d[i]*1000 + d[i+1]*100 + d[i+2]*10 + d[i+3]);
  }
  for(int i = 0; i < 10000; i++){
    if(S.count(i) == 0){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;


struct Node{
	int key;
	Node *next,*prev;
};

Node *nil;

void init(){
	nil = (Node*)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key){
	Node *x = (Node*)malloc(sizeof(Node));
	x->key=key;
	x->next = nil->next;
	nil->next->prev =x;
	nil->next=x;
	x->prev=nil;
}

Node* listSearch(int key){
	Node *cur = nil->next;
	while(cur->key!=key&&cur!=nil){
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node* t){
	if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	deleteNode(listSearch(key));
}

void printList(){
	Node *cur = nil->next;
	int isf=0;
	while(1){
		if(cur==nil) break;
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}

int main(){
	int key=0,n,np=0,size=0,nd=0;
	char c[20];
	init();
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		scanf("%s %d",c,&key);
		if(c[0]=='i'){
			insert(key);
			np++;
			size++;
		}else if(c[0]=='d'){
			if(c[6]=='F'){
				deleteFirst();
			}else if(c[6]=='L'){
				deleteLast();
			} else{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}

Measured memory_bytes: 34460
#include<stdio.h>
#include<string.h>

int main()
{
	char S[5];
	scanf("%s", S);
	int i;
	for(i=0;i<strlen(S)-1;i++)
		if (S[i]=='A'&&S[i+1]=='C')
		{
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
// AOJ 2916: Twins
// 2019.2.17 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	char a[20];

	scanf("%s", a);
	if (a[0] == 'a') printf("square1001\n");
	else printf("e869120\n");
	return 0;
}



Measured memory_bytes: 1952
#include<iostream>

using namespace std;

int main(){
	
	while(1){
		int n,m;
		
		cin>>n>>m;
		
		if(n==0 && m ==0){
			break;
		}
		int input[100000];
		
		for(int i=0;i<n;i++){
			cin>>input[i];
		}
		
		int cont = m;
		
		int now = 0;
		for(int i=0;i<m;i++){
			now += input[i];
		}
		
		
		int max = now;
		for(int i=m;i<n;i++){
			now-=input[i-m];
			now+=input[i];
			
			if(now>max){
				max=now;
			}
		}
	
	cout<<max<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1236
N,K=map(int,input().split())
A=list(map(int,input().split()))

D={}
for a in A:
    if a in D:
        D[a]+=1
    else:
        D[a]=1

if len(D)<=K:
    print(0)
else:
    E=sorted(D.values())
    print(sum(E[:len(D)-K]))


Measured memory_bytes: 122136
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=20010,M=2000010,NN=80010;
struct position{
	int pos,id;
}pt[N];
struct node{
	int f;
}tree[NN];
struct edge{
	int y,next;
}data[M];
int n,l,r,num,num1,num2,top,sta[NN],h[NN],dfn[NN],low[NN],arc[NN];
bool vis[NN],insta[NN];
inline int read(){
	int x=0,f=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f?-x:x;
}
inline void add(int x,int y){
	data[++num].y=y;data[num].next=h[x];h[x]=num;
}
bool cmp(position i,position j){
	return i.pos<j.pos;
}
inline int get_front(int pos,int a,int b){
	while(a<=b){
		int mid=(a+b)>>1;
		if(pt[mid].pos<pos)a=mid+1;
		else b=mid-1;
	}
	return a;
}
inline int get_back(int pos,int a,int b){
	while(a<=b){
		int mid=(a+b)>>1;
		if(pt[mid].pos>pos)b=mid-1;
		else a=mid+1;
	}
	return b;
}
void build(int p,int a,int b){
	if(a==b){arc[pt[a-1].id]=p;return;}
	int mid=(a+b)>>1;
	build(p<<1,a,mid);build(p<<1|1,mid+1,b);
	add(p<<1,p);add(p<<1|1,p);
}
void addedge(int p,int pa,int pb,int a,int b,int x){
	if(a<=pa&&pb<=b){add(p,x);return;}
	int mid=(pa+pb)>>1;
	if(a<=mid)addedge(p<<1,pa,mid,a,b,x);
	if(mid<b)addedge(p<<1|1,mid+1,pb,a,b,x);
}
void tarjan(int u){
	sta[++top]=u;
	insta[u]=vis[u]=true;
	dfn[u]=low[u]=++num1;
	for(int i=h[u];i!=-1;i=data[i].next){
		int v=data[i].y;
		if(!dfn[v]){tarjan(v);low[u]=min(low[u],low[v]);}
		else if(insta[v]&&low[u]>dfn[v])low[u]=dfn[v];
	}
	if(dfn[u]==low[u]){
		num2++;
		while(dfn[sta[top]]!=low[sta[top]]){
			tree[sta[top]].f=num2;insta[sta[top--]]=false;
		}
		tree[u].f=num2;insta[sta[top--]]=false;
	}
}
void print(int p,int a,int b){
	printf("%d-%d:p%d f%d\n",a,b,p,tree[p].f);
	if(a==b)return;
	int mid=(a+b)>>1;
	print(p<<1,a,mid);print(p<<1|1,mid+1,b);
}
bool two_sat(int x){
	memset(h,-1,sizeof h);num=num1=num2=top=0;
	build(1,1,n+n);//printf("x%d:\n",x);
	//printf("tree:\n");print(1,1,n+n);printf("\n");
	for(int l1,r1,i=0;i<n+n;i++){
		l1=get_front(pt[i].pos-x+1,0,i-1);
		r1=get_back(pt[i].pos+x-1,i+1,n+n-1);
	//	printf("%d %d %d %d\n",pt[i].pos,l1,r1,arc[pt[i].id^1]);
		if(l1<i)addedge(1,1,n+n,l1+1,i,arc[pt[i].id^1]);
		if(i<r1)addedge(1,1,n+n,i+2,r1+1,arc[pt[i].id^1]);
	}
	memset(dfn,0,sizeof dfn);
	memset(vis,false,sizeof vis);
	for(int i=0;i<n+n;i++)if(!vis[arc[i]])tarjan(arc[i]);
//	for(int i=1;i<=17;i++){
//		printf("%d:\n",i);
//		for(int j=h[i];j!=-1;j=data[j].next)printf("%d ",data[j].y);
//		printf("\n");
//	}
	//for(int i=0;i<n;i++)printf("%d %d\n",arc[i<<1],arc[i<<1|1]);
	for(int i=0;i<n;i++)if(tree[arc[i<<1]].f==tree[arc[i<<1|1]].f)return false;
	return true;
}
int main(){
	n=read();
	for(int i=0;i<n;i++){
		pt[i<<1].pos=read();pt[i<<1].id=i<<1;
		pt[i<<1|1].pos=read();pt[i<<1|1].id=i<<1|1;
	}
	sort(pt,pt+n+n,cmp);
//	printf("pt:\n");
//	for(int i=0;i<n+n;i++)printf("%d %d\n",pt[i].id,pt[i].pos);
	l=0;r=1000000000;
	while(l<=r){
		int mid=(l+r)>>1;
		if(two_sat(mid))l=mid+1;
		else r=mid-1;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 9344
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;
int dx,dy;

int main(){
  int d;cin>>d;
  int n;
  cin>>n;
  if(n==100)n++;
  int x=std::pow(100,d);
  cout<<x*n<<endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
def solve():
  d = [0]*n
  for i in range(n):
    for j in range(3):
      d[i] += a[i][j]
  d.sort()
  return sum(d[n-m:])
ans = 0
for di in range(2):
  for i in range(n):
    a[i][0] *= -1
  for dj in range(2):
    for i in range(n):
      a[i][1] *= -1
    for dk in range(2):
      for i in range(n):
        a[i][2] *= -1
      ans = max(ans,solve())
print(ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
    --a;
  }
  
  vector<int> P(N, -1);
  vector<int> dp(N);
  
  for (int i = 0; i < N; ++i) {
    if (A[i] == 0 || P[A[i] - 1] == -1) {
      dp[i] = 1;
    } else {
      dp[i] = 1 + dp[P[A[i] - 1]];
    }
    
    P[A[i]] = i;
  }
  
  cout << N - *max_element(dp.begin(), dp.end()) << '\n';
  
  return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt(), M = sc.nextInt();
		boolean graph[][] = new boolean[N+1][N+1];
				
		for(int i = 1; i<=M; i++) {
			int a = sc.nextInt(), b = sc.nextInt();
			graph[a][b] = graph[b][a] = true;
		}
		
		int count = 0;
		
		for(int i = 1; i<=N; i++) {
			for(int j = i+1; j<=N; j++) {
				if(graph[i][j]) {
					graph[j][i] = graph[i][j] = false;
					if(!BFS(graph, N)) count++;
					graph[j][i] = graph[i][j] = true;
				}
			}
		}
		
		System.out.println(count);
		
		
		
	}
	
	public static boolean BFS(boolean graph[][], int N) {
		
		LinkedList<Integer> list = new LinkedList<Integer>();
		
		list.add(1);
		boolean dist[] = new boolean[N+1];
		dist[1] = true;
		
		while(!list.isEmpty()) {
			int node = list.pop();
			for(int i = 1; i<=N; i++) {
				if(graph[node][i] && !dist[i]) {
					dist[i] = true;
					list.add(i);
				}
			}
		}
		
		for(int i = 1; i<=N; i++) {
			if(!dist[i]) return false;
		}
		return true;
		
	}

}


Measured memory_bytes: 22100
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})
local N = read.n()
local t = {}
for i=1,N do
    local a = io.read("n")
    t[i] = {i, a}
end
table.sort(t, function(x,y) return x[2] < y[2] end)
local ans = {}
for i=1,N do
    ans[i] = t[i][1]
end
print(table.concat(ans, " "))


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

int main() {
	// your code goes here
	int a,b;
	while(cin >> a >> b){
	cout <<  (int)log10(a+b)+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		out.println(instr().substring(0,1) + instr().charAt(1) + instr().charAt(2));

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 20684
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k;
	cin>>n>>k;
	long long int arr[n];
	for(long long int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	long long int sum=0;
	if(k>=n)
		cout<<"0";
	else
	{
		sort(arr,arr+n);
		for(long long int i=0;i<n-k;i++)
			sum=sum+arr[i];
		cout<<sum;


	}
	cout<<"\n";
}

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def make_divisors(n): # nの約数を列挙
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

# 最大公約数が1から順番に数える
MOD = 10 ** 9 + 7
N, K = lr()
answer = 0
reset = [0] * (K+1)
for i in range(1, K+1):
    num = K // i
    cmb = pow(num, N, MOD)
    arr = make_divisors(i)
    x = i
    for a in arr[:-1]:
        x -= reset[a]
    reset[i] = x
    answer += x * cmb

print(answer % MOD)


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

int main(){
	int ans[6],i;
	for(i = 0;i < 5;i++){
		cin>>ans[i];
	}
	sort(ans,ans+5);

	while(i--){
		if(i == 4)
		cout<<ans[i];
		else
		cout<<" "<<ans[i];
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1176
s = input()
t_list = ['dream','dreamer','erase','eraser']

flg = True
while len(s) > 0:
    if   s[-7:] in t_list:
        s = s[:-7]
    elif s[-6:] in t_list:
        s = s[:-6]
    elif s[-5:] in t_list:
        s = s[:-5]
    else:
        flg = False
        break

if flg:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int n = s.length;
			Set<Character> set = new HashSet<>();

			for (char c : s) {
				set.add(c);
			}

			if (set.size() < 26) {
				for (char c = 'a'; c <= 'z'; c = (char)(c + 1)) {
					if (!set.contains(c)) {
						out.println(new String(s) + c);
						return;
					}
				}
				
				
			} else {
				int ptr = n - 1;
				while (ptr >= 0) {
					set.remove(s[ptr]);

					for (char c = (char)(s[ptr] + 1); c <= 'z'; c = (char)(c + 1)) {
						if (!set.contains(c)) {
							out.println(new String(Arrays.copyOf(s, ptr)) + c);
							return;
						}

					}

					ptr--;
				}
			}

			out.println(-1);

		}
	}

	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 long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

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

	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	vector<ll> L(n);
	rep(i, n)
	{
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int cnt = 0;
	rep(i, n)
	{
		ll a = L[i];
		rep2(j, i + 1, n)
		{
			ll b = L[j];
			if (b == a)
				continue;
			rep2(k, j + 1, n)
			{
				ll c = L[k];
				if (b == c)
					continue;
				if (a + b > c && a + c > b && b + c > a)
					cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
	string str;

	cin >> str;

	str.replace(5, 1, " ");
	str.replace(13, 1, " ");

	cout << str << "\n";




	return 0;
}


Measured memory_bytes: 256
//
//AISing 2020
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    map<int, int> ans;
    int nn=sqrt(n)+10;
    FOR(x,1,nn){
        FOR(y,1,nn){
            FOR(z,1,nn){
                ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }
    FOR(i,1,n){
        //cout << i << " ";
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()
#define re(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define CV(v) for(auto i : v) cout << i << " ";cout << endl
#define IN(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vp;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;

int main()
{
    ll N,K;
    cin >> N >> K;
    vl A(N),F(N);
    IN(N,A);IN(N,F);
    so(A);so(F);
    re(F);
    
    vpl B(N);
    rep(i,N) B[i].fi = A[i]*F[i],B[i].se = i;
    so(B);
    
    ll a = 0, b = B[N-1].fi;
    
    while (b-a > 1) {
        ll ab = (a+b)/2;
        ll c = 0;
        rep(i,N) if(B[i].fi > ab){
            if(F[B[i].se] == 1) c += (B[i].fi-ab);
            else if((B[i].fi-ab)%F[B[i].se] == 0) c += (B[i].fi-ab)/F[B[i].se];
            else c += (B[i].fi-ab)/F[B[i].se]+1;
        }
    
        
        if(c > K) a = ab;
        else if(c < K) b = ab;
        else b = ab;
    }
    
    ll c = 0;
    rep(i,N) if(B[i].fi > a){
        if(F[B[i].se] == 1) c += (B[i].fi-a);
        else if((B[i].fi-a)%F[B[i].se] == 0) c += (B[i].fi-a)/F[B[i].se];
        else c += (B[i].fi-a)/F[B[i].se]+1;
    }
    if(c <= K) cout << a << endl;
    else cout << b << endl;
    return 0;
}



Measured memory_bytes: 6528