akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

double dp[150000], ans[150000];
vector<int>E[150000];
double dfs(int v, int p) {
	double ans = 0;
	for (int u : E[v]) {
		if (u != p)ans += (dfs(u, v) + 1) / double(E[v].size() - (p != -1));
	}
	return dp[v] = ans;
}
void dfs2(int v, int p) {
	if (p == -1)ans[v] = dp[v];
	else {
		if (E[p].size() == 1)ans[v] = 1. / E[v].size() + dp[v] * (E[v].size() - 1) / E[v].size();
		else if (E[v].size() == 1) {
			ans[v] = (ans[p] * E[p].size() - dp[v] - 1) / (E[p].size() - 1) + 1;
		}
		else {
			ans[v] = ((ans[p] * E[p].size() - dp[v] - 1) / (E[p].size() - 1) + 1) / E[v].size() + dp[v] * (E[v].size() - 1) / E[v].size();
		}
	}
	for (int u : E[v]) {
		if (u != p)dfs2(u, v);
	}
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n - 1) {
		int u, v; scanf("%d%d", &u, &v); u--; v--;
		E[u].push_back(v); E[v].push_back(u);
	}
	dfs(0, -1); dfs2(0, -1);
	rep(i, n)printf("%.12lf\n", ans[i]);
}

Measured memory_bytes: 18816
#include <cstdio>
#include <utility>
#include <unordered_set>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for(char c:s)pcu(c);}
//_vo(string s){for(char c:s)pcu(c);}
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
//_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	unordered_set<int> A;
	for (int i = in(); i; i--)
		if (in() == 0) {
			A.insert(in());
			outl(A.size());
		} else
			outl(A.count(in()));
}


Measured memory_bytes: 10432
n=int(input())
l,dp=[],[]
for i in range(n):l.append(list(map(int,input().split())))
dp.append(l[0])
for i in range(1,n):
	x=[0]*3
	x[0]=l[i][0]+max(dp[i-1][1],dp[i-1][2])
	x[1]=l[i][1]+max(dp[i-1][0],dp[i-1][2])
	x[2]=l[i][2]+max(dp[i-1][0],dp[i-1][1])
	dp.append(x)
print(max(dp[-1]))

Measured memory_bytes: 99160
#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main(){
  int K;
  int S;
  cin >> K >> S;
  int Sx,Sy;
  int count=0;

  for(int i=0;i<=K;i++){
    Sx=S-i;
    for(int j=0;j<=K;j++){
      Sy=Sx-j;
      if((K>=Sy)&&(Sy>=0)){
	count=count+1;
      } 
    }
  }
  cout << count << endl;
  

  return 0;
}

Measured memory_bytes: 256
n = int(input())


