akhauriyash/Code-Regression huggingface dataset:
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int gomi1;
  char gomi2;
  string s;
  vi t(4);
  while (cin >> gomi1 >> gomi2 >> s) {
    t[s == "A" ? 0 : s == "B" ? 1 : s == "AB" ? 2 : 3]++;
  }
  rep(i, 4) cout << t[i] << endl;
}

Measured memory_bytes: 3112
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

struct war {
	int a, b;
	bool operator < (const war& ano) {
		return b < ano.b;
	}
};
war w[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> w[i].a >> w[i].b;
	}
	sort(w, w + M);
	int ans = 0;
	int p = 0;
	for (int i = 0; i < M; i++) {
		if (!(w[i].a <= p && w[i].b >= p)) {
			ans++;
			p = w[i].b - 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4388
#include <iostream>
#include <vector>
#include <stack>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

struct bl {
    int first;
    int last;
    int num;
};

int main() {
    int n;
    cin >> n;
    vector<int> A(n);

    for (auto &e: A) cin >> e;

    int first = 0;
    int last = n;

    while (last - first > 1) {
        int mid = (last + first) / 2;

        bool f = true;
        stack<bl> str;
        str.push({1, A[0], 1});
        for (int i = 1; i < n; ++i) {
            if (A[i] > A[i-1]) {
                if (str.top().num == 1) {
                    str.top().last += A[i] - A[i-1];
                } else {
                    str.push({A[i-1]+1, A[i], 1});
                }
            } else {
                while (str.top().first > A[i] || str.top().num == mid) {
                    str.pop();
                    if (str.empty()) break;
                }
                if (str.empty()) {
                    f = false;
                    break;
                }
                if (str.top().last > A[i]) str.top().last = A[i];

                int num = str.top().num+1;
                if (str.top().first == str.top().last) {
                    str.pop();
                } else {
                    --str.top().last;
                }


                if (!str.empty() && str.top().num == num) {
                    ++str.top().last;
                } else {
                    if (str.empty()) {
                        str.push({1, 1, num});
                    } else {
                        str.push({str.top().last+1, str.top().last+1, num});
                    }
                }

                if (str.top().last != A[i]) {
                    str.push({str.top().last+1, A[i], 1});
                }
            }
        }

        if (f) {
            last = mid;
        } else {
            first = mid;
        }

    }

    cout << last << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
	int H,W;
	
	int i,j,k,l;
	char str[101][101];
	
	scanf("%d",&H);
	scanf("%d",&W);
	for(i=0;i<H;i++){
		scanf("%s",&str[i][0]);
		}
	for(j=0;j<W+2;j++){
		printf("#");
	}
	printf("\n");
	for(k=0;k<H;k++){
		printf("#%s#\n",&str[k][0]);
	}
	for(l=0;l<W+2;l++){
		printf("#");
	}
	
	return 0;
}
	

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let a = get!([usize]);
    if a.iter().sum::<usize>() >= 22 {
        println!("bust");
    } else{
        println!("win");
    }
}


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

int main(){
  string s;
  cin>>s;
  int count = 0, ans = 0;
  for(int i=0; i<s.length(); i++) {
    if(s[i] == 'S'){
      ans = max(count, ans);
      count = 0;
   } else {
      count++;
   }
}
 ans = max(count, ans);
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0)  cout<<"Possible";
	else  cout<<"Impossible";
	cout<<endl;
	return 0;
} 

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
B = Counter(A)
DP = [[[0.0] * (B[3] + 1) for _ in range(N + 1)] for __ in range(N + 2)]

for k in range(B[3]+1):
    for j in range(B[2] + B[3] + 1 - k):
        for i in range(B[1] + B[2] + B[3] + 1 - k - j):
            if i == j == k == 0:
                continue
            tmp = float(N)
            if i > 0:
                tmp += i * DP[i - 1][j][k]
            if j > 0:
                tmp += j * DP[i + 1][j - 1][k]
            if k > 0:
                tmp += k * DP[i][j + 1][k - 1]
            DP[i][j][k] = tmp / (i + j + k)
