akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long>
#define vvi vector<vector<long>>
int main(void){
    long n,ans=0;
    cin>>n;
    vi m(n+1);
    vi y(n);
    for(long i=0; i<=n; i++){
        cin>>m[i];
    }
    for (long  i = 0; i < n; i++)
    {
        cin>>y[i];
    }
    for (long  i = 0; i < n; i++)
    {
        if(y[i]>m[i]){
            long  ysup = min(y[i]-m[i],m[i+1]);//>0
            ans += (m[i]+ysup);
            m[i+1] -= ysup;
        }else{
            ans += y[i];
        }
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

LL POW(LL x, LL y)
{
    LL ans = 1;
    LL base = x;
    while (y)
    {
        if (y & 1)
        {
            ans *= base;
        }
        base = base * base;
        y = y >> 1;
    }
    return ans;
}

int main()
{
    fastinput;
    LL n, i, j, k, t, temp, tc;
    LL M;
    cin >> M >> k;
    LL limit = POW(2, M) - 1;
    short freq[limit + 1] = {0};
    if (k > limit)
    {
        cout << -1 << endl;
    }
    else
    {
        if (M == 0)
        {
            if (k == 0)
            {
                cout << "0 0" << endl;
            }
        }
        else if (M == 1)
        {
            if (k == 0)
            {
                cout << "1 0 0 1" << endl;
            }
            else
            {
                cout << -1 << endl;
            }
        }
        else
        {

            for (i = 0; i <= limit; i++)
            {
                if (i != k)
                {
                    cout << i << " ";
                }
            }
            cout << k << " ";
            for (i = limit; i >= 0; i--)
            {
                if (i != k)
                {
                    cout << i << " ";
                }
            }
            cout << k << " ";
        }
    }
    return 0;
}


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

const int maxn = 2010;

int n,m,q;
char tmp[maxn];
int s[maxn][maxn];
int sum1[maxn][maxn]; //blue dots
int sum2[maxn][maxn]; //vertically adjacent
int sum3[maxn][maxn]; //horizontally adjacent

void pre()
{
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) sum1[i][j] = s[i][j] + sum1[i-1][j] + sum1[i][j-1] - sum1[i-1][j-1];
	}
	
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) sum2[i][j] = (s[i][j] + s[i-1][j] == 2 ? 1 : 0) + sum2[i-1][j] + sum2[i][j-1] - sum2[i-1][j-1];
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++) sum3[i][j] = (s[i][j] + s[i][j-1] == 2 ? 1 : 0) + sum3[i-1][j] + sum3[i][j-1] - sum3[i-1][j-1];
	}
}

int main()
{
	//freopen("C.in","r",stdin);
	scanf("%d%d%d",&n,&m,&q);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",tmp);
		for (int j=1;j<=m;j++) s[i][j] = tmp[j-1] - '0';
	}
	pre();
	while (q--)
	{
		int x0,y0,x1,y1;
		scanf("%d%d%d%d",&x0,&y0,&x1,&y1);
		int ans1 = sum1[x1][y1] - sum1[x1][y0-1] - sum1[x0-1][y1] + sum1[x0-1][y0-1];
		int ans2 = sum2[x1][y1] - sum2[x1][y0-1] - sum2[x0][y1] + sum2[x0][y0-1];
		int ans3 = sum3[x1][y1] - sum3[x1][y0] - sum3[x0-1][y1] + sum3[x0-1][y0];
		//cout<<ans1<<" "<<ans2<<" "<<ans3<<endl;
		printf("%d\n",ans1 - ans2 - ans3);
	}
	return 0;
}


Measured memory_bytes: 64896
from collections import deque
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
d=deque()
d.append(1)
check=[0]*n
check[0]=1
ans=[0]*n
kyori=[0]*n
while len(d)!=0:
  v=d.popleft()
  for i in l[v-1][2:]:
    if check[i-1]==0:
      check[i-1]=1
      ans[i-1]=(kyori[v-1]+1)
      kyori[i-1]=(kyori[v-1]+1)
      d.append(i)
for i in range(1,n):
  if ans[i]==0:
    ans[i]=-1
for i in range(n):
    print(i+1,ans[i])


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

bool check(char c) {
  if ((c == 'A') || (c == 'T') || (c == 'G') || (c == 'C'))
    return true;
  else
    return false;
}

int main() {
  int a, b;
  cin >> a >> b;
  int ans = max(0, a - 2 * b);
  cout << ans << endl;
  return 0;
}


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

#define fors(i, n) for (int i = 0; i < n; i++)