def prime_factorization(n):
    pmax = int(n ** 0.5 // 1) + 1

    factors = {}
    for p in range(2, pmax + 1):
        while n % p == 0:
            factors[p] = factors.get(p, 0) + 1
            n //= p
    if n != 1:
        factors[n] = factors.get(n, 0) + 1

    return factors


factors = prime_factorization(n)

answer = 0
for power in factors.values():
    n = 1
    while (n + 1) * (n + 2) // 2 <= power:
        n += 1
    answer += n



print(answer)



Measured memory_bytes: 9460
def march(N: int, S: list) -> int:
    d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
    for s in S:
        k = ''
        if s.startswith('M'):
            k = 'M'
        elif s.startswith('A'):
            k = 'A'
        elif s.startswith('R'):
            k = 'R'
        elif s.startswith('C'):
            k = 'C'
        elif s.startswith('H'):
            k = 'H'
        else:
            continue
        d[k] += 1

    count = 0
    val = list(d.values())
    for i in range(5):
        for j in range(i + 1, 5):
            for k in range(j + 1, 5):
                count += val[i] * val[j] * val[k]

    return count


if __name__ == "__main__":
    N = int(input())
    S = [input() for _ in range(N)]
    ans = march(N, S)
    print(ans)


Measured memory_bytes: 9752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c){
    cout << "1" << endl;
  }else if(a == b){
    cout << "2" << endl;
  }else if(b == c){
    cout << "2" << endl;
  }else if(a == c){
    cout << "2" << endl;
  }else{
    cout << "3" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <bits/stdc++.h>
#include <string.h>

using namespace std;

long long n, u;

int main () {
    cin >> n;
    u = (n / 500) * 1000; n = n % 500;
    u = u + (n / 5) * 5;
    cout << u;
}


Measured memory_bytes: 256
package main

import (
  "fmt"
  "unicode"
  "strings"
)

func main() {
  var S string
  fmt.Scan(&S)
  
  ret := "AC"
  
  if string(S[0]) != "A" {
    ret = "WA"
  }
  cnt := 0
  for i:=1; i<len(S); i++ {
    s := S[i]
    if unicode.IsUpper(rune(s)) {
      if string(s) != "C" || strings.Index(S, "C") <= 1 || strings.Index(S, "C") >= len(S) -1 {
        ret = "WA"
      }
    } else {
      cnt++
    }
  }
  
  if cnt != len(S) - 2 {
    ret = "WA"
  }
  
  fmt.Println(ret)
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <numeric>

using namespace std;

#define int long long

signed main()
{
    int n;
    vector<int> a;

    cin >> n;

    a.resize(n);

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

    int ans = n - 1;
    int sum = accumulate(a.begin(), a.end(), 0);

    for(int i = n - 2; i >= 0; --i)
    {
        if(abs(sum - a[i] * n) <= abs(sum - a[ans] * n))
        {
            ans = i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
D = 0
for i in range(N):
    d = min(A[i], B[i])
    D += d
    B[i] -= d

    d = min(A[i+1], B[i])
    D += d
    A[i+1] -= d

print(D)

Measured memory_bytes: 18624
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    map<long, long> xx;
    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
        xx[a[i]]++;
    }

    ll save=-1;
    auto it = xx.rbegin();
    for(; it!=xx.rend(); ++it) {
        if(it->second>3 && save<0) {
            printf("%lld\n", (ll)(it->first)*(it->first));
            return 0;
        }
        else if(it->second>1) {
            if(save>0) {
                printf("%lld\n", (ll)(it->first)*save);
                return 0;
            }
            else {
                save = (ll)(it->first);
            }
        }

    }

    printf("0\n");

    return 0;
}


Measured memory_bytes: 7296
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	int ans = 1;
	if(n <= 2){
		cout << ans << endl;
		return 0;
	}
	int st = 0;
	if(a[0] > a[1]) st = 1;
	if(a[0] < a[1]) st = 2;
	repn(i, 2, n){
		if(!st){
			if(a[i - 1] > a[i]) st = 1;
			if(a[i - 1] < a[i]) st = 2;
		}
		else if(st == 1){
			if(!(a[i - 1] >= a[i])){
				ans++;
				if(i == (n - 1)) break;
				st = 0;
				if(a[i] > a[i + 1]) st = 1;
				if(a[i] < a[i + 1]) st = 2;
			}
		}
		else{
			if(!(a[i - 1] <= a[i])){
				ans++;
				if(i == (n - 1)) break;
				st = 0;
				if(a[i] > a[i + 1]) st = 1;
				if(a[i] < a[i + 1]) st = 2;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3684
#include <stdio.h>

int main(){
	int sum = 0;
	char ch;

	while(true)
	{
		while((ch = getchar()) != '\n'){
			sum += ch - '0';
		}
		if(sum == 0)
			break;
		else{
			printf("%d\n",sum);
			sum = 0;
		}
	}
}


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

int main(){
  int64_t N, M;
  cin >> N;
  M = 0;
  for(int i = 1; i <= N; i++){
    if(i % 3 == 0){
      M = M + 0;
    }
    else if(i % 5 == 0){
      M = M + 0;
    }
    else{
      M = M + i;
    }
  }
  cout << M << endl;
}

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

int main(){
    int a,i;
    
    for(i=1; ;i++){
        scanf("%d",&a);
        if(a==0)break;
        printf("Case %d: %d\n",i,a);
    }
    
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;
ll P;

template<typename T>
struct treeDP{
  vvl G;
  T INIT, ZERO;
  vector<T> TMP_DATA, dat;
  function<T(T, T)> f;
  function<T(T)> g;
  treeDP(ll n, T init, T zero, function<T(T, T)> func, function<T(T)> func2):f(func), g(func2){
    G.resize(n+1, vector<ll>(0));
    dat.resize(n+1, zero);
    TMP_DATA.resize(n+1, zero);
    INIT = init, ZERO = zero;
  }

  inline void dfs(ll now, ll from){
    ll cnt = 0;
    for(int i=0;i<G[now].size();i++){
      if(G[now][i]==from) continue;
      dfs(G[now][i], now);
      TMP_DATA[now] = f(TMP_DATA[now], g(TMP_DATA[G[now][i]]));
      cnt++;
    }
    if(cnt==0) TMP_DATA[now] = INIT;
  }

  inline void dfs2(ll now, ll from, T rev){
    vector<T> left, right;
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][i];
      if(to==from) continue;
      left.push_back(g(TMP_DATA[to]));
      ll s = left.size();
      if(s!=1) left[s-1] = f(left[s-1], left[s-2]);
    }
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][G[now].size()-1-i];
      if(to==from) continue;
      right.push_back(g(TMP_DATA[to]));
      ll s = right.size();
      if(s!=1) right[s-1] = f(right[s-1], right[s-2]);
    }

    dat[now] = f((left.size()==0?ZERO:left[left.size()-1]), rev);

    ll cnt = 0;
    for(int i=0;i<G[now].size();i++){
      ll to = G[now][i];
      if(to==from) continue;
      T tmp = rev;
      if(cnt!=0) tmp = f(tmp, left[cnt-1]);
      if(cnt!=right.size()-1) tmp = f(tmp, right[right.size()-2-cnt]);
      dfs2(to, now, g(tmp));
      cnt++;
    }
  }

  void insert(ll a, ll b){ G[a].push_back(b);G[b].push_back(a); }

  void calc(){
    ll root = -1;
    for(int i=1;i<=G.size()-1;i++) {
      if(G[i].size()==1||G[i].size()==0){
        root = i;
        break;
      }
    }
    dfs(root, -1);
    dfs2(root, -1, INIT);
  }
  T & operator [](int i){return dat[i];}
};

ll mg(ll a, ll b){
  return (a*b)%P;
}
ll st(ll a){
  return (a+1)%P;
}

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n >> P;
  treeDP<ll> tdp(n+1, 1, 1, mg, st);

  re(i, n-1){
    ll a, b;scanf("%lld %lld", &a, &b);
    tdp.insert(a, b);
  }
  tdp.calc();
  for(int i=1;i<=n;i++) std::cout << tdp[i] << '\n';
}


Measured memory_bytes: 41088
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{

    lli n;
    cin>>n;
    lli a[2 * n];
    for(int i = 0; i < 2 * n; i ++ ) {
        cin>>a[i];
    }
    sort(a, a + 2 * n);
    lli ans = 0;
    for(int i = 0; i < 2 * n; i += 2) {
        ans += a[i];
    }
    cout<<ans;
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
N = input().split()
H = input().split()
number = 0
H = [int(v) for v in H]
def f(x):
    s = 0
    for j in range(x):
        if H[x] >=  H[j]:
            s += 1
            continue
        else:
            break
        break
    if s == x:
        global number
        number += 1

for i in range(int(N[0])):
    f(i)

print(number)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<queue>
#include<iostream>
#include<climits>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define rep(i,a,b) for(register int i=(a);i<(b);++i)
#define pb push_back
#define mp make_pair
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
    {
        return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
    }
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
    {
        x=0;static char ch;T f=1;
        for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
        for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
        x*=f;
    }

    template<typename T>inline void write(T x,char ch='\n')
    {
        if(!x)*nowps++='0';
        if(x<0)*nowps++='-',x=-x;
        static uint32 sta[111],tp;
        for(tp=0;x;x/=10)sta[++tp]=x%10;
        for(;tp;*nowps++=sta[tp--]^48);
        *nowps++=ch;
        if(nowps-Out>=1<<23)flush();
    }
}
using namespace IO;

void file()
{
#ifndef ONLINE_JUDGE
    FILE*DSD=freopen("water.in","r",stdin);
    FILE*CSC=freopen("water.out","w",stdout);
#endif
}

inline void Chkmin(int&u,int v){u>v?u=v:0;}

inline void Chkmax(int&u,int v){u<v?u=v:0;}

inline void Chkmax(ll&u,ll v){u<v?u=v:0;}

inline void Chkmin(ll&u,ll v){u>v?u=v:0;}

const int MAXN=1e5+7,mod=1e9+7;

static int dp[2][MAXN],n,x,a[MAXN];

inline void init()
{
	read(n),read(x);
	Rep(i,1,n)read(a[i]);
	sort(a+1,a+n+1,greater<int>());
}

inline void solve()
{
	dp[0][x]=1;
	Rep(i,0,n-1)
	{
		int *cr=dp[i&1],*nx=dp[~i&1];
		memset(nx+1,0,sizeof(int)*x);
		Rep(j,1,x)if(cr[j])
		{
			nx[j%a[i+1]]=(nx[j%a[i+1]]+cr[j])%mod;
			nx[j]=(nx[j]+(ll)cr[j]*(n-i-1))%mod;
		}
	}
	static int ans=0;
	Rep(i,1,x)ans=(ans+(ll)i*dp[n&1][i])%mod;
	cout<<ans<<endl;
}

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

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long int int64;

#define POS(i,j) ((i)*l+(j))

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char *s=(char *)calloc(h*w+1,sizeof(char));
  int i,j,k;
  for(i=0;i<h;i++) scanf("%s",s+i*w);
  const int l=h+w-1;
  char *b=(char *)calloc(l*l,sizeof(char));
  memset(b,'.',sizeof(char)*l*l);
  for(i=0;i<h;i++) for(j=0;j<w;j++) b[POS(i+j,j-i+h-1)]=s[i*w+j];
  int *row=(int *)calloc(l*l,sizeof(int));
  for(i=0;i<l;i++){
    row[POS(i,0)]=b[POS(i,0)]=='#'?1:0;
    for(j=1;j<l;j++) row[POS(i,j)]=row[POS(i,j-1)]+(b[POS(i,j)]=='#'?1:0);
  }
  int *col=(int *)calloc(l*l,sizeof(int));
  for(j=0;j<l;j++){
    col[POS(0,j)]=b[POS(0,j)]=='#'?1:0;
    for(i=1;i<l;i++) col[POS(i,j)]=col[POS(i-1,j)]+(b[POS(i,j)]=='#'?1:0);
  }
  int64 ans=0;
  for(i=0;i<l;i++){
    for(j=0;j<l;j++){
      if(b[POS(i,j)]!='#') continue;
      for(k=j+2;k<l;k+=2){
	if(b[POS(i,k)]!='#') continue;
	int d=k-j;
	if(i-d>=0) ans+=row[POS(i-d,k)]-row[POS(i-d,j)];
	if(i+d<l){
	  ans+=row[POS(i+d,k)]-row[POS(i+d,j)];
	  if(b[POS(i+d,j)]=='#') ans++;
	}
      }
      for(k=i+2;k<l;k+=2){
	if(b[POS(k,j)]!='#') continue;
	int d=k-i;
	if(j-d>=0){
	  ans+=col[POS(k,j-d)]-col[POS(i,j-d)];
	  if(b[POS(k,j-d)]=='#') ans--;
	}
	if(j+d<l) ans+=col[POS(k,j+d)]-col[POS(i,j+d)];
      }
    }
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 3456
from functools import reduce
X,Y = map(int,input().split())
x = (-X+2*Y) /3
y = (2*X-Y) /3
MOD = 10**9+7

def mod_comb(n,m,mod):
  def mod_mult(a,b,mod1=mod):
    return (a*b) % mod1
  n1 = reduce(mod_mult ,range(n,n-m,-1),1)
  n2 = reduce(mod_mult ,range(m,1,-1),1)
  n2inv = pow(n2,mod-2,mod) 
  return ((n1*n2inv) % mod)


if int(x) == x and int(y) == y and x>=0 and y>=0 :
  sum1 = int(x+y)
  bunbo = min([int(x),int(y)])
  print(mod_comb(sum1,bunbo,MOD))
else:
  print(0)
  

Measured memory_bytes: 4196
N, M, V, P = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True) + [-10 ** 10]
L, R, sA, lP = 0, N, [A[P - 1]], A[P - 1]
for i in range(P, N):
    sA.append(sA[-1] + A[i])

while R - L > 1:
    mid = L + (R - L) // 2
    if mid < P:
        L = mid
    elif A[mid] + M < lP:
        R = mid
    else:
        mi = mid - P + 1
        if M * (N - mi) + (A[mid] + M) * mi - sA[mi - 1] >= M * V:
            L = mid
        else:
            R = mid
print(L + 1)


Measured memory_bytes: 64152
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

import java.util.*;
import java.io.*;

class Main
{
	public static void main(String[] args){
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int N=sc.nextInt();
		int[] A=new int[N];
		for(int i=0;i<N;++i)A[i]=sc.nextInt();
		for(int i=0;i<N;++i)H-=A[i];
		System.out.println(H<=0?"Yes":"No");
	}
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 49300
#include<stdio.h>
int main(void)
{
    int n,x,i,ii,iii,A;
    while(1)
    {
        A=0;
        scanf("%d%d",&n,&x);
        if(n==0&&x==0)
        {
            break;
        }
        for(i=1;i<=n;i++)
        {
            for(ii=1;ii<=n;ii++)
            {
                if(i!=ii)
                {
                    for(iii=1;iii<=n;iii++)
                    {
                        if(i!=iii&&ii!=iii)
                        {
                            if(i+ii+iii==x)
                            {
                                A++;
                            }
                        }
                    }
                }
            }
        }
        printf("%d\n",A/6);
    }
    return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<algorithm>
using namespace std;

int arr[222];
int main(){
	int n; scanf("%d", &n); for (int i = 0; i < 2 * n; i++) scanf("%d", arr + i);
	sort(arr, arr + 2 * n);
	int ans = 0;
	for (int i = 0; i < 2 * n; i += 2)
		ans += arr[i];
	printf("%d", ans);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
const char* solve() {
    int A, B, C;
    cin >> A >> B >> C;
    for (int i = A; i <= A * B; i += A) {
        if (i % B == C) return "YES";
    }
    return "NO";
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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;
}

struct edge
{
public:
    int to;
    int cost;
};

// O(|E|(log|V|))
void dijkstra(std::vector<int> &dist, const std::vector<std::vector<edge>> &graph, int s)
{
    typedef std::pair<int, int> P;
    std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
    for (auto &e : dist)
    {
        e = INF;
    }

    dist[s] = 0;
    // P(distance from start, vertex index)
    pq.push(P(0, s));
    while (!pq.empty())
    {
        P cur = pq.top();
        pq.pop();
        int v = cur.second;
        int cost = cur.first;
        if (dist[v] < cost)
        {
            continue;
        }
        for (const auto &next : graph[v])
        {
            if (dist[next.to] > next.cost + dist[v])
            {
                dist[next.to] = next.cost + dist[v];
                pq.push(P(dist[next.to], next.to));
            }
        }
    }
}

void restorePath(
    std::vector<int> &path,
    const std::vector<int> &dist,
    const std::vector<std::vector<edge>> &graph,
    int e)
{
    int cur = e;
    path.push_back(e);
    while (dist[cur] != 0)
    {
        for (const auto &n : graph[cur])
        {
            if (dist[n.to] + n.cost == dist[cur])
            {
                path.push_back(n.to);
                cur = n.to;
                break;
            }
        }
    }
    std::reverse(path.begin(), path.end());
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

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

    int a, b;
    cin >> a >> b;
    int c = 0;
    for (int i = a; i <= b; i++)
    {
        if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10){
            c++;
        }
    }
    cout << c << "\n";

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> C(N-1),S(N-1),F(N-1);
    rep(i,0,N-1){
        cin >> C[i] >> S[i] >> F[i];
    }
    rep(i,0,N){
        int t = 0;
        rep(j,i,N-1){
            t = max(S[j], (t + F[j] - 1) / F[j] * F[j]);
            t += C[j];
        }
        cout << t << endl;
    }
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const int N=2000000;
const int M=2000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N];
int main()
{
    Run();
    int n,k;
    cin>>n>>k;
    for (int i=0;i<n;++i)
        cin>>a[i];

    for (int i=k;i<n;++i)
    {
        if (a[i]>a[i-k])
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    string s;
    cin >> s;
    if((s[6] == '4' || s[6] =='1' && s[5] == '0' || s[6] == '2' && s[5] == '0' || s[6] == '3' )  && (s[8] == '0' || s[8] == '1' || s[8] == '2' || s[8] == '3')){
        cout << "Heisei" << endl;
    }else {
        cout << "TBD" << endl;
    }
}

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
ll md=1000000007;

const double PI=acos(-1);

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

#define     sz(v)       ((int)((v).size()))
#define     all(v)      ((v).begin()),((v).end())
#define     pb           push_back
#define     ff           first
#define     ss           second
#define     line         printf("\n")
#define     gap          ' '
#define     ctn          continue;
ll poW(ll a ,ll n)
{
    if(n==0) return 1;
    if(n%2==0)
    {
        ll b=poW(a,n/2);
        return (b*b)%md;
    }
    return (poW(a,n-1)*a)%md;
}
bool cmp(const pii &a,const pii &b)     { return (a.ff*b.ss) < (a.ss*b.ff);}
bool isOdd(int n)       { return (n%2)!=0; }
template <class T>
void printVector(vector <T> &v,string s="")
{
    cout<<s;
    for(int i=0;i<sz(v);i++)
    {
        cout<<v[i]<<gap;
    }
    line;
}

int toInt(string str) {
	int num;
	istringstream iss(str);
	iss>>num; return num;
}

template <class T> string toStr(T par) {
	ostringstream oss;
	oss<<par;
	return oss.str();
}

void sieve(vector<int>&v)
{
    int i,j;
    v.pb(1);
    bool visit[1002];
    memset(visit,0,sizeof(visit));
    for(i=2;i<=1001;i++)
    {
        if(!visit[i])
        {
            for(j=i*i;j<=1001;j+=i)
            {
                visit[j]=1;
            }
            v.pb(i);
            //cout<<i<<gap<<v.back();line;
        }
    }
}
bool isPrime(int x) {
	if (x < 2) return false;
	for (int y = 2; y * y <= x; y++)
		if (x % y == 0)
			return false;
	return true;
}


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        string s,t;
        cin>>s;
        cin>>t;
        int i,n=sz(s),cnt=0;
        for(i=0;i<n;i++){
            if(s[i]!=t[i]) cnt++;
        }
        cout<<cnt;

    }
}


Measured memory_bytes: 3904
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)

class Point{
  public:
  double x,y;

  Point(double x = 0,double y = 0) : x(x), y(y) {}

  Point operator + (Point p){
    return Point(x + p.x , y + p.y);
  }

  Point operator - (Point p){
    return Point(x - p.x , y - p.y);
  }

  Point operator * (double k){
    return Point(x * k , y * k);
  }

  double norm(){
    return x*x + y*y;
  }
};

struct Segment{
  Point p1,p2;
};

typedef Point Vector;

double dot(Vector a,Vector b){
  return a.x*b.x + a.y*b.y;
}

Point project(Segment s,Point p){
  Vector base = s.p2 - s.p1;
  double t = dot(p - s.p1 , base) / base.norm();
  return s.p1 + base * t;
}

Point reflect(Segment s,Point p){
  return p + (project(s,p) - p) * 2.0;
}

int main(){
  Point p1,p2,q;

  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf" 
	      ,&p1.x ,&p1.y, &p2.x ,&p2.y ,&q.x ,&q.y) != EOF){

    Segment s = {p1,p2};
    Point p = reflect(s,q);

    printf("%.6f %.6f\n" ,p.x ,p.y);
  }

  return 0;
}

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

