akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
#define mp make_pair
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecisi
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    map<ll,ll> ma;
    ll n,m;
    rep(i,N){
        cin >> n;
        ma[n]++;
    }
    rep(i,M){
        cin >> n >> m;
        ma[m] += n;
    }
    vector<P> vec;
    for(auto x : ma){
        vec.push_back(P(x.first,x.second));
    }
    reverse(all(vec));
    ll s = vec.size();
    ll cnt = 0,ans = 0,pos = 0;
    while(cnt <= N){
        if(vec[pos].second + cnt <= N){
            ans += vec[pos].first * vec[pos].second;
            cnt += vec[pos].second;
            pos++;
        }
        else{
            ans += vec[pos].first * (N - cnt);
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19852
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int N;
	cin >> N;



	cout << N*N*N << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    x,y,a,b,c=map(int, input().split())
    p=list(map(int, input().split()))
    q=list(map(int, input().split()))
    r=list(map(int, input().split()))
    p.sort(reverse=True)
    q.sort(reverse=True)
    r.sort(reverse=True)
    p=[10**10]+p[:x]
    q=[10**10]+q[:y]
    r+=[0]*(a+b)
    ans=sum(p)+sum(q)-2*10**10
    pcnt,qcnt=0,0
    for i in range(x+y):
        if p[-1-pcnt] >= r[i] and q[-1-qcnt] >= r[i]:
            break
        elif p[-1-pcnt] > q[-1-qcnt]:
            ans += -q[-1-qcnt] + r[i]
            qcnt +=1
        else:
            ans += -p[-1-pcnt] + r[i]
            pcnt +=1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 29080
<?php
    $info = explode(' ', trim(fgets(STDIN)));
    $enemy = explode(' ', trim(fgets(STDIN)));
    
    if ($info[0] <= $info[1]) {
        echo 0 . PHP_EOL;
        return;
    }
    
    rsort($enemy);
    array_splice($enemy, 0, $info[1]);
    echo array_sum($enemy) . PHP_EOL;

Measured memory_bytes: 31284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int mxn = 305;
int cnt[mxn], n;
ld dp[mxn][mxn][mxn];
ld f(int a, int b, int c){
	if(a + b + c == 0)
		return 0;
	if(dp[a][b][c] != -1.0)
		return dp[a][b][c];
	ld ret = (ld) n / (a + b + c);
	if(a > 0)
		ret += (ld) a / (a + b + c) * f(a - 1, b, c);
	if(b > 0)
		ret += (ld) b / (a + b + c) * f(a + 1, b - 1, c);
	if(c > 0)
		ret += (ld) c / (a + b + c) * f(a, b + 1, c - 1);
	return dp[a][b][c] = ret;
}

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

	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		cnt[x]++;
	}
	for(int i = 0; i < mxn; i++)
		for(int j = 0; j < mxn; j++)
			for(int k = 0; k < mxn; k++)
				dp[i][j][k] = -1.0;
	cout << fixed << setprecision(10) << f(cnt[1], cnt[2], cnt[3]);
}

Measured memory_bytes: 443648
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

constexpr ll mod = 1e9 + 7;
ll fact[200010];
ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
ll comb(ll n, ll r) {
	ll ret = 1;
	for (int i = 0; i < r; i++)
		ret = ret * (n - i) % mod;
	return ret * power(fact[r], mod - 2) % mod;
}
int n, a, b;
int main() {
	scanf("%d %d %d", &n, &a, &b);
	fact[0] = 1;
	for (int i = 1; i <= 200000; i++)
		fact[i] = fact[i - 1] * i % mod;
	ll s = power(2, n) - comb(n, a) - comb(n, b) - 1;
	printf("%lld\n", (s % mod + mod) % mod);
}

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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int p=sc.nextInt();
        long[]w=new long[n],b=new long[n],d=new long[n];
        long total=0;
        for(int i=0;i<n;++i){
            w[i]=(100-p)*sc.nextLong();
            b[i]=-p*sc.nextLong();
            d[i]=w[i]-b[i];
            total+=b[i];
        }
        Arrays.sort(d);
        int i=0;
        for(;i<n;++i){
            total+=d[n-1-i];
            if(total>=0)break;
        }
        out.println(i+1);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] nextIntArray(int n){
            int[]r=new int[n];
            for(int i=0;i<n;++i)r[i]=nextInt();
            return r;
        }
    }
}


