akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
typedef long long int lli;
const long long int MaxN=3005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli dp[MaxN][MaxN];
	/* dp[ind let a][ind let b]=
			if(match let a && let b) dp[ind let a-1][ind let b-1]+1
			max(dp[inda][indb],max(dp[inda-1][indb],dp[inda][indb-1]));
	*/
	void solve(){
		lli N,M,i,j,p,q;
		string a,b;
		cin>>a>>b;
		N=a.size(),M=b.size();	
		a='0'+a,b='0'+b;
		for(i=1;i<=N;i++){
			for(j=1;j<=M;j++){
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				if(a[i]==b[j])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
			}
		}		
		bool next;
		lli x,y;
		x=N,y=M;
		string res="";
		while(x!=0&&y!=0){
			if(a[x]==b[y]){
				next=0;
				if(dp[x-1][y-1]+1==dp[x][y]){
					res.push_back(a[x]);
					x-=1;
					y-=1;
					next=1;
				}
				if(next)continue;
			}
			if(dp[x-1][y]==dp[x][y])x-=1;
			else if(dp[x][y-1]==dp[x][y])y-=1;
		}
		//cout<<res<<"\n";
		for(i=res.size()-1;i>=0;i--)cout<<res[i];
		//cout<<dp[N][M]<<"\n";
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,j,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
	
}

Measured memory_bytes: 73960
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const lli SIZE = 1000001;
const lli mod = 1e9 + 7;

lli fact[SIZE];
void fact_init() {
  fact[0] = 1;
  for (lli i=1; i<SIZE; ++i) {
    fact[i] = i * fact[i-1] % mod;
  }
}

lli inv(lli x) {
  lli y = 1;
  for (lli n = mod - 2; n > 0; n >>= 1) {
    if (n & 1) y = y * x % mod;
    x = x * x % mod;
  }
  return y;
}

lli perm(lli a, lli b) {
  return fact[a] * inv(fact[a-b]) % mod;
}

lli n, m;
vector<lli> a, b;
int main() {
  fact_init();

  cin >> n >> m;
  read_n(a, n); read_n(b, m);
  sort(begin(a), end(a), greater<lli>());
  sort(begin(b), end(b), greater<lli>());
  a.push_back(0); b.push_back(0);
  if (a[0] != b[0]) { cout << 0 << endl; return 0; }

  lli ans = 1, space = 0, past = a[0];
  for (lli i=0, j=0; ; ) {
    if (past == a[i+1] || past == b[j+1]) {
      cout << 0 << endl; return 0;
    }
    // cout << a[i+1] << ' ' << b[j+1] << endl;
    if (a[i+1] == b[j+1]) {
      ++i; ++j;
      lli t = past - a[i] - 1;
      if (t > space) { cout << 0 << endl; return 0; }
      ans = (ans * perm(space, t)) % mod;
      space = space + i + j - t;
      past = a[i];
    } else if (a[i+1] > b[j+1]) {
      ++i;
      lli t = past - a[i] - 1;
      if (t > space) { cout << 0 << endl; return 0; }
      ans = (ans * (j+1) % mod * perm(space, t)) % mod;
      space = space + j - t;
      past = a[i];
    } else {
      ++j;
      lli t = past - b[j] - 1;
      if (t > space) { cout << 0 << endl; return 0; }
      ans = (ans * (i+1) % mod * perm(space, t)) % mod;
      space = space + i - t;
      past = b[j];
    }
    // cout << i << ' ' << j << ' ' << a[i] << ' '<< b[j] << ' ' << space << endl;
    // cout << ans << endl;
    if (a[i+1] == 0 && b[j+1] == 0) break;
  }
  ans = (ans * fact[space]) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final long a = s.nextLong();
			final long b = s.nextLong();
			final long c = s.nextLong();
			final long d = s.nextLong();

			if(c == 1 || d == 1) {
				System.out.println("0");
				return;
			}

			long count = 0;

			count += (b / c - (a - 1) / c);
			count += (b / d - (a - 1) / d);
			count -= (b / lcm(c, d) - (a - 1) / lcm(c, d));

			System.out.println(b - a + 1 - count);
		}
	}

	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return (c / b);
	}

}