using namespace std;

const int INF = 1 << 30;

int main()
{
  int N;

  scanf("%d", &N);

  int S = (INF - 1) * 2, ret = -INF;
  for(int i = 0; i < N; i++) {
    int R;
    scanf("%d", &R);
    ret = max(ret, R - S);
    S = min(S, R);
  }
  printf("%d\n", ret);
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vvi to;
vi d;

void bfs(int s) {
        d[s] = 0;
        queue<int> q;
        q.push(s);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (auto nv : to[v]) {
                if (d[nv] >= 0) continue;
                d[nv] = d[v] + 1;
                q.push(nv);
            }
        }
    }


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    to = vvi(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    d = vi(n, -1);
    bfs(0);
    if (d[n-1] == 2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13168
MOD=10**9+7
N,a,b=[int(s) for s in input().split()]

MAX = N
inv = [0, 1]
for i in range(2, b+1):
  inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)

r=1
for i in range(a):
  r=r*(N-i)%MOD
  r=r*inv[i+1]%MOD

s=r
for i in range(a,b):
  r=r*(N-i)%MOD
  r=r*inv[i+1]%MOD

base=2
n=1
pow=[1,base]
while n<MAX:
  pow.append((pow[-1]**2)%MOD)
  n*=2
  
n=N
i=1
p=1
while n>0: 
  if n%2==1:
    p=p*pow[i]%MOD
  n//=2
  i+=1

print((p-1-r-s)%MOD)

Measured memory_bytes: 11052
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m, d;

int main(){
	cin >> n >> m >> d;
	double ans = (d == 0)? double(m-1)/n : double(2*(m-1)*(n-d))/(n*n);
	cout << setprecision(10) << ans << endl;
	return 0;
}

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

int main(){
  int n, m;
  while(cin >> n >> m, n){
    vector<int> A(n);
    for(int i = 0; i < n; ++i) cin >> A[i];
    int ans = -1;
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < i; ++j){
        if(A[i]+A[j] <= m)
          ans = max(ans,A[i]+A[j]);
      }
    }
    if(ans < 0) cout << "NONE" << endl;
    else cout << ans << endl;
  }
}