char maps[4][6][50];
int cases[24][6] = {{1, 2, 0, 5, 3, 4}, {1, 5, 2, 3, 0, 4}, {1, 3, 5, 0, 2, 4}, {1, 0, 3, 2, 5, 4}, {2, 1, 5, 0, 4, 3}, {2, 0, 1, 4, 5, 3}, {2, 4, 0, 5, 1, 3}, {2, 5, 4, 1, 0, 3}, {3, 4, 5, 0, 1, 2}, {3, 5, 1, 4, 0, 2}, {3, 1, 0, 5, 4, 2}, {3, 0, 4, 1, 5, 2}, {4, 0, 2, 3, 5, 1}, {4, 2, 5, 0, 3, 1}, {4, 5, 3, 2, 0, 1}, {4, 3, 0, 5, 2, 1}, {5, 2, 1, 4, 3, 0}, {5, 4, 2, 3, 1, 0}, {5, 1, 3, 2, 4, 0}, {5, 3, 4, 1, 2, 0}, {0, 2, 4, 1, 3, 5}, {0, 1, 2, 3, 4, 5}, {0, 3, 1, 4, 2, 5}, {0, 4, 3, 2, 1, 5}};

int min = 100000, n, data[4];

int color(char ch[5][50]) // input is rotated dices same face
{
	int counts[5] = {0};
	fors(i, n)
	{
		fors(j, n)
		{
			if (!strcmp(ch[i], ch[j])) // same color
				counts[i]++;
		}
	}
	int max = 0;
	fors(c, n)
	{
		if (counts[c] > counts[max]) // best color
			max = c;
	}
	int flag = 0;
	fors(i, n) if (strcmp(ch[i], ch[max])) // diff color count
		flag++;
	return flag;// return repaint count
}

void min_repaint()
{
	int sum = 0;
	fors(i, 6)
	{
		char temp[5][50]; //dices's same face
		fors(j, n)
		{
			strcpy(temp[j], maps[j][cases[data[j]][i]]); //set surface name, rotate by data
		}
		sum += color(temp);
	}
	if (sum < min)
		min = sum;
}

void set_data_dfs(int depth)
{
	if (depth == n - 1)
		min_repaint();
	else
		fors(i, 24)
		{
			data[depth] = i;
			set_data_dfs(depth + 1);
		}
}

int main()
{
	while (scanf("%d", &n) && n != 0)
	{
		fors(i, n) fors(j, 6)
			scanf("%s", maps[i][j]);
		min = 1000000;
		set_data_dfs(0);
		printf("%d\n", min);
	}
	return 0;
}


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

using BIT=bitset<25>;
struct State{
    int h,w;
    BIT bit;
    int t;
};
int solve(int n){
    vector<string> f(n);
    for(int i=0;i<n;i++) cin>>f[i];
    State ini;
    auto toIdx=[&](int i,int j){
        return i*n+j;
    };
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(f[i][j]=='@'){
                ini.h=i,ini.w=j;
                ini.t=0;
            }           
            if(f[i][j]=='#'){
                ini.bit[toIdx(i,j)]=true;
            }     
        }
    }
    auto isRange=[&](int i,int j){
        return 0<=i && i<n && 0<=j && j<n;
    };
    auto calcInfected=[&](int i,int j,const BIT& bit){
        int cnt=0;
        for(int di=-1;di<=1;di++){
            for(int dj=-1;dj<=1;dj++){
                if(di==0 && dj==0 || !isRange(i+di,j+dj) || !bit[toIdx(i+di,j+dj)]) continue;
                cnt++;
            }
        }
        return cnt;
    };
    queue<State> que;
    que.push(ini);
    set<tuple<int,int,int>> s;
    while(!que.empty()){
        State st=que.front(); que.pop();
        if(st.bit==0) return st.t;
        for(int di=-1;di<=1;di++) for(int dj=-1;dj<=1;dj++){
            if(di==0 && dj==0) continue;
            int toh=st.h+di,tow=st.w+dj;
            if(!isRange(toh,tow) || st.bit[toIdx(toh,tow)]) continue;
            st.bit[toIdx(toh,tow)]=true;
            BIT tobit;
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    int cnt=calcInfected(i,j,st.bit);
                    tobit[toIdx(i,j)]=(st.bit[toIdx(i,j)] && 2<=cnt && cnt<=3) || (!st.bit[toIdx(i,j)] && cnt==3);
                }
            } 
            tobit[toIdx(toh,tow)]=false;
            st.bit[toIdx(toh,tow)]=false;
            State to;
            to.h=toh,to.w=tow,to.t=st.t+1,to.bit=tobit;
            if(!s.count(make_tuple(toh,tow,(int)(tobit.to_ulong())))){
                s.insert(make_tuple(toh,tow,(int)(tobit.to_ulong())));
                que.push(to);
            }
        }
    }
    return -1;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 4616