Measured memory_bytes: 22996
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  string s; cin >>s;
  int n=s.size();
  int cnt=1,tmp=0;
  vector<int> ans(n,0);
  repa(i,1,n){
    if(s[i-1]=='R' and s[i]=='L'){
      ans[i-1]+=(cnt+1)/2;
      ans[i]+=cnt/2;
      tmp=i;
      cnt=1;
    }else if(s[i-1]!=s[i]){
      ans[tmp]+=(cnt+1)/2;
      ans[tmp-1]+=cnt/2;
      cnt=1;
    }else{
      cnt++;
    }
  }
  ans[tmp]+=(cnt+1)/2;
  ans[tmp-1]+=cnt/2;
  print(ans);
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){

  int Q, H, S, D, N;   cin >> Q >> H >> S >> D >> N;
  int sub_Q, sub_H, sub_S;
  long sum = 0;
  while(2 <= N){
    sub_Q = 8 * Q; sub_H = 4 * H; sub_S = 2 * S;
    sum += min(min(sub_Q, sub_H), min(sub_S, D));
    N -= 2;
  }
  while(1 <= N){
    sub_Q = 4 * Q; sub_H = 2 * H;;
    sum += min(min(sub_Q, sub_H), S);
    N -= 1;
  }
  double sub_N = (double)N;
  while(0.5 <= N){
    sub_Q = 2 * Q;;
    sum += min(sub_Q, H);
    N -= 0.5;
  }
  while(N != 0){
    sum += Q;
    N -= Q;
  }

  cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int k;
	int a,b;
	cin >> k;
	int k2 = k;
	cin >> a >> b;
	int cnt = 2;
	while(k < a){
		k = k2*cnt;
		cnt++;
	}
	if(k > b){
		cout << "NG" << endl;
	}else{
		cout << "OK" << endl;
	}
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ins(S);
  int ans = 0;
  rep(i,sz(S) - 1){
    ans += S[i] != S[i + 1];
  }
  out(ans);


}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    char str[103];
    scanf("%s", str);
    int i = 0, cnt = 0;
    while(str[i] != '\0') {
        if(str[i] == '\n') { break; }
        cnt++; i++;
    }
    printf("%c%d%c\n", str[0], cnt-2, str[i-1] );
    return 0;
}

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

typedef struct hoge{
	long long int y;
	long long int x;
	long long int res;
} hoge;


int main(){
	long long int n;
	long long int len;
	long long int swap;
	hoge a;
	scanf("%lld %lld",&n,&a.x);
	a.y = n - a.x;
	a.res = a.x + a.y;
	while(a.x){
		swap = a.y;
		len = a.y / a.x;
		a.res += len * a.x * 2;
		a.y = a.x;
		a.x = swap % a.x;
	}
	a.res -= a.y;
	printf("%lld\n", a.res);

	return 0;
}


Measured memory_bytes: 128
f=0
while 1:
    a={}
    n=int(input())
    if n==0:break
    if f:print()
    f=1
    for i in range(n):
        b=input().split()
        a[b[0]]=[int(b[1])*3+int(b[3]),-i]
    for y,z in sorted(a.items(),key=lambda x:x[1])[::-1]:
        print('%s,%d'%(y,z[0]))

Measured memory_bytes: 7700
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k):
    if a == [n] * n:
        break
    else:
        a2 = [0] * (n + 1)
        for j in range(n):
            temp = a[j]
            a2[max(j - temp, 0)] += 1
            a2[min(j + temp + 1, n)] -= 1
        a3 = [0]
        for j in range(n):
            a3.append(a3[-1] + a2[j])
        a = a3[1:]
for i in range(n):
    print(a[i], end = " ")
print()

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

namespace ABC165E
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NM = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int N = NM[0];
            int M = NM[1];

            int[] ai = new int[M];
            int[] bi = new int[M];
            for (int i = 0; i < M; i++)
            {
                int num = i / 2;
                if (i % 2 == 0)
                {
                    ai[i] = N / 2 - num;
                    bi[i] = N / 2 + num + 1;
                }
                else
                {
                    ai[i] = num + 1;
                    bi[i] = N - num - 1;
                }
            }

            for (int i = 0; i < M; i++)
            {
                Console.Write(ai[i] + " " + bi[i]);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}


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

using namespace std;