Measured memory_bytes: 3120
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let k: i64 = input();

    let mut ans = 0;
    for b in k + 1..n + 1 {
        ans += (b - k) * (n / b) + std::cmp::max(0, (n % b) + 1 - k);
        if k == 0 {
            ans -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
     x=-x;
  }
  while(x){
    f[s++]=x%10;
     x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int A, B;
  rd(A);
  rd(B);
  wt_L((A+B)%24);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170330-1


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll n,i,c;
string a;
bool f;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a;
    n = a.length();
    if(a[0] == 'A'){
        rep(i,2,n - 1) c += (a[i] == 'C');
        if(c == 1){
            f = 1;
            rep(i,0,n) if(a[i] >= 'A' and a[i] <= 'Z'){
                if(a[i] != 'A' and a[i] != 'C'){
                    f = 0;
                    break;
                }
            }
        }
    }
    cout<<(f ? "AC" : "WA");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);

  	int length;	cin >> length;
	int ans = 1;
	string s;	cin >> s;
	for(int i = 1 ; i < length ; i++)
	 	if(s[i] != s[i - 1])	ans += 1;

	SCOUT(ans) << endl;

	return 0;

}

Measured memory_bytes: 512
#include <iostream>

static int S[2000000];
static int idx = 0;

void insert() {
    int child = idx;
    int parent = child / 2;
    while (parent > 0) {
        if (S[child] > S[parent]) {
            std::swap(S[child], S[parent]);
        }
        child = parent;
        parent = parent / 2;
    }
}