s = gets.chomp
t = gets.chomp
sl = s.length
tl = t.length
min_count = tl
for offset in 0..(sl - tl) do
  count = 0
  for i in 0...tl do
    if s[i + offset] != t[i]
      count += 1
    end
  end
  min_count = count if min_count > count
end
puts min_count


Measured memory_bytes: 14324
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);
        }

    }
}



Measured memory_bytes: 66168
#include <bits/stdc++.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/range/irange.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using boost::irange;
using boost::algorithm::join;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll A, B, K;
  cin >> A >> B >> K;

  if (A>=K) {
    A -= K;
    cout << A << " " << B << endl;
    return 0;
  }

  K = K-A;
  A = 0;

  B -= K;
  if (B<0) B=0;

  cout << A << " " << B << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        
        if(N.contains("000")||N.contains("111")||N.contains("222")||N.contains("333")||N.contains("444")||N.contains("555")||N.contains("666")||N.contains("777")||N.contains("888")||N.contains("999")){
            System.out.println("Yes");
        } else{
            System.out.println("No");
        }
		
    }
}



Measured memory_bytes: 21844
use std::collections::BTreeMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Debug, Clone)]
struct Restaurant {
    n: u32,
    score: u32,
}

fn main() {
    let n = read::<u32>();
    let mut regions = {
        let mut rows: BTreeMap<String, Vec<Restaurant>> = BTreeMap::new();
        for i in 1..n + 1 {
            let record = rows.entry(read::<String>()).or_insert(vec![]);
            record.push(Restaurant {
                n: i,
                score: read::<u32>(),
            });
        }
        rows
    };

    for region in regions.values_mut() {
        region.sort_by(|a, b| a.score.cmp(&b.score));
        region.reverse();
    }

    for region in regions.values() {
        for restaurant in region {
            println!("{}", restaurant.n);
        }
    }
}


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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	string S;
	cin >> S;
	// vector<llint> A(N);
	// rep(i,0,N) {
	// 	cin >> A[i];
	// }
	// string S;
	// cin >> S;
	llint len;
	len = S.length();
	llint ans = 0;

	rep(i,0,len) {
		if (i%2 == 0) {
			if (S[i] != 'h') {
				ans = 1;
			}
		} else {
			if (S[i] != 'i') {
				ans = 1;
			}
		}

	}

	//SOLVE
	if (ans == 1) {
		cout << "No" << endl;
	} else {
		if (len%2 == 0) {
			cout <<  "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()

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

	string s;
	cin >> s;

	vector<set<int>> pos(26);

	rep(i, N)
	{
		pos[s[i] - 'a'].insert(i);
	}

	int Q;
	cin >> Q;

	vll ans;

	rep(i, Q)
	{
		int t;
		cin >> t;

		if (t == 1)
		{
			int idx;
			char c;
			cin >> idx >> c;

			--idx;

			if (s[idx] != c)
			{
				pos[s[idx] - 'a'].erase(idx);
				pos[c - 'a'].insert(idx);
				s[idx] = c;
			}
		}
		else
		{
			int l, r;
			cin >> l >> r;

			--l;
			--r;

			int count = 0;
			rep(j, 26)
			{
				//文字jの最も左の位置を取得
				auto lb = pos[j].lower_bound(l);

				if (lb == pos[j].end()) continue;

				if (*lb > r) continue;

				count++;
			}

			ans.push_back(count);
		}
	}

	for (auto x : ans) cout << x << endl;

	return 0;
}

Measured memory_bytes: 24708
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,a,ma=0,mi=1000;
	cin>>n;
	rep(i,n){
		cin>>a;ma=max(ma,a);mi=min(mi,a);
	}
	cout<<ma-mi<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll ara[105],dp[105][4],n,p;

ll f(int pos,int rem)
{
    if(pos==n)
    {
        if(rem==p)return 1;
        else return 0;
    }
    if(dp[pos][rem]!=-1)return dp[pos][rem];
    ll p1,p2;
    p1=f(pos+1,(rem+ara[pos])%2);
    p2=f(pos+1,rem%2);
    return dp[pos][rem]=p1+p2;
}

int main()
{
    ll i,rslt;
    while(cin>>n>>p)
    {
        for(i=0;i<n;i++)cin>>ara[i];
        memset(dp,-1,sizeof(dp));
        rslt=f(0,0);
        cout<<rslt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

// go run main.go < in

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(a / b)
	fmt.Println(a % b)

	c := float64(a) / float64(b)
	fmt.Println(strconv.FormatFloat(c, 'f', 5, 64))

}


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

int main(){
	string s, t;
	cin >> s;
	for(int i = 0;;){
		if(s == t){
			cout << "YES" << endl;
			return 0;
		}
		if(s[i] == 'd'){
			if("dreameraser" == s.substr(i,11)){
				i += 11;
				t += "dreameraser";
				continue;
			}
			if("dreamerase" == s.substr(i,10)){
				i += 10;
				t += "dreamerase";
				continue;
			}
			if("dreamer" == s.substr(i,7)){
				i += 7;
				t += "dreamer";
				continue;
			}
			if("dream" == s.substr(i,5)){
				i += 5;
				t += "dream";
				continue;
			}
		}
		if(s[i] == 'e'){
			if("eraser" == s.substr(i,6)){
				i += 6;
				t += "eraser";
				continue;
			}
			if("erase" == s.substr(i,5)){
				i += 5;
				t += "erase";
				continue;
			}
		}
		break;
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    long long A[N + 1];
    long long B[N + 1];
    long long M[N + 1];

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

    long long count = 0;
    long long zan = 0;
    for (int i = 0; i < N + 1; i ++) {
        if (M[i] < B[i]) {
            count += M[i];
            zan = B[i] - M[i];
            if (M[i+1] < zan) {
                count += M[i + 1];
                M[i+1] = 0;
            } else {
                count += zan;
                M[i+1] -= zan;
            }
        } else {
            count += B[i];
        }
    }

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

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<array>
using namespace std;

int main(){

    int a;
    cin >> a;
    if (a / 1000 == (a / 100 - (a / 1000) * 10) || (a - (a / 1000) * 1000) / 100 == (a % 100 - a % 10) / 10 || (a % 100 - a % 10) / 10 == a % 10) {
        cout << "Bad";
    }else {
        cout << "Good";
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();

		System.out.println(judge(a, b));

		sc.close();
	}

	static String judge(String a, String b) {
		if (a.length() == b.length()) {
			int ia = Integer.parseInt("" + a.charAt(0));
			int ib = Integer.parseInt("" + b.charAt(0));
			if (ia == ib) {
				return "EQUAL";
			} else if (ia > ib) {
				return "GREATER";
			} else {
				return "LESS";
			}
		} else if (a.length() > b.length()) {
			return "GREATER";
		} else {
			return "LESS";
		}
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

typedef pair<ll, ll> p;
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n);re(i, n) std::cin >> a[i];
  ll ans = 0;
  multimap<ll, p> mp;
  sort(all(a));
  reverse(all(a));
  mp.emplace(a[0], p(a[0], a[0]));

  for(int i=1;i<n;i++){
    auto itr = --mp.end();
    ans += (*itr).first;
    ll l = (*itr).second.first;
    ll r = (*itr).second.second;
    mp.erase(itr);
    mp.emplace(min(a[i], l), p(a[i], l));
    mp.emplace(min(a[i], r), p(a[i], r));
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 16876
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
typedef long long ll;
ll a[N],m,psum[N];
int n;

ll numpair(ll sum) { //geq sum
	int x = n;
	ll ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		while (x > 0 && a[i] + a[x] < sum) --x;
		ans += x;
	}
	return ans;
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + n + 1, greater<ll>());
	psum[0] = 0; for (int i = 1; i <= n; ++i) psum[i] = psum[i - 1] + a[i];
	ll l = a[n] + a[n], r = a[1] + a[1], x = a[1]+a[1]+1;
	while (l <= r) {
		ll mid = (l + r) / 2;
		ll tmp = numpair(mid);
		if (tmp <= m) {
			x = mid;
			if (tmp == m) break;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	int y = n;
	ll ans = 0LL;
	for (int i = 1; i <= n; ++i) {
		while (y > 0 && a[i] + a[y] < x) --y;
		ans += a[i] * y + psum[y];
	}
	m -= numpair(x);
	--x; ans += m * x;
	cout << ans << endl;
}

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

int main() {
  int a, b, c, d , e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double noudo = -999;
  int ans1, ans2;
  for (int i = 0; i <= f; i += 100*a) {
    for (int j = 0; j <= f; j += 100*b) {
      for (int k = 0; k <= f; k += c) {
        for (int l = 0; l <= f; l += d) {
          int water = i + j;
          int sugar = k + l;
          double tmp = ((double)(sugar)*100)/(double)(water + sugar);
          if (tmp > noudo && sugar <= (water*e)/100 && water + sugar <= f) {
            noudo = tmp;
            ans1 = water + sugar;
            ans2 = sugar;
          }
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}

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

int main(){
	int x,y,d,r;
	cin>>x>>y;
	if(x>=y)swap(x,y);
	while(y>0)/*gcd(x,y)????????£????????£??????y???0????????????*/
	{
		r=x%y;//r?????????????????????
		x=y;
		y=r;
	}
	cout <<x<<endl;

}//????????????????????????????????????O(logN)????¨?????????§?????????

Measured memory_bytes: 3120
// https://atcoder.jp/contests/abc172/tasks/abc172_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(N + 1), B(M + 1);

    REP(i, N) { cin >> A[i + 1]; }
    REP(i, M) { cin >> B[i + 1]; }
    REP(i, N) { A[i + 1] += A[i]; }
    REP(i, M) { B[i + 1] += B[i]; }
    int idx = 0, ans = 0;
    for (int i = N; i >= 0; i--) {
        if (A[i] + B[idx] > K) {
            continue;
        }
        while (idx + 1 <= M && A[i] + B[idx + 1] <= K) {
            idx++;
        }
        ans = max(ans, i + idx);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6364
#include <cstdio>
using namespace std;

int F[50];

int fibonacci(int n) {
    if (n==0||n==1) {
        return F[n] = 1;
    }
    if (F[n] != -1) {
        return F[n];
    }

    return F[n] = fibonacci(n-1) + fibonacci(n-2);
}

int main (void) {
    int N, i;

    for(i = 0 ; i < 50 ; i ++ ) {
        F[i] = -1;
    }

    scanf("%d", &N);
    printf("%d\n", fibonacci(N));

    return 0;
}

Measured memory_bytes: 2736
import math  # noqa: F401
from collections import deque  # noqa: F401
from typing import Deque, Dict, List, Optional, Tuple, Union  # noqa: F401


def main(L, R, d):
    ans = 0
    for i in range(L, R + 1):
        if i % d == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    L, R, d = map(int, input().split())
    main(L, R, d)


Measured memory_bytes: 10256
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

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

    private void run() {
        String s = sc.next();
        String t = sc.next();

        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == t.charAt(i)) ans++;
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 21716
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            // Input
            string[] str = Console.ReadLine().Split(' ');

            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);

            if ((x == 0) && (y == 0))
            {
                break;
            }
            if (x > y)
            {
                // Sort
                int temp = x;
                x = y;
                y = temp;
            }
            // Output
            Console.WriteLine("{0} {1}", x , y);
        }
    }
}

Measured memory_bytes: 9200
S = input()
T = input()
t_len = len(T)
s_len = len(S)
output_list = [''] * len(S)
flag = False
hatena_to_a_str = ''
for i in range(s_len):
    if S[i] == '?':
        hatena_to_a_str += 'a'
    else:
        hatena_to_a_str += S[i]
#print(hatena_to_a_str)
current_min = 'z' * (s_len+1)
for i in reversed(range(s_len-t_len+1)):
    #print(i)
    text = S[i:i+t_len]
    if S[i:t_len] == T:
        flag = False
    else:
        for j in range(t_len):
            if text[j] != T[j] and text[j] != '?':
                break 
            if j == t_len-1:
                flag = True
                for s in range(t_len):
                    output_list[i+s] = T[s]
    if flag:
        tmp = hatena_to_a_str[:i] + T + hatena_to_a_str[i+t_len:s_len]
        current_min = min(current_min,tmp)
        flag = False

if current_min == 'z' * (s_len+1):
    print('UNRESTORABLE')
else:
    print(current_min)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int f(int** graph, int* index, int* dp, int val)
{
    if(graph[0][val] == -1)
    {
        dp[val] = 0;
        return 0;
    }
    if(dp[val] == -1)
    {
        int m;
        m = 1 + f(graph, index, dp, graph[0][val]);
        for(int i = 1; i < index[val]; i++)
        {

            int m2 = 1 + f(graph, index, dp, graph[i][val]);
            if(m2 > m)
            {
                m = m2;
            }
        }
        dp[val] = m;
        return dp[val];
    }
    else 
        return dp[val];
}
int main()
{
    int nodes  ;
    int paths;
    scanf("%d", &nodes );
    scanf("%d", &paths);
    int** graph = (int **)malloc((nodes + 1) * sizeof(int *));
    for(int i = 0; i < nodes + 1 ;i ++)
    {
        graph[i] = (int *)malloc((nodes + 1) * sizeof(int));
    }
    int* index = (int *)malloc((nodes + 1) * sizeof(int));
    int* dp = (int *)malloc((nodes + 1) * sizeof(int));
    for(int i = 0; i < (nodes + 1); i++)
    {
        graph[0][i] = -1;
        index[i] = 0;
        dp[i] = -1;
    }
    /*printf("Index : \n");
    for(int i = 0; i < nodes + 1 ; i++)
    {
        printf("%d ", index[i]);
    }*/
    for(int i = 0; i < paths; i++)
    {
        int val ;
        scanf("%d", &val);
        scanf("%d", &graph[index[val]][val]);
        index[val]++;
    }
    /*printf("Graph : \n");
    for(int i = 0 ; i < nodes + 1 ; i ++)
    {
        for(int j = 0; j < nodes + 1 ; j++)
        {
            printf("%d ", graph[i][j]);
        }
        printf("\n");
    }
    printf("Index : \n");
    for(int i = 0; i < nodes + 1 ; i++)
    {
        printf("%d ", index[i]);
    }*/
    int m = f(graph, index, dp, 1);
    for(int i = 2; i <= nodes; i ++)
    {
        int m2 = f(graph, index, dp, i);
        if(m2 > m)
            m = m2;
    }
    //printf("\n");

    printf("%d ", m);
}

Measured memory_bytes: 405504
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>k;

      cin>>str;

      char ch=str[k-1]+32;

      str[k-1]=ch;

      cout<<str<<endl;













}



Measured memory_bytes: 3640
aa=list(map(int, input().split()))
ab=list(map(int, input().split()))
ac=list(map(int, input().split()))
n=int(input())
b=[int(input()) for i in range (n)]
aaa=0
aab=0
aac=0
aba=0
abb=0
abc=0
aca=0
acb=0
acc=0
for i in range (n):
    if aa[0]==b[i]:
        aaa=aaa+1
    elif aa[1]==b[i]:
        aab=aab+1
    elif aa[2]==b[i]:
        aac=aac+1
    elif ab[0]==b[i]:
        aba=aba+1
    elif ab[1]==b[i]:
        abb=abb+1
    elif ab[2]==b[i]:
        abc=abc+1
    elif ac[0]==b[i]:
        aca=aca+1
    elif ac[1]==b[i]:
        acb=acb+1
    elif ac[2]==b[i]:
        acc=acc+1
ha=aaa*aab*aac
hb=aba*abb*abc
hc=aca*acb*acc
va=aaa*aba*aca
vb=aab*abb*acb
vc=aac*abc*acc
ca=aaa*abb*acc
cb=aac*abb*aca
if ha+hb+hc+va+vb+vc+ca+cb==0:
    print('No')
else:
    print('Yes')

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

int main() {
    int x, y, z; scanf("%d%d%d", &x, &y, &z);
    int n = x + y + z;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);

    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return b[i] - c[i] > b[j] - c[j];
    });

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    long long ysum = 0, xsum = 0;
    vector<long long> pref(n), suff(n);
    for (int i = 0; i < n; ++i) {
        pq.emplace(b[ord[i]] - a[ord[i]], ord[i]); 
        ysum += b[ord[i]];
        while (pq.size() > y) {
            int j = pq.top().second;
            ysum -= b[j];
            xsum += a[j];
            pq.pop();
        }
        pref[i] = xsum + ysum;
    }
    while (!pq.empty()) pq.pop();
    long long zsum = 0;
    xsum = 0;
    for (int i = n - 1; i >= 0; --i) {
        pq.emplace(c[ord[i]] - a[ord[i]], ord[i]); 
        zsum += c[ord[i]];
        while (pq.size() > z) {
            int j = pq.top().second;
            zsum -= c[j];
            xsum += a[j];
            pq.pop();
        }
        suff[i] = xsum + zsum;
    }
    long long ans = 0;
    for (int i = y - 1; i < n; ++i) {
        if (n - i - 1 < z) continue;
        ans = max(ans, pref[i] + suff[i + 1]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4472
#include<bits/stdc++.h>
#define ll long long
using namespace std;
/*struct aaa{
	int x,y;
}b[200010];*/
int flag,n,m,tot,rt,b[200010],du[200010],e[200010],hd[200010],nt[200010],le[200010],re[200010],a[200010];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void dfs(int x,int fa){
	int i,sum=0;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
		sum+=b[e[i]];
		if(b[e[i]]>a[x]){
			flag=1;
		}
		//b[++m].x=le[e[i]];b[m].y=re[e[i]];
	}
	if(du[x]==1){
		b[x]=a[x];return;
	}
	b[x]=a[x]*2-sum;
	if(b[x]<0||b[x]>a[x])flag=1;
	/*m=0;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		b[++m].x=le[e[i]];b[m].y=re[e[i]];
	}
	/*if(!m){
		le[x]=re[x]=a[x];return;
	}
	int mx=0,op,sum=0;
	for(i=1;i<=m;i++){
	  re[i]+=b[i].y;
	  if(b[i].x>=mx)mx=b[i].x,op=i;
    }
    for(i=1;i<=m;i++)if(op!=i)sum+=b[i].y;
    if(sum>=b[op].x)le[i]=0;
     else le[i]=b[op].x-sum;*/
}
int main(){
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	if(n==2){
		if(a[1]!=a[2])puts("NO");
		 else puts("YES");
		return 0;
	}
	
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
		du[x]++;du[y]++;
	}
	for(i=1;i<=n;i++)if(du[i]>1)rt=i;
	//printf("%d\n",rt);
	dfs(rt,0);
	if(flag)return puts("NO"),0;
	if(b[rt]==0)puts("YES");
	 else puts("NO");
}

Measured memory_bytes: 8960
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
from functools import lru_cache
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())


n = inp()
h = inpl()
dp = [INF] * (n)
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(n-2):
    left = dp[i + 1] + abs(h[i + 2] - h[i + 1])
    right = dp[i] + abs(h[i + 2] - h[i])
    dp[i + 2] = min(left, right)
print(dp[n-1])

Measured memory_bytes: 56220
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		String anser = "No";

		StringBuilder sb = new StringBuilder(s);

		if (s.equals(sb.reverse().toString())) {

			String sbe = s.substring(0, (s.length() - 1) / 2);
			String sba = s.substring((s.length() + 1) / 2, s.length());

			StringBuilder sbbe = new StringBuilder(sbe);
			StringBuilder sbba = new StringBuilder(sba);

			if (sbe.equals(sbbe.reverse().toString()) && sba.equals(sbba.reverse().toString())) {
				anser = "Yes";

			}

		}
		System.out.println(anser);

	}

}


Measured memory_bytes: 22996
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <vector>
#include <queue>


typedef long long llong;
using namespace std;

int paper[10][10] = { 0 };

void add(int x, int y) {
	if (x >= 0 && y >= 0 && x < 10 && y < 10)paper[x][y]++;
	return;
}

int small(int x, int y) {
	add(x, y);
	add(x + 1, y); add(x - 1, y);
	add(x, y + 1); add(x, y - 1);
	return 0;
}

int medi(int x, int y) {
	for (int i = x - 1; i <= x + 1; i++) {
		for (int j = y - 1; j <= y + 1; j++) {
			add(i, j);
		}
	}
	return 0;
}

int large(int x, int y) {
	add(x, y + 2); add(x, y - 2);
	for (int i = x - 1; i <= x + 1; i++) {
		add(i, y + 1); add(i, y - 1);
	}
	for (int i = x - 2; i <= x + 2; i++) {
		add(i, y);
	}
	return 0;
}
int main() {
	int x, y, s;

	while (cin >> x&&getchar()&&cin >> y&&getchar()&&cin >> s) {
		if (s == 1)small(x, y);
		else if (s == 2)medi(x, y);
		else if (s == 3)large(x, y);
	}

	int cnt = 0; int maxim = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			if (paper[i][j] == 0)cnt++;
			if (paper[i][j] > maxim)maxim = paper[i][j];
			
		}
	}
	cout << cnt << endl << maxim << endl;

	return 0;
}
 


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