long long int gcd(long long int k,int i,int j,int l)
{
    long long int a, b, c;

                a = i;
                b = j;
                while (1)
                {

                    if (a == 0)
                    {
                        c = l;
                        while (1)
                        {

                            if (b == 0)
                            {
                                return  c;
                                
                            }
                            else if (c == 0)
                            {
                                return b;
                               
                            }
                            (b >= c) ? b %= c : c %= b;
                        }
                    }
                    else if (b == 0)
                    {
                        c = l;
                        while (1)
                        {

                            if (a == 0)
                            {
                                return c;
                               
                            }
                            else if (c == 0)
                            {
                                return a;
                               
                            }
                            (a >= c) ? a %= c : c %= a;
                        }
                    }
                    (a >= b) ? a %= b : b %= a;
                }
 }

int main()
{

    long long int k, result = 0;
    cin >> k;

    for (int i = 1; i < (k+1);i++)
    {
        for (int j = 1; j < (k+1); j++)
        {
            for (int l = 1; l < (k+1); l++)
            {
                result += gcd(k,i,j,l);
            }
        }
    }

        cout << result;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() { 	string s; std::cin >> s; if(s>"2019/04/30"){ std::cout << "TBD" << endl; } else{ std::cout << "Heisei"<< endl; } 	return 0; }


Measured memory_bytes: 256
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool samax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool samin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <functional>

int main() {
	usize n;
	::std::cin >> n;
	::std::multiset<u32,::std::greater<u32>> st;
	while (n--) {
		u32 a;
		::std::cin >> a;
		st.insert(a);
	}

	usize ans{ 0 };
	u32 ht{ ~static_cast<u32>(0) };
	for (auto itr = st.begin();itr != st.end();++itr) {
		const u32 v = *itr;
		while (ht > v * 2)ht >>= 1;
		const u32 p = ~v + 1 & ht;
		if (v == p) {
			const usize c = st.count(v);
			itr = ::std::prev(st.upper_bound(v));
			ans += c / 2;
		}
		else {
			auto pi = st.find(p);
			if (pi != st.end()) {
				st.erase(pi);
				++ans;
			}
		}
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


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


int main(void) {

	int n, m;
	scanf("%d %d", &n, &m);
	int L, R;
	int min=n, max=1;
	for (int i = 0; i < m; ++i) {
		scanf("%d %d", &L, &R);
		min = R < min ? R : min;
		max = L > max ? L : max;
	}
	printf("%d", min-max+1>0?min-max+1:0);


	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX 101
#define TRUE 1
#define FALSE 0

//init
int data[MAX];
int top=0;


int isEmpty()
{
  if(top==0) return TRUE;
  return FALSE;
}

int isFull()
{
  if(top==MAX-1) return TRUE;
  return FALSE;
}

int push(int x)
{
  if(isFull()==TRUE) return FALSE;
  top++;
  data[top-1] = x;
  return TRUE;
}

int pop()
{
  if(isEmpty()==TRUE) return FALSE;
  top--;
  return data[top];
}


int main()
{
  char input[3];
  int d1,d2, stat, num;
  while(1)
  {

    stat = scanf("%s", input);
    if(stat==EOF) break;

      if(input[0]=='+')
      {
	d1 = pop();
	d2 = pop();
	push(d1+d2);
      }
      else if(input[0]=='-')
      {
	d1 = pop();
	d2 = pop();
	push(d2-d1);
      }
      else if(input[0]=='*')
      {
	d1 = pop();
	d2 = pop();
	push(d2*d1);
      }
    else
    {
      push(atoi(input));
    }	
  }

    printf("%d",data[0]);
  printf("\n");
  
  
  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int dp[3][810];

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

	const int limit = 1 + 26 + 26 * 26;

	rep(i, 3) rep(j, limit) dp[i][j] = -1;
	dp[0][0] = 0;

	rep(i, n){
		const int prv = (i + 2) % 3;
		const int cur = i % 3;
		const int nxt = (i + 1) % 3;

		rep(j, limit) dp[nxt][j] = -1;

		rep(j, limit){
			const int one = (s[i] - 'a');
			const int nj = one + 1;
			if (j != nj and dp[cur][j] != -1) {
				chmax(dp[nxt][nj], dp[cur][j] + 1);
			}

			if (i - 1 >= 0) {
				const int two = 26 * (s[i - 1] - 'a') + one;
				const int nj2 = two + 27;
				if (j != nj2 and dp[prv][j] != -1) {
					chmax(dp[nxt][nj2], dp[prv][j] + 1);
				}
			}
		}
	}

	int ans = 0;
	rep(j, limit) chmax(ans, dp[n % 3][j]);
	cout << ans << endl;

	return 0;
}

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

	static int INF = 2 << 27;
	static int m;
	static int n;
	static int k;
	static int d;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n == 0) break;
			Data[] data = new Data[n];
			for(int i = 0; i < n; i++) {
				data[i] = new Data(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			for(int i = 0; i < n; i++) {
				for(int j = i + 1; j < n; j++) {
					boolean check = check(data,i,j);
					if(check) data[j].up |= (1 << i);
				}
			}
			boolean[] dp = new boolean[1 << n];
			dp[0] = true;
			for(int i = 0; i < dp.length; i++) {
				if(!dp[i]) continue;
				ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
				for(int j = 0; j < 5; j++) {
					list.add(new ArrayList<Integer>());
				}
				for(int j = 0; j < n; j++) {
					if((i & (1 << j)) != 0) continue;
					if((i & data[j].up) != data[j].up) continue;
					list.get(data[j].c).add(j);
				}
				IN:for(int j = 1; j < 5; j++) {
					if(list.get(j).size() < 2) continue;
					for(int k = 0; k < list.get(j).size()-1; k++) {
						for(int l = k + 1; l < list.get(j).size(); l++) {
							int next = i;
							next |= (1 << list.get(j).get(k));
							next |= (1 << list.get(j).get(l));
							dp[next] = true;
						}
					}
				}
			}
			int max = 0;
			for(int i = 0; i < dp.length; i++) {
				if(dp[i]) max = Math.max(max, Integer.bitCount(i));
			}
			System.out.println(max);
			
		}
	}
	static boolean check(Data[] data, int a, int b) {
		int dis = (int)(Math.pow(data[a].x - data[b].x, 2) + Math.pow(data[a].y - data[b].y, 2));
		return dis < Math.pow(data[a].r + data[b].r,2);
	}
	static class Data {
		int up = 0;
		int x;
		int y;
		int r;
		int c;
		Data(int a, int b, int c, int d) {
			this.x = a;
			this.y = b;
			this.r = c;
			this.c = d;
		}
	}
}

Measured memory_bytes: 241004
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int X; std::cin >> X;
  int m = X / 100;
  int n = X % 100;

  if ( 5*m >= n ) std::cout << 1 << std::endl;
  else std::cout << 0 << std::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);
		
		int ninzuu = sc.nextInt();
		int densha = sc.nextInt();
		int taxi = sc.nextInt();
		
		int ans = ninzuu * densha;
		if(ans >= taxi){
			ans = taxi;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <stdio.h>
#define INFTY 1000000001

int mergesort(int *,int,int);
int merge(int *,int,int,int);
int main (){
  int n,i,A[500000],cnt;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  cnt=mergesort(A,0,i);
  for(i=0;i<n;i++){
    if(i)
      printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);
  return 0;
}

int mergesort(int *A,int left,int right){
  int mid,cnt=0;
  if(left+1<right){
    mid=(left+right)/2;
    cnt+=mergesort(A,left,mid);
    cnt+=mergesort(A,mid,right);
    cnt+=merge(A,left,mid,right);
  }
  return cnt;
}
int merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k,cnt=0;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=0;i<n1;i++)
    L[i]=A[left+i];
  for(i=0;i<n2;i++)
    R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }
    else{
      A[k]=R[j];
      j++;
    }
  }
  return cnt;
}

    
  
  
   
  
    
  



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