print(DP[B[1]][B[2]][B[3]])





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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 1) cout << "Borys";
    else cout << "Alice";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	long double a,b,ta,tb;
  	cin>>a>>b;
	ta=(a+b)/0.18;
  	tb=(a+b+2)/0.18;
  	ta=floor(ta);
  	tb=ceil(tb);
  	for(int i=ta;i<=tb;i++){
      if(floor(i*0.08)==a&&floor(i*0.10)==b) {cout<<i;return 0;}
    }
  	cout<<-1;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long cnt = 0;
	for(int i = 0;i*a<=d;i++){
		int x = i*a;
		for(int j=0;j*b<=(d-x);j++){
			int y = j*b;
			if((d-x-y)%c==0){
				cnt++;
				//cout<<i<<" "<<j<<" "<<(d-x-y)/c<<endl;
			}
			}
		}
		cout<<cnt<<endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main() {
    int n, r, a;
    scanf("%d%d", &n, &a);
    
    if(n >= 500)
    {
        r = n%500;
        if(r <= a)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else if(n < 500)
    {
        if(n < a)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<int,double> pid;
typedef long double ld;
const int maxn = 1e5+5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x7f7f7f7f7f7f7f7f;
const int mod = 1e9+7;
const int M=1e4+5;
const double PI = acos(-1.0);
const double eps = 1e-5;
ll a[maxn],inv[maxn];
ll fac=1;
ll qpow(ll x,int p)
{
    ll ans = 1;
    while(p)
    {
        if(p&1)
            ans = ans*x%mod;
        x = x*x%mod;
        p>>=1;
    }
    return ans;
}

int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        fac = fac*i%mod;
        inv[i] = qpow(i,mod-2);
    }
    for(int i=1; i<=n; i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=2; i<=n; i++)
    {
        inv[i] = (inv[i]+inv[i-1])%mod;
    }
    ll ans = 0;
    for(int i=1; i<=n; i++)
    {
        ans = (ans+(a[i]*(inv[i]+inv[n-i+1]-1)%mod)%mod)%mod;
    }
    printf("%lld",ans*fac%mod);
}


Measured memory_bytes: 5196
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














char C;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> C;
	C++;
	cout << C << endl;
}







Measured memory_bytes: 256
// 1_8_B
#include <iostream>
#include <string>
using namespace std;