void heapify(int parent) {
    int left = parent * 2;
    int right = left + 1;
    int largest = parent;
    if (left <= idx && S[largest] < S[left]) {
        largest = left;
    }
    if (right <= idx && S[largest] < S[right]) {
        largest = right;
    }
    if (largest != parent) {
        std::swap(S[parent], S[largest]);
        heapify(largest);
    }
}

void extractMax() {
    std::cout << S[1] << std::endl;
    std::swap(S[1], S[idx]);
    idx--;
    heapify(1);
}


int main() {
    std::string command;
    while (true) {
        std::cin >> command;
        if (command == "insert") {
            idx++;
            std::cin >> S[idx];
            insert();
        } else if (command == "extract") {
            extractMax();
        } else if (command == "end") {
            break;
        }
    }
}



Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> a >>b;
cout << a*b <<" "<< a*2+b*2 <<endl;
return 0;
}



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

typedef long long ll;

int main() {
    int N, Q, a, b, c;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    rep(i, N) {
        cin >> a;
        fw.add(i, a);
    }
    while(Q--) {
        cin >> a >> b >> c;
        if (a) {
            cout << fw.sum(b, c) << "\n";
        } else {
            fw.add(b, c);
        }
    }
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;
int dp[100100];

void solve() {
    int N;
    cin >> N;
    for (int i = 0; i <= N; ++i) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i <= N - 1; ++i) {
        for (int j = 1; j < INF; ++j) {
            int n = pow(9, j);
            if (N < i + n) break;
            dp[i+n] = min(dp[i+n], dp[i] + 1);
        }
        for (int j = 1; j < INF; ++j) {
            int n = pow(6, j);
            if (N < i + n) break;
            dp[i+n] = min(dp[i+n], dp[i] + 1);
        }
        dp[i+1] = min(dp[i+1], dp[i] + 1);
    }
    cout << dp[N] << endl;
}

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


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