Measured memory_bytes: 46648
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,q;
vector<int>c;
vector<int>ans(1001);
main()
{
	cin>>n>>q;
	c.push_back(0);
	for(int i=0;i<n;i++)
	{
		int C;cin>>C;c.push_back(C);
	}
	sort(c.begin(),c.end());
	for(int i=1;i<=1000;i++)
	{
		int a=0;
		for(int j=1;j<=n;j++)a=max(a,c[j]%i);
		ans[i]=a;
	}
	for(;q--;)
	{
		int a;cin>>a;
		if(a<=1000)cout<<ans[a]<<endl;
		else
		{
			int s=0;
			for(int i=1;(i-1)*a<=3e5;i++)
			{
				auto it=lower_bound(c.begin(),c.end(),i*a);
				if(it!=c.begin())
				{
					s=max(s,*--it%a);
				}
			}
			cout<<s<<endl;
		}
	}
}



Measured memory_bytes: 4988
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
	int N, K; cin >> N >> K;
	vector<int> A(N);
	for (auto& ai : A) cin >> ai;
	for (int i = K; i < N; ++i){
		cout << (A[i - K] < A[i] ? "Yes" : "No") << endl;
	}
	return 0;
}

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

namespace A
{

    class Program
    {
        public static void Main(string[] args)
        {
            var s = ReadLineIntSpilit();
            Console.WriteLine(s[0] <= s[1] ? "unsafe" : "safe");
            ReadLine();

        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

int main() {
  string W, T;
  cin >> W;
  transform(W.begin(), W.end(), W.begin(), ::tolower);

  int ans{};
  while (getline(cin, T)) {
    if (T == "END_OF_TEXT") break;
    transform(T.begin(), T.end(), T.begin(), ::tolower);
    size_t start(T.find_first_not_of(' '));
    while (start < T.size()) {
      size_t end{T.find_first_of(' ', start)};
      if (end == string::npos) end = T.size();
      if (T.substr(start, end - start) == W) ++ans;
      start = T.find_first_not_of(' ', end);
    }
  }
  cout << ans << endl;

  return 0;
}



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

vector<int> L;

int main(void){
    int N,X;
    cin >> N >> X;
    int ans = 1,d=0;

    L = vector<int>(N);
    for(int i=0;i<N;i++){
        cin >> L[i];
        d += L[i];
        if(d <= X) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll a,b;
  cin>>a>>b;
  if(a>=13)op(b)
  else if(a>=6)op(b/2)
  else op(0);
  return 0;
}

Measured memory_bytes: 256
s = int(input())
syo = True
ans = 1
while syo:
    if s == 4 or s == 1 or s == 2:
        print(ans + 3)
        break
    if s%2 == 1:
        s = s*3+1
    else:
        s //= 2
    ans += 1
    


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

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M; cin >> N >> M;
    unordered_map<int, int> um;
    rep(i, N){
        int k; cin >> k;
        rep(j, k){
            int b; cin >> b;
            um[b]++;
        }
    }
    int res = 0;
    for(auto a: um){
        if(a.second == N) res++;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    //今から文字入力
    //while文を使おうかなあ
    int a,b;
    char op;
    cin>>a>>op>>b;
    while(op!='?')
    {
        int c;
        if(op=='+') c=a+b;
        if(op=='-') c=a-b;
        if(op=='*') c=a*b;
        if(op=='/') c=a/b;
        cout<<c<<endl;
        cin>>a>>op>>b;
    }
   return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <typename Monoid>
struct SegmentTree {
  using F = function<Monoid(Monoid, Monoid)>;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) { seg[k + sz] = x; }

  void build() {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const { return seg[k + sz]; }

  template <typename C>
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while (a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if (check(nxt))
        a = 2 * a + type;
      else
        M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }

  template <typename C>
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if (a <= 0) {
      if (check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) {
        Monoid nxt = f(L, seg[a]);
        if (check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template <typename C>
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if (b >= sz) {
      if (check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for (b += sz; a < b; a >>= 1, b >>= 1) {
      if (b & 1) {
        Monoid nxt = f(seg[--b], R);
        if (check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

int N;
vector<int> h, a;

int main() {
  cin >> N;
  h.resize(N), a.resize(N);
  rep(i, N) cin >> h[i];
  rep(i, N) cin >> a[i];

  SegmentTree<ll> seg(
      N + 1, [](ll a, ll b) { return max(a, b); }, 0);

  rep(i, N) {
    ll v = max(seg.query(h[i], h[i] + 1), seg.query(0, h[i]) + a[i]);
    seg.update(h[i], v);
  }

  cout << seg.query(1, N + 1) << endl;
  return 0;
}


Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
  int N,K;
  cin >> N >> K;
  if(N == 1){
    cout << K << endl;
    return 0;
  }
  else if(N == 2){
    cout << K*(K-1) << endl;
    return 0;
  }
  int ans = K*(K-1);
  for(int i=0; i<N-2; i++){
    ans *= K-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3568
n, m = map(int, input().split())
n, m = n-1, m-1
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x.sort()
y.sort()

h, w = 0, 0
for i in range(n):
    h += (i + 1) * (n - i) * (x[i+1] - x[i])
    h %= mod

for j in range(m):
    w += (j + 1) * (m - j) * (y[j+1] - y[j])
    w %= mod

print(h * w % mod)

Measured memory_bytes: 18556
#include<bits/stdc++.h>
    using namespace std;
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define ll long long
    #define int long long
    #define lb long double
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define take(a,n) f(i,0,n)cin>>a[i];
    #define show(a,n) f(i,0,n){cout<<a[i]<<" ";}
    #define ashow(a)  for(auto i:a)cout<<i<<" ";
    #define khtm     cout<<endl;
    #define all(s) s.begin(),s.end()
    #define len(a) a.length()
    #define INF 1e18
    #define MAXN 2000009
    const double pi=3.14159265358979323;
    const int mod=1e9+7;
    bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
     signed main() {

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);  
        cout.tie(0);  
     // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1;
    // cin>>t;
    while(t--)
    {
      

        int n,k,x=1,y=0;
        int mx=-1,mi=INF,mn=INF;
        int tm=0;
         char c;
         cin>>n>>k;
         int a[n];
         take(a,n);
         sort(a,a+n);
         for(int i=0;i<k;i++)
            y+=a[i];
        cout<<y<<endl;
}

 }

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

int main(){
	int n,l,*ice,buf,prog,over,h=0,sz;
	queue<int> q;
	
	cin >> n >> l;
	
	ice = new int[n+2];
	ice[0] = ice[n+1] = 0;
	for(int i = 1; i < n+1; i++){
		cin >> ice[i];
	}
	
	for(int i = 1; i < n+1; i++){
		if(ice[i]){
			if((ice[i] > ice[i-1]) && (ice[i] > ice[i+1])){
				q.push(i);
			}
		}
	}
	
	while(1){
		buf = q.front();
		prog = (l - ice[buf]) > 0?(l - ice[buf]):0;
		
		sz = q.size();
		for(int i = 0; i < sz; i++){
			buf = q.front();
			q.pop();
			
			ice[buf] += prog;
			over = (ice[buf] - l) >= 0?(ice[buf] - l):-1;
			if(over != -1){
				ice[buf] = 0;
				if(ice[buf-1] > ice[buf-2]){
					ice[buf-1] += over;
					q.push(buf-1);
				}
				if(ice[buf+1] > ice[buf+2]){
					ice[buf+1] += over;
					q.push(buf+1);
				}
			}else{
				q.push(buf);
			}
		}
		h += prog;
		
		if(q.empty()){
			break;
		}
	}
	
	cout << h << endl;
	
	return 0;
}

Measured memory_bytes: 0
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];
        
        for (int i = 0; i < N; i++) {
            A[i]=sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            if (A[i]%2==0&&A[i]%3!=0&&A[i]%5!=0) {
                System.out.println("DENIED");
                System.exit(0);
            }
        }

        System.out.println("APPROVED");

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define REP(i,n) for (lint i = 0; i < (n); i++)
#define REP1(i,n) for (lint i = 1; i < (n); i++)

int a, b;

int main(void){
    cin >> a >> b;
    if (a > b) {
        REP (i, a) cout << b;
    } else {
        REP (i, b) cout << a;
    }
    cout << "" <<endl;
    return 0;
}

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

#define pi 2*acos(0.00)
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
#define null '\0'
#define mod 1000000007

using namespace std;
int main()
{
    fastio;
    ll n,k,x,ans=0;
    cin>>n>>k;
    for(x=k;x<=n+1;x++)
    {
        ans+=x*(n+1-x)+1;
        ans%=mod;
    }
    cout<<ans<<nl;
    return 0;
}





Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <tuple>
#include <bitset>
#include <random>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;


int d,g;

vector<vector<int>> dp(11,vector<int>(1001,0));

 
int main() {
  cin>>d>>g;
  vector<int> p(d+1,0), c(d+1,0);
  for(int i=1;i<=d;i++){
    cin>>p.at(i)>>c.at(i);
  }

  REP(i,d){
    REP(n,1001){
      dp.at(i+1).at(n)=max(dp.at(i+1).at(n),dp.at(i).at(n));
      for(int k=1;k<p.at(i+1)&&k<=n;k++){
        dp.at(i+1).at(n)=max(dp.at(i+1).at(n),100*(i+1)*k+dp.at(i).at(n-k));
      }
      if(p[i+1]<=n){
        dp.at(i+1).at(n)=max(dp.at(i+1).at(n),100*(i+1)*p.at(i+1)+c.at(i+1)+dp.at(i).at(n-p.at(i+1)));

      }

    }
  }
  REP(n,1001){
    if(dp.at(d).at(n)>=g){
      cout<<n<<endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

// ABC170-B
public class Main {

	public static void main(String[] args) {

		int tsuruLegs = 2;
		int kameLegs = 4;

		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		boolean bool = false;

		for (int i = 0; i <= x; i++) {
			int legs = i * tsuruLegs + (x - i) * kameLegs;

			if (legs == y) {
				bool = true;
			}
		}

		if (bool) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}


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

using namespace std;

int main()
{
	int N;
	long double sum = 0;
	double x;
	char u[4];
	
	cin >> N;
	
	for(int i=0;i<N;i++){
		cin >> x >> u[0] >> u[1] >> u[2];
		if(u[0] == 'J' && u[1] == 'P' && u[2] =='Y')sum += x;
		else sum += x*380000.0;
	}
	
	cout << sum << endl;

	
	return 0;
}

Measured memory_bytes: 256
import copy

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

dir = [(i, j) for i in range(-1, 2) for j in range(-1, 2)]
ans = copy.deepcopy(s)
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            cnt = 0
            for y, x in dir:
                iy, jx = i+y, j+x
                if 0 <= iy < h and 0 <= jx < w:
                    if s[iy][jx] == '#':
                        cnt += 1
            ans[i][j] = cnt
for i in ans:
    print(''.join(map(str, i)))


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

int main() {
  int s, a, b;
  cin >> s;
  a = s / 100;
  b = s % 100;
  string ans;
  if(1<=a && a<=12 && 1<=b && b<=12) ans ="AMBIGUOUS";
  else if(0<=a && a<=99 && 1<=b && b<=12) ans ="YYMM";
  else if(1<=a && a<=12 && 0<=b && b<=99) ans ="MMYY";
  else ans ="NA";
  cout << ans << endl;
}


Measured memory_bytes: 3484
// MatrixMultiplication.cc
//
// n×mの行列 Aと m×lの行列 Bを入力し、それらの積である n×lの行列 Cを
// 出力するプログラムを作成してください。
// 行列 Cの各要素 cij は次の式で得られます：
//   c ij = k-1Σm aik bkj
// ここで、A、B、Cの各要素をそれぞれ aij、bij、cij とします。
// 【入力】
// １行目に n、m、l が空白区切りで与えられます。
// 続く行に n×m の行列 A と m×l の行列 B が与えられます。
// 【出力】
// n×l の行列 C の要素 cij を出力してください。
// 各行の隣り合う要素を１つの空白で区切ってください。
// 【制限】
// ・1≤n,m,l≤100
// ・0≤aij,bij≤10000
// 【例】
// 入力：
// 3 2 3
// 1 2
/// 0 3
// 4 5
// 1 2 1
// 0 3 2
// 出力：
// 1 8 5
// 0 9 6
// 4 23 14
#include<iostream>
using namespace std;

int main( void) {
  int n, m, l;
  long long A[100][100], B[100][100], C[100][100]={};

  // 入力データの処理
  cin >> n >> m >> l;

  for ( int i = 0; i < n; i++) {
    for ( int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for ( int j = 0; j < m; j++) {
    for ( int k = 0; k < l; k++) {
      cin >> B[j][k];
    }
  }

  // 新しい行列Cの計算
  for ( int i = 0; i < n; i++) {
    for ( int k = 0; k < l; k++) {
      for ( int j = 0; j < m; j++) {
	C[i][k] += A[i][j] * B[j][k];
      }
    }
  }

  // 行列Cの出力
  for ( int i = 0; i < n; i++) {
    for ( int k = 0; k < l; k++) {
      cout << C[i][k];
      if ( k < l - 1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
char a;
int main()
{
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	{
		cout<<"vowel"<<endl;
		return 0;
	}
	else
	{
		cout<<"consonant";
		return 0;
	}
    return 0;
}

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

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

using ll = long long;
using namespace std;

int
main ()
{
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    vector<int> b(n+1);

    rep(n + 1, i) {
      if (i < n) {
        cin >> a[i];
        b[i] = (i > 0) ? a[i] - a[i-1] : a[0];
      } else {
        b[n] = k - a[n-1];
      }
    }

    int curv_1 = b[0] + b[n];
    int curv_2 = 0;
    rep(n + 1, i) {
      if (b[i] > curv_2) curv_2 = b[i];
    }

    cout << (curv_1 < curv_2 ? k - curv_2: k - curv_1) << endl;
}


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  int ans=0;
  int mx = 0;
  for(int i=0;i<n;i++){
    int t;cin>>t;
    mx = max(mx, t);
    ans+=t;
  }
  ans -= mx / 2;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3656
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll s;
    std::cin >> s;
    ll a,b;
    
    bool yymm = false;
    bool mmyy = false;
    a = s/100;
    b = s%100;
    if(a<=12 && a!=0){
        mmyy = true;
    }
    if(b<=12 && b!=0){
        yymm = true;
    }
    if( mmyy && yymm){
        std::cout << "AMBIGUOUS" << std::endl;
    }else if(mmyy){
        std::cout << "MMYY" << std::endl;
    }else if(yymm){
        std::cout << "YYMM" << std::endl;
    }else{
        std::cout << "NA" << std::endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  int N,D;
  double X,Y;
  int cn=0;
  cin >> N >> D;
  while(N--) {
    cin >> X >> Y;
    if (sqrt(pow(X,2)+ pow(Y,2)) <= D)cn++;
  }
  cout << cn << endl;
  return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[100]={0};
    int n=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++)
    {
        scanf("%d", &a[i]);
        if(i!=n-1){
        printf("%d ", a[i]);
        }
        else{printf("%d", a[i]);}
    }
    printf("\n");
    for(int j=1;j<=n-1;j++)
    {
        int key=a[j];
        int m=j-1;
        while(m>=0&a[m]>key)
        {
            a[m+1]=a[m];
            m=m-1;
            a[m+1]=key;
        }
        for(int e=0;e<n;e++)
        {
            if(e!=n-1)
            {
                printf("%d ", a[e]);
            }
            else{printf("%d", a[e]);}
        }
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int pref[1<<20];
int main(){
  int n;
    string s;cin>>n;
    cin>>s;
   for(int i=0;i<n;++i){
       if(s[i]=='E')pref[i+1]=1+pref[i];
       else pref[i+1]=pref[i];
   }
    int ans=1<<20;
    for(int i=1;i<=n;++i){
        ans=min(ans,(i-1-pref[i-1])+(pref[n]-pref[i]));
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
string a,b="CODEFESTIVAL2016";
int c=16;
int main()
{
    cin>>a;
    for(int i=0;i<16;i++)
    c-=(a[i]==b[i])?1:0;
    cout<<c<<endl;
    return 0;
}

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

int main() {
  int a,b;
  cin >> a >> b  ;
  if ( a ==1)
    a =14 ;
  if ( b ==1)
    b =14 ;
  if(a==b)
    cout << "Draw";
  if(a<b)
    cout << "Bob";
  if(a>b)
    cout << "Alice";

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int a[200006];
int rwa[200006];
signed main() {
	int n, k; cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n)rwa[i + 1] += a[i];
	rep(i, n)rwa[i + 1] += rwa[i];
	for (int i = n; i >= 0; i--) {
		rwa[i] += n - i;
	}
	rep(i, n + 1)rwa[i] %= k;
	map<int, int>M;
	int ans = 0;
	rep(i, n + 1) {
		M[rwa[i]]++;
		if (i >= k) {
			M[rwa[i - k]]--;
		}
		int k = M[rwa[i]];
		ans += (k - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 15872
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    count = {}
    for aa in a:
        if aa in count:
            count[aa] += 1
        else:
            count[aa] = 1
    all_way = 0
    for c in count.values():
        all_way += c * (c - 1) // 2
    for i in range(n):
        if a[i] in count:
            print(all_way - count[a[i]] + 1)
        else:
            print(all_way)


if __name__ == '__main__':
    main()



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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int N, M;
const int MAX_N=100005;
bool use[MAX_N];
mint stairs[MAX_N];

void solve() {
  stairs[0] = 1;
  stairs[1] = (use[1] ? 1 : 0);
  for(int i=2; i<=N; i++) {
    if(!use[i]) {
      stairs[i] = 0;
    } else {
      stairs[i] = stairs[i-1] + stairs[i-2];
    }
  }
  cout << stairs[N].x << endl;
}

int main() {
  cin >> N >> M;
  rep(i, N+1) {
    use[i] = true;
  }
  int a;
  rep(i, M) {
    cin >> a;
    use[a] = false;
  }
  solve();
  return 0;
}



Measured memory_bytes: 1152
a = gets.chomp.split("").map(&:to_i)
a_len = a.length

ans = 0

for bit in 0..2**(a_len-1)-1 do
    cur, sum = a[0], 0
    for i in 0..a_len-2 do
        if (bit >> i) & 1 == 1 then
            sum += cur
            cur = a[i+1]
        else
            cur *= 10
            cur += a[i+1]
        end
    end
    sum += cur
    ans += sum
end

p ans



Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 200010;

int n;
int h[N], a[N];
ll fw[N];

int lowBit(int k) { return k & -k; }

void ch(int k, ll x) {
  for (; k <= n; k += lowBit(k))
    fw[k] = max(fw[k], x);
}

ll qry(int k) {
  ll ret = 0;
  for (; k; k -= lowBit(k))
    ret = max(ret, fw[k]);
  return ret;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &h[i]);
  }
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    ch(h[i], qry(h[i]) + a[i]);
  printf("%lld\n", qry(n));

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 3328
#import sys
from collections import deque
import copy
#input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=deque([])
for w,v in WV:
    nlst=deque([[w,v]])
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1+w<=W:
            if w1:
                nlst.append([w1+w,v1+v])
    if not lst:
        lst=copy.copy(nlst)
        continue
    Xlst=lst
    lst=deque()

    if Xlst or nlst:
        w1,v1=nlst[0]
        w2,v2=Xlst[0]
        if w1<w2:
            lst.append(nlst.popleft())
        else:
            lst.append(Xlst.popleft())
    while Xlst or nlst:
        w,v=lst[-1]
        if Xlst and nlst:
            w1,v1=nlst[0]
            w2,v2=Xlst[0]

            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            elif w==w2:
                if v>=v2:
                    Xlst.popleft()
                else:
                    lst.pop()
                    lst.append(Xlst.popleft())
            else:
                if w1<w2:
                    if v>=v1:
                        nlst.popleft()
                    else:
                        lst.append(nlst.popleft())
                else:
                    if v>=v2:
                        Xlst.popleft()
                    else:
                        lst.append(Xlst.popleft())
        elif nlst:
            w1,v1=nlst[0]
            if w==w1:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.pop()
                    lst.append(nlst.popleft())
            else:
                if v>=v1:
                    nlst.popleft()
                else:
                    lst.append(nlst.popleft())
        elif Xlst:
            nlst=Xlst
            Xlst=deque()



lst.append([0,0])
print(max([v for w,v in lst if w<=W]))


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

const int MAX = 1e9;
int main()
{
  	int x;
  	cin>>x;
  	int res = 0, temp = 0;
  	for(int i = 1; i < MAX; i++)
    {
    	res = (i*(i+1))/2;
      	if(res == x)
        {
        	cout<<i;
          	break;
        }
      	else if((x < res) && (x > temp))
        {
        	cout<<i;
          	break;
        }
      	temp = res;
    }
	return 0;
}

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

int sh(string s);

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

    int a = 0;
    int b = 0;
    for (int i=0; i<s.length(); i++) {
        if (s[i] == '0') a++;
        if (s[i] == '1') b++;
    }
    cout << min(a, b) * 2 << endl;

    return 0;
}

Measured memory_bytes: 512
n, k = map(int, input().split())
lis = list(map(int, input().split()))

su = [0] * (n + 1)

for i in range(n):
    su[i + 1] = su[i] + ((lis[i] + 1) / 2)

res = 0
for j in range(n - k + 1):
    res = max(res, su[j + k] - su[j])
    
print('{:.12f}'.format(res))


Measured memory_bytes: 25060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication40
{
    class Program
    {
        static void Main()
        {
            int A, B, AB, O;
            A = B = AB = O = 0;
            while (true)
            {
                string g = Console.ReadLine();
                if (g == null) break;
                string k = g.Split(',')[1];
                switch (k)
                {
                    case "A":A++; break;
                    case "B":B++; break;
                    case "AB":AB++; break;
                    case "O":O++; break;
                }
            }
            Console.WriteLine(A);
            Console.WriteLine(B);
            Console.WriteLine(AB);
            Console.WriteLine(O);
        }
    }
}

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

int main() {
    string n;

    cin >> n;
	
    if ((n[0] == n[1]) && (n[1] == n[2])) {
        cout << "Yes" << endl;
    }
    else if ((n[1] == n[2]) && (n[2] == n[3])) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

vector<ll> v[N + 1];
bool vis[N + 1];
ll dp[N + 1][2];
const ll M = 1e9 + 7;
void dfs(ll i)
{
    dp[i][0] = dp[i][1] = 1;

    for (auto j : v[i])
    {

        //0 Black 1 White

        if (!vis[j])
        {

            vis[j] = true;
            dfs(j);

            dp[i][0] = (dp[i][0] % M * dp[j][1] % M) % M;
            dp[i][1] = (dp[i][1] % M * (dp[j][0] + dp[j][1]) % M) % M;
        }
    }
}
int main()
{
    //freopen("input.txt", "r", stdin);
    memset(vis, false, sizeof(vis));
    memset(dp, -1, sizeof(dp));
    ll n;

    cin >> n;

    f(i, 1, n - 1)
    {
        ll x, y;
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    vis[1] = true;

    dfs(1);

    cout << (dp[1][0] + dp[1][1]) % M << endl;
}

Measured memory_bytes: 11520
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    String w1 = sc.next();
    String w2 = sc.next();

    int c = 0;
    for (int i = 0; i < w1.length(); i++) {
      if (w1.charAt(i) == w2.charAt(i)) {
        c++;
      }
    }

    System.out.println(c);
  }
}


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

int main(){
    int64_t X, K, D, ans, a;
    cin >> X >> K >> D;

    if(X < 0){
        X = abs(X);
    }

    ans = X % D;
    if(X / D < K){
        if((K - X / D) % 2 == 0){
            cout << ans << endl;
        } else {
            a = D - ans;
            cout << a << endl;
        }
    } else {
        a = X - K * D;
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>

int main() {
  std::list<char> S;
  std::string str;
  std::cin >> str;
  for (auto c : str) {
    S.push_back(c);
  }

  int Q, T, F;
  char c;
  std::cin >> Q;
  bool left = true;
  for (size_t i = 0; i < Q; ++i) {
    std::cin >> T;
    if (T == 1) {
      left = !left;
      // S.reverse();
    } else {
      std::cin >> F >> c;
      if (F == 1) {
        if (left)
          S.push_front(c);
        else
          S.push_back(c);
      } else {
        if (left)
          S.push_back(c);
        else
          S.push_front(c);
      }
    }
  }

  if (!left) S.reverse();
  std::for_each(S.begin(), S.end(), [](auto x) { std::cout << x; });
  std::cout << std::endl;

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    vector<ll> wa;
    REP(i, 3010){
    	REP(j, 3010){
    		wa.push_back(R*i + G*j);
    	}
    }
    sort(wa.begin(), wa.end());
    ll res = 0;
    REP(i, 3010){
    	res += upper_bound(wa.begin(), wa.end(), N - i*B) - lower_bound(wa.begin(), wa.end(), N - i*B);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 133212
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();

        // 主処理
        int result = 0;
        int sum = 0;
        String[] array = s.split("");
        for (String c : array) {
            if ("I".equals(c)) {
                sum++;
            } else if ("D".equals(c)) {
                sum--;
            }
            result = Math.max(result, sum);
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
 int S;
 cin>>S;
bool a=false;
bool b=false;
if(0<S%100&&S%100<13){
    b=true;
}
if((S-S%100)/100<13&&0<(S-S%100)/100){
    a=true;
}
if(a==true&&b==true){
    cout<<"AMBIGUOUS"<<endl;
}
else if(b==true&&a==false){
    cout<<"YYMM"<<endl;
}
else if(b==false&&a==true){
    cout<<"MMYY"<<endl;
}
else
cout<<"NA"<<endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,i,j,ans=0;
    string s;
    cin>>s;
    for(i=0; i<s.length()-1; i++)
    {
        if(s[i]==s[i+1])
        {
            ans++;
            if(s[i]=='0')
                s[i+1]='1';
            else
                s[i+1]='0';
        }

    }
    cout<<ans<<endl;



    return 0;
}




Measured memory_bytes: 3688