const char* table[] = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", 
                       "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs",
                       "Asg", "Nyt", "Fks", "Mts"};//18種類
int main() {
    int m, n;

    while ( cin >> m >> n && m != 0 || n != 0 ) {

	vector<int> block(18);
	block[0] = m;
	for ( int i=1; i<n; ++i ) {
	    for ( int j=0; j<18; ++j ) block[j] *= m; //全ブロックにmを掛ける
	    for ( int j=0; j<18; ++j ) {//繰り上がり処理
		if ( block[j] >= 10000 ) {
		    int carry = block[j]/10000;//繰り上がり分
		    block[j+1] += carry;
		    block[j] -= carry*10000;
		}
	    }
	}

	//出力
	for ( int i=17; i>=0; --i ) 
	    if ( block[i] ) cout << block[i] << table[i];
	cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i;
	cin>>n;
	int x=n;
	int sum=0;
	while(x>0){
		sum+=x%10;
		x/=10;
	}
	if(n%sum==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
	

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

int main(){
    long A, B, C, K;
    cin >> A >> B >> C >> K;
    long ans = 0;
    if(A > K){
        ans += K;
        K = 0;
    }
    else{
        ans += A;
        K -= A;
    }
    if(B > K){
        K = 0;
    }
    else{
        K -= B;
    }
    if(C > K){
        ans -= K;
        K = 0;
    }
    else{
        ans -= C;
        K -= C;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

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

        final int A = sc.nextInt();
        final int B = sc.nextInt();

        int ans = 0;
        for (int i = A; i <= B; i++) {
            int q = i / 10000 % 10;
            int w = i / 1000 % 10;
            int r = i / 10 % 10;
            int t = i % 10;
            if (q == t && w == r) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s,t;
  cin >> s >> t;
  ll n = s.size(), m = t.size();
  vector<vector<int> > index(n, vector<int>('z'-'a'+1,-1)); //i文字目以降で始めてxが登場
  string words = s; //sの文字
  sort(all(words));
  words.erase(unique(all(words)),words.end());
  for (int i = n-1; i >= 0; --i) {
    for (auto x : words) {
      int ind = x-'a';
      if (s[i] == x) {
        index[i][ind] = i; //更新
      }
      else if (i < n-1) {
        index[i][ind] = index[i+1][ind];
      }
    }
  }
  rep(i,m) {
    int ind = t[i] - 'a';
    if (index[0][ind] == -1) { //存在しない
      cout << -1 << endl;
      return 0;
    }
  } 
  ll ans = 0;
  ll si = 0, ti = 0;
  while(ti < m) {
    int ind = t[ti] - 'a';
    if (si == n || index[si][ind] == -1) { //今より後ろに無い
      si = 0;
      ans += n;
    }
    else {
      si = index[si][ind] + 1;
      ti++;
    }
  }
  ans += si;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 13904
n, m = map(int, input().split())
tmp  = [0]*n
wtmp = [0]*n
for _ in range(m):
    P, s = map(str, input().split())
    p = int(P)
    p -= 1
    if not tmp[p] == 0:
        continue
    if s == 'AC':
        tmp[p] = 1
    else:
        wtmp[p] += 1
ans1 = sum(tmp)
ans2 = 0
for i in range(n):
    if tmp[i] == 1:
        ans2 += wtmp[i]
print(ans1, ans2)

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  const int p = 2019;

  vector<int> d(n+1);
  int ten = 1;
  for (int i = n-1; i >= 0; --i) {
    int a = (s[i]-'0') * ten % p;
    d[i] = (d[i+1]+a) % p;
    ten *= 10; ten %= p;
  }
  vector<int> cnt(p);
  ll ans = 0;
  for (int i = n; i >= 0; --i) {
    ans += cnt[d[i]];
    cnt[d[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4336
n, k = list(map(int, input().split()))
s = input()

s =str(1)+ s + 'E'   # 終端処理
ans = -1    # 答えの初期値

L=1
count=0
L2=[1]
for i in range(n):
    if i>=1:
        count-=1
    v=0
    for j in range(L,n+2):
        if s[j]==str(0):
            #連続してる所は飛ばす。
            if s[j-1]==str(0):
                continue
                
            else:
                count+=1
                
        #0のあと初めて1が出たらindexを取得
        if s[j]==str(1):
            if s[j-1]==str(0):
                L2.append(j)
                
            
        if count==k+1:
            
            ans=max(ans,j-L2[i])
            #次はｊ+１から始める
            L=j+1
            break
            
        if s[j]=='E':
            ans=max(ans,j-L2[i])
            print(ans)
            exit()

Measured memory_bytes: 43628
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int main()
{
	long long a, b;
	long long sol;

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

	a--;

	switch (b % 4)
	{
	case 0:
		sol = b;
		break;
	case 1:
		sol = 1;
		break;
	case 2:
		sol = b + 1;
		break;
	case 3:
		sol = 0;
		break;
	}

	if (a >= 0)
	{
		switch (a % 4)
		{
		case 0:
			sol ^= a;
			break;
		case 1:
			sol ^= 1;
			break;
		case 2:
			sol ^= a + 1;
			break;
		case 3:
			sol ^= 0;
			break;
		}
	}

	printf("%lld\n", sol);

	return 0;
}

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

int main()
{
  int n,x;
  cin>>x>>n;
  set<int> s;
  for(int i=1;i<=1000;i++){s.insert(i);s.insert(-1*i);}
  s.insert(0);
  for(int i=0;i<n;i++)
  {
  	int a;
  	cin>>a;
  	s.erase(a);
  }
  vector<pair<int,int>> v;
  for(auto it:s)
  {
    int d=abs(x-it);
    v.push_back({d,it});
  }
  sort(v.begin(),v.end());
  if(n==0)
  {
  	cout<<x;
  	return 0;
  }
  cout<<v[0].second;
}


Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

void solve()
{
    string s;
    cin >> s;
    s[3] = '8';
    cout << s;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

bool solve(int k)
{
    int a = sqrt(k);
    if (a*a == k) return true;
    return false;
}

int main()
{
    int n,d; cin >> n >> d;
    int arr[n][d];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < d; ++j)
            cin >> arr[i][j];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i+1; j < n; ++j)
        {
            int sum = 0;
            for (int k = 0; k < d; ++k)
                sum += ((arr[i][k]-arr[j][k])*(arr[i][k]-arr[j][k]));
            if (solve(sum)) ++ans;
        }
    }
    cout << ans;
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int n,m;
    cin>>n>>m;

    vector<double> arr;
    double total=0;
    for(int i=0;i<n;i++) {
        double num;
        cin>>num;
        total+=num;
        arr.push_back(num);
    }

    sort(arr.begin(), arr.end(), greater<int>());

    int count=0;
    double limit=(1/(4*double(m)));
    for(int i=0;i<m;i++) {
        double percentage=(arr[i]/double(total));
        if(percentage>=limit) {
            count++;
        }
    }

    if(count==m) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }

}




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



int main(){
    string N;
    int K;
    cin >> N;
    cin >> K;
    
    int keta = N.size();
    int dp[105][4][2];
    for (int i=0; i<105; i++) {
        for (int j=0; j<4; j++) {
            for (int k=0; k<2; k++) {
                dp[i][j][k] = 0;
            }
        }
    }
    dp[0][0][0] = 1;

    for (int i=0; i<keta; i++) {
        for (int j=0; j<K+1; j++) {
            for (int k=0; k<2; k++) {
                int nd = N[i] - '0';
                for (int d=0; d<10; d++) {
                    int ni = i+1;
                    int nj = j;
                    int nk = k;
                    if (d!=0) { nj++; }
                    if (nj>K) { continue; }
                    if (k==0) {
                        if (d<nd) { nk=1; }
                        else if (d>nd) { continue; }
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    
    int ans = dp[keta][K][0] + dp[keta][K][1];
    std::cout << ans << std::endl;
    
    
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    int[long] rev;
    foreach (i; 0..N) rev[A[i]] = i;

    auto rbt = new RedBlackTree!(int)();
    rbt.insert(-1);
    rbt.insert(N);

    long ans = 0;
    foreach (a; 1..N+1) {
        auto i = rev[a.to!long];
        auto left  = i - rbt.lowerBound(i).back;
        auto right = rbt.upperBound(i).front - i;
        ans += 1L * right * left * a;
        rbt.insert(i);
    }

    ans.writeln;

}


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

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

  long long a[100010];
  long long ans = 0;
  long long tmp = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }

  long long b;
  for(int i = 0;i < m;i++){
    cin >> b;
    tmp += b;
  }

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

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3884
program main
  implicit none
  integer, parameter :: binsize = 2000, nbin = 250
  integer :: n, i, t, l, r, numq, cnt(26, nbin)
  character(500000) :: s
  character(100) :: q
  character(1) :: c
  read *, n
  read *, s
  call prep
  read *, numq
  do i = 1, numq
    read *, t, l, q
    if (t == 1) then
      read (q, *) c
      call type1(l, c)
    else
      read (q, *) r
      call type2(l, r)
    end if
  end do
  contains

  subroutine prep()
    integer :: i, j, b
    cnt(:, :) = 0
    do i = 1, n
      j = iachar(s(i:i)) - iachar("a") + 1
      b = i_to_bin(i)
      cnt(j, b) = cnt(j, b) + 1
    end do
  end subroutine prep

  subroutine type1(i, c)
    integer, intent(in) :: i
    character(1), intent(in) :: c
    integer :: b, j
    b = i_to_bin(i)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) - 1
    s(i:i) = c(1:1)
    j = iachar(s(i:i)) - iachar("a") + 1
    cnt(j, b) = cnt(j, b) + 1
  end subroutine type1

  subroutine type2(l, r)
    integer, intent(in) :: l, r
    integer :: scnt(26), b, tot, a
    scnt(:) = 0
    do b = 1, nbin
      scnt(:) = scnt(:) + query(b, l, r)
    end do
    tot = 0
    do a = 1, 26
      if (scnt(a) > 0) tot = tot + 1
    end do
    print "(i0)", tot
  end subroutine type2

  pure integer function i_to_bin(i)
    integer, intent(in) :: i
    i_to_bin = (i - 1) / binsize + 1
  end function i_to_bin

  pure integer function b_to_i(b)
    integer, intent(in) :: b
    b_to_i = (b - 1) * binsize + 1
  end function b_to_i

  function query(b, l, r)
    integer :: query(26)
    integer, intent(in) :: b, l, r
    integer :: i, j, k, ic
    query(:) = 0
    i = b_to_i(b)
    j = i + binsize - 1
    if (r < i) return
    if (l > j) return
    if (l <= i .and. j <= r) then
      query(:) = cnt(:, b)
    else
      do k = max(i, l), min(j, r)
        ic = iachar(s(k:k)) - iachar("a") + 1
        query(ic) = query(ic) + 1
      end do
    end if
  end function query
end program main


Measured memory_bytes: 1980
def f(): return map(int,raw_input().split())
n,q=f()
a0,v0=0,0
A=[0]*(n+1)
for _ in range(q):
  a,v=f()
  A[a]+=v
  if a==a0 and v<0:
    v0=max(A)
    a0=A.index(v0)
  elif A[a]>v0: a0,v0=a,A[a]
  elif A[a]==v0 and a<a0: a0=a
  print a0,v0

Measured memory_bytes: 15088
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    private static final int INTERVAL = 10;

    private static class Dish {
        final int time;
        final int roundUp;
        final int timeWasted;

        private Dish(int time, int roundUp, int timeWasted) {
            this.time = time;
            this.roundUp = roundUp;
            this.timeWasted = timeWasted;
        }

        static Dish fromInt(int i) {
            int roundUp = ((i + INTERVAL - 1) / INTERVAL) * INTERVAL;
            int timeWasted = roundUp - i;
            return new Dish(i, roundUp, timeWasted);
        }

        int getTimeWasted() {
            return this.timeWasted;
        }

        int getRoundUp() {
            return this.roundUp;
        }
    }

    public static String process(int a, int b, int c, int d, int e) {
        List<Dish> dishes = Stream.of(a, b, c, d, e)
                .map(Dish::fromInt)
                .sorted(Comparator.comparing(Dish::getTimeWasted))
                .collect(Collectors.toList());

        int lastDish = dishes.size() - 1;
        int lastDishTime = dishes.get(lastDish).time;
        int totalTime = lastDishTime + IntStream.range(0, lastDish).mapToObj(dishes::get).mapToInt(Dish::getRoundUp).sum();

        return String.valueOf(totalTime);
    }
    // Util func

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();

        final String result = process(a, b, c, d, e);

        output(result);
    }

    private static void output(String result) {
        System.out.println(result);
    }
}


Measured memory_bytes: 28244
#include <stdio.h>
int main(){
	int a;
	int weight[10]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	while(~scanf("%d",&a)){
		bool t[10];
		for(int i=9;i>-1;i--) t[i]=false;
		for(int i=9;i>-1;i--){
			if(weight[i]<=a){
				a-=weight[i];
				t[i]=true;
			}
		}
		int i;
		for(i=0;i<10;i++){
			if(t[i]){
				printf("%d",weight[i]);
				break;
			}
		}
		for(i++;i<10;i++){
			if(t[i]) printf(" %d",weight[i]);
		}
		printf("\n");
	}
	return 0;
}

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


typedef long long ll;
typedef pair<int, int> P;

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}

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


Measured memory_bytes: 5156
#include <iostream>

#define CASE double

using namespace std;

int GCD(CASE x, CASE y)
{
	if (x == 0 || y == 0)
		return x + y;
	else
	{
		if (x >= y)
		{
			x = x - y;
			GCD(x, y);
		}
		else
		{
			y = y - x;
			GCD(x, y);
		}
	}
}

int main(){
	CASE a, b;
	unsigned long int d, l;
	while (cin >> a >> b){

		d = (unsigned long int)GCD(a, b);
		l = a * b / d;
		cout << d << " " << l << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<int> VI;
typedef pair<int, int> PII;
# define mp make_pair
# define pb push_back
# define FOR(i, a, b) for (int i = a; i <= b; ++i)
# define FDR(i, a, b) for (int i = a; i >= b; --i)
const int N = 100005;
const int MOD = 1000000007;
// code begin...

int dp[105];

int main ()
{
    int n;
    cin >> n;
    dp[0] = 1;
    FOR(i, 1, n) {
        if (i >= 4) dp[i] |= dp[i - 4];
        if (i >= 7) dp[i] |= dp[i - 7];
    }
    puts(dp[n] ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    long x=sc.nextLong();
    n=n-x;
    long ans=n+x;
    while(x!=0){
      long t=n%x;
      ans=ans+n/x*x*2;
      n=x;
      x=t;
    }
    System.out.println(ans-n);
  }
}

Measured memory_bytes: 35856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n]; int[] B = new int[n];
		for(int i = 0 ; i < n ; i++) {
			A[i] = sc.nextInt();
			B[i] = 0;
		}
		int ans = 1;
		for(int i = 0 ; i < n ; i++) {
			ans *= 3;
		}
		int cnt = 1;
		for(int i = 0 ; i < n ; i++) {
			if(A[i] % 2 == 0) {
				B[i] = 2;
			} else {
				B[i] = 1;
			}
		}
		for(int i = 0 ; i < n ; i++) {
			cnt *= B[i];
		}
		System.out.println(ans - cnt);
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define LL long long int
using namespace std;
int const MAXN = 4e5+5;
int pref[MAXN][62];
int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    LL a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    LL ans = 0;
    LL mod = 1e9+7;
    for (int i = n - 1; i >= 0; i--){
        for (LL j = 0; j <= 60 ;j ++){
            LL bit = ((1LL<<j) & a[i])>>j;
            pref[i][j] = pref[i+1][j] + bit;
            LL x = n - 1 - i;
            if (bit){
              ans =    (((1LL << j)%mod) * (x - pref[i+1][j])%mod)%mod + ans % mod;
              ans %= mod;
            }else {
                ans =    (((1LL << j)%mod) * (pref[i+1][j])%mod)%mod + ans % mod;
              ans %= mod;
            }

        }
    }
    cout << ans;

}


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

bool tf[30];

int main() {
	string s;
	cin >> s;
	if (s.size() == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << "\n";
			return 0;
		}
		else {
			int cur = -1;
			int i;
			for (i = 25; i >= 0; i--) {
				if (s[i]-'a' > cur) {
					cur = s[i]-'a';
					tf[cur] = true;
				}
				else break;
			}
			for (int j = 0; j < 26; j++) if (tf[j] && j > s[i]-'a') {
				for (int k = 0; k < i; k++) cout << s[k];
				cout << (char)('a'+j) << "\n";
				return 0;
			}
		}
	} else {
		for (int i = 0; i < s.size(); i++) tf[s[i]-'a'] = true;
		for (int i = 0; i < 26; i++) if (!tf[i]) {
			cout << s;
			cout << (char)('a'+i) << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
def csort(A,B,k):
    C=[0]*(k+1)
    for i in range(len(A)):
        C[A[i]]+=1
    for i in range(1,len(C)):
        C[i]+=C[i-1]
    for i in range(len(A))[::-1]:
        B[C[A[i]]-1]=A[i]
        C[A[i]]-=1
        
# input
n=int(input())
data=list(map(int, input().split()))
result=[0]*len(data)
csort(data,result,10000)
print(*result)


Measured memory_bytes: 224504