#define int long long

using namespace std;

int a[10001];

int32_t main()
{
    int n,x;
    cin >> n >> x;

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

    sort(a,a+n);

    for(int i=1;i<n;i++)
        a[i] += a[i-1];

    if(x > a[n-1])
        cout << n-1 << endl;
    else
        cout << upper_bound(a,a+n,x) - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
vector<set<int> >adj;
//vector<set<int> >indegree;
vector<int>ans;
vector<int>visited;
int n,m;
int dfs(int x){
  visited[x]=1;
  if(x==4){
      ans[x]=1;
      //visited[x]=2;
  }else{
    for(int i : adj[x]){
      if(visited[i]==-1){
        dfs(i);
      }
       ans[x]+=ans[i];
       ans[x]%=mod;
    }
  }
 // visited[x]=2;
  return ans[x];
}
*/

int main(){
    boost;
    int TESTS=1;
   // cin>>TESTS;
    while(TESTS--){
        int a,b;
        cin>>a>>b;
        if(a<=5)cout<<0<<endl;
        else if(a<=12)cout<<b/2<<endl;
        else cout<<b<<endl;
    }
}











Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, 0, n) cin >> l[i];
    ll syahen = *max_element(all(l));
    auto index = distance(l.begin(), max_element(all(l)));
    ll nokori = 0;
    rep(i, 0, n) if (i != index) nokori += l[i];
    if (syahen < nokori)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
    const int S = 100001;
    int A[S];
