akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

int main(){
    int N, C, K;
    std::cin >> N >> C >> K;
    std::vector<int> T;
    for (int i = 0; i < N; i++) {
        int j;
        std::cin >> j;
        T.push_back(j);
    }
    std::sort(T.begin(), T.end());
    int count = 1;
    int start = T.at(0);
    int num = 1;
    for (int i = 1; i < N; i++) {
        int j = T.at(i);
        if (j > start + K || num >= C) {
            start = j;
            num = 1;
            count++;
        } else {
            num ++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <map>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    std::map<std::string, int> seqLen;
    int n;
    cin >> n;
    int maxs=0;
    string s;
     for(int i=0;i<n;i++){
         cin>>s;
         seqLen[s]++;
    }
    int mx=-1;
    for(auto p: seqLen) mx=max(mx,p.second);
    for(auto p: seqLen){
        if(p.second != mx)continue;
        cout << p.first << endl;
    }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


int main() {
    ll n, m;
    cin >> n >> m;
    
    ll ans = 0;
    ll tmp = min(n, m / 2);
    ans += tmp;
    n -= tmp;
    m -= tmp * 2;
    cout << ans + m / 4 << endl;
}


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

using namespace std;

int main(){
    long long int N,M,sum=0,ans=0;
    cin >> N >> M;
    vector<long long int> A(N);
    map<long long int,long long int> mp;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    mp[A[0]%M]++;
    sum = A[0]%M;

    for(int i=1;i<N;i++){
        sum += A[i];
        sum %= M;
        mp[sum]++;
    }

    for(auto itr = mp.begin();itr!=mp.end();itr++){
        ans += itr->second*(itr->second-1)/2;
    }

    cout << ans + mp[0] << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;
  long double b;
  cin >> a >> b;
  // if(a % 10 == 0) b *= 10, a /= 10;
  // if(a % 10 == 0) b *= 10, a /= 10;
  // cout << a << endl;
  // cout << b << endl;
  ll res = a * b;
  cout << res << endl;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

const vector<ll> nmatch = {2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> as(m, 0);
    for(int i = 0; i < m; ++i){
        cin >> as.at(i);
    }
    sort(as.begin(), as.end(), greater<ll>());

    vector<ll> dp(n + 1, -n);
    dp.at(0) = 0;
    for(ll i = 1; i <= n; ++i){
        for(ll a : as){
            if(nmatch.at(a - 1) <= i){
                dp.at(i) = max(
                    dp.at(i),
                    dp.at(i - nmatch.at(a - 1)) + 1
                );
            }
        }
    }

    ll cur = n;
    while(cur != 0){
        for(ll a : as){
            if(cur >= nmatch.at(a - 1) &&
               dp.at(cur) == dp.at(cur - nmatch.at(a - 1)) + 1){
                cout << a;
                cur -= nmatch.at(a - 1);
                break;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int d, t,s;
  cin>>d>>t>>s;
  int dd = t*s;
  if (dd < d) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=500010;
int n,a[N],len,f[N],o[N];
int main(){
	n=gi();for(int i=1;i<=n;i++)a[i]=gi();
	for(int i=n;i;i--){
		if(f[len]<=a[i])f[++len]=a[i];
		else{
			int k=upper_bound(f+1,f+len+1,a[i])-f;
			f[k]=a[i];
		}
	}
	printf("%d\n",len);
	return 0; 
}


Measured memory_bytes: 2560
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a = INT()
if a == 0:
    print(1)
else:
    print(0)

Measured memory_bytes: 10588
#include<cstdio>
#include<algorithm>
using namespace std;
int n,Sum[300005],Ans=1e9;
char ch[300005];
int main(){
	scanf("%d",&n);gets(ch);gets(ch);
	for(int i=0;i<n;i++) Sum[i+1]=Sum[i]+(ch[i]=='W');
	for(int i=1;i<=n;i++){
		int Left=Sum[i-1],Right=Sum[n]-Sum[i];
		Ans=min(Ans,Left+n-i-Right);
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 1664
import math

a,b,h,m = map(float,input().rstrip().split())
rad_h = 2*math.pi/12*(h+m/60)
rad_m = 2*math.pi/60*m

delta_theta = abs(rad_m - rad_h)
if delta_theta > math.pi:
    delta_theta = 2*math.pi-delta_theta
c = math.sqrt(a*a + b*b - 2*a*b*math.cos(delta_theta))
print(c)

Measured memory_bytes: 9324
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(long long i=0; i<x;i++)
#define mod 1000000007
#define INF 10000000000000000
typedef long long 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; }


int main(){
  ios::sync_with_stdio(false);
  
  ll N;
  cin>>N;
  
  ll a[N];
  rep(i,N) cin>>a[i];
  
  ll dp[N+1][N+1];
	rep(i,N)rep(j,N) dp[i][j] = 0;  
  for(int len=1;len<N;len++){
  	for(int j=0;j<N-len;j++){
      ll sum =0;
      ll tmp = INF;
      for(int k = j; k<j+len;k++){
      	tmp = min(tmp,dp[j][k] + dp[k+1][j+len]);
        sum+=a[k];
      }
      sum+=a[j+len];
      dp[j][j+len] = tmp+sum;
    }
  }
  
  cout<<dp[0][N-1];
  
}

Measured memory_bytes: 1536
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    string S;

    cin >> S;

    int n = S.length();

    int l = -1;
    int r = -1;

    for (int i = 0; i + 1 < n; ++i) {
        if (S[i] == S[i + 1]) {
            l = i;
            r = i + 1;
            break;
        }
        if (i + 2 < n) {
            if (S[i] == S[i + 2]) {
                l = i;
                r = i + 2;
                break;
            }
        }
    }

    if (l >= 0) {
        ++l, ++r;
    }
    cout << l << " " << r << "\n";


    return 0;
}

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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int tot = 60*(h2 - h1) + m2 - m1;
	int ans = tot - k;
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

  ll ans = 0;
  for (ll m = 1; m*m <= N; ++m) {
    if (N%m != 0) continue;

    if (m != 1 and N/(m-1) == N%(m-1)) ans += m-1;

    if (N == m*m) continue;

    ll mm = N/m;
    if ((N/(mm-1) == (N/(mm-1))%(mm-1))) ans += mm-1;
  }

  cout << ans << endl;
}

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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

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

    rep(i,n) cin >> a[i];

    int l,r=0;
    if(k > 50){
        k = 50;
    }

    rep(i,k){
        rep(j,n){
            l = j-a[j];
            r = j+a[j]+1;
            if(l < 0) l = 0;
            if(r > n) r = n;
            tmp[l]++;
            tmp[r]--;
        }
        
// rep(i,n){
//             cout << tmp[i] << " ";
//         }
//         cout << endl;

        reps(j,1,n){
            tmp[j] += tmp[j-1];
        }
        
        rep(j,n){
            a[j] = tmp[j];
            tmp[j] = 0;
        }
    }

    rep(i,n) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}

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

int main(){
	int     a,b,c   ;
	int A,B,C,x,y,z;
	
	cin>>  a>>b>>c ;
	A = a*3600 + b*60 + c;
	cin>>  a>>b>>c    ;
	B = a*3600 + b*60 + c;
	C = B-A;
	if(C>3600)x= C/3600;
	else x = 0;
	C -= x*3600;
	if(C>60 )y = C/60;
	else y = 0;
	C -= y*60;
	z = C;
	cout <<  x <<" "<<y<<" "<<  z<<endl;
	
	cin>>  a>>b>>c ;
	A = a*3600 + b*60 + c;
	cin>>  a>>b>>c    ;
	B = a*3600 + b*60 + c;
	C = B-A;
	if(C>3600)x= C/3600;
	else x = 0;
	C -= x*3600;
	if(C>60 )y = C/60;
	else y = 0;
	C -= y*60;
	z = C;
	cout <<  x <<" "<<y<<" "<<  z<<endl;
	
	cin>>  a>>b>>c ;
	A = a*3600 + b*60 + c;
	cin>>  a>>b>>c    ;
	B = a*3600 + b*60 + c;
	C = B-A;
	if(C>3600)x= C/3600;
	else x = 0;
	C -= x*3600;
	if(C>60 )y = C/60;
	else y = 0;
	C -= y*60;
	z = C;
	cout <<  x <<" "<<y<<" "<<  z<<endl;

	
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int x, y;
    cin >> x >> y;
    if (x * 2 == y || x * 4 == y) {
        cout << "Yes\n";
        return 0;
    }
    int cnt = 0;
    for (int i = 1; i <= x; i++) {
        int a = i - 1;
        int b = x - i + 1;
        int legs = (a * 2) + (b * 4);
        if (legs == y) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll,ll> a;
    ll k;
    rep(i,n){
        cin >> k;
        a[k]++;
    }
    int cnt = 0;
    for(auto i = a.begin();i != a.end();i++){
        if ((*i).second%2) cnt++;
    }
    PRINT(cnt);
}


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

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>>G(h,vector<int>(w,0));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin >> c;
            if(c=='#'){
                G[i][j]=1;
            }
        }
    }
    int ans=0;
    for(int bit_a=0;bit_a<(1<<h);bit_a++){
        for(int bit_b=0;bit_b<(1<<w);bit_b++){
            int black=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(bit_a&(1<<i) && bit_b&(1<<j)){
                        black+=G[i][j];
                    }
                }
            }
            if(black==k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}
  


Measured memory_bytes: 3532
#include <iostream>
using namespace std;
const long long mod = 1e9+7;
int main(void){
    long long N;
    cin >> N;
    long long ans = 1;
    for(long long i=1;i<=N;i++){
        ans = (ans * i) % mod;
    }
    cout << ans << endl;
}


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

const int MAX_D = 100;

int main() {
    int n;
    cin >> n;
    vector<int> flag(MAX_D);
    rep(i, n){
        int d;
        cin >> d;
        flag.at(d - 1) = 1;
    }
    int answer = 0;
    rep(i, MAX_D){
        if(flag.at(i)){
            answer++;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 3576
V = list(input())
N = len(V) - 1
for bit in range(1 << N):
    op = ['+' if bit & (1 << i) else '-' for i in range(N)]
    s = V[0] + op[0] + V[1] + op[1] + V[2] + op[2] + V[3]
    # print(s)
    if eval(s) == 7:
        print(s + '=7')
        exit()


Measured memory_bytes: 3064
import numpy as np

A = []
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))
A.append(int(input()))

A = np.array(A)
tmp = (A-1) % 10 + 1
idx = np.argmin(tmp)

res = A[idx]
A = np.delete(A, idx)
res += (np.sum(np.ceil(A/10)*10))
print(int(res))


Measured memory_bytes: 21520
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector<long long> a;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        a.push_back(s);
    }
    sort(a.begin(),a.end(),greater<int>());
    long long e1=-1,e2=-1,count=0,now=0;
    int i;
    for(i=0;i<n;i++){
        if(e1!=-1&&e2!=-1)break;
        if(a[i]==a[now])count++;
        else{
            //cout<<count<<endl;
            if(count>=4&&e1==-1){
                e1=a[now];
                e2=a[now];
            }
            if(count>=2){
                if(e1==-1){
                    e1=a[now];
                }
                else e2=a[now];
            }
            count=1;
            now=i;
        }
    }
    if(e1==-1||e2==-1){
        if(count>=4&&e1==-1){
            e1=a[now];
            e2=a[now];
        }
        if(count>=2){
            if(e1==-1){
                e1=a[now];
            }
            else e2=a[now];
        }
    }
    long long ans=e1*e2;
    if(e1==-1||e2==-1)cout<<0<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#define N 100005
#define F first
#define S second
using namespace std;

int n, t, h, mx, cnt, num, a[N];
map<int, int> c;
pair<int, int> b[N];
bool v[N];
int main()
{
    int i;
//    freopen ("input.txt", "r", stdin);
    cin >> n >> t;
    for (i = 0; i < n; i++) {
        scanf ("%d", &a[i]);
        b[i].F = a[i];
        b[i].S = i;
//        h = max(h, a[i]);
    }
    sort(b, b + n);
    for (i = 0; i < n; i++) {
        c[b[i].F] = i;
    }
    h = n - 1;
    mx = -2e9;
    for (i = 0; i < n; i++) {
        v[c[a[i]]] = true;
        while (h >= 0) {
            if (!v[h]) break;
            h--;
        }
        num = 0;
        if (h >= 0 && mx < b[h].F - a[i]) {
            mx = b[h].F - a[i];
            cnt = 1;
        } else if (h >= 0 && mx == b[h].F - a[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6144
# include <bits/stdc++.h>
# define int long long
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int f1[N], f2[N];
int bin_pow(int x, int y){
    int ans = 1, cur = x;
    while(y){
        if(y & 1){
            ans = ans * cur % mod;
        }
        cur = cur * cur % mod;
        y >>= 1;
    }
    return ans;
}
main(){
    int n, a, b;
    cin >> n >> a >> b; 
    int all = bin_pow(2, n) - 1;
    int mx = max(a, b);
    f1[0] = 1;
    f2[0] = n;
    for(int i = 1; i <= mx; i++)f1[i] = f1[i - 1] * i % mod;
    for(int i = 1; i <= mx; i++)f2[i] = f2[i - 1] * (n - i) % mod; 
    int A = f2[a - 1] * bin_pow(f1[a], mod - 2) % mod;
    int B = f2[b - 1] * bin_pow(f1[b], mod - 2) % mod;
    int ans = all - A - B + 5 * mod;
    cout << ans % mod << endl;
    
}

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

char s1[2000];
char s2[2000];

int LCS(int,int);

int main(){
  int sumstring;
  int i, j, k;
  scanf("%d",&sumstring);

  for(i = 0; i < sumstring; i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",LCS(strlen(s1),strlen(s2)));
  }

  return 0;
}

int LCS(int len1, int len2){

  int i, j, a;
  int answer[1001][1001];

  a = 0;

  for(i = 0; i < len1; i++){
    answer[i][0] = 0;
  }

  for(i = 0; i < len2; i++){
    answer[0][i] = 0;
  }
  for(i = 0; i < len1; i++){
    for(j = 0; j < len2; j++){
      if(s1[i]==s2[j] && s1[i]!=' ' && s2[i] != ' '){
        if(i == 0 || j == 0){
          answer[i][j] = 1;
        }
        else{
          answer[i][j] = answer[i-1][j-1]+1  ;
        }
      }

      else{
        if(i == 0 && j != 0){
          answer[i][j] = answer[0][j-1];
        }
        else if(i !=0 && j == 0){
          answer[i][j] = answer[i-1][0];
        }
        else if(i == 0 && j == 0){
          answer[0][0] = 0;
        }
        else if(i != 0 && answer[i-1][j] > answer[i][j-1]){
          answer[i][j] = answer[i-1][j];
        }
        else if(answer[i-1][j] <= answer[i][j-1]){
          answer[i][j] = answer[i][j-1];
        }
      }
    }
  }
  return answer[len1-1][len2-1];
}



Measured memory_bytes: 5684
#include<stdio.h>

#define MAX 100001

int main(void)
{
   int i,n,k,a[MAX],S,s;
   
   while(1)
   {
    scanf("%d%d",&n,&k);
	if(n==0 && k==0) break;
    a[0]=0;
    for(i=1;i<=n;i++)
    {
    	scanf("%d",&a[i]);
    }
	S=0;
    for(i=1;i<=k;i++)
    {
    	S+=a[i];
    }
	s=S;
	for(i=k+1;i<=n;i++)
	{
		s+=a[i]-a[i-k];
		if(s>S) S=s;
	}
	printf("%d\n",S);
   }
   return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

const int MAXN = 205000;

int n;
int d[MAXN];
long long c[MAXN];

int main() {
  //assert(freopen("input.txt","r",stdin));
  //assert(freopen("output.txt","w",stdout));

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d %lld", &d[i], &c[i]);
  }

  int cur = 0;
  long long ans = 0;

  for (int i = 0; i < n; i++) {
    int count = 0;
    int cost = 0;
    bool cycled = false;

    map<int, pair<int, int> > mp;

    while (c[i] > 0) {
      if (!cycled) {
        count++;
      }
      c[i]--;
      
      cur = cur + d[i];
      if (!cycled) {
        cost++;
      }
      ans++;

      while (cur >= 10) {
        cur = cur / 10 + cur % 10;
        if (!cycled) {
          cost++;
        }
        ans++;
      }

      if (cycled) {
        continue;
      }

      if (mp.count(cur)) {
        int cycleCost = cost - mp[cur].first;
        int cycleLen = count - mp[cur].second;

        ans += 1ll * cycleCost * (c[i] / cycleLen);
        c[i] %= cycleLen;
        cycled = true;
      } else {
        mp[cur] = make_pair(cost, count);
      }
    }

    // cerr << ans << endl;
  }

  cout << ans - 1 << endl;

  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
using namespace std;
int main(){
    int N;
    double sum;
    cin >> N;
    double a[N];
    string u[N];
    for(int i=0;i<N;i++){
        cin >> a[i] >> u[i];
        if (u[i] == "JPY"){
            sum += a[i];
        }else if(u[i] == "BTC"){
            sum += a[i]*380000;
        }
    }
    cout << sum << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define size(x) int(x.size())
typedef long long ll;
using namespace std;
int main(){
    int M,D; cin >> M >> D;
    int ans = 0;
    REP(i,M){
        for(int j = 2; j<= 9; j++){
            for(int k=2;k<=9;k++){
                
                if((i+1 == j*k) && ((10*j+k) <= D)){
                    ans++;
                }
            }
        }
    }

    cout << ans <<endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

grid = [input() for _ in range(H)]
# print(grid)

dp = [[0 for _ in range(W + 1)]for _ in range(H + 1)]
# print(dp)

dp[1][1] = 1
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if not (i == 1 and j == 1):
            if grid[i - 1][j - 1] == "#":
                dp[i][j] = 0
            else:
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (10**9 + 7)

# print(dp)
ans = dp[-1][-1]
print(ans)


Measured memory_bytes: 83640
import math
N = int(input())
lsa = list(map(int,input().split()))
lcm = lsa[0]
for i in range(1,N):
    lcm = lcm*lsa[i]//math.gcd(lcm,lsa[i])
m = lcm-1
ans = 0
for i in range(N):
    ans += m % lsa[i]
print(ans)

Measured memory_bytes: 9280
n = int(input())
s = sorted([list(input()) for _ in range(n)], key=len)

ans = []
for i in s[0]:
  t = float("inf")
  for j in s:
    t = min(t, j.count(i))
  ans.append(i*t)
ans = sorted(list(set(ans)))
print("".join(ans))

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

using namespace std;

int main(){
  map<char, char> mp{{'A', 'T'}, {'T', 'A'}, {'C', 'G'}, {'G', 'C'}};
  char b;
  cin >> b;
  cout << mp[b] << endl;  
  return 0;
}

Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    ll ans = 0;
    int n, l, wa[2002] = {};
    vector <int> le(2000);
    cin >> n;
    REP(i,n){
        cin >> l;
        le[i] = l;
    }
    sort(le.begin(), le.begin()+n);
    wa[0] = 0;
    REP(i, n){
        wa[le[i]]++;
    }
    REP1(i, 2001){
        wa[i] = wa[i-1] + wa[i];
    }
    //REP(i, 8) cout << wa[i] << " ";
    REP(i, n){
        for(int j = i+1; j<n; j++){
            int a = le[i];
            int b = le[j];
            int mi = abs(b-a);
            int ma = a+b;
            ans += wa[ma-1] - wa[mi];
            if(mi < a && a < ma && ans>0)ans--;
            if(mi < b && b < ma && ans>0)ans--;
            
        }
    }
    cout << ans/3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    long long ans=0;
    string s;
    cin>>s;
    rep(i,s.size()-1) if(s[i]=='B'&&s[i+1]=='C') s.erase(s.begin()+i,s.begin()+i+2),s.insert(s.begin()+i,'X');
    int i=0,b,c=0;
    while(i<s.size()){
        b=0,c=0;
        while(s[i]=='A'||s[i]=='X'){
            if(s[i]=='X') b++,ans+=c-b+1;
            i++;c++;
        }
        i++;
    }
    cout<<ans;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    string S;
    cin >> S;

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
import * as fs from 'fs';
const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');
const n = +input[0];
const a = [];
let result = true
for(let i = 0; i < n; i++){
  a.push(input[i+1].split(' ').map((x: string): number => +x));
  const [ti, xi, yi] = a[i]
  const [tj, xj, yj] = i === 0 ? [0, 0, 0] : a[i-1]
  const dt = ti - tj
  const dist = Math.abs(xi - xj) + Math.abs(yi - yj);
  if (dt < dist) {
    result = false;
    break;
  }
  if (dist % 2 != dt % 2) {
    result = false;
    break;
  }
}
console.log(result ? 'Yes' : 'No');

Measured memory_bytes: 50508
#ifdef _WIN32
#include "XOR.h"
#endif

#include <stdio.h>

#include <iostream>
#include <vector>
#include <array>

constexpr int64_t MOD = 1'000'000'007;
constexpr int64_t help = 1;

#define ll long long int

void fastscan(ll& number) {
	//variable to indicate sign of input number 
	int c;

	number = 0;

	// extract current character from buffer 
	c = getchar();

	// Keep on extracting characters if they are integers 
	// i.e ASCII Value lies from '0'(48) to '9' (57) 
	for (; (c > 47 && c < 58); c = getchar())
		number = number * 10 + c - 48;

	// if scanned input has a negative sign, negate the 
	// value of the input number 
}
#ifdef _WIN32
namespace XOR
{
#endif 

	int main() {
		ll n;

		fastscan(n);


		std::array<ll, 62> bits{};
		for (ll i = 0; i < n; i++) {
			ll d;
			fastscan(d);
			for (ll b = 0; b < 62; b++) {
				bits[b] += !!(d & (help << b));
			}
		}

		ll ans = 0;

		for (ll b = 0; b < 62; b++) {
			ll p = (help << b) % MOD;
			ans += (bits[b] * (n - bits[b]) % MOD) * p;
			ans %= MOD;
		}

		std::cout << ans;
	}
#ifdef _WIN32
}
#endif 


Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 3001;
int dp[N][N] = {};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t, s;
	cin >> n >> t >> s;
	
	int a, b;
	for(int i = 1; i <= n; ++i){
		cin >> a >> b;
		for(int j = 1; j <= t; ++j){
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if(j >= b && !(j - b < s && j > s))
				dp[i][j] = max(dp[i][j], dp[i - 1][j - b] + a);
		}
	}

	cout << dp[n][t] << endl;
	
	return 0;
}

Measured memory_bytes: 36372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>

using namespace std;


//BEGIN
template <unsigned long long MOD = 1000000007, unsigned long long base = 2009>
struct RollingHash {
	vector<unsigned long long> hash, power;

	RollingHash() {}
	RollingHash(const string& s) {
		int n = s.size();
		hash.assign(n + 1, 0);
		power.assign(n + 1, 1);
		for (int i = 0; i < n; ++i) {
			hash[i + 1] = (hash[i] * base + s[i]) % MOD;
			power[i + 1] = power[i] * base % MOD;
		}
	}
	
	unsigned long long get(int l, int r) {
		unsigned long long res = hash[r] + MOD - (hash[l] * power[r - l] % MOD);
		return res - (res >= MOD ? MOD : 0);
	}

	int LCP(const RollingHash<MOD, base>& b, int l1, int r1, int l2, int r2) {
		int len = min(r1 - l1, r2 - l2);
		int low = -1, high = len + 1;
		while (high - low > 1) {
			int mid = (low + high) / 2;
			if (get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
			else high = mid;
		}
		return low;
	}
};
//END


int main() {
	string T, P; cin >> T >> P;
	RollingHash<> rht(T), rhp(P);
	auto pval = rhp.get(0, P.size());
	for (int i = 0; i + P.size() <= T.size(); ++i)
		if (rht.get(i, i + P.size()) == pval)
			printf("%d\n",i);

	return 0;
}
/*
	created: 2019-11-12
	https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/14/ALDS1_14_B
*/


Measured memory_bytes: 19772
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	string s;cin>>s;
	rep(i,len(s)){
		if(s[i]=='?')s[i]='D';
	}
	cout<<s<<endl;
}


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str1,str2;
  cin>>str1>>str2;
  int cnt=0;
  for(int i=0;i<str1.size();i++)
  {
    if(str1[i]==str2[i])
    {
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

int n;
int v[2001];
bitset <4000001> b;

inline void getBit() {
    b[0] = 1;
    for (int i = 1; i <= n; ++i)
        b |= (b << v[i]);
    int MAX = 0;
    for (int i = 1; i <= n; ++i)
        MAX += v[i];
    int p = (MAX >> 1) + (MAX & 1);
    while (p && !b[p])
        ++p;
    cout << p;
}

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

    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> v[i];
    getBit();
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=200005;
int inv[maxn],q[maxn],p[maxn],n;
int mini1[maxn][20],mini2[maxn][20],tot1,tot2;
priority_queue<pair<int,pin>,vector<pair<int,pin> >,greater<pair<int,pin> > >heap;
inline int query(int a[][20],int l,int r){
	int tmp=log2(r-l+1);
	return min(a[l][tmp],a[r-(1<<tmp)+1][tmp]);
}
inline void add(int l,int r){
	if(l>r)return;
	assert((l&1)!=(r&1));
	int mini;
	if(l&1)
		mini=query(mini1,(l+1)/2,(r+1)/2);
	else
		mini=query(mini2,l/2,r/2);
	heap.push(mk(mini,mk(l,r)));
}
int main(){
	read(n);
	rep(i,1,n)read(p[i]),inv[p[i]]=i;
	rep(i,1,n){
		if(i&1)
			mini1[(i+1)/2][0]=p[i],tot1=(i+1)/2;
		else
			mini2[i/2][0]=p[i],tot2=i/2;
	}
	rep(j,1,19)rep(i,1,n-(1<<j)+1){
		mini1[i][j]=min(mini1[i][j-1],mini1[i+(1<<(j-1))][j-1]);
		mini2[i][j]=min(mini2[i][j-1],mini2[i+(1<<(j-1))][j-1]);	
	}add(1,n);
	for(int i=1;i<=n;i+=2){
		fprintf(stderr,"%d\n",i);
		pair<int,pin> x=heap.top();heap.pop();
		int l=x.w2.w1,r=x.w2.w2;
		q[i]=x.w1;
		int stplace=inv[q[i]],v2;
		if(l&1){
//			fprintf(stderr,"%d %d\n",(stplace+1)/2,(r-1)/2);
			v2=query(mini2,(stplace+1)/2,(r)/2);
		}else{
		//	fprintf(stderr,"%d %d\n",(stplace+2)/2,(r-1)/2);
			v2=query(mini1,(stplace+2)/2,(r+1)/2);
		}
		q[i+1]=v2;int edplace=inv[v2];
		add(l,stplace-1);
		add(stplace+1,edplace-1);
		add(edplace+1,r);
	}
	rep(i,1,n)printf("%d ",q[i]);
	return 0;
}


Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2345;
int upto[maxn][maxn], sz[maxn], k;
vector<int> e[maxn];
vector<pair<int,int> > eds;
int count(int u, int v, int d){
	if(d < 0) return 0;
	int ans = 1;
	for(int nxt : e[u]) if(nxt != v) ans += count(nxt, u, d - 1);
	return ans;
}
int main(){
	int n; cin >> n >> k;
	for(int i = 0; i < n - 1; i++){
		int x, y; 
		cin >> x >> y;
	       	eds.push_back({x, y});	
		e[x].push_back(y); 
		e[y].push_back(x);
	}
	int res = 0;
	for(int i = 1; i <= n; i++) {
		res = max(res, count(i, 0, k/2));
	}
	for(auto e : eds){
		res = max(res, count(e.first, e.second, (k - 1)/2) + count(e.second, e.first, (k - 1)/2));
	}
	cout << n - res << endl;
	return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


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

    vector<int>a(n+2);
    rep2(i,1,n)cin>>a[i];

    vector<int>l(n+2),r(n+2);
    l[0]=a[0];
    r[n+1]=a[n+1];

    rep2(i,1,n+1)l[i]=__gcd(l[i-1],a[i]);
    repr(i,n,1)r[i]=__gcd(r[i+1],a[i]);

    int ans=0;

    rep2(i,1,n){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		if (s == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a + b);
		}
		sc.close();
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define Pi pair<int,int>
#define all(V) V.begin(),V.end()

int R;
set<int> ans;
stack<int> st;
vector<int> r(8);
vector<vector<pair<int, int>>> T(200);
vector<vector<int>> Cost(200, vector<int>(200, -1));

void sts() {
	auto sta = st;
	int a, b, c = 0;
	while (1) {
		a = sta.top();
		sta.pop();
		if (sta.empty()) break;
		b = sta.top();
		c += Cost[a][b];
	}
	ans.insert(c);
}

void Pa(set<int> E) {
	for (int i = 0;i < R;i++) {
		if (E.count(r[i])) continue;
		E.insert(r[i]);
		st.push(r[i]);
		Pa(E);
		if (st.size() == R) sts();
		st.pop();
		E.erase(r[i]);
	}
}

int main() {
	int N, M, a, b, c;
	cin >> N >> M >> R;
	for (int i = 0;i < R;i++) {
		cin >> a;
		r[i] = a - 1;
	}
	for (int i = 0;i < M;i++) {
		cin >> a >> b >> c;
		a--;b--;
		T[a].push_back({ c,b });
		T[b].push_back({ c,a });
	}
	priority_queue<Pi, vector<Pi>, greater<Pi>> Q;
	Pi p;
	for (int i = 0;i < N;i++) {
		Q.push({ 0,i });
		while (!Q.empty()) {
			a = Q.top().first;
			b = Q.top().second;
			Q.pop();
			if (Cost[i][b]<0 || Cost[i][b]>a) {
				Cost[i][b] = a;
				for (Pi k : T[b])
					Q.push({ a + k.first,k.second });
			}
		}
	}
	Pa({});
	//for (int i : ans) cout << i << endl;
	//cout << ans.size() << endl;
	cout << *(ans.begin()) << endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int a, b;

int main() {
	cin >> a >> b;
	
	cout << (a <= 5 ? 0 : (a <= 12 ? b / 2 : b)) << endl;
	
	return 0;
}


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

int h;

int parent(int i) {
    return i / 2;
}

int left(int i) {
    return i * 2;
}

int right(int i) {
    return i * 2 + 1;
}

void maxheapify(vector<int> &T, int i) {
    int l = left(i);
    int r = right(i);
    int MAX;
    if (l <= h && T.at(l) > T.at(i)) {
        MAX = l;
    } else {
        MAX = i;
    }
    if (r <= h && T.at(r) > T.at(MAX)) {
        MAX = r;
    }

    if (MAX != i) {
        swap(T.at(i), T.at(MAX));
        maxheapify(T, MAX);
    }
}

void buildMaxHeap(vector<int> &T) {
    for (int i = h / 2; i >= 1; i--) {
        maxheapify(T, i);
    }
}

int main() {
    cin >> h;
    vector<int> T(h + 1);
    for (int i = 1; i <= h; i++) {
        cin >> T.at(i);
    }

    buildMaxHeap(T);

    for (int i = 1; i <= h; i++) {
        cout << " " << T.at(i);
        
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 4592
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int X, A, B;
  cin>>X>>A>>B;
  Int N;
  cin>>N;
  for(Int i=0;i<N;i++){
    string s;
    cin>>s;
    if(s[0] == 'n'){
      X += A;
    }
    if(s[0] == 't'){
      X += B;

    }
    if(s[0] == 'k'){
      X = 0;
    }
    Max(X, (Int)0);
  }
  cout<<X<<endl;

  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3030, mod = 1'000'000'007;
int f[maxn][maxn][2];
void upd(int i, int j, int k, int v){
	f[i][j][k] += v;
	if(f[i][j][k] >= mod) f[i][j][k] -= mod;
}
int main(){
	int n, m; cin >> n >> m;
	for(int i = 1; i <= n; i++) f[0][i][0] = 1;
	f[0][0][1] = 1;
	for(int i = 0; i < m; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < 2; k++){
				if(f[i][j][k]){
					if(j != n){
						upd(i + 1, j + 1, k, f[i][j][k]);
						upd(i + 1, j, k, f[i][j][k]);
					}	
					if(j){
						upd(i + 1, j - 1, k | (j == 1), f[i][j][k]);
						upd(i + 1, j, k | (j == 1), f[i][j][k]);
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= n; i++){
		ans += f[m][i][1];
		if(ans >= mod) ans -= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 71936
#include <stdio.h>
#pragma warning(disable : 4996)

int main(){

	int i = 0, x = 0, y = 0, tmp = 0;

	for (i = 1; 1; i++){
		scanf("%d %d", &x, &y);
		if ((x == 0) && (y == 0)){
			break;
		}
		if (x > y){
			tmp = x;
			x = y;
			y = tmp;
		}
		printf("%d %d\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

constexpr ll MOD = 1e9 + 7;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, MOD - 2) % MOD;
}

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % MOD);
}

int n;
vector<vector<int>> graph;

struct data {
    int size;
    ll ret;
};

vector<data> fromLeaf;
vector<data> fromRoot;

data dfs(int here, int prev) {
    int count = 0;
    ll ret = 1;
    for (auto next:graph[here]) {
        if (next == prev)continue;

        auto a = dfs(next, here);
        ret *= a.ret, ret %= MOD;
        ret *= calc_comb(count + a.size, a.size), ret %= MOD, count += a.size;
    }

    count++;
    fromLeaf[here] = {count, ret};
    return {count, ret};
}

void dfs2(int here, int prev) {
    for (auto next:graph[here]) {
        if (next == prev)continue;
        data others = {
                fromLeaf[here].size - 1 - fromLeaf[next].size,
                calc_div(calc_div(fromLeaf[here].ret, fromLeaf[next].ret),
                         calc_comb(fromLeaf[here].size - 1, fromLeaf[next].size))
        };
        fromRoot[next].size = fromRoot[here].size + others.size + 1;
        fromRoot[next].ret = fromRoot[here].ret * others.ret % MOD;
        fromRoot[next].ret *= calc_comb(fromRoot[here].size + others.size, others.size), fromRoot[next].ret %= MOD;
        dfs2(next, here);
    }
}

int main() {
    init_fact(4000000);

    cin >> n;
    graph.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b, a--, b--;
        graph[a].push_back(b), graph[b].push_back(a);
    }

    fromLeaf.resize(n), dfs(0, -1);
    fromRoot.resize(n), fromRoot[0] = {0, 1}, dfs2(0, -1);

    for (int i = 0; i < n; i++) {
        ll ret = fromLeaf[i].ret * fromRoot[i].ret % MOD;
        ret *= calc_comb(n - 1, fromLeaf[i].size - 1), ret %= MOD;
        cout << ret << endl;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 51444