akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int h, w;
        String[][] mat;
        // 読み込み
        try(Scanner sn = new Scanner(System.in)) {
            h = sn.nextInt();
            w = sn.nextInt();
            mat = new String[h][];
            for (int i = 0; i < h; i++)
                mat[i] = sn.next().split("");
        }
        List<Integer> showRowIndex = new LinkedList<>();
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++)
                if (mat[i][j].equals("#")) {
                    showRowIndex.add(i);
                    break;
                }
        List<Integer> showColIndex = new LinkedList<>();
        for (int i = 0; i < w; i++)
            for (int j: showRowIndex)
                if (mat[j][i].equals("#")) {
                    showColIndex.add(i);
                    break;
                }
        // 表示
        for (int i: showRowIndex) {
            for (int j: showColIndex) {
                System.out.print(mat[i][j]);
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 27328
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
  string w,ans="Yes";

  cin>>w;
  vector<int> a(30);
  for(int i=0;i<w.size();i++){

    int t=w[i]-'a';
    a.at(t)++;
    //printf("%d\n",w[i]-'a');

  }
  for(int i=0;i<w.size();i++){
    int t=w[i]-'a';

    if(a.at(t)%2==1){
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;

}


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

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

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

    if (n % 2 == 1){
        cout << 0 << '\n';
        return 0;
    }

    sort(a.begin(), a.end());
    
    if (a[n / 2] == a[n / 2 - 1]){
        cout << 0 << '\n';
    }
    else{
        cout << a[n / 2] - a[n / 2 - 1] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 640
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let mut abc = util::gets::<usize>();

    abc.sort();
    abc.reverse();

    println!("{}", abc[0] * 10 + abc[1] + abc[2]);
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));

    for (int i = n - 1; i >= 0; i--) {
        for (int j = n - 1; j >= 0; j--) {
            if (s[i] == s[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            }
        }
    }

    int ans = 0;
    REP(i, n) {
        FOR(j, i + 1, n) {
            chmax(ans, min(dp[i][j], j - i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 98176
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    lint L, R;
    scanf("%lld%lld", &L, &R);
    const lint mod = 1e9 + 7;
    lint dp[64][2][2][2];
    rep(i, 64)rep(j, 2)rep(k, 2)rep(l, 2) dp[i][j][k][l] = 0;
    dp[63][0][0][0] = 1;
    rrep(i, 63){
        int rd = (R >> i) & 1;
        int ld = (L >> i) & 1;
        rep(j, 2)rep(k, 2)rep(l, 2)if(dp[i+1][j][k][l] >= 1)rep(dy, 2)rep(dx, 2){
            if(l == 0 && dy != dx) continue;
            if(dy == 0 && dx == 1) continue;
            if(j == 1 && k == 1){
                dp[i][j][k][l] = (dp[i][j][k][l] + dp[i+1][j][k][l]) % mod;
            }
            if(j == 1 && k == 0){
                if(dx < ld) continue;
                dp[i][j][k | (dx > ld)][l | dy | dx] = (dp[i][j][k | (dx > ld)][l | dy | dx] + dp[i+1][j][k][l]) % mod;
            }
            if(j == 0 && k == 1){
                if(rd < dy) continue;
                dp[i][j | (dy < rd)][k][l] = (dp[i][j | (dy < rd)][k][l] + dp[i+1][j][k][l]) % mod;
            }
            if(j == 0 && k == 0){
                if((dy > rd) || (dx < ld)) continue;
                dp[i][j | (dy < rd)][k | (dx > ld)][l | dy | dx] = (dp[i][j | (dy < rd)][k | (dx > ld)][l | dy | dx] + dp[i+1][j][k][l]) % mod;
            }
        }
    }
    lint ans = 0;
    rep(j, 2)rep(k, 2) ans = (ans + dp[0][j][k][1]) % mod;
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
namespace QiFeng233{
	const int maxn=110;
	int n,a[maxn];
	int maxpos=-1,minpos=0x7fffffff;
	int ans=0x7fffffff;
	int max(int a,int b){
		return a>b?a:b;
	}
	int min(int a,int b){
		return a<b?a:b;
	}
	int calc(int pos){
		int ans=0;
		for(int i=1;i<=n;++i)
			ans+=(a[i]-pos)*(a[i]-pos);
		return ans;
	}
	void solve(){
		scanf("%d",&n);
		for(int i=1;i<=n;++i){
			scanf("%d",a+i);
			maxpos=max(maxpos,a[i]);
			minpos=min(minpos,a[i]);
		}
		for(int i=minpos;i<=maxpos;++i)
			ans=min(ans,calc(i));
		printf("%d\n",ans);
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    string ans = "No";
    if(abs(a-c) <= d) ans = "Yes";
    if((abs(b-a)<= d) && (abs(c-b) <= d)) ans = "Yes";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(x) cout<<x<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  startupcpp();
  ll i,j,N,D,ans;
  cin>>D>>N;
  if(N==100)N++;
  D=pow(100,D);
  cout<<N*D<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
mi = float('INF')
t=0
for i in range(n):
    if abs(a[i])<mi:
        mi=abs(a[i])
        t=i
a1=a.copy()
sum1=0
for i in range(n-2):
    if a1[i]<0:
        sum1+=a1[i]*(-1)
        a1[i+1]*=-1
    else:
        sum1+=a1[i]
if a1[n-2]+a1[n-1]>(a1[n-2]+a1[n-1])*(-1):
    sum1+=a1[n-2]+a1[n-1]
else:
    sum1+=(a1[n-2]+a1[n-1])*(-1)

sum2=0
for i in range(n-2):
    if i==t and a[i]<0:
        sum2+=a[i]
        continue
    elif i==t and a[i]>0:
        sum2-=a[i]
        a[i+1]*=-1
        continue
    if a[i]<0:
        sum2+=a[i]*(-1)
        a[i+1]*=-1
    else:
        sum2+=a[i]
if a[n-2]+a[n-1]>(a[n-2]+a[n-1])*(-1):
    sum2+=a[n-2]+a[n-1]
else:
    sum2+=(a[n-2]+a[n-1])*(-1)
print(max(sum1,sum2))


Measured memory_bytes: 14412
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	string S;
	cin >> S;
	int win = 0;
	rep(i, S.size()) {
		if (S.at(i) == 'o') win++;
	}
	cout << (8 - win <= 15 - S.size() ? "YES" : "NO") << endl;
	return 0;
}

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

const ll INF = pow(10, 9) + 7;

int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s)cout << a - 1 << " " << b;
	else cout << a << " " << b - 1;
}



// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

class Program
{
    static void Main(string[] args)
    {

        long[] inp = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

        long a, b;
        a = inp[0]; b = inp[1];


        long ans = -1;
        for (int i = 1; i < 2001; i++)
        {
            if (Math.Floor(i * 0.08) == a && Math.Floor(i * 0.1) == b)
            {
                ans = i;
                break;
            }
        }


        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 13268
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x = gi();
    int y = int(x/500) * 1000;
    x %= 500;
    y += x;
    y -= x%5;
    printf("%d\n", y);

    return 0;
}


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

namespace Test01
{       
    class Program
    {       
        static List<long> CommonMultiple(long A, long B)
        {
            List<long> f = new List<long>();
            long min = (long)Math.Min(A, B);
            long max = (long)Math.Max(A, B);

            for(int i = 1; i <= (long)Math.Sqrt(min); i++)
            {
                if (min % i == 0)
                {
                    f.Add(i);
                    if (i != min / i) f.Add(min / i);
                }
                
            }
          
            List<long> rec = new List<long>();

            foreach(var s in f)
            {
                if (max % s == 0) rec.Add(s);               
            }

            return rec;
        }      

        static void Main(string[] args)
        {
            long[] data = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            long A = data[0];
            long B = data[1];

            List<long> factor = CommonMultiple(A, B).OrderBy(x => x).ToList();
            
            int ans = 1;
            int cnt = 2;
            while (true)
            {
                bool fin = false;

                if (cnt > factor.Count())
                {
                    fin = true;
                    break;
                }

                if (fin) break;

                long pri = factor[cnt - 1];
                ans++;
                for (int i = cnt; i < factor.Count(); i++)
                {
                    if (factor[i] % pri == 0) {factor.RemoveAt(i); i--; }
                }

                cnt++;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13484
#include <bits/stdc++.h>
using namespace std;
int n, a[200100], b[200100];

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

    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);

    if (n % 2 == 1)
        cout << b[(n + 1) / 2] - a[(n + 1) / 2] + 1;
    else {
        double l = (double)(a[n / 2] + a[n / 2 + 1]) / (double)2;
        double r = (double)(b[n / 2] + b[n / 2 + 1]) / (double)2;
        cout << (long long)((r - l + 0.5) * 2);
    }
    return 0;
}


Measured memory_bytes: 5188
N = int(input())
P = [0] + list(map(int,input().split())) + [-1]
ans = 0
i = 1
while i < N + 1:
    if P[i] == i and P[i+1] == i + 1:
        ans += 1
        i += 2
    elif P[i] == i:
        ans += 1
        i += 1
    else:
        i += 1
print(ans)

Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
double min(double x, double y)  
{  
    return (x < y)? x: y;  
}  
double calcAngle(int h, int m)  
{  
    if (h <0 || m < 0 || h >12 || m > 60)  
        printf("Wrong input");  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
    double hour_angle = 0.5 * (double(h) * 60 + double(m));  
    double minute_angle = 6 * double(m);  
    double angle = abs(hour_angle - minute_angle);  
    angle = min(360 - angle, angle);  
    return angle;  
}  
int main()
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle=calcAngle(h,m);
    angle=angle*3.141592653589793238/180;
    cout<<fixed<<setprecision(20)<<sqrt((a*a)+(b*b)-(2*a*b*cos(angle)))<<"\n";
    return 0;
}


Measured memory_bytes: 4164
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    int num = 0;
    if((b<=a&&a<=(b+W))||(a<=b&&b<(a+W))){

    }else if(Math.abs(a-(b+W))>=Math.abs(b-(a+W))){
      num = Math.abs(b-(a+W));
    }else{
      num = Math.abs(a-(b+W));
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 21844
n=int(input())
for a in range(n//4+1,3501):
 for b in range((n*a)//(4*a-n),3501):
  if 4*a*b-n*b-a*n==0:
   continue
  c=(n*a*b)/(4*a*b-n*b-a*n)
  if c==int(c) and c>=1:
    print(a,b,int(c))
    exit()

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

main(){
	int n,m;
	int i;
	double x;
	scanf("%d%d",&n,&m);
	x=(n-m)*100+1900*m;
	x=x*pow(2,m);
	printf("%.0f",x);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int n,a;
    cin>>n>>a;
    cout<<n*n-a<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main 
{
 public static void main(String args[]) throws IOException
 {
   int a,b;
   Scanner sc=new Scanner(System.in);
   a=sc.nextInt();
   b=sc.nextInt();
   System.out.println(a*b);
 
 }
}
  

Measured memory_bytes: 27024
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 2e9;



int main() {
	int n, x; cin >> n >> x;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	ll ans = 0;
	if (a[0] > x) {
		ans += a[0] - x; a[0] = x;
	}
	rep(i, 0, n - 1) {
		if (a[i + 1] + a[i] > x) {
			ans += a[i + 1] + a[i] - x;
			a[i + 1] = x - a[i];
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	ll k;
	std::string s;
	std::cin >> s >> k;
	ll f = 0;
	while (s[f] == '1') {
		f++;
	}
	if (k <= f) {
		std::cout << 1 << std::endl;
		return 0;
	}

	rep(i, s.size()) {
		if (s[i] != '1') {
			std::cout << s[i] <<std::endl;
			return 0;
		}

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

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n; cin >> n;
    if (n == 0) return;
    map<int, pair<int, int>> ma;
    ma[0] = make_pair(0, 0);
    rep(i, n - 1) {
      int n, d; cin >> n >> d;
      auto p = ma[n];
      switch (d) {
      case 0: ma[i + 1] = make_pair(p.first - 1, p.second); break;
      case 1: ma[i + 1] = make_pair(p.first, p.second + 1); break;
      case 2: ma[i + 1] = make_pair(p.first + 1, p.second); break;
      case 3: ma[i + 1] = make_pair(p.first, p.second - 1); break;
      }
    }
    int minx = 1e9, miny = 1e9, maxx = -1e9, maxy = -1e9;
    each(m, ma) {
      amin(minx, m.second.first);
      amin(miny, m.second.second);
      amax(maxx, m.second.first);
      amax(maxy, m.second.second);
    }
    cout << maxx - minx + 1 << " " << maxy - miny + 1 << '\n';
  }
}



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

int INF=10005;
int n, x, y;
vector<int> dig[2005];
vector<int> ans(2005);
vector<int> dist(2005);
void bfs(int start){
    queue <int> que;
    que.push(start);
    rep(i, n) dist[i]=INF;
    dist[start]=0;
    while(!que.empty()){
        int p = que.front();
        que.pop();
        for(auto t : dig[p]){
            if(dist[t]==INF) {
                dist[t]=dist[p]+1;
                ans[dist[t]]++;
                que.push(t);
            }
        }
    }
}
int main(void){
    cin>>n>>x>>y;
    --x;
    --y;
    rep(i, n-1){
        dig[i].push_back(i+1);
        dig[i+1].push_back(i);
    }
    dig[x].push_back(y);
    dig[y].push_back(x);
    rep(i, n) bfs(i);
    for(int i=1;i<=n-1;i++){
        cout<<ans[i]/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K):

    g = defaultdict(dict)
    for i in range(1, K+1):
        g[i % K][(i+1) % K] = 1
        g[i % K][(i*10) % K] = 0

    q = deque()
    q.append((1, 0))

    vis = {}
    while q:
        u, cc = q.popleft()
        if u == 0:
            return cc + 1
        vis[u] = True
        for v, c in g[u].items():
            if v in vis:
                continue
            if c == 0:
                q.appendleft((v, cc))
            else:
                q.append((v, cc+c))


def main():
    K = read_int()
    print(slv(K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115028
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<stack>
#include<map>
#include<bitset>
#include <cstdlib>
#include<cstring>
#define ll long long;
#define pb push_back
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const double eps = 1e-11;
const double pi = acos(-1.0); 
using namespace std;
using uint = unsigned int;
using int64 = long long;
using uint64 = unsigned long long;
#define ma = 2147483647;
#define mi = -2147483647;
const int N = 1e5 + 10;
struct node
{
	int x, y, z = 1;
}q[N];
int s[N];
int state[N] = {1};
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	for (int i = 0; i < N; i++)
	{
		state[i] = 1;
	}
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> s[i];

	for (int i = 0; i < m; i++)
	{
		cin >> q[i].x >> q[i].y;
	}
	for (int i = 0; i < m; i++)
	{
		if (s[q[i].x - 1] < s[q[i].y - 1])
		{
			state[q[i].x - 1] = 0;
		}
		else if (s[q[i].x - 1] == s[q[i].y - 1])
			{
				state[q[i].x - 1] = 0;
				state[q[i].y - 1] = 0;
			}
		else if(s[q[i].x - 1] > s[q[i].y - 1]){
				state[q[i].y - 1] = 0;
			}

	}
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (state[i] == 1)
			ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
    string yes = "Yes", no = "No";
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n);
    rep(i, q) {
        int x;
        cin >> x;
        --x;
        a[x]++;
    }
    // dumpV(a);
    rep(i, n) {
        if(q - a[i] < k) cout << yes << '\n';
        else cout << no << '\n';
    }
    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
 
typedef long long ll;
typedef long double ld;
 
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
 
using namespace std;

int n;

vector <int> g[1000000];

int label[1000000], f[300000][20], ans;

int dfs (int x, int p)
{
	int mx = 0;
	for (int to : g[x])
		if (to != p)
		{
			dfs (to, x);

			for (int i = 0; i < 20; i++)
			{
				if (f[x][i] && f[to][i]) mx = max (mx, i);
				f[x][i] |= f[to][i];
			}
		}

	while (f[x][mx]) mx++;

	label[x] = mx;

	ans = max (label[x], ans);

	f[x][mx] = 1;

	for (int i = 0; i < mx; i++)
		f[x][i] = 0;

	return label[x];
}

int main ()
{
	cin >> n;

	for (int i = 0; i < n - 1; i++)
	{
		int a, b;

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

		g[a-1].push_back (b - 1);
		g[b-1].push_back (a - 1);
	}

	dfs (0, -1);

	cout << ans;
}

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

int main() {
	while (true) {
	int n;
	std::cin >> n;
	if (n == 0) break;
	std::vector<int> a(n);
	int sum = 0;
	for(auto& v : a) {
		std::cin>>v;
		sum += v;
	}

	int ans = 0;
	for(auto v : a) {
		if (v * n <= sum) ++ans;
	}

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

}


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

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	ll h[n+1];
	for(ll i = 1; i <= n; i++){
		cin >> h[i];
	}
	ll dp[n+1];
	dp[1] = 0;
	for(ll i = 2; i <= n; i++){dp[i] = INF;}
	rep(i, 1, n){
		if(i+1 <= n){
			dp[i+1] = min(dp[i]+abs(h[i]-h[i+1]), dp[i+1]);
		}
		if(i+2 <= n){
			dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+2]);
		}
	}
	print(dp[n])
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

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

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}


int main(int argc, const char * argv[]) {
  int k;
  int d;
  scanf("%d", &k);
  if (k % 2 == 1) {
    d = (int)((k + 1) / 2);
    cout << d * (d - 1) << endl;
  }
  else {
    d = (int)(k / 2);
    cout << d * d << endl;
  }

  return 0;
}

Measured memory_bytes: 256
/*Counting Sort*/
#include<iostream>
#define N 2000000
using namespace std;

int n;
int A[N];
int B[N];

void CountingSort(int A[],int B[],int n,int k){
    int C[10002];
    for(int i=0;i<=k;i++){
        C[i]=0;
    }
    for(int j=0;j<n;j++){
        C[A[j]]=C[A[j]]+1;
    }
    for(int i=1;i<=k;i++) C[i]=C[i]+C[i-1];
    //for(int i=0;i<=k;i++) cout<<C[i]<<' '; cout<<endl;
    for(int j=n-1;j>=0;j--){
        B[C[A[j]]-1]=A[j];   //注意这里的写法
        C[A[j]]=C[A[j]]-1;

        //cout<<"j= "<<j<<" || ";
        //for(int i=0;i<=k;i++) cout<<C[i]<<" ";  cout<<" || ";
        //for(int i=0;i<n;i++) cout<<B[i]<<' '; cout<<endl;

    }
}

int main(){
    int mnum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
        mnum=max(A[i],mnum);
    }
    CountingSort(A,B,n,mnum);
    for(int i=0;i<n;i++){
        if(i) cout<<' ';
        cout<<B[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 18780
#!python3

from collections import deque


# input
K = int(input())


def solve():
    visit = [False] * K
    # (s, num)
    dq = deque([(0, 1)])
    while dq:
        s, num = dq.popleft()
        visit[num] = True
        if num == 0:
            return s
        a = num * 10 % K
        if not visit[a]:
            dq.appendleft((s, a))
        b = (num + 1) % K
        if not visit[b]:
            dq.append((s + 1, b))
    
    assert False


def main():
    ans = solve() + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10988
import java.util.Scanner;
import java.io.PrintWriter;
import java.util.Deque;
import java.util.ArrayDeque;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(sc.next());
        Deque<Integer> B = new ArrayDeque<Integer>();
        int a;
        for (int i = 0; i < N; i++){
            a = Integer.parseInt(sc.next());
            if (i % 2 == 0){
                B.addLast(a);
            } 
            else{
                B.addFirst(a);
            }
        }
        
        for (int i = 0; i < N; i++){
            if (N % 2 == 0){
                out.print(B.pop() + " ");
            }
            else{
                out.print(B.removeLast() + " ");
            }
            
        }

        //テンプレ
        sc.close();
        out.flush();
    }
}

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

int main(void){
    int N;
    cin>>N;
    vector<long long> A(N+1);
    vector<long long> B(N);
    for(int i=0;i<N+1;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    long long ans=0;
    for(int i=0;i<N;i++){
        ans+=min(A[i],B[i]);
        B[i]=B[i]-min(A[i],B[i]);
        ans+=min(A[i+1],B[i]);
        A[i+1]=A[i+1]-min(A[i+1],B[i]);
    }
    cout<<ans<<endl;
}


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

int stop[15] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1};

int main() {
    int n;
    cin >> n;
    while (n--) {
        int a, b;
        cin >> a >> b;
        int i;
        if (a > 5 || a < b) {
            cout << stop[a];
            for (i = a + 1; stop[i] != b; i = (i + 1) % 15) {
                cout << " " << stop[i];
            }
            cout << " " << stop[i];
            cout << endl;
        } else {
            cout << stop[15 - a];
            for (i = 15 - a + 1; stop[i] != b; i = (i + 1) % 15) {
                cout << " " << stop[i];
            }
            cout << " " << stop[i];
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3052
import heapq
N = int(input())
Alist = list(map(int, input().split()))
while len(Alist) > 1:
    heapq.heapify(Alist)
    attack = heapq.heappop(Alist)
    Alist = [a % attack for a in Alist if a % attack != 0]
    heapq.heappush(Alist, attack)
print(Alist[0])


Measured memory_bytes: 14180
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 1;; i++) {
			int x = sc.nextInt();
			if (x == 0) {
				break;
			}
			System.out.printf("Case %d: %d\n", i, x);
		}
		sc.close();
	}

}


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

int main(){
  while(true){
    string s;
    string bottom;
    string top;
    int m;
    int h;
    cin >> s;
    if(s=="-")break;
    cin >> m;
    for(int i=0; i<m; i++){
      cin >> h;
      //cout << h << endl;
      bottom = s.substr(0, h);
      top = s.substr(h, s.length()-h);
      //cout << bottom << " " << top << endl;
      for(int i=0; i<s.length()-h;i++){
        s[i] = top[i];
      }
      for(int i=0; i<h; i++){
        s[i+s.length()-h]=bottom[i];
      }
    }
    cout << s << endl;
  }
}


Measured memory_bytes: 3200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.Solve(in, out);
        out.close();
    }
    
    static class TaskC {


        public void Solve(InputReader in, PrintWriter out) {
int R = in.NextInt();
int G = in.NextInt();
out.println(G*2 -R);
        }
    }

    public static int GetMax(int[] ar) {
        int max = Integer.MIN_VALUE;
        for (int a : ar) {
            max = Math.max(max, a);
        }
        return max;
    }

    public static int GetMin(int[] ar) {
        int min = Integer.MAX_VALUE;
        for (int a : ar) {
            min = Math.min(min, a);
        }
        return min;
    }

    public static int[] GetCount(int[] ar) {
        return GetCount(ar, GetMax(ar));
    }

    public static int[] GetCount(int[] ar, int maxValue) {
        int[] dp = new int[maxValue + 1];
        for (int a : ar) {
            dp[a]++;
        }
        return dp;
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String Next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NextInt() {
            return Integer.parseInt(Next());
        }

        public long NextLong() {
            return Long.parseLong(Next());
        }

        public double NextDouble() {
            return Double.parseDouble(Next());
        }

        public int[] NextIntArray(int n) {
            return NextIntArray(n, 0);
        }

        public int[] NextIntArray(int n, int offset) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = NextInt() - offset;
            }
            return a;
        }

        public int[][] NextIntMatrix(int n, int m) {
            return NextIntMatrix(n, m, 0);
        }

        public int[][] NextIntMatrix(int n, int m, int offset) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = NextInt() - offset;
                }
            }
            return a;
        }
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int ha,hb,hc,hd;
    cin >> ha >> hb >> hc >> hd;
    int a,b,c,d; cin >> a >> b >> c >> d;
    int hiroshi = a * ha + ha/10 * c + hb * b + hb/20 * d;
    int keijiro = a * hc + hc/10 * c + hd * b + hd/20 * d;
    if(hiroshi == keijiro)cout << "even" << endl;
    else if(hiroshi > keijiro)cout << "hiroshi" << endl;
    else cout <<"kenjiro" << endl;
}





Measured memory_bytes: 3024
#coding:utf-8
from math import *
N,H=map(int,raw_input().split())
A=[];B=[]
for i in range(N):
    a,b=map(int,raw_input().split())
    A.append(a);B.append(b)
am=max(A)
B.sort()
B.reverse()
B.append(-1)
h=0
c=0
bi=0
while h<H:
    b=B[bi]
    if b<am:
        c+=int(ceil((H-h)*1.0/am))
        break
    else:
        h+=b
        c+=1
        bi+=1
print(c)
        





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

int visited[251][251][251];

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

	int a,b,c;

	memset(visited,-1,sizeof(visited));
	cin >> a >> b >> c;
	visited[a][b][c] = 0;

	queue <pair<int,pair<int,int>>> que;
	que.push(make_pair(a,make_pair(b,c)));

	while(!que.empty())
	{
		int A = que.front().first;
		int B = que.front().second.first;
		int C = que.front().second.second;
		que.pop();

		if(A==B && A==C)
		{
			cout << visited[A][B][C] << '\n';
			break;
		}

		if(A+2<=500 && visited[A+2][B][C]==-1)
		{
			visited[A+2][B][C] = visited[A][B][C] + 1;
			que.push(make_pair(A+2,make_pair(B,C)));
		}
		if(B+2<=500 && visited[A][B+2][C]==-1)
		{
			visited[A][B+2][C] = visited[A][B][C] + 1;
			que.push(make_pair(A,make_pair(B+2,C)));
		}
		if(C+2<=500 && visited[A][B][C+2]==-1)
		{
			visited[A][B][C+2] = visited[A][B][C] + 1;
			que.push(make_pair(A,make_pair(B,C+2)));
		}	
		if(A+1<=500 && B+1<=500 && visited[A+1][B+1][C]==-1)
		{
			visited[A+1][B+1][C] = visited[A][B][C] + 1;
			que.push(make_pair(A+1,make_pair(B+1,C)));
		}
		if(A+1<=500 && C+1<=500 && visited[A+1][B][C+1]==-1)
		{
			visited[A+1][B][C+1] = visited[A][B][C] + 1;
			que.push(make_pair(A+1,make_pair(B,C+1)));
		}	
		if(B+1<=500 && C+1<=500 && visited[A][B+1][C+1]==-1)
		{
			visited[A][B+1][C+1] = visited[A][B][C] + 1;
			que.push(make_pair(A,make_pair(B+1,C+1)));
		}								
	}
	return 0;
}

Measured memory_bytes: 65456
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h,w;
    cin >> h >> w;

    vector<vector<char> > mat(h+1,vector<char>(w+1));
    
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            cin >> mat[i][j];
        }
    }

    vector<vector<int> > dp(h+1,vector<int>(w+1,INF));
    dp[1][1] = (mat[1][1] == '#');

    reps(i,h){
        reps(j,w){
            if(i == 1 && j == 1) continue;
            dp[i][j] = min(dp[i-1][j] + (mat[i-1][j] == '.' && mat[i][j] == '#'),
                             dp[i][j-1] + (mat[i][j-1] == '.' && mat[i][j] == '#'));
        }
    }

    cout << dp[h][w] << '\n';

    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef  long long int  ll;
typedef long double ld;
ll N;
ll ac,wa,tle,re;
string str;
void solve()
{
    cin>>N;
    ac=0,wa=0,tle=0,re=0;
    while(N--)
    {
        cin>>str;
        if(str=="AC")
        ac++;
        else if(str=="WA")
        wa++;
        else if(str=="TLE")
        tle++;
        else
        {
            re++;
        }
    }
    cout<<"AC"<<" "<<"x"<<" "<<ac<<"\n";
    cout<<"WA"<<" "<<"x"<<" "<<wa<<"\n";
    cout<<"TLE"<<" "<<"x"<<" "<<tle<<"\n";
    cout<<"RE"<<" "<<"x"<<" "<<re<<"\n";
    
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
}

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

int main() {
    int N;
    cin >> N;
    map<string, int> ans;
    rep(i, N) {
        string s;
        cin >> s;
        ans[s]++;
    }
    for (string s: {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << ans[s] << endl;
    }
}


Measured memory_bytes: 3624
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int k = parseInt(sc.next());
//		char[] s = sc.next().toCharArray();
		String s = sc.next();
		sc.close();
		String ans=s;
		if(s.length()>k) {
			ans=s.substring(0,k) + "...";
		}
		out.println(ans);
	}
}


Measured memory_bytes: 26848