int main() {
    int H, N, total = 0;
    cin >> H >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }
    if (total >= H)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

int main(){

    int n;
    cin >> n;
    vector<int> C(500);
    vector<int> S(500);
    vector<int> F(500);

    for(int i = 0;i < n-1;i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i =0;i < n;i++){
        int t = 0;
        for(int j = i;j < n-1;j++){

            if(t < S[j]){
                t = S[j];
            }else if(t % F[j] == 0){

            }else{
                t = t + F[j] - t%F[j];
            }

            t += C[j];
        }
        cout << t << endl;
    }






    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<tuple>
#include<utility>

using namespace std;


int main() {

	int n;
	cin >> n;

	vector <tuple<string, int,int>> t(n);

	for (int i = 0; i < n; i++) {
		string s;
		int p;
		cin >> s >> p;

		t[i] = make_tuple(s, -p,i+1);
	}

	sort(t.begin(), t.end());

	for (int i = 0; i < n; i++) {
		
		cout << get<2>(t[i]) << endl;
	}
	
	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

#define M 4

typedef struct{
  int A[M][M];
}Pazzle;

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

int heuristic(Pazzle P){
  int i,j;
  int hx,hy,sum=0;

  for(i=0; i<M; i++){
    for(j=0; j<M; j++){
      if(P.A[i][j] == 0)continue;

      hx = (P.A[i][j]-1)%M-j;
      hy = (P.A[i][j]-1)/M-i;

      if(hx < 0)sum -= hx;
      else sum += hx;

      if(hy < 0)sum -= hy;
      else sum += hy;
    }
  }

  return sum;
}

int dfs(int x,int y,int max,int cnt,int n){
  int i,temp;
  int x0,y0,ans=-1,h;

  h = heuristic(P);

  if(h == 0)return cnt;
  if(cnt + h > max)return -1;

  for(i=0; i<4; i++){
    x0 = x + dx[i];
    y0 = y + dy[i];

    if((i == (n+2)%4 && n != -1) || !(0<=x0 && x0<M && 0<=y0 && y0<M))continue;
    temp = P.A[y][x];
    P.A[y][x] = P.A[y0][x0];
    P.A[y0][x0] = temp;

    ans = dfs(x0,y0,max,cnt+1,i);

    if(ans != -1)return ans;
    temp = P.A[y][x];
    P.A[y][x] = P.A[y0][x0];
    P.A[y0][x0] = temp;
  }

  return -1;
}

int main(){
  int i,j;
  int kx,ky,ans,a;
  Pazzle tP;

  for(i=0; i<M; i++){
    for(j=0; j<M; j++){
      scanf("%d",&a);
      P.A[i][j] = a;
      if(a == 0){
        kx = j;
        ky = i;
      }
    }
  }

  tP = P;

  for(i=1; i<46; i++){
    P=tP;
    ans = dfs(kx,ky,i,0,-1);
    if(ans != -1){
      printf("%d\n",ans);
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 2080
N=int(raw_input())
TT=[]
for _ in xrange(N):
    w,s,v=list(map(int,raw_input().strip().split(' ')))
    TT+=[(w,s,v)]
TT=sorted(TT,key=lambda X:X[1]+X[0])
dp=[[0]*(2*10**4+1) for i in xrange(N)]
 
#for L in range()
#dp[i][weight]=max(dp[i-1][weight-W[i]]+V[i],dp[i-1][weight]
for i in xrange(N):
    if i==0:
        dp[0][TT[0][0]]=TT[0][2]
        continue
    
    
    for weight in xrange(1,2*10**4+1):
        if TT[i][1]>=weight-TT[i][0] and weight-TT[i][0]>=0:
            dp[i][weight]=max(dp[i-1][weight],dp[i-1][weight-TT[i][0]]+TT[i][2])
        else:
            dp[i][weight]=dp[i-1][weight]
print(max(dp[-1]))

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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,j,n) for(int i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define inf 1e17
#define N 100010
priority_queue<pll,vector<pll>,greater<pll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

ll T = 1,n,m,k;

int main(){
    if(fopen("input.txt", "r"))
    freopen("input.txt", "r", stdin),
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n;
    ll a[n];
    map<ll, ll>m;
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }
    ll q;
    cin >> q;
    ll b[q], c[q];
    for(int i=0;i<q;i++)
        cin >> b[i] >> c[i];
    for(int i=0;i<q;i++){
        ll d = m[b[i]];
        sum -= (d*b[i]);
        sum += (d*c[i]);
        m[b[i]]=0;
        m[c[i]]+=d;
        cout << sum << "\n";
    }

    return 0;
}


Measured memory_bytes: 11792
def main():
    a, b, c = map(int, input().split())
    array = list(map(int, input().split()))
    
    # 多重リスト
    multi_list = [list(map(int, input().split())) for _ in range(a)]

    cnt = 0

    for i in range(a):
        sum = 0
        for j in range(b):
            sum += multi_list[i][j] * array[j]
        if sum + c > 0:
            cnt += 1


    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);
    if (abs(x-a) > abs(x-b)) printf("B\n");
    else printf("A\n");
    return 0;
}


Measured memory_bytes: 128