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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

string su = "Sunny";
string cl = "Cloudy";
string ra = "Rainy";
void solve(std::string S) {
    if (S == su) print(cl);
    if (S == cl) print(ra);
    if (S == ra) print(su);
}
signed main() {
    std::string S;
    std::cin >> S;
    solve(S);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long n, a, b ;
int main(void){
     
    cin >> n >> a >> b ;
    
    if(a > b || (n == 1 && a != b)){
         cout << 0 << endl ;
    }
    else{
         cout << a + b * (n-1) - a * (n-1) - b + 1 << endl ;
    }
}


Measured memory_bytes: 256
let rec solution a i c ans =
    if i == Array.length a-1 then max c ans
    else if a.(i) >= a.(i+1) then solution a (i+1) (c+1) ans
    else solution a (i+1) 0 @@ max c ans;;

Printf.printf "%d\n" @@
Scanf.scanf "%d\n" @@ fun n ->
    let a = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun n -> n in
    solution a 0 0 0;;


Measured memory_bytes: 6676
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  int min = a+b;
  if (min >= b+c) min = b+c;
  if (min >= a+c) min = a+c;
  
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 3003, M = N << 1;

int n;
double dp[N][N], p[N];

int main()
{
	//File("");
	n = gi <int> ();
	for (int i = 1; i <= n; i+=1) scanf("%lf", &p[i]);
	dp[1][0] = 1 - p[1], dp[1][1] = p[1];
	for (int i = 2; i <= n; i+=1)
		for (int j = 0; j <= i; j+=1)
			dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
	double ans = 0;
	for (int i = n; i >= (n + 1) / 2; i-=1) ans += dp[n][i];
	printf("%.10lf\n", ans);
	return 0;
}


Measured memory_bytes: 50008
#include <iostream>
#include <vector>
#include "unordered_map"
#include "map"
#include <cmath>
#include <climits>
#include "queue"
#include "tuple"
#include <algorithm>
#include <iomanip>
#include "sstream"
#include <math.h>

using ll=long long;
using ull=unsigned long long;
using ld=long double;
using namespace std;

//const double PI = M_PI;

template <typename T>
inline void printQueue(queue<T>&oq){queue<T>q(oq);int qCount=q.size();for(int i=0;i<qCount;++i){T qe=q.front();q.pop();
    cout<<qe;if(i!=qCount-1){cout << ", ";}q.push(qe);}cout << endl;}

template<typename T>
inline void PV(vector<T> v){int vc=v.size();for(int i=0;i<vc;++i){cout << v[i];if(i!=vc-1){cout<<", ";}}cout << endl;}

inline double round( double val )
{
  if( val < 0 ) return ceil(val - 0.5);
  return floor(val + 0.5);
}

int main() {
//  freopen("../input.txt","r",stdin);
//    freopen("../output.txt","w",stdout);
//    for(int i = 1; i <= n; ++i) {
  ull an;
  cin >> an;
  ull bn;
  cin >> bn;
  ull cn;
  cin >> cn;
  int x;
  cin >> x;
  int y;
  cin >> y;
  int c = 0;
  if(x > 0 && y > 0) {
    if(cn * 2 < (an + bn)) {
      if(x > y) {
        x -= y;
        c += y * 2 * cn;
        y = 0;
      }
      else {
        y -= x;
        c += x * 2 * cn;
        x = 0;
      }
    }
    else {
      if(x > y) {
        x -= y;
        c += y * an;
        c += y * bn;
        y = 0;
      }
      else {
        y -= x;
        c += x * an;
        c += x * bn;
        x = 0;
      }
    }
  }
  if(x > 0) {
    if(2 * cn < an) {
      c += 2 * cn * x;
    }
    else {
      c += an * x;
    }
  }
  if(y > 0) {
    if(2 * cn < bn) {
      c += 2 * cn * y;
    }
    else {
      c += bn * y;
    }
  }
  cout << c;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
using ll = long long;
//#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int x,y,z; cin>>x>>y>>z;
    for(int i=0; ;i++){
        if(i*y+(i+1)*z>x){
            cout<<i-1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>



int main(void) {

	// 1_7-B How many ways?
	
	int n,x;
	int i,j,k;
	int result;

	scanf("%d",&n);
	scanf("%d",&x);

	while( (n!=0) || (x!=0) ){
		result = 0;
		for(i=1; i<=n-2; i++){
			for(j=i+1; j<=n-1; j++){
				k = x-(i+j);
				if( (j<k) && (k<=n) ){	
					result++;
				}
			}
		}
		printf("%d\n",result);
		
		scanf("%d",&n);
		scanf("%d",&x);
	}

	return 0;

}

Measured memory_bytes: 600
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    rep(i, n) {
        int tmpx = x[i];
        int tmpy = y[i];
        x[i] = tmpx - tmpy;
        y[i] = tmpx + tmpy;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    cout << max(abs(x[0] - x.back()), abs(y[0] - y.back())) << '\n';

}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = (1 << 18) + 100;

int n, q, v[N], w[N], maxL, qv[N], ql[N], f[12][N], sumV[N], sumW[N], ans[N];
vector<int> que[N];

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

void dfs(int now, int dep) {
	if (now >= 512) return;
	for (R int i = 0; i <= maxL; ++i)
		f[dep][i] = max(f[dep - 1][i], i >= w[now] ? f[dep - 1][i - w[now]] + v[now] : 0);
	for (auto &i : que[now]) {
		vector<int> a;
		for (R int j = qv[i]; j != now; j >>= 1)
			a.push_back(j);
		ans[i] = f[dep][ql[i]];
		for (R int j = 1, sz = a.size(); j < 1 << sz; ++j) {
			int k = 0;
			while (~j & (1 << k)) ++k;
			sumV[j] = sumV[j ^ (1 << k)] + v[a[k]];
			sumW[j] = sumW[j ^ (1 << k)] + w[a[k]];
			if (sumW[j] <= ql[i]) ans[i] = max(ans[i], sumV[j] + f[dep][ql[i] - sumW[j]]);
		}
	}
	dfs(now << 1, dep + 1), dfs(now << 1 | 1, dep + 1);
	return;
}

int main() {
	read(n);
	for (R int i = 1; i <= n; ++i) read(v[i]), read(w[i]);
	read(q);
	for (R int i = 1; i <= q; ++i) {
		read(qv[i]), read(ql[i]);
		maxL = max(maxL, ql[i]);
		int cur = qv[i];
		while (cur >= 512) cur >>= 1;
		que[cur].push_back(i);
	}
	dfs(1, 1);
	for (R int i = 1; i <= q; ++i)
		cout << ans[i] << '\n';
	return 0;
}

Measured memory_bytes: 17084
#include <stdio.h>

int main()
{
    char ch;
    
    while(scanf("%c", &ch) != EOF){
        if (ch == '\n') break;
        else if ('a' <= ch && ch <= 'z') printf("%c", toupper(ch));
        else if ('A' <= ch && ch <= 'Z') printf("%c", tolower(ch));
        else printf("%c", ch);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
import java.util.*

fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
	val s = readLine()!!.trim().split(' ').map{ x -> x.toLong() }

	var dp = Array<LongArray>(n) { LongArray(n) { 0L } }

	for (i in 0..n - 1) {
		dp[i][i] = s[i]
	}

	for (i in (n - 2) downTo 0) {
		for (j in (i + 1) .. (n - 1)) {
			var a = s[i] - dp[i + 1][j]
			var b = s[j] - dp[i][j - 1]
			if (a > b) {
				dp[i][j] = a
			} else {
				dp[i][j] = b
			}
		}
	}

	println(dp[0][n - 1])
}

Measured memory_bytes: 128028
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	v<v<ll>> dp(n+1,v<ll>(k+1));
	for(int i=0;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(j==0){
				dp[i][j]=1;
			}
			else if(i==0){
				dp[i][j]=dp[i][j-1];
			}
			else{
				int h=j-a[i-1];
				if(h<=0)
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modF;
				else
					dp[i][j]=(dp[i-1][j]-dp[i-1][h-1]+dp[i][j-1]+modF)%modF;
			}
		}
	}
	if(k==0){
		cout<<1<<"\n";
		return;
	}
	cout<<(dp[n][k]-dp[n][k-1]+modF)%modF<<"\n";
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 83164
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int X, Y; cin >> X >> Y;
int ans = 0;
if (X == 3) ans += 100000;
else if (X == 2) ans += 200000;
else if (X == 1) ans += 300000;
if (Y == 3) ans += 100000;
else if (Y == 2) ans += 200000;
else if (Y == 1) ans += 300000;

if (X == 1 && Y == 1) ans += 400000; 

cout << ans << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <iostream>
#include <map>


using namespace std;


const long long MOD = 1000000000 + 7;

long long pow(long long x, long long n) {
    if (n == 0) return 1;
    if (n == 1) return x % MOD;
    if (n % 2 == 0) {
        long long a = pow(x, n / 2);
        return (a * a) % MOD;
    }
    return x * pow(x, n - 1) % MOD;
}
long long inv(long long x) {
    return pow(x, MOD - 2);
}


int main() {
    int x, y;
    cin >> x >> y;
    int a,b;
    a = 2*x - y;
    b= 2*y - x;
    if (a < 0 || b < 0) {
        cout << 0;
        return 0;
    }
    if ((a % 3) != 0 || (b % 3)!= 0 ) {
        cout << 0;
        return 0;
    }
    a /= 3;//(1,2)
    b /= 3;//(2,1)
    long long up = 1, down1 = 1, down2 = 1;
    for (int i = 1; i <= a + b; i++) {
        up *= i;
        up %= MOD;
    }
    for (int i = 1; i <= b; i++) {
        down1 *= i;
        down1 %= MOD;
    }
    for (int i = 1; i <= a; i++) {
        down2 *= i;
        down2 %= MOD;
    }
    cout << (((up * inv(down1)) % MOD) * inv(down2)) % MOD;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
 
sum_a = sum(a)
len_a = len(a)
kaisu = sum_a // ( (1/2)*(len_a)*(len_a+1) )
 
if sum_a % ( (1/2)*(len_a)*(len_a+1) ) !=0:
  print("NO")
  exit()

ans_kaisu = 0
a.append(a[0])

for i in range(n):
  tmp = (kaisu - (a[i+1]-a[i])) // len_a
  if (kaisu - (a[i+1]-a[i])) % len_a !=0 or tmp < 0:
    print("NO")
    exit()
  ans_kaisu += tmp
  
if ans_kaisu ==kaisu:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 14436
S = list(input())
N = len(S)
ans = 0

for i in range(2 ** (N - 1)):#n=1234なら，iは000, 001, 010, 011, 100, 101, 110, 111
    s = S[:]
    for j in range(N):
        if i & 2**j:#AND論理積,jは000, 001, 010, 100
            s[j] = s[j] + '+'
    #print(''.join(s))
    ans += eval(''.join(s))
print(ans)

Measured memory_bytes: 3060
from itertools import product
H,W,K = map(int,input().split())
C = [input().strip() for _ in range(H)]
ans = 0
for row in product((0,1),repeat=H):
    for col in product((0,1),repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if row[i]==0 and col[j]==0 and C[i][j]=="#":
                    cnt += 1
        if cnt==K:
            ans += 1
print(ans)

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

int main(){

 int N, num=0;
 cin >> N;
 string S;
 cin >> S;

 for(int i=0; i<N; i++){
   if(S[i]=='R'){
      num++;
    }
 }

 if((num*2-N)>0){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll m,n;
    cin>>m>>n;
    if(m <=8 && n <= 8) pr("Yay!");
    else pr(":(");
}



Measured memory_bytes: 888
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
map<ll,ll> pfac(ll x){
  map<ll,ll> mp;
  for(ll i=2;i*i<=x;i++){
    ll cnt=0;
    while(x%i==0){
      x/=i;
      cnt++;
    }
    if(cnt!=0) mp[i] = cnt;
  }
  if(x!=1) mp[x]++;
  return mp;
}
signed main(){
  init_io();
  ll n,p,ans=1;
  cin >> n >> p;
  map<ll,ll> mp = pfac(p);
  for(auto p:mp){
    for(ll i=0;i<p.second/n;i++){
      ans *= p.first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
l=[]
while gets
  n,m=$_.split.map(&:to_i)
  if n==0 and m==0
    tf=true
    # p l.sort
    (1..(l.max)).each do |x|
    	# p "x:#{x}, cnt:#{l.count(x)}"
      if x.between?(1,2) then tf=l.count(x).odd?
      else tf=l.count(x).even? end
      break unless tf
    end
    puts tf ? "OK" : "NG"
    l=[]
  else
    l<<n<<m
  end
end

Measured memory_bytes: 8764
N = int(input())
MOD = 10**9 + 7
A_s = list(map(int, input().split()))
ruiseki = [] 
for i, A in enumerate(A_s):
    if i == 0:
        ruiseki.append(A)
        continue
    ruiseki.append(ruiseki[i-1]+A)
answer = 0
for i, r in enumerate(ruiseki):
    answer += (A_s[i] * (ruiseki[N-1]-ruiseki[i]))
    answer %= MOD
print(answer)

Measured memory_bytes: 109516
import java.util.*;

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

        String S = sc.next();
        String T = sc.next();
        int N = S.length();
        
        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) != T.charAt(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 41168
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::iter::{self, Product, Sum};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref,
    DerefMut, Div, DivAssign, Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        a: u32,
        b: u32,
    }
    let s = 2 * a - 1;
    let t = 2 * b - 1;
    let r = a + b;
    println!("{}", [s, t, r].iter().cloned().max().unwrap());
}


Measured memory_bytes: 4352
/*-----------------------------------------atcoder------------------------------------------*/
/*------------------------------------------turtle----------------------------------------*/
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int

int main() {
	int k,n;
	cin>>k>>n;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	int ans=0;
	for(int i=1;i<n;i++){
		ans=max(ans,abs(arr[i-1]-arr[i]));
	}
	ans=max(ans,abs(arr[n-1]-k)+abs(arr[0]-0));
	
	cout<<k-ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int m,i;
    long long a[10000];
    a[0]=2;a[1]=1;
    scanf("%d",&m);
    for(i=2;i<=m;i++)
        a[i]=a[i-1]+a[i-2];
    printf("%lld",a[m]);
    return 0;
    }


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

int main(){

    int n;
    cin >> n;
    vector<int> w(n);
    int t, i, j;
    for (int i=0; i<n; i++){
        cin >> w.at(i);
    }

    int sum1, sum2, diff, min_num = 1e5;
    for (int t=0; t<n; t++){
        sum1 = 0;
        sum2 = 0;
        diff = 0;

        for (int i=0; i<t; i++){
            sum1 += w.at(i);
        }
        for (int j=t; j<n; j++){
            sum2 += w.at(j);
        }
        diff = abs(sum1-sum2);
        min_num = min(min_num, diff);
    }

    cout << min_num << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Node{
	int key;
	Node *right,*left,*parent;
};
Node *root,*NIL;
void insert(int k){
	Node *x=root;
	Node *y =NULL;
	Node *z=(Node *)malloc(sizeof(Node));
	z->key=k;z->left=NULL;z->right=NULL;
	while(x!=NULL){
		y=x;
		if(x->key>z->key){
			x=x->left;
		}
		else x=x->right;
	}
	z->parent=y;
	if(y==NULL)root=z;
	else {
		if(y->key>z->key){
			y->left=z;
		}
		else y->right=z;
	} 
	
}
void inorder(Node *u){
	if(u==NIL)return ;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
} 

void preorder(Node *u){
	if(u==NIL)return ;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
int main(){
	int n,i,x;
	string com;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		cin>>com;
		if(com=="insert"){
			scanf("%d",&x);
			insert(x); 
		}else if(com=="print"){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
			} 
} 


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

typedef long long int ll;



ll dp[5001];
int n,m;

void update(int x){
	for(int r=0;r<x;r++)
		for(int i=r;i+x<=n;i+=x)
			dp[i+x]=(dp[i+x]+dp[i])%m;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	int k=n/2;
	dp[0]=1;
	if(n&1){
		for(int i=1;i<=k;i++)
			update(i);
		for(int i=2;i<=k+1;i++)
			update(i);
	}
	else{
		for(int i=1;i<=k;i++)
			update(i);
		for(int i=2;i<=k;i++)
			update(i);
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+(n-i)*dp[i])%m;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	const double PI = 3.14159265358979323846;
	double r;
	cin >> r;
	cout << 2 * r*PI << endl;
	return 0;
}

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

using namespace std;

int const INF = 1e9;
int const NMAX = 1e5;
int n;
//a = 1, b = 2, c = 3;
int a[1 + NMAX], b[1 + NMAX], c[1 + NMAX];
int dp[1 + NMAX][1 + 3];

int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  for(int i = 1; i <= n; i++) {
    dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + a[i];
    dp[i][2] = max(dp[i-1][3], dp[i-1][1]) + b[i];
    dp[i][3] = max(dp[i-1][1], dp[i-1][2]) + c[i];
  }
  cout << max(max(dp[n][1], dp[n][2]), dp[n][3]);
}


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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *NIL, *root;


void insert(int key){

    Node *x, *y, *z;

    z = new Node;
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    y = NIL;
    x = root;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == NIL) root = z;
    else if(z->key < y->key)y->left = z;
    else y->right = z;
}

Node* find(int key){
    Node *x, *y;
    int target = key;
    x = root;
    while(x != NIL && x->key !=  target){
        if(target > (x->key)){
            x = x->right;
        }
        else if(target < (x->key)){
            x = x->left;
        }
    }
    //if(judge) cout << "yes" << endl;
    //else cout << "no" << endl;
    return x;
}


Node* next_node(Node *node){
    Node *x;

    if(node->right != NIL){
        x = node->right;
        while(x->left != NIL){
            x = x->left;
        }
    }
    else{
    x = node;
    while(x->parent != NIL && x == x->parent->right){
        x = x->parent;
    }
    x = x->parent;
    }
    return x;
}

void delete_node(int key){
    Node *x,*y,*z;

    z = find(key);

    if(z->left == NIL || z->right == NIL){
        y = z;
    } else{
        y = next_node(z);
    }
    if(y->left != NIL) x = y->left;
    else x = y->right;

    if(x != NIL) x->parent = y->parent;
    if(y->parent == NIL) root = x;
    else if(y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;

    if(z != y) z->key = y->key;

    delete y;
}

void preorder(Node *node){
    if(node == NIL) return ;
    cout << " " << node->key;
    if(node->left != NIL) preorder(node->left);
    if(node->right != NIL) preorder(node->right);
}

void inorder(Node *node){
    if(node == NIL) return;
    if(node->left != NIL) inorder(node->left);
    cout << " " << node->key;
    if(node->right != NIL) inorder(node->right);
}


void print(){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

int main(){
    int i, m, key;

    string command;

    cin >> m;
    for(i = 0; i < m ; i++){
        cin >> command;
        if(command[0] == 'i'){
            cin >> key;
            insert(key);
        } else if(command[0] == 'p'){
            print();
        }
        else if(command[0] == 'd'){
            cin >> key;
            delete_node(key);
        }
        else{
            cin >> key;
            //find(key);
            if (find(key) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21872
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,y) for(int i=(x);i<=(y);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int w,h;
    cin>>w>>h;
    string s[w];
    rep(i,w){
        cin>>s[i];
    }
    rep(i,w){
        s[i]='#'+s[i]+'#';
    }
    rep(i,h+2)cout<<'#';
    cout<<endl;
    rep(i,w){
        cout<<s[i]<<endl;
    }
    rep(i,h+2)cout<<'#';
    return 0;
}


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

using static Input;
using static Util;
class Program
{
    static long N;

    static void INPUT()
    {
        N = NextLong();
    }

    static long dfs(long n)
    {
        if (n == 1) return 1;
        return dfs(n / 2) * 2 + 1;
    }
    static void OUT()
    {
        Console.WriteLine(dfs(N));
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 13268
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int a[200010] = {};
	REP(i, 0, n){
		int x;
		scanf("%d", &x);
		a[x]++;
	}
	std::sort(a, a+200010);
	int ans = 0;
	REP(i, 0, 200010) ans += a[i];
	for(int i=200009; i>=0; i--){
		if(a[i]){
			ans -= a[i];
			k--;
			if(k==0) break;
		}
	}
	printf("%d\n", ans);
	return 0;
}



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

int main(){
    char str[21];
    int num;
    int i;
    int ch[5]={0};

    gets(str);
    num = strlen(str);
    if(num>5) ch[0]=1;
    
    for(i=0;i<num;i++){
        if(str[i]>47 && str[i]<58){
            ch[1]=1;
        }
        else if(str[i]>64 && str[i]<91){
            ch[2]=1;
        }
        else if(str[i]>96 && str[i]<123){
            ch[3]=1;
        }
        else{
            ch[4]=-1;
        }
    }
    if(ch[0]==1 && ch[1]==1 && ch[2]==1 && ch[3]==1 && ch[4]!=-1){
        printf("VALID\n");
    }
    else{
        printf("INVALID\n"); 
    }

    return 0;
}

Measured memory_bytes: 524
from pprint import pprint
import sys

n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()

count = 0
for i in range(1000):
    pin = str(i).zfill(3)
    start = 0
    flags = [False] * 3
    for i, pin_i in enumerate(pin):
        flag = False
        for j, s_j in enumerate(s):
            if j < start:
                continue
            if s_j == pin_i:
                flag = True
                start = j + 1
                break
        flags[i] = flag
    if flags[0] and flags[1] and flags[2]:
        # print(pin)
        count += 1

print(count)

Measured memory_bytes: 44320
import numpy as np

H, W = map(int, input().split())
grid = (np.array([list(input())
                  for _ in range(H)]) == "#")
cost = np.full((H, W), 10 ** 9, dtype=np.int64)
cost[grid[:, :]] = 0

for i in range(1, H):
    cost[i] = np.minimum(cost[i], cost[i - 1] + 1)

for i in range(H - 2, -1, -1):
    cost[i] = np.minimum(cost[i], cost[i + 1] + 1)

for i in range(1, W):
    cost[:, i] = np.minimum(cost[:, i], cost[:, i - 1] + 1)

for i in range(W - 2, -1, -1):
    cost[:, i] = np.minimum(cost[:, i], cost[:, i + 1] + 1)

print(np.max(cost))


Measured memory_bytes: 27220
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int N = S.size();

    vector<int> check(26);
    vector<string> can;
    for (int i = 0; i < N; i++) {
        check[S[i] - 'a'] = 1;
        string tmp = S.substr(0, i);
        int m = -1;
        for (int j = S[i] - 'a'; j < 26; j++) {
            if (check[j] == 0) {
                tmp.push_back((char)('a' + j));
                m = 1;
                break;
            }
        }
        if (m != -1) can.push_back(tmp);
    }

    if (N == 26) {
        if (can.size() > 0) {
            sort(can.begin(), can.end());
            cout << can[0] << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    for (int i = 0; i < 26; i++) {
        if (check[i] == 0) {
            cout << S << char(i + 'a') << endl;
            return 0;
        }
    }
}


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

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

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

    ll s = 0;
    for(int i = 0; i < n; i++){
        s ^= a[i];
    }

    for(int i = 0; i < n; i++){
        ll ans = s ^ a[i];
        if(i != n - 1){
            cout << ans << " ";
        }else{
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 5168
h, w = map(int, input().split())

board = []
for i in range(h):
    board.append(input())

hm = []
for i in range(h):
    if board[i] == '.' * w:
        hm.append(i)

wm = []
for i in range(w):
    for j in range(h):
        if board[j][i] != '.':
            break
        if j == h-1:
            wm.append(i)


for i in range(h):
    for j in range(w):
        if i not in hm and j not in wm:
            print(board[i][j], end='')
    if i not in hm:
        print()



Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rev(i,n,a) for(ll i=n-1;i>=a;i--)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define secreterror() ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve(){

    string str;
    cin>>str;

    rep(i,0,3){
        cout<<str[i];
    }
    cout<<endl;

    
}


int main()
{
    secreterror()
    // ll t;
    // cin>>t;
    //while(t--){
        solve();
        
    //}

}

Measured memory_bytes: 3616
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    double ans = (n - d) / (n * (double)n) * (m - 1);
    if(d != 0)
        ans *= 2.0;
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 256
# B
N = int(input())
A_list = list(map(int, input().split()))
LARGE = 10**9+7

def pinv(p, k):
    return pow(k, p-2, p)

Npow = 1
for i in range(2, N+1):
    Npow = Npow*i % LARGE

K = 0
for i in range(N):
    K += pinv(LARGE, i+1)

res = (K*A_list[0]) % LARGE

for i in range(1, N):
    K -= pinv(LARGE, N+1-i)
    K += pinv(LARGE, i+1)
    res = (res + K*A_list[i]) % LARGE
    
print(res*Npow % LARGE)

Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll n, ans = 0;
    ll a;
    string s;
    
    cin >> a >> s;

    (a >= 3200) ? (cout << s << endl) : (cout << "red" << endl);

    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[105][5][2];

int main() {
  string N;
  cin>>N;
  int K;
  cin>>K;
  DP[0][1][1] = N[0]-'1';
  DP[0][1][0] = 1;
  for(int i=1;i<N.size();++i) {
    for(int j=0;j<=K;++j) {
      if(N[i]=='0') {
        DP[i][j][0] = DP[i-1][j][0];
        if(j>0) DP[i][j][1] = DP[i-1][j-1][1]*9 + DP[i-1][j][1];
        else DP[i][j][1] = DP[i-1][j][1];
      }
      else {
        if(j>0) DP[i][j][0] = DP[i-1][j-1][0];
        if(j>0) DP[i][j][1] = DP[i-1][j][0] + DP[i-1][j][1] + DP[i-1][j-1][0]*(N[i]-'1') + DP[i-1][j-1][1]*9;
      }
    }
    DP[i][1][1] += 9;
  }
  cout<<DP[N.size()-1][K][0]+DP[N.size()-1][K][1]<<endl;
}



Measured memory_bytes: 3640
#include <cassert>
#include <cstdio>
#include <cstring>

const int N = 40;
const int M = 5 + 7 + 5;
const int MOD = (int)1e9 + 7;

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int ten[N + 1], dp[2][1 << M];

int main()
{
#ifdef LOCAL_JUDGE
    freopen("C.in", "r", stdin);
#endif
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    ten[0] = 1;
    for (int i = 1; i <= n; ++ i) {
        ten[i] = 10LL * ten[i - 1] % MOD;
    }
    int m = x + y + z;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int result = 0;
    for (int i = 0; i < n; ++ i) {
        memset(dp[i + 1 & 1], 0, sizeof(dp[i + 1 & 1]));
        for (int msk = 0; msk < 1 << m; ++ msk) {
            if (dp[i & 1][msk]) {
                for (int d = 1; d <= 10; ++ d) {
                    int new_msk = msk >> d;
                    if (d <= m) {
                        new_msk |= 1 << m - d;
                    }
                    assert(new_msk < 1 << m);
                    if ((new_msk >> x + y & 1) && (new_msk >> x & 1) && (new_msk & 1)) {
                        update(result, 1LL * dp[i & 1][msk] * ten[n - 1 - i] % MOD);
                    } else {
                        update(dp[i + 1 & 1][new_msk], dp[i & 1][msk]);
                    }
                }
            }
        }
    }
    printf("%d\n", result);
}


Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        
        int count = h[0];
        for (int i = 1; i < n; i++) {
            count += Math.max(h[i] - h[i-1], 0);
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    rep(i,1,1000){
        if(N==i*(i-1)/2){
            vector<int> ans[i+1];
            int a=1,b=2;
            rep(j,1,N+1){
                ans[a].pb(j);
                ans[b].pb(j);
                if(a<i-1&&b==i){
                    a++;
                    b=a+1;
                }
                else b++;
            }
            cout <<"Yes"<<"\n";
            cout <<i<<"\n";
            rep(j,1,i+1){
                cout <<sz(ans[j])<<" ";
                rep(k,0,sz(ans[j])){
                    if(k==sz(ans[j])-1) cout<<ans[j][k]<<"\n";
                    else cout<<ans[j][k]<<" ";
                }
            }
            return 0;
        }
    }
    cout <<"No"<<"\n";
}

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

const int MaxN = 300;
const int MaxM = 300;

int n, m;
char s[MaxN + 2];

int f[MaxN + 1][MaxN + 1][MaxM + 1];

int main()
{
	cin >> s + 1 >> m;

	n = strlen(s + 1);
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= m; ++j)
			f[i][i][j] = 1;
	for (int i = 1; i < n; ++i)
	{
		f[i][i + 1][0] = 1 + (s[i] == s[i + 1]);
		for (int j = 1; j <= m; ++j)
			f[i][i + 1][j] = 2;
	}

	for (int k = 3; k <= n; ++k)
		for (int l = 1; l <= n - k + 1; ++l)
		{
			int r = l + k - 1;
			for (int i = 0; i <= m; ++i)
			{
				int j = i - (s[l] != s[r]);
				int w = j >= 0 ? f[l + 1][r - 1][j] + 2 : -1;
				f[l][r][i] = max(f[l + 1][r][i], f[l][r - 1][i]);
				f[l][r][i] = max(f[l][r][i], w);
			}
		}

	cout << f[1][n][m] << endl;

	return 0;
}

Measured memory_bytes: 106368
(x, y, z) = gets.split(" ")

person_count = 0
total_space = 0
total_space += z.to_i

while true do
    total_space += y.to_i
    total_space += z.to_i
    
    if total_space > x.to_i
        print person_count
        break
    end
    
    person_count += 1
end

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

long long fuct(int n){
	long long m;
	if(n==0) return 1;
	m = fuct(n-1);
	return m * n;
}

int main(){
	long long ans;
	int n;
	cin >> n;
	ans = fuct(n);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main()
{
    queue<string> qname;
    queue<int> qtime;
    string s;
    int n,q,t,sum=0;
    cin>>n>>q;
    for (int i=0; i<n; i++)
    {
        cin>>s>>t;
        qname.push(s);
        qtime.push(t);
    }
    while (!qtime.empty())
    {
        t=qtime.front();
        qtime.pop();
        if (t>q)
        {
            qtime.push(t-q);
            sum+=q;
            qname.push(qname.front());
        }
        else
        {
            sum+=t;
            cout<<qname.front()<<" "<<sum<<'\n';
        }
        qname.pop();
    }
    return 0;
}



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

const int MAXN = 200005;

int n, m, a[MAXN], cnt[MAXN], b[MAXN], ans = 0;
int x, y;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) { 
		cin >> a[i];
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < cnt[i] && i-j >= 1; j++)
			b[i-j]++;
	for (int i = 1; i <= n; i++)
		ans += (b[i] == 0);
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
		if (a[x]-cnt[a[x]]+1 >= 1) ans += ((--b[a[x]-cnt[a[x]]+1])==0);
		cnt[a[x]]--, cnt[y]++, a[x] = y; 
		if (y-cnt[y]+1 >= 1) ans -= ((b[y-cnt[y]+1]++)==0);
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  int N,cnt=0;
  cin >> N;
  vector<int>a(N+1);
  for(int i=1;i<N+1;i++){
    cin >> a.at(i);
  }
  for(int i=1;i<N+1;i++){
    if(a.at(i)!=i-cnt){
      cnt++;
    }
  }
  if(cnt==N){
    cnt=-1;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
int x,y,z,n,m,o,p,q;
int main(){
	scanf("%d%d%d%d",&x,&y,&z,&n);
	if(500*x+100*y+50*z<n){
		printf("0");
		return 0;
	}
	m=0;
	for(int i=0;i<=x&&500*i<=n;i++){
		for(int j=0;j<=y&&(100*j+500*i)<=n;j++){
			int k=(n-500*i-100*j)/50;
			if(k<=z)m++;
		}
	}printf("%d",m);
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(a * b, c * d) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict
from itertools import accumulate


def read():
    s = input().strip()
    return s,


def solve(s):
    z = defaultdict(list)
    for i in range(len(s)):
        z[s[i]].append(i)
    ans = 99999
    for k, v in z.items():
        prev = -1
        diffmax = 0
        for i in v:
            diffmax = max(diffmax, i-prev-1)
            prev = i
        diffmax = max(diffmax, len(s)-v[-1]-1)
        ans = min(ans, diffmax)
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll q;
    cin>>q;
    ll si=q;
    vector<pair<ll,ll>>v;
    while(q--){
    ll n,m;
    cin>>n>>m;
     v.push_back({n,m});
    }
    vector<ll>a,b;
    for(int i=0;i<si;i++)
    {
        a.push_back(v[i].first+v[i].second);
        b.push_back(v[i].first-v[i].second);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans = abs(a[si-1]-a[0]);
    ans=max(ans,b[si-1]-b[0]);
 cout<<ans;
}

Measured memory_bytes: 11352