using namespace std;

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

    long long N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << "\n";
    } else {
        long long res = 0;
        N /= 2;
        while (N) {
            res += N / 5;
            N /= 5;
        }
        cout << res << "\n";
    }

    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;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int k;
string s;
ll solve(){
   ll ans=0;
   

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

    cin>>k>>s;
    int sz=s.size();
    if(sz<=k){
        cout<<s<<endl;
        return 0;
    }else{
        string cur=s.substr(0,k)+"...";
        cout<<cur<<endl;
        return 0;
    }
    //cout<<solve()<<endl;
    return 0;
}

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


#define fr(i,x,y) for(int i = x; i <= y; i++)
int n;
int a[2][105],b[2][105];
int main(){
    scanf("%d",&n);
    fr(i,1,2)
        fr(j,1,n)
            scanf("%d", &a[i][j]);
    b[1][1]=a[1][1];
    int temp;
    fr(i,1,2)fr(j,1,n){
            if (i == 1 && j == 1) continue;
            temp=0;
            if (i>1) temp = max(temp, b[i-1][j]);
            if (j>1) temp = max(temp, b[i][j-1]);
            b[i][j] = temp+a[i][j];
        }
    printf("%d\n",b[2][n]);

}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int A1, A2, A3;
  std::cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) std::cout << "bust" << std::endl;
  else std::cout << "win" << std::endl;
  return 0;
}