int main(){
  int i, ans;
  string n;

  while(true){
    ans = 0;
    cin >> n;
    if(n == "0") return 0;

    for(i = 0; i < (int)n.length(); i++){
      ans += n[i] - '0';
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N), b(N), c(N);
  for(int i=0;i<N;i++) cin >> a[i];
  for(int i=0;i<N;i++) cin >> b[i];
  for(int i=0;i<N;i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  for(int i=0;i<N;i++){
    ans += ((lower_bound(a.begin(), a.end(), b[i])) - a.begin()) * (N - ((upper_bound(c.begin(), c.end(), b[i])) - c.begin()));
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 4556
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    keys = []
    for _ in range(m):
        bit = ["0"] * n
        a, b = map(int, input().split())
        C = map(int, input().split())
        for c in C:
            bit[c - 1] = "1"
        bit = int("".join(bit), 2)
        keys.append([bit, a])

    dp = [f_inf] * (1 << n)
    dp[0] = 0
    for i in range(1 << n):
        for k, cost in keys:
            idx = i | k
            dp[idx] = min(dp[idx], dp[i] + cost)

    print(dp[-1] if dp[-1] != f_inf else -1)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9372
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100000+10;
vector<int>edge[MAXN];
int n,cnt[3];
int tree[MAXN];
void bfs()
{
    queue<int>q;
    q.push(1),q.push(n);
    while(!q.empty())
    {
        int temp=q.front();
        q.pop();
        cnt[tree[temp]]++;
        for(int i=0;i<edge[temp].size();i++)
        {
            int v=edge[temp][i];
            if(tree[v])continue;
            else tree[v]=tree[temp];
            q.push(v);
        }
    }
}
int main()
{
    memset(tree,0,sizeof(tree));
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    tree[1]=1,tree[n]=2;
    bfs();
    if(cnt[2]>=cnt[1]){
		cout<<"Snuke"<<endl;
	}
    else{
    	cout<<"Fennec"<<endl;
	}
    return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int x,y,z,m;
  double e;
  while(cin>>e,e){
    m=1000000;
    for(z=0;z*z*z<=e;z++){
      y=(int)pow(e-z*z*z,0.5);
      x=e-y*y-z*z*z;
      if(m>x+y+z)m=x+y+z;
    }
    printf("%d\n",m);
  }
}

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

ll N,M;

int main(void){
    cin >> N >> M;
    if(N < M) swap(N,M);
    if(N == 1 && M==1){
        cout << 1 << endl;
        return 0;
    } 
    
    if(M==1){
        cout << N -2 << endl;
        return 0;
    }
    
    cout << (M-2)*(N-2) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
P p[200010];
signed main(){
	int n,cnt=0;
	cin>>n;
	f(i,n){
		cin>>p[i].S>>p[i].F;
	}
	sort(p,p+n);
	f(i,n){
		cnt+=p[i].S;
		if(cnt>p[i].F){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3328
// ALDS1_6_D.cpp
// Sort II - Minimum Cost Sort

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXW = 10005;
int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    vector<int> w_sorted(MAXW, -1);
    int w_min = MAXW;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        w_sorted[w[i]]++;
        w_min = min(w_min, w[i]);
    }

    int w_cnt = 0;
    for (int i = 0; i < w_sorted.size(); i++) {
        if (w_sorted[i] >= 0) {
            w_sorted[i] += w_cnt;
            w_cnt++;
        }
    }

    int w_sum = 0;

    for (int i = 0; i < n; i++) {
        if (w_sorted[w[i]] == -1) continue;
        int w_cnt1 = 0;
        int w_min_partial = w[i];
        for (int j = i; w_sorted[w[j]] != -1; ) {
            w_min_partial = min(w_min_partial, w[j]);
            w_cnt1++;
            w_sum += w[j];
            int tmp = j;
            j = w_sorted[w[j]];
            w_sorted[w[tmp]] = -1;
        }
        w_sum += min((w_cnt1 - 2) * w_min_partial, (w_cnt1 + 1) * w_min + w_min_partial);
    }

    cout << w_sum << endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    pi a[maxn];
    int n;
    i64 dp[maxn][2], nx[maxn];
    void solve() {
        cin >> n;
        for (int i = 0; i < n; ++i) {
            cin >> a[i].first >> a[i].second;
        }
        sort(a, a + n);
        dp[n][0] = 1;
        build(1, 0, n - 1);
        for (int i = n - 1; i >= 0; --i) {
            int id = lower_bound(a, a + n,
                                 make_pair(a[i].first + a[i].second - 1, 0)) -
                     a;
            if (a[id].first != a[i].first + a[i].second - 1)
                --id;
            nx[i] = query(1, 0, n - 1, i, id);
            upd(1, 0, n - 1, i, nx[i]);
            dp[i][1] = (dp[nx[i] + 1][0] + dp[nx[i] + 1][1]) % MOD;
            dp[i][0] = (dp[i + 1][0] + dp[i + 1][1]) % MOD;
        }
        cout << (dp[0][0] + dp[0][1]) % MOD << '\n';
    }
    int Max[maxn << 2];
    void build(int rt, int l, int r) {
        if (l == r) {
            Max[rt] = l;
            return;
        }
        int mid = l + r >> 1;
        build(rt << 1, l, mid);
        build(rt << 1 | 1, mid + 1, r);
        Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]);
    }
    void upd(int rt, int l, int r, int p, int v) {
        if (l == r) {
            Max[rt] = v;
            return;
        }
        int mid = l + r >> 1;
        if (p <= mid)
            upd(rt << 1, l, mid, p, v);
        else
            upd(rt << 1 | 1, mid + 1, r, p, v);
        Max[rt] = max(Max[rt << 1], Max[rt << 1 | 1]);
    }
    int query(int rt, int l, int r, int ll, int rr) {
        if (ll <= l && rr >= r) {
            return Max[rt];
        }
        int mid = l + r >> 1;
        int res = -1;
        if (ll <= mid)
            res = max(res, query(rt << 1, l, mid, ll, rr));
        if (rr > mid)
            res = max(res, query(rt << 1 | 1, mid + 1, r, ll, rr));
        return res;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 8576
def floor_sum(n, m, a, b):
    ans = 0
    while True:
        ans += (n - 1) * n // 2 * (a // m) + n * (b // m)
        a %= m
        b %= m
        y = (a * n + b) // m
        x = b - y * m
        if y == 0: return ans
        ans += (x // a + n) * y
        n, m, a, b = y, a, m, x % a

import sys
input = sys.stdin.readline

T = int(input())
for _ in range(T):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))

Measured memory_bytes: 70988
H,L,M,W,F,S=%w{heavy light middle welter fly \ };$<.map{|s|puts Hash[H,91,L+S+H,81,M,75,L+S+M,69,W,64,L+S+W,60,L,57,"feather",54,"bantam",51,F,48,L+S+F,0].find{|k,v|s.to_f>v}[0]}

Measured memory_bytes: 6116
from collections import deque
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

table = [0] * 45

table[0] = 1
table[1] = 1

for i in range(2,45):
    table[i] = table[i-1]+table[i-2]


N = int(input())
print("%d"%(table[N]))


Measured memory_bytes: 6372
using System;

public class Test
{
	public static void Main()
	{
		string line;
		line = Console.ReadLine();
		char c = Convert.ToChar(line);
		if(c == 'a'||c=='i'||c=='u'||c=='e'||c=='o'){
			Console.WriteLine("vowel");
		} else {
			Console.WriteLine("consonant");
		}
	}
}

Measured memory_bytes: 2904
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

solve x y k s a
  | x > k = a
  | y > k = solve (x+1) 0 k s a
  | otherwise = solve x (y+1) k s (a + (if 0 <= z && z <= k then 1 else 0))
  where z = s - x - y
                                           

main = do
  [k,s] <- getInts
  print $ solve 0 0 k s 0


Measured memory_bytes: 892
m=1001
A=range(10)
d=[[0]*m for i in A]
d[0][0]=1
for i in range(101):
  for j in A[1:][::-1]:
    for k in range(m-i): d[j][k+i]+=d[j-1][k]
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  print d[n][s]

Measured memory_bytes: 4392
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        int a,b;
        while(~getII(a,b)) printf("%d\n",6-a-b);
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  ll N;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  N /= (ll)2;
  ll ans = 0;
  for(ll i = 5; i <= N; i *= (ll)5) {
    ans += N/i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
class Main{
    public static void main(String[] a){
	int i,j;
	for(i=1;i<10;i++){
	    for(j=1;j<10;j++){
		System.out.print(i);
		System.out.print("x");
		System.out.print(j);
		System.out.print("=");
		System.out.println(i*j);
	    }
	}
    }
}

Measured memory_bytes: 9536
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;

    bool ok = true;

    // cond 1
    ok &= (s[0] == 'A');
    // cerr << ok << endl;

    // cond 2
    int f = s.find('C');
    ok &= (f != string::npos);
    ok &= (2 <= f && f <= (int)(s.size() - 2));
    // cerr << ok << endl;

    // cond 3
    for(int i=0; i<s.size(); i++) {
        if(i == 0 || i == f) continue;
        ok &= ('a' <= s[i] && s[i] <= 'z');
        // cerr << s[i] << endl;
    }
    // cerr << ok << endl;

    // cerr << f << endl;
    cout << (ok ? "AC" : "WA") << endl;
    return 0;
}

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

int main(){
	double xa, ya;
	double x, y;
	double x1, y1;
	double x2, y2;
	double xp, yp;
	double dx, dy;
	double r, r2;
	char c;
	while(cin >> x1 >> c >> y1 >> c >> x2 >> c
		>> y2 >> c >> xp >> c >> yp)
	{
		dx = x2 - x1;
		dy = y2 - y1;
		r = -dy * x1 + dx * y1;
		r2 = dx * xp + dy * yp;
		y = (r * dx + r2 * dy) / (dx * dx + dy * dy);
		x = (r2 * dx - r * dy) / (dx * dx + dy * dy);
		xa = xp + (x - xp) * 2;
		ya = yp + (y - yp) * 2;
		cout << fixed << setprecision(6) << xa << " " << ya << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n,k=map(int,input().split())
L=[[] for i in range(n+1)]

for i in range(n-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)
    
C=[k for i in range(n+1)]
V=[0 for i in range(n+1)]
mod=1_000_000_007
ans=1
que=[(1,0)]
V[1]=1
head=0

cnt=1
while len(que)>head:
    now=que[head]
    head+=1
    ans=ans*(k-now[1])%mod
    for i in range(len(L[now[0]])):
        nex=L[now[0]][i]
        if V[nex]==0:
            V[nex]=1
            que.append((nex,cnt))
            cnt+=1
    cnt=2

#ans=ans*pow(k-1,mod-2,mod)*k%mod
print(ans)

Measured memory_bytes: 110896
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const ll N=1e5+5;
bool f;
ll n,m,arr[N],dp[N];
ll solve(ll i=0)
{
  if(i==n-1)return 0;
  if(i>n)return INT_MAX;
  ll &ret=dp[i];
  if(~ret)return ret;
  ret=INT_MAX;
  for(int j=i+1;j<=min(n,i+m);j++)
   {
       ret=min(ret,solve(j)+abs(arr[i]-arr[j]));
   }
   return ret;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   cin>>n>>m;
   memset(dp,-1,sizeof dp);
   rep(i,n) cin>>arr[i];
   cout<<solve();
go;
}


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

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var i = Partition(A, 0, A.Length - 1);
			var ans = new string[A.Length];
			for (int j = 0; j < ans.Length; j++)
			{
				ans[j] = j == i ? $"[{A[j]}]" : $"{A[j]}";
			}
			System.Console.WriteLine(string.Join(" ", ans));
		}

		static int Partition(int[] A, int p, int r)
		{
			var x = A[r];
			var i = p - 1;
			for (int j = p; j < r; j++)
			{
				if (A[j] <= x)
				{
					i++;
					var tmp = A[j];
					A[j] = A[i];
					A[i] = tmp;
				}
			}
			var tmp2 = A[i + 1];
			A[i + 1] = A[r];
			A[r] = tmp2;

			return i + 1;
		}
	}
}



Measured memory_bytes: 36232
#include<iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	int x;
	int max = -1000000;
	int min = 10000000;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			if (min > i) {
				min = i;
			}
		}
	}
	for (int i = 0; i < s.size(); i++) {

			if (s[i] == 'Z') {
				
				if (i > max) {
					max = i;
				}

			}
		
	}
	cout << max-min+1<< endl;
	return 0;
}

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

sys.setrecursionlimit(10000)


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


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


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


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


def read_str():
    return input().strip()


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, M, A):
    c = [
        -1,
        2, # 1 
        5, # 2
        5, # 3
        4, # 4
        5, # 5
        6, # 6
        3, # 7
        7, # 8
        6, # 9
        ]
    
    if 2 in A and 5 in A:
        A.remove(2)
    if 3 in A and 5 in A:
        A.remove(3)
    if 2 in A and 3 in A:
        A.remove(2)
    if 6 in A and 9 in A:
        A.remove(6)



    dp = [None] * (N+1) 
    dp[N] = 0
    for i in range(N, 0, -1):
        if dp[i] is None:
            continue
        
        for a in A:
            if i - c[a] < 0:
                continue
            
            if dp[i-c[a]] is None or dp[i] * 10 + a > dp[i-c[a]]:
                dp[i-c[a]] =  dp[i] * 10 + a

    return dp[0]


