akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
char s[MAXN];
int t[MAXN], d[MAXN];

bool check1(int ans, int N, int Q) {
     int cur = ans;
     for (int i = 0; i < Q; i++) {
         if (s[cur] - 'A' != t[i]) continue;
         cur += d[i];
         if (cur < 0) return true;
     }
     return false;
}

bool check2(int ans, int N, int Q) {
     int cur = ans;
     for (int i = 0; i < Q; i++) {
         if (s[cur] - 'A' != t[i]) continue;
         cur += d[i];
         if (cur >= N) return true;
     }
     return false;
}

int main() {
    int N, Q;
    scanf("%d %d", &N, &Q);
    scanf("%s", s);
    for (int i = 0; i < Q; i++) {
        char tmp[6];
        scanf("%s", tmp);
        t[i] = tmp[0] - 'A';
        scanf("%s", tmp);
        if (tmp[0] == 'R') d[i] = 1;
        else d[i] = -1;
    }
    int l = 0, r = N, ans1 = -1, ans2 = N;
    while (l < r) {
          int mid = (l + r) / 2;
          if (check1(mid, N, Q)) {
             ans1 = mid;
             l = mid + 1;
          } else r = mid;
    }
    l = 0, r = N;
    while (l < r) {
          int mid = (l + r) / 2;
          if (check2(mid, N, Q)) {
             ans2 = mid;
             r = mid;
          } else l = mid + 1;
    }
    int ans = N;
    ans -= (ans1 + 1);
    ans -= (N - ans2);
    if (ans < 0) ans = 0;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
#define pb push_back
#define mp make_pair

ll a[1001],dp[500][500],cum_sum[2000];

int main(){

	int n,i,j,k;	
	scanf("%d",&n);
	cum_sum[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		cum_sum[i]=cum_sum[i-1]+a[i];
	}

	for(int i=0;i<=n;i++){
		for(j=0;j<=n;j++)
			dp[i][j]=100000000000000;
	}
	for(i=1;i<=n;i++){
		dp[i][i]=0;
	}
	// for(int i=0;i<=n;i++){
	// 	dp[i][i+1]=a[i]+a[i+1];
	// }


	for(i=n-1;i>=1;i--){
		for(j=i+1;j<=n;j++){
			for(k=i;k<j;k++){
				int p = k-i+1;
				int q = j-k;
				dp[i][j] = min(dp[i][k]+dp[k+1][j]+cum_sum[j]-cum_sum[i-1],dp[i][j]);
			}
		}
	}
	// for(i=1;i<=n;i++){
	// 	for(j=1;j<=n;j++)
	// 		printf("%lld ",dp[i][j] );
	// 	printf("\n");
	// }
	ll ans=dp[1][n];
	
	printf("%lld\n",ans );
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, q; cin >> n >> q;
  vi32 a(n); cin >> a;
  vi64 X(q); cin >> X;
  each(x, X) {
    i64 ans = 0;
    i64 sum = 0;
    for (int l = 0, r = 0; l < n; ) {
      while (r < n && sum + a[r] <= x) {
        sum += a[r++];
      }
      ans += r - l;
      sum -= a[l++];
      if (l > r) r = l, sum = 0;
    }
    cout << ans << '\n';
  }
}



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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

#ifdef DEBUG
#define cin cerr<<"> ";cin
#endif

int main(){
    int n,k;cin>>n>>k;
    priority_queue<P,vP,greater<P>> dat;
    {
        vi in(n);
        REP(i,n){
            int t;cin>>t;t--;
            in[t]++;
        }
        REP(i,n){
            if(in[i]==0)continue;
            dat.push((P){in[i],i});
        }
    }
    int res=0;
    int loop=dat.size()-k;
    REP(i,loop){
        P t=dat.top();
        dat.pop();
        cerr<<t.first<<"\t"<<t.second<<endl;
        res+=t.first;
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include<cmath>


using namespace std;

int main(){
    string s;
    cin>>s;
    int counter=0;
    if(s[0]=='1')++counter;
    if(s[1]=='1')++counter;
    if(s[2]=='1')++counter;

    cout<<counter<<endl;
}

Measured memory_bytes: 256
//2020-04-09 16:04:39
//#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll cost1=a*x+b*y;
    ll cost2=0;
    if(x<y)
    {
        cost2=(2*x*c);
        cost2+=((y-x)*b);
    }
    else
    {
        cost2=(2*y*c);
        cost2+=((x-y)*a);
    }
    ll cost3=(max(x,y))*c*2;
    cout<<min(cost1,min(cost2,cost3));
}

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

int main(){
  
  ll N,M;
  cin >> N >> M;
  
  if(N>=2 && M>=2){
   cout << (N-2)*(M-2) << endl;
  }else if(N==1 && M!=1){
    cout << M-2 << endl;
  }else if(N!=1 && M==1){
     cout << N-2 << endl;
  }else{
    cout << 1 << endl;
  }
  
  
  
  
}

Measured memory_bytes: 256
fact = [1 for _ in range(1000000)]
inv = [1 for _ in range(1000000)]
fact_inv = [1 for _ in range(1000000)]

P = 10**9+7
for i in range(2, 1000000):
    fact[i] = (fact[i-1]*i) % P
    inv[i] = P - (inv[P % i] * (P // i)) % P
    fact_inv[i] = (fact_inv[i-1] * inv[i]) % P

X, Y = map(int, input().split())
res = 0
if (X+Y) % 3 == 0:
    a = (-X+2*Y) // 3
    b = (2*X-Y) // 3
    if a >= 0 and b >= 0:
        res = fact[a+b] * ((fact_inv[a] * fact_inv[b]) % P) % P
print(res)

Measured memory_bytes: 127560
#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    int width,height;
    cin >> width >> height;

    int area = width * height;
    int perimeter = (width * 2) + (height * 2);
    cout << area << " " << perimeter << endl;
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    
    ll ans = 0;
    for(ll i=0;i<n;i++){
        ll d = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll e = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += d*e;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <iostream>
using namespace std;
struct edge { int to, cost; };
int N, Q, K, a, b, c; long long dist[100009]; vector<edge> g[100009];
void dfs(int pos, int pre) {
	for (edge e : g[pos]) {
		if (e.to == pre) continue;
		dist[e.to] = dist[pos] + e.cost;
		dfs(e.to, pos);
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> a >> b >> c; a--, b--;
		g[a].push_back(edge{ b, c });
		g[b].push_back(edge{ a, c });
	}
	cin >> Q >> K; K--;
	dfs(K, -1);
	for (int i = 0; i < Q; i++) {
		cin >> a >> b; a--, b--;
		cout << dist[a] + dist[b] << endl;
	}
	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n,k,one_pos,result=0;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n){
        cin >> v[i];
        if(v[i]==1){
            one_pos = i;
        }
    }
    int j = 0;
    while(one_pos-j*(k-1)>0){
        j++;
    }
    result += j;
    one_pos -= one_pos - j * (k - 1);
    j = 0;
    while(one_pos+j*(k-1)<n-1){
        j++;
    }
    result += j;

    cout << result << endl;


    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << ": " << x << endl; 
#define MAX_K 1001
#define rep(i, n) for(int i=0; i<n; i++)
int N, K;
int s[3*MAX_K][3*MAX_K], a[2][MAX_K][MAX_K];
signed main(void){
	cin >> N >> K;
	for(int i=0; i<N; i++){
		int x, y;
		char c;
		cin >> x >> y >> c;
		if(c == 'B') x += K;
		x %= 2*K;
		y %= 2*K;
		s[x][y]++;
		s[x + K][y]--;
		s[x][y + K]--;
		s[x + K][y + K]++;
	}

	rep(i, 3*K) rep(j, 3*K) s[i][j+1] += s[i][j];
	rep(i, 3*K) rep(j, 3*K) s[i+1][j] += s[i][j];
	rep(i, 3*K) rep(j, 3*K){
		int k = (i / K + j / K) % 2;
		a[k][i%K][j%K] += s[i][j];
	} 
	// rep(k, 2) rep(i, K){
	// 	rep(j, K) cerr << a[k][i][j] << ' ';
	// 	cerr << endl;
	// }
	int ret = 0;
	rep(k, 2) rep(i, K) rep(j, K) ret = max(ret, a[k][i][j]);
	cout << ret << endl;
}

Measured memory_bytes: 43264
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n,i,j,len,s1cal,s2cal,cal,m,c,x,ii;
  string s1,s2;
  cin >> n;
  for(i=0;i<n;i++){
    s1cal=0;
    cin >> s1;
    len=s1.size();
    for(j=0;j<len;j++){
      if(s1[j]=='m'){
    if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+1000*(s1[j-1]-'0');
    else s1cal=s1cal+1000;
      }
      else if(s1[j]=='c'){
    if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+100*(s1[j-1]-'0');
    else s1cal=s1cal+100;
      }
      else if(s1[j]=='x'){
    if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9') s1cal=s1cal+10*(s1[j-1]-'0');
    else s1cal=s1cal+10;
      }
      else if(s1[j]=='i'){
    if(j-1!=-1&&'2'<=s1[j-1]&&s1[j-1]<='9'){
      s1cal=s1cal+(s1[j-1]-'0');
    }
    else s1cal=s1cal+1;
      }
    }
    s2cal=0;
    cin >> s2;
    len=s2.size();
    for(j=0;j<len;j++){
      if(s2[j]=='m'){
    if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+1000*(s2[j-1]-'0');
    else s2cal=s2cal+1000;
      }
      else if(s2[j]=='c'){
    if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+100*(s2[j-1]-'0');
    else s2cal=s2cal+100;
      }
      else if(s2[j]=='x'){
    if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+10*(s2[j-1]-'0');
    else s2cal=s2cal+10;
      }
      else if(s2[j]=='i'){
    if(j-1!=-1&&'2'<=s2[j-1]&&s2[j-1]<='9') s2cal=s2cal+(s2[j-1]-'0');
    else{
      s2cal=s2cal+1;
    }
      }
    }
    cal=s1cal+s2cal;
    m=0;
    c=0;
    x=0;
    ii=0;
    if(cal/1000>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
      cal=cal/10;
      c=cal%10;
      cal=cal/10;
      m=cal%10;      
    }
    else if(cal/100>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
      cal=cal/10;
      c=cal%10;
    }
    else if(cal/10>0){
      ii=cal%10;
      cal=cal/10;
      x=cal%10;
    }
    else ii=cal;
    if(m!=0){
      if(m!=1) cout << m << 'm';
      else cout << 'm';
    }
    if(c!=0){
      if(c!=1) cout << c << 'c';
      else cout << 'c';
    }
    if(x!=0){
      if(x!=1) cout << x << 'x';
      else cout << 'x';      
    }
    if(ii!=0){
      if(ii!=1) cout << ii << 'i';
      else cout << 'i';
    }
    cout << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin>>a.at(i);
        // cout<<a.at(i)<<endl;
    }
    sort(a.begin(),a.end());
  	reverse(a.begin(),a.end());
    // for (int i=0;i<n;i++){
    //     cout<<a.at(i)<<endl;
    // }
    int alice=0,bob=0;
    for (int i=0 ;i<n;i++){
        if(i %2==0){
        bob+=a.at(i);
        }else{
        alice+=a.at(i);    
        }
        // cout<<bob<<endl;
    }
    
    cout<<bob-alice<<endl;
    
    return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <map>

using namespace std;

int main() {
    map<int, int> m;
    for (int i = 0; i < 3; i++) {
        int d;
        scanf("%d", &d);
        m[d]++;
    }
    for (auto x : m) {
        if(x.second == 1) printf("%d\n", x.first);
    }
    return 0;
}


Measured memory_bytes: 256
mod = 1000000007

h,w = map(int,input().split())
vals = []
for i in range(h):
	vals.append(input())


v_up_length = [[0 for i in range(w)]for j in range(h)]
v_down_length = [[0 for i in range(w)]for j in range(h)]
h_right_length = [[0 for i in range(w)]for j in range(h)]
h_left_length = [[0 for i in range(w)]for j in range(h)]

for x in range(w):
	for y in range(h):
		if vals[y][x]== "#":
			continue
		if x != 0:
			if vals[y][x-1] == ".":
				h_left_length[y][x] = h_left_length[y][x-1] + 1
		if y != 0:
			if vals[y-1][x] == ".":
				v_up_length[y][x] = v_up_length[y-1][x] + 1



for x in range(w-1,-1,-1):
	for y in range(h-1,-1,-1):
		if vals[y][x]== "#":
			continue
		if x != w-1:
			if vals[y][x+1] == ".":
				h_right_length[y][x] = h_right_length[y][x+1] + 1
		if y != h-1:
			if vals[y+1][x] == ".":
				v_down_length[y][x] = v_down_length[y+1][x] + 1


ans = 0
scores = [[0 for i in range(w)]for j in range(h)]
for x in range(w):
	for y in range(h):
		if vals[y][x]== "#":
			continue
		
		scores[y][x] = 1 + v_up_length[y][x] + v_down_length[y][x] + h_right_length[y][x] + h_left_length[y][x]
		
		ans = max(ans, 1 + v_up_length[y][x] + v_down_length[y][x] + h_right_length[y][x] + h_left_length[y][x])

#for i,vec in enumerate([v_up_length,v_down_length,h_right_length,h_left_length,scores]):
#	print("===============================")
#	print(i)
#	for tmp in vec:
#		print(tmp)


print(ans)

Measured memory_bytes: 219016
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int ox, oy, x, y; cin >> ox >> oy >> x >> y;
	
	int X = x - ox, Y = y - oy;
	
	cout << -Y + ox + X << " " << X + oy + Y << " ";
	cout << -Y + ox << " " << X + oy << endl;
	return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

string s;
string ans;
int now[26];
int to[200001][26];
int cost[200001];

int main(){
    cin >> s;
    s = " " + s;
    memset(to, -1, sizeof(to));
    memset(now, -1, sizeof(now));
    rep(i,200001) cost[i] = 10000000;
    for(int i = s.size()-1; i >= 0; i--) {
        rep(j,26) {
            to[i][j] = now[j];
            if(to[i][j] == -1) {
                cost[i] = 0;
            } else {
                cost[i] = min(cost[i], cost[to[i][j]]+1);
            }
        }
        if(i != 0) {
            now[s[i]-'a'] = i;
        }
    }
    
    string ans;
    int xx = 0;
    for(int i = 0;; i++) {
        int mi = 2000000;
        int pos = -1;
        bool end = false;
        rep(j,26) {
            if(to[xx][j] == -1) {
                ans.push_back('a'+j);
                end = true;
                break;
            }
            if(cost[to[xx][j]] < mi) {
                mi = cost[to[xx][j]];
                pos = to[xx][j];
            }
        }
        if(end) break;
        ans.push_back(s[pos]);
        xx = pos;
    }
    cout << ans << endl;
}


Measured memory_bytes: 21696
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

import java.util.HashSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (b == 1) {
            System.out.println(0);
            return;
        }
        for (int i = 1; i < 22; i++) {
            int temp = i * a - i + 1;
            if (temp >= b) {
                System.out.println(i);
                return;
            }
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, q;
int a[55], b[55], c[55], d[55];
int x[15];
int ans = 0;

void dfs(int cur, int tmp){
    if(cur == n){
        int sum = 0;
        rep(i, q)if(x[b[i]] - x[a[i]] == c[i]) sum += d[i];
        chmax(ans, sum);
    }
    else{
        For(i, tmp, m+1){
            x[cur] = tmp;
            dfs(cur+1, i);
        }
    }
}

int main(){
    scanf("%d%d%d", &n, &m, &q);
    rep(i, q){
        scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
        --a[i]; --b[i];
    }
    dfs(0, 1);
    printf("%d\n", ans);
}

Measured memory_bytes: 3760
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    for(int i = 0; i < s.length(); i = i+2) {
      System.out.print(s.charAt(i));
    }
    System.out.println();
  }
}


Measured memory_bytes: 30884
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

VI c = { 1,9,
			9 * 9,
			9 * 9 * 9,
			9 * 9 * 9 * 9,
			9 * 9 * 9 * 9 * 9,
			9 * 9 * 9 * 9 * 9 * 9,
	6,
	6 * 6,
	6 * 6 * 6,
	6 * 6 * 6 * 6,
	6 * 6 * 6 * 6 * 6,
	6 * 6 * 6 * 6 * 6 * 6,
	6 * 6 * 6 * 6 * 6 * 6 * 6
};
const int inf = 1000000;

int main()
{
	int n;
	cin >> n;
	VVI dp = VVI(c.size()+1);
	REP(i, c.size()+1) {
		dp[i] = VI(n+1);
		REP(j, n+1)
		{
			dp[i][j] = inf;
		}
	}

	dp[0][0] = 0;
	REP(i, c.size())
	{
		REP(j, n+1)
		{
			if (j < c[i]) dp[i + 1][j] = dp[i][j];
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i+1][j - c[i]] + 1);
			}
		}
	}
	cout << dp[c.size()-1][n] << endl;
	return 0;
}



Measured memory_bytes: 6144
#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int,int> pii;
const int N = 100;
int A[N],B[N],C[N],p[N],n,ans;

int main(){
    cin >> n;
    for(int i=1;i<=n;++i)   cin >> A[i], p[A[i]] = i;
    for(int i=1;i<=n;++i)   cin >> B[i];
    for(int i=1;i<=n-1;++i) cin >> C[i+1];
    for(int i=1;i<=n;++i){
        ans += B[A[i]];
        if(A[i]-1==A[i-1])  ans+= C[A[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using ll = long long;
// #define int ll
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
void fastios(){ ios_base::sync_with_stdio(0); cin.tie(0); }
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

pair<vector<Weight>, bool> spfa(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    const int n = g.size(); queue<int> q;
    vector<Weight> dist(n, inf); vector<int> inQ(n);
    vector<int> count(n);
    dist[s] = 0; q.emplace(s); inQ[s] = true; ++count[s];
    bool negCycle = false;
    while(q.size()){
        int v = q.front(); q.pop(); inQ[v] = false;
        for(auto &e : g[v]){
            if(dist[v] != inf && dist[e.dst] > dist[v] + e.weight){
                dist[e.dst] = dist[v] + e.weight;
                if(!inQ[e.dst]){
                    q.emplace(e.dst); inQ[e.dst] = true; ++count[e.dst];
                    if(count[e.dst] >= n){ negCycle = true; goto END; }
                }
            }
        }
    }
 END:;
    return make_pair(dist, !negCycle);
}

int main(){
    fastios();
    int n;
    cin >> n;
    Graph g(n);
    rep(i,n){
        int u,k;
        cin >> u >> k;
        rep(j,k){
            int v,c;
            cin >> v >> c;
            g[u].eb(u,v,c);
        }
    }
    auto dist = spfa(g,0);
    rep(i,n){
        cout << i << ' ' << get<0>(dist)[i] << '\n';
    }
}

Measured memory_bytes: 9688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll tmp = 0;
  rep(i, n) {
    if (v.at(i) == tmp+1) tmp++;
  }
  if (tmp == 0) {
    cout << -1 << endl;
  } else {
    cout << n-tmp << endl;
  }
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int main() {
	int N;
	int H[100008];
	scanf("%d", &N);
	for (int i = 0; i < N; i++)scanf("%d", &H[i]);

	bool end = false;

	for (int i = N - 1; i >= 1; i--) {
		if (H[i-1] - H[i] >= 2) {
			printf("No");
			end = true;
			break;
		}
		else if(H[i-1] - H[i] == 1)H[i-1]--;	
	}

	if (!end)printf("Yes");


}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>

// template {{{
using namespace std;

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define fill(x, y) memset(x, y, sizeof(x))

using int64 = long long;

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

bool in_field(int W, int H, int x, int y) {
  return (0 <= x && x < W) && (0 <= y && y < H);
}

// pair
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template <typename T> ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << "\t";
  }
  return s;
}

// }}}

// url: https://atcoder.jp/contests/abc124/tasks/abc124_d

int N, K;
string S;

int main() {
  cin >> N >> K >> S;

  int l = 0, r = 0, k = 0, sum = 0;
  int ans = 0;
  while (r < N) {
    while (r < N && k < K) {
      if (S[r] == '0' && S[r + 1] == '1') {
        k++;
      }
      r++;
      sum++;
    }

    while (S[r] == '1') {
      r++;
      sum++;
    }
    ans = max(sum, ans);
    while (k == K) {
      if (S[l] == '0' && S[l + 1] == '1') {
        k--;
      }
      l++;
      sum--;
    }
  }
  cout << ans << endl;

  return 0;
}

// vim: foldmethod=marker


Measured memory_bytes: 512
#include <stdio.h>

char data[7][4]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

int main()
{
    char s[4];
    scanf("%s",s);
    for(int i=0;i<7;i++)
    {
        for(int j=0;j<3;j++)
            if(s[j]!=data[i][j]) goto DIFF;
        printf("%d\n",7-i);
        return 0;
DIFF:;
    }
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  ll dp[100010][3];  // i日目に、プランjを選んだ時の最大値
  for (int i = 0; i < 100010; i++)
    for (int j = 0; j < 3; j++) dp[i][j] = 0;

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

  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    ll ans = 0;
    map<char, int> m;
    vector<char> C = {'R', 'G', 'B'};
    for (int i = 0; i < N; i++) {
        ll tmp = 1;
        for (int j = 0; j < 3; j++) {
            if (S[i] != C[j]) {
                tmp *= m[C[j]];
            }
        }
        ans += tmp;
        for (int j = i + 1; j < N; j++) {
            int k = 2 * i - j;
            if (0 <= k && k < N && S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
        }
        m[S[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
//#define int long long


//booooooooooooost
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)



LL inv_mod(LL a, LL m)
{
	LL b, x, u, q, tmp;

	b = m; x = 1; u = 0;
	while (b > 0) {
		q = a / b;
		tmp = u; u = x - q * u; x = tmp;
		tmp = b; b = a - q * b; a = tmp;
	}

	return (x < 0) ? m + x : x;
}



signed main() {

	string s;
	cin >> s;
	string s2 = "CODEFESTIVAL2016";
	int ans = 0;
	REP(i, 16) {
		if (s[i] != s2[i]) ++ans;
	}
	cout << ans << endl;




	return 0;
}

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

const int INF = 1e+9;

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
	operator int() const noexcept { return to; }
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

template<class T>
vector<T> dijkstra(const WeightedGraph<T> &G,int source = 0){
	using P = pair<T,int>;
	vector<T> dist(G.size(),T(INF,INF));
	priority_queue<P,vector<P>,greater<P>> que;
	dist[source] = T(0,INF);
	que.emplace(dist[source],source);
	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(const auto &e : G[v]){
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				que.emplace(dist[e.to],e.to);
			}
		}
	}
	return dist;
}

using P = pair<int,int>;

P operator+(const P &p1,const P &p2){
	return P(p1.first + p2.first,min(p1.second,p2.second));
}

template<class T>
ostream &operator<<(ostream &os,const Edge<T> &e){ return os << "(" << e.to << "," << e.cost << ")"; }
ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

signed main(){
	int n,m,a[3];
	vector<int> vec[3];
	cin >> n;
	WeightedGraph<P> G(n + 3);
	for(int i = 0;i < 3;i++) cin >> a[i];
	for(int i = 0;i < 3;i++){
		vec[i].resize(a[i]);
		for(int j = 0;j < a[i];j++){
			cin >> vec[i][j]; vec[i][j]--;
			G[n + i].emplace_back(vec[i][j],P(0,vec[i][j]));
			G[vec[i][j]].emplace_back(n + i,P(0,vec[i][j]));
		}
	}
	cin >> m;
	for(int i = 0;i < m;i++){
		int x,y;
		cin >> x >> y; x--;y--;
		G[x].emplace_back(y,P(1,min(x,y)));
		G[y].emplace_back(x,P(1,min(x,y)));
	}
	vector<P> dist[3];
	for(int i = 0;i < 3;i++) dist[i] = dijkstra(G,n + i);
	P ans(INF,INF);
	for(int i = 0;i < n;i++){
		ans = min(ans,dist[0][i] + dist[1][i] + dist[2][i]);
	}
	cout << ans.first << " " << ans.second + 1 << endl;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];

  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    if (i == 0) cout << a[i];
    else cout << a[i] << " ";
  }

  cout << endl;
  return 0;
}

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


int main() {
    int A, B, C;

    cin >> A >> B;

    C = A * B % 2;

    if (C == 0) {
        cout << "Even" << endl;
    }
    else{
        cout << "Odd" << endl;
    }

}


Measured memory_bytes: 256
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
P = rl()

cnt = 0
for i in range(1, N-1):
	if P[i-1] < P[i] < P[i+1] or P[i-1] > P[i] > P[i+1]:
		cnt += 1
print(cnt)


Measured memory_bytes: 68524
<?php

    $N = intval(trim(fgets(STDIN)));
    
    $array = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    //偶数を取り出す
    foreach($array as $value){
        if($value%2==0){
            if(($value%3 ==0) || ($value%5 ==0)){
            }else{
                // echo $value." ";
                echo "DENIED\n";
                exit;
            }
        }
    }
    echo "APPROVED\n";
    
?>

Measured memory_bytes: 16120
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf,exp
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.865 #ループの時間制限  
A=26 #アルファベットの数
START=time.time()

ALPHA=20
ep=10**(-6) #アニーリングの微小温度
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[True]+list(map(int,input().split())) #減る満足度のベース
S=[True]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
t=time.time()-START
while t<TIME_LIMIT:
    d=randint(1,D)
    p=T[d]
    q=randint(1,A)
    Y=(d-g(p,d,T))*(f(p,d,T)-d)
    Z=(d-g(q,d,T))*(f(q,d,T)-d)
        
    Delta=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
    if (Delta>=0) or (Delta<0 and random()<exp(Delta/(ALPHA*(TIME_LIMIT-t)+ep))):
        T[d]=q
    
    t=time.time()-START

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 93688
#include <cstdio>
#include <algorithm>
using std::min;
 
#define MAXN 100003

int abs(int z)
{
    if (z<0)
        return -z;
    else
        return z;
}
 
int main(void)
{
    int N,i,j;
    int h[MAXN], p[MAXN];
    scanf("%d",&N);
    for (i=0;i<N;i++)
    {
        scanf("%d",h+i);
    }
    p[N-1]=0;
    p[N-2]=abs(h[N-2]-h[N-1]);
    for(i=N-3;i>=0;i--)
    {
        p[i]=min(p[i+1]+abs(h[i]-h[i+1]),p[i+2]+abs(h[i]-h[i+2]));
    }
    printf("%d\n",p[0]);
 
    return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
A = [int(x) for x in input().split()]

b = sum(A)/(4*M)
cnt = 0
for i in range(len(A)):
    if A[i] >= b:
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define F first
#define S second
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl

double v;

void solve(){
	double h=v*v/9.8/2.0;
	//cout<<h<<endl;
	
	li res=h/5;
	if(h-res*5>0)res++;
	cout<<res+1<<endl;
}

int main(){
	while(cin>>v)solve();
	
	return 0;
}

Measured memory_bytes: 1220
antena = [int(input()) for x in range(5)]
lim = int(input())
boo = True
for i in range(1, 5):
  for j in range(i):
    k = antena[i] - antena[j]
    if k > lim:
      boo = False
if boo:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3060
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    DList!int queue;

    foreach (i; 0..N) {
        if (i % 2 == 0) queue.insertFront(A[i]);
        else            queue.insertBack(A[i]);
    }

    if (N % 2 == 0) foreach (i; 0..N) write(queue.back, " "),  queue.removeBack;
    else            foreach (i; 0..N) write(queue.front, " "), queue.removeFront;
    writeln;
}


Measured memory_bytes: 19184
n = int(input());

sf = [ [0]*2 for i in range(n) ];
for i in range(n) :
	xl = input().split(' ');
	sf[i][0] = int(xl[0]) - int(xl[1]);
	sf[i][1] = int(xl[0]) + int(xl[1]);
	

sf.sort(key=lambda x:x[1] );

ans = 1;
end = sf[0][1];
for i in range(1,n) :
	if end <=  sf[i][0] :
		end = sf[i][1];
		ans += 1;

print(ans);

Measured memory_bytes: 21320
using System;
using System.Linq;

class Program {
  static void Main() {
    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int left = a[0] + a[1];
    int right = a[2] + a[3];
    if (left > right) {
      Console.WriteLine("Left");
    } else if (left < right) {
      Console.WriteLine("Right");
    } else {
      Console.WriteLine("Balanced");
    }
  }
}

Measured memory_bytes: 13268
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	B := ReadInts(N)
	C := ReadInts(N)

	sort.Ints(A)
	sort.Ints(C)

	ans := 0
	for i := 0; i < N; i++ {
		l := sort.SearchInts(A, B[i])
		r := N - sort.Search(N, func(j int) bool {
			return C[j] > B[i]
		})
		ans += l * r
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll>A(n);
    for(auto& x:A){
        cin >> x;
    }
    ll ret = 0;
    ll now = 0;
    for(auto& x:A){
        if(x!=now+1){
            ret++;
        }else{
            now++;
        }
    }
    if(now>0){
        cout << ret << endl;
    }else {
        cout << -1 << endl;
    }
    return 0;
}

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

using namespace std;

map <string , int  > mp;

int main () {
    int N;
    cin >> N;
    string S;
    while (N--) {
        cin >> S;
        mp[S]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
static const int mod = 998244353;

ll *fact, *inv;

ll C(int n, int r) {
    if (n < 0 || r < 0 || r > n) { return 0; }
    if (r > n / 2) { r = n - r; }
    return fact[n] * inv[r] % mod * inv[n-r] % mod;
}

ll extpow(ll x, ll y) {
    if (y == 0) { return 1; }
    else if (y == 1) { return x % mod; }
    else {
        ll part = extpow(x, y/2);
        if (y % 2 == 0) {
            return part * part % mod;
        } else { 
            return part * part % mod * x % mod;
        }
    }
}

int main() {
    int n, a, b;
    ll k;
    scanf("%d %d %d %lld", &n, &a, &b, &k);

    fact = new ll[n+1];
    inv = new ll[n+1];
    fact[0] = 1;

    for (int i = 1; i < n + 1; i++) {
        fact[i] = i * fact[i-1] % mod;
    }

    inv[n] = extpow(fact[n], mod - 2);
    // printf("inv[%d] = %lld\n", n, inv[n]);
    for (int i = n - 1; i >= 0; i--) {
        inv[i] = inv[i+1] * (i+1) % mod;
        // printf("inv[%d] = %lld\n", i, inv[i]);
    }

    // a <= b
    if (a > b) { swap(a, b); }

    ll ans = 0;
    for (ll j = 0; j <= k / b; j++) {
        if ((k - b * j) % a == 0) {
            ll i = (k - b * j) / a;
            if (i >= 0 && i <= n) {
                ans = (ans + C(n, i) * C(n, j)) % mod;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

///////////////////////////


	
int main() {
	ll p;
	ll a[5000];
	cin >> p;
	rep(i, p) cin >> a[i];

	ll b[5000] = {};

	if (a[0] == 1) { b[p - 1] = p-1; b[0] = 1; }

	repn(i, p - 1) {
		if (a[i] == 0) { continue; }
		ll c = p-1;
		for (ll j = p - 1; j >= 1; j--) {
			b[j] += c;
			c = c * i%p;
		}
	}

	rep(i, p) {
		b[i] %= p;
		cout << b[i] << " ";
	}


	system("PAUSE");
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
typedef pair<int,int> P;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}

int R,C;
int sy,sx;
int gy,gx;
string c[51];
void solve(){
	queue<P> qp;
	qp.push({sy,sx});
}
int main(){
	int a,b;
	cin>>a>>b;
	int sa=b-a;
	int t1=0;
	int t2=0;
	rep(i,1000){
		t1+=i;
		if(i+1+t1-t1==sa){
			cout<<t1-a<<endl;
			return 0;
		}
	}
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define inf 10000000000000005LL
#define mex 3005
int mat[mex][mex],dp[mex][mex][4];

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n,m,k; cin>>n>>m>>k; 
    fill(mat,0); fill(dp,0);
    for(int i=0;i<k;i++){
        int x,y,v; cin>>x>>y>>v;
        mat[x][y]=v;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            for(int l=1;l<=3;l++) dp[i][j][l]=max({dp[i][j-1][l],dp[i-1][j][3],dp[i][j-1][l-1]+mat[i][j],dp[i-1][j][3]+mat[i][j]});
        }
    }
    int ans=0;
    for(int i=0;i<4;i++) ans=max(ans,dp[n][m][i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 356368