Measured memory_bytes: 3552
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int INF = 1e9;

inline int dis(int x, int y) {
  return abs(x - y);
}

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

  int n, k; cin >> n >> k;
  int h[n]; rep(i, n) cin >> h[i];

  int dp[n + 110];  //  dp[i] : minimum cost to reach i + 1
  fill(dp, dp + n + 5, INF);

  dp[0] = 0; dp[1] = dis(h[1], h[0]);

  for (int i = 0; i < n; ++i){
    for (int j = 1; j <= k; ++j){
      dp[i + j] = min(dp[i] + dis(h[i], h[i + j]), dp[i + j]);
    }
  }
  print(dp[n - 1]);

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

typedef long long ll;



int main() {
	
	int n, x, t;
	cin >> n >> x >> t;
	if (n % x == 0) {
		cout << n / x * t << endl;
	}
	else cout << (n / x + 1) * t << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main() {
       ll k;
       ll a,b;
       cin>>k>>a>>b;
       int flag=0;
       for(ll i=a;i<=b;i++){
        //cout<<i<<endl;
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }
        cout<<"NG";
        return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char hairetu[100];
  int t;
}P;

void initialize(void);
int isEmpty(void);
int isFull(void);
void enqueue(P);
P dequeue(void);


P Q[LEN+1];
int head, tail, n;

void initialize(){
  head = tail = 0;
}

int isEmpty(){
  return head == tail;
}

int isFull(){
  return head == ( tail + 1 ) % LEN;
}

void enqueue(P x){
  if(isFull()) return;
  Q[tail] = x;
  if(tail+1 == LEN) tail = 0;
  else tail++;
}

P dequeue(){
  
  P x;
  if(isEmpty()) return;
  x = Q[head];
  if(head+1 == LEN) head = 0;
  else head++;
  return x;
}


int main(){
  
  int elaps = 0, c;
  int i, q;
  P u;
  
  scanf("%d %d", &n, &q);
  initialize();
  tail=n;
  for ( i = 0; i < n; i++){
    scanf("%s", Q[i].hairetu);
    scanf("%d", &Q[i].t);
  }
  
  while(!isEmpty()){
    u = dequeue();

    if(u.t-q>0){
      u.t-=q;
      enqueue(u);
      elaps+=q;
    }
    else if(u.t!=(-1))
      {
      elaps+=u.t;
      printf("%s %d\n", u.hairetu,elaps);
      u.t=(-1);
    }
  }
  

  
  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    int ans = A.front();
    for(int i = 0; i < n; i++)
    {
        ans = __gcd(ans, A[i]);
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,k;
	bool dame[10];
	for(int i=0;i<10;i++) dame[i] = false;
	scanf("%d %d",&n,&k);
	for(int i=0;i<k;i++){
		int x;
		scanf("%d",&x);
		dame[x] = true;
	}
	for(int i=n;;i++){
		int x = i;
		bool flag = true;
		while(x>0){
			if(dame[x%10]){
				flag = false;
				break;
			}
			x/=10;
		}
		if(flag){
			printf("%d\n",i);
			return 0;
		}
	}
}


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

int main() {
    string s;
    cin >> s;

    if(s.at(0) == 'R') {
        if(s.at(1) == 'R') {
            if(s.at(2) == 'R') {
                cout << "3" << endl;//RRR
                return 0;
            }else {
                cout << "2" << endl;//RRS
                return 0;
            }
        }else {
            if(s.at(2) == 'R') {
                cout << "1" << endl;//RSR
                return 0;
            }else {
                cout << "1" << endl;//RSS
                return 0;
            }
        }
    }else {
        if(s.at(1) == 'R') {
            if(s.at(2) == 'R') {
                cout << "2" << endl;//SRR
                return 0;
            }else {
                cout << "1" << endl;//SRS
                return 0;
            }
        }else {
            if(s.at(2) == 'R') {
                cout << "1" << endl;//SSR
                return 0;
            }else {
                cout << "0" << endl; //SSS
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3628
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n,m=map(int,stdin.readline().rstrip().split())
s=min(n,m//2)
c=max((m-n*2)//4,0)
print(s+c)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
        int n;
        cin>>n;
        int a[300000];
        for(int i=0; i<n*3; i++){
                cin>>a[i];
        }
        long long int ans=0;

        sort(a, a+3*n);

        for(int i=0; i<n; i++){
                ans+=a[3*n-2-2*i];
        }
        cout<<ans<<endl;
        return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m;
    cin>>n>>m;
    long long int a[n];
    for(long long int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);

    pair<long long int,long long int> b[m];
    for (int i = 0; i < m; ++i) {
        cin>>b[i].second>>b[i].first;
    }

    sort(b,b+m);
    reverse(b,b+m);

    long long int x=0;
    for (long long int i = 0; i < m; ++i) {
        long long int cnt=0;
        if(x<n)
        while (a[x]<b[i].first)
        {
            a[x]=b[i].first;
            cnt++;
            x++;
            if(x==n)
                break;
            if(cnt==b[i].second)
                break;
        }
        else
            break;
    }

    long long int ans=0;
    for (long long int i = 0; i < n; ++i) {
        ans+=a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int mini = INT_MAX,len,temp,temp1;
    cin>>s;
    len = s.size();
    for(int i = 0; i<len-2; i++)
    {
        int x = (s[i]-'0');
        int y = (s[i+1]-'0');
        int z = (s[i+2]-'0');
        temp = x*pow(10,2)+ y *pow(10,1)+ z*pow(10,0);
        temp1 = abs(753-temp);
        mini = min(mini,temp1);
    }
    cout<<mini;
}


Measured memory_bytes: 256