def main():
    # N = read_int()
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 17084
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long int
long long  INF=1e18L+5;
void max_self(ll& a,ll b)
{
    a=max(a,b);
}
void min_self(ll& a,ll b)
{
    a=min(a,b);
}

int main()
{   ios_base::sync_with_stdio(0);
     cin.tie(0);
    ll n,w,sum_value=0;
    cin>>n>>w;
    vector<ll> weight(n),value(n);
    for(int i=0;i<n;i++)
    {
        cin>>weight[i]>>value[i];
    }
    for(ll x:value)
    {
        sum_value+=x;
    }
    vector<ll> dp(sum_value+1,INF);
    dp[0]=0;
    for(ll item=0;item<n;item++)
    {
      for(ll valuet_alredy=sum_value-value[item];valuet_alredy>=0;valuet_alredy--)
        {
            min_self(dp[valuet_alredy+value[item]],dp[valuet_alredy]+weight[item]);
        }
    }
    ll answer =0;
    for(ll i=0;i<=sum_value;i++)
    {   if(dp[i]<=w)
    {
        answer=max(answer,(ll)i);
    }
      //  min_self(answer,dp[i]);
    }
    cout<<answer<<"\n";
    return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
ab_inputs = [[int(j) for j in input().split()]for i in range(n)]

cost_li = sorted(ab_inputs,key=lambda x:x[0])

ans=0
for c in cost_li:
    if m==0:
        break
    if m<c[1]:
        ans+=c[0]*m
        break
    ans+=c[0]*c[1]
    m-=c[1]
print(ans)


Measured memory_bytes: 23524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
const int MAXN = 2e5+9;
const ll MOD = 1e9+7;

ll fat[MAXN], inv[MAXN];

pll euclid(ll x, ll y){
	if(x==0)return{0,1};
	pll aux = euclid(y%x, x);
	return {aux.second - (y/x)*aux.first, aux.first};
}

ll paths(pll p1, pll p2){//caminhos de p1 ate p2
	ll dx = p2.first - p1.first;
	ll dy = p2.second - p1.second;
	return (((fat[dx+dy]*inv[dx])%MOD)*inv[dy])%MOD;
}

int main(){
	fat[0] = 1; inv[0] = 1;
	fat[1] = 1; inv[1] = 1;
	
	for(ll i=2; i<MAXN; i++){
		fat[i] = (i*fat[i-1])%MOD;
		inv[i] = (euclid(i, MOD).first*inv[i-1])%MOD;
	}
	ll h,w,a,b, ans=0;
	cin >> h >> w >> a >> b;
	for(ll i=1; i <= h-a; i++){//ponto linha i, coluna b
		ans = (ans + ( paths({1,1}, {i,b})*paths({i,b+1}, {h,w}) )%MOD)%MOD;
	}
	if(ans<0)ans += MOD;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3328
N = int(input())
itemList = input().split(' ')
hoge = []
for i in itemList:
    hoge.append(int(i))
hoge.sort()
hoge.reverse()

A = 0
B = 0

for i in range(0, N):
    if i % 2 == 0:
        A += hoge[i]
    else:
        B += hoge[i]

print(A-B)


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

using namespace std;

int K, R, L;
double P, E, T;

double solve(int k, double l, double r)
{
  double H = (l + r) / 2.0;
  if(k == 0) return (fabs(T-H) <= E ? 1.0 : 0.0);
  if(r < T-E || T+E < l) return 0.0;
  if(T-E <= l && r <= T+E) return 1.0;
  if(H <= T) return P*solve(k-1, l, H) + (1.0-P)*solve(k-1, H, r);
  return P*solve(k-1, H, r) + (1.0-P)*solve(k-1, l, H);
}

int main()
{
  cin >> K >> L >> R >> P >> E >> T;
  printf("%.10f\n", solve(K, L, R)); 
  return 0;
}
	 

Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
 	string s;
  	cin >> s;
  	int i,size = s.length(),n = 0,ans[2]{};

   	while(n<size-1){
       	if(s[n]=='0')ans[0]++;
       	if(s[n+1]=='1') ans[0]++;
   		n += 2;
    }
   	if(size%2==1 && s[size-1]=='0') ans[0]++;
  
  	n=0;
  	while(n<size-1){
       	if(s[n]=='1')ans[1]++;
       	if(s[n+1]=='0') ans[1]++;
   		n += 2;
    }
   	if(size%2==1 && s[size-1]=='1') ans[1]++;
  
  	cout << min(ans[0],ans[1]) << endl;
  	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll a,b; cin>>a>>b;
  cout<<(b-a-1)*(b-a)/2-a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
int main() {
	ll x, m = 100;
	int y = 0;
	scanf("%lld", &x);
	while (1) {
		m = m * 1.01;
		y++;
		if (m >= x) {
			break;
		}
	}
	printf("%d\n", y);
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  string s;
  while (cin >> n >> s) {
    const int sheep = 0;
    const int wolf = 1;
    vector<int> v(n, -1);

    auto fn = [&] () {
      for (int i = 0; i < n; ++i) {
        int j = (i - 1 + n) % n;
        int k = (i + 1) % n;
        if (v[i] == sheep) {
          if (s[i] == 'o' && v[j] != v[k]) return false;
          if (s[i] == 'x' && v[j] == v[k]) return false;
        }
        if (v[i] == wolf) {
          if (s[i] == 'x' && v[j] != v[k]) return false;
          if (s[i] == 'o' && v[j] == v[k]) return false;
        }
      }
      return true;
    };

    for (int a = 0; a <= 1; ++a) {
      for (int b = 0; b <= 1; ++b) {
        v[0] = a;
        v[1] = b;
        for (int i = 1; i < n; ++i) {
          const int j = (i - 1 + n) % n;
          const int k = (i + 1) % n;
          if (v[i] == sheep) {
            if (s[i] == 'o') v[k] = v[j];
            else v[k] = v[j] ^ 1;
          }
          if (v[i] == wolf) {
            if (s[i] == 'o') v[k] = v[j] ^ 1;
            else v[k] = v[j];
          }
        }
        if (fn()) a = b = 2;
      }
    }

    if (fn()) {
      each (i, v) {
        if (i == sheep) cout << 'S';
        else cout << 'W';
      }
      cout << endl;
    } else {
      cout << -1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 976
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    int N; cin>>N;
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin>>p[i];
    }
    sort(p.begin(),p.end());

    int sum = 0;
    for (int i = 0; i < N; i++) {
        if(i==N-1){
            sum+=p[i]/2;
        }else{
            sum+=p[i];
        }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
mod = 10**9 + 7
d = (1..n).inject{|sum, x|sum * x % mod }
s = (1..m).inject{|sum, x|sum * x % mod }

if (n - m).abs == 0
  puts d * s * 2 % mod
elsif (n - m).abs == 1
  puts d * s % mod
else
  puts 0
end

Measured memory_bytes: 3836
import math
k = int(input())
s = len(input())

mod = 10**9 + 7

m25 = [] # 25の階乗をmodで割ったあまりを記録する配列
m26 = [] # 26の階乗
m_n = [1] # 逆元を記録する
a = 1
b = 1

for i in range(k+1):
    m25.append(a)
    a *= 25
    a %= mod

for i in range(k+1):
    m26.append(b)
    b *= 26
    b %= mod

for i in range(2,k+s):
    x = mod % i
    y = mod // i
    c = - m_n[x-1] * y
    c %= mod
    m_n.append(c)

samu = 0
fc = 1
for i in range(k):
    sm = fc
    sm *= m25[i]
    sm *= m26[k-i]
    sm %= mod
    samu += sm

    fc *= (s + i)
    fc %= mod
    fc *= m_n[i]
    fc %= mod

sm = fc
sm *= m25[k]
sm %= mod
samu += sm

samu %= mod
print(samu)

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

const int N = 2e5 + 7;
const int H = 2e4;
int dir[4][2] = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
int f[N];

struct OK{
	int t, cost;
	bool operator<(const struct OK &A) const{
		if(A.cost != cost){
			return A.cost > cost;
		}else{
			return A.t < t;
		}
	}
}ok[N];



int main()
{
	ios::sync_with_stdio(false);
	int h, n;
	cin >> h >> n;
	memset(f, -1, sizeof(f));
	for(int i = 0; i < n; i++){
		cin >> ok[i].t >> ok[i].cost;
	}
	f[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = ok[i].t; j < H; j++){
			if(f[j - ok[i].t] == -1)
				continue;
			if(f[j] == -1){
				f[j] = f[j - ok[i].t] + ok[i].cost;
			}else{
				f[j] = min(f[j], f[j - ok[i].t] + ok[i].cost);
			}
		}
	}
	int ans = 0x3f3f3f3f;
	for(int i = h; i < H; i++){
		if(f[i] != -1){
			ans = min(f[i], ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import numpy as np
N,M=map(int,input().split(' '))
AB=[list(map(int,input().split(' '))) for _ in range(N)]

AB=sorted(AB,key=lambda x:x[0])

ans=0
m=0
for x in AB:
  if m+x[1]<M:
    ans+=x[0]*x[1]
    m+=x[1]
  else:
    ans+=x[0]*(M-m)
    break
print(ans)

Measured memory_bytes: 38764
import java.util.*;

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

		long INF = Long.MAX_VALUE/2;
		long ans = INF;
		for(int i=1;i<h+1;i++) {
			
			long s[] = new long[3];
			
			//vertical
			s[0] = (long)i * w;
			s[1] = ((long)h - i) * (w/2);
			s[2] = ((long)h - i) * (w-w/2);
			Arrays.sort(s);
			long res = s[2]-s[0];
			ans = Math.min(ans, res);
			
			//horizon
			int th = (h - i)/2;
			s[0] = (long)i * w;
			s[1] = ((long)th) * w;
			s[2] = ((long)h - i - th) * w;
			Arrays.sort(s);
			res = s[2]-s[0];
			ans = Math.min(ans, res);
		}
		
		//hとwをスワップ
		int tmp = h;
		h = w;
		w = tmp;
		
		for(int i=1;i<h+1;i++) {
			
			long s[] = new long[3];
			
			//vertical
			s[0] = (long)i * w;
			s[1] = ((long)h - i) * (w/2);
			s[2] = ((long)h - i) * (w-w/2);
			Arrays.sort(s);
			long res = s[2]-s[0];
			ans = Math.min(ans, res);
			
			//horizon
			int th = (h - i)/2;
			s[0] = (long)i * w;
			s[1] = ((long)th) * w;
			s[2] = ((long)h - i - th) * w;
			Arrays.sort(s);
			res = s[2]-s[0];
			ans = Math.min(ans, res);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 28500
s = input()
res = []

for i in range(len(s)):
    if s[i] == "0":
        res.append("0")
    elif s[i] == "1":
        res.append("1")
    elif s[i] == "B":
        if len(res) > 0:
            res.pop()

print("".join(res))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	rep(i, 0, N * 2) {
		if ((int)(i * 1.08 + 1e-5) == N) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int h,w;
    while(cin >> h >> w,h*w){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

//ベルマンフォード法で頂点sから各点への最短距離を求める(負の辺があっても動作する)
//計算量 O(E*V)

struct edge{
    int from, to;
    ll cost;
};

const int MAX_V = 3000;
vector<edge> es;
vector<ll> d(MAX_V);

//sから到達可能な負の経路を検出
bool bellman_ford(int s){
    fill(all(d), INF);
    d[s] = 0;
    bool ret = false;
    rep(i, 2*MAX_V){
        for(auto &e: es){
            if(d[e.from] == INF) continue;
            if(chmin(d[e.to], d[e.from]+e.cost)){
                if(i >= MAX_V-1) d[e.to] = -INF, ret = true;
            }
        }
    }
    return ret;
}

//全ての負の閉路を検出
bool negative_loop(){
    fill(all(d), 0);
    rep(i, MAX_V){
        for(auto &e: es){
            if(chmin(d[e.to], d[e.from]+e.cost)){
                if(i == MAX_V-1) return true;
            }
        }
    }
    return false;
}

int main(){
    int V, E, s;
    cin >> V >> E >> s;
    rep(i, E){
        int u, v; ll c;
        cin >> u >> v >> c;
        es.eb((edge){u, v, c});
    }
    if(bellman_ford(s)){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    rep(i, V){
        if(d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();
        for (int i = 0; i <= x; i++) {
            if (y == 2 * i + 4 * (x - i)) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 32712