akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import numpy as np
import types

# Input
i = list(input())
r = int(i[0] + i[1])
l = int(i[2] + i[3])

# Process
out = ""
if 1 <= r & r <= 12:
    out += "MM"
else:
    out += "YY"

if 1 <= l & l <= 12:
    out += "MM"
else:
    out += "YY"

# Print
if out == "MMMM":
    print("AMBIGUOUS")
elif out == "YYYY":
    print("NA")
else:
    print(out)


Measured memory_bytes: 12384
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define mp make_pair
const ll INF = 1e18;
const int MX=3e5+1;
int N, M, k;
set<int> st;
int main()
{
    string s;
    cin>>s;
    int good=0;
    for(int i=2;i<s.size();i++)
    {
       if(s[i] == s[i-1] && s[i-1] == s[i-2]) good=1;
    }
    if(good)cout<<"Yes\n";
    else cout<<"No\n";
    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<int, int> P;

bool is_prime[2000000];

int a[2000000];
vector<int> v[2000000];

int main() {
    memset(is_prime, true, sizeof(is_prime));
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i < 2000000; i++) {
        if (!is_prime[i]) continue;
        v[i].push_back(i);
        for (int j = 2 * i; j < 2000000; j += i) {
            is_prime[j] = false;
            v[j].push_back(i);
        }
    }
    int n;
    cin >> n;
    int g = 0;
    unordered_map<int, int> mp;
    rep(i, n) {
        scanf("%d", &a[i]);
        g = __gcd(g, a[i]);
        for (int u : v[a[i]]) {
            mp[u]++;
        }
    }
    bool ok = true;
    for (auto p : mp) {
        if (p.second != 1) ok = false;
    }
    if (ok)
        puts("pairwise coprime");
    else if (g == 1)
        puts("setwise coprime");
    else
        puts("not coprime");
}

Measured memory_bytes: 123604
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while (true) {

		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}

	}


	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int n,x,l[105];
int main()
{
  scanf("%d%d",&n,&x);
  for(int i=1;i<=n;++i)
  {scanf("%d",&l[i]);
  l[i]+=l[i-1];
  }
  printf("%d\n",upper_bound(l+1,l+n+1,x)-l);
return 0;
}

Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $ans = 0;
  for($i=1; $i<=$n; $i++){
    if($i%3 == 0 || $i%5 == 0){
      $ans += 0;
    }else {
      $ans += $i;
    }
  }
  echo $ans."\n";


Measured memory_bytes: 16132
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define PB push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mod 100000000
// #define int ll

const int N = 100002;
int a[N];
int n;
int pos[N];
int seg[4*N];
void build(int node,int st,int ed){
	if(st==ed){
		seg[node] = a[st];
		return;
	}
	build(2*node,st,(st+ed)/2);
	build(2*node+1,(st+ed)/2+1,ed);
	seg[node] = max(seg[2*node],seg[2*node+1]);
	return;
}
int query(int node,int st,int ed,int l,int r){
	if(l>r) return 0;
	if(ed<l||r<st) return 0;
	if(l<=st&&ed<=r) return seg[node];
	int a = query(2*node,st,(st+ed)/2,l,r);
	int b = query(2*node+1,(st+ed)/2+1,ed,l,r);
	return max(a,b);
}

int clc(int st,int ed,int val){
	if(st==0){
		int l = st;
		int r = ed;
		int ans = -1;
		while(l<=r){
			int mid = l+r;
			mid /= 2;
			int a = query(1,0,n-1,mid,r);
			if(a>val){
				ans = mid;
				l = mid+1;
			}
			else r = mid-1;
		}
		if(ans==-1) return -1;
		return ans;
	}else if(ed==n-1){
		int l = st;
		int r = ed;
		int ans = -1;
		while(l<=r){
			int mid = l+r;
			mid /= 2;
			int a = query(1,0,n-1,l,mid);
			if(a>val){
				ans = mid;
				r = mid-1;
			}
			else l = mid+1;
		}
		if(ans==-1) return n;
		return ans;
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];
	build(1,0,n-1);
	for(int i=0;i<n;i++) pos[a[i]] = i;
	ll ans = 0;
	for(int i=0;i<n;i++){
		int l1,l2,r1,r2;
		l1 = clc(0,i-1,a[i]);
		l2 = clc(0,l1-1,a[i]);
		r1 = clc(i+1,n-1,a[i]);
		r2 = clc(r1+1,n-1,a[i]);
		if(l1>=0){
			ll x = l1-l2;
			ll y = r1-i;
			ans += x*y*a[i];
		}
		if(r1<n){
			ll x = r2-r1;
			ll y = i-l1;
			ans += x*y*a[i];
		}
	}
	cout << ans << endl;
	
 	return 0;
}

Measured memory_bytes: 2048
S = input()
T = input()
len_S, len_T = len(S), len(T)
ans = []
for i in range(len_S-len_T+1):
	f = True
	for j in range(len_T):
		if S[i+j] != T[j] and S[i+j] != '?':
			f = False
			break
	if f:
		s = S[:i] + T + S[i+j+1:]
		ans.append(s.replace('?', 'a'))
if len(ans) == 0:
	print('UNRESTORABLE')
else:
	ans.sort()
	print(ans[0])

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n, m;
    cin >> n >> m >> s;
    n = s.length();
    int q = 0;
    for(int i=0; i<n; i++) {
        if(s[i]=='1')
            q++;
        else
            q = 0;
        if(q==m) {
            cout << -1;
            return 0;
        }
    }
    int pre[n+1];
    for(int i=0; i<n; i++){
        int t= i;
        while(s[t] == '1') t++;
        for(int jj = i; jj<t; jj++)
            pre[jj]  = t;
    }
    int dp[n];
    memset(dp, -1, sizeof dp);
    dp[0] = 0;
    for(int i=1; i<n; i++)
        if(s[i] == '0') {
            if(dp[max(0, i-m)]==-1)
                dp[i] = dp[pre[max(0, i-m)]]+1;
            else
                dp[i] = dp[max(0, i-m)]+1;
        }
    vector<int> res;
    for(int i = n-1; i>0; ) {
        int p = max(0, i-m);
        while(dp[p] == -1 || dp[i] - dp[p] > 1)
            p++;
        res.push_back(i-p);
        i = p;
    }
    for(int i=dp[n-1]-1; i>=0; i--)
        cout << res[i] << " ";
    return 0;
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; 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; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int L;
int A[200010];
int dp[200010][5];

int cost(int i, int k) {
    if (k == 0 || k == 4) return A[i];
    if (k == 1 || k == 3) {
        if (A[i] == 0) return 2;
        return A[i] % 2 == 1;
    }
    return A[i] % 2 == 0;
}

void _main() {
    cin >> L;
    REP(i, L) cin >> A[i];
    MINF(dp);
    dp[0][0] = 0;
    REP(i, L) REP(j, 5) FOR(k, j, 5) {
        CHMIN(dp[i + 1][k], dp[i][j] + cost(i, k));
    }
    int ans = INF;
    REP(i, 5) CHMIN(ans, dp[L][i]);
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 9600
a = []
for i in range(3):
  a.append(list(map(int, input().split())))

n = int(input())
for _ in range(n):
  b = int(input())

  for i in range(3):
    for j in range(3):
      if b == a[i][j]:
        a[i][j] = 0

for i in range(3):
  bingo = False
  if sum(a[i]) == 0:
    print('Yes')
    exit()
  if sum([a[0][i], a[1][i], a[2][i]]) == 0:
    print('Yes')
    exit()
if sum([a[0][0], a[1][1], a[2][2]]) == 0:
  print('Yes')
  exit()
if sum([a[2][0], a[1][1], a[0][2]]) == 0:
  print('Yes')
  exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include<iomanip>
using namespace std;
using P = pair<int, int>;

int N;
int memo[10][10];

int sentou(int a) {
	while (a > 9) {
		a = (int)a / 10;
	}
	return a;
}

int matubi(int a) {
	return a % 10;
}

int count(int a,int b) {
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int B = i;
		if (sentou(B) == b && matubi(B) == a) ans++;
	}
	memo[a][b] = ans;
	return ans;
}

int main()
{
	cin >> N;
	long long int ans = 0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			count(i,j);
		}
	}
	for (int i = 1; i <= N; i++) {
		int A = i;
		ans += memo[sentou(A)][matubi(A)];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 998244353; //1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

	 int h,w,n;
	 cin>>h>>w>>n;
	 if(h>w)
	 {
	 	cout<<(n+h-1)/h;
	 } 	
	 else{
	 	cout<<(n+w-1)/w;
	 } 
}
// h*k>=n
// I never lose. I either win or I learn

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    int n = in();
    VI as = in(n);

    LL ans = INFL;
    for (int y = -100; y <= 100; ++y) {
        LL cost = 0;
        for (auto x : as) {
            LL t = x - y;
            cost += t * t;
        }
        MINUD(ans, cost);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 605;
const int MM = 1000000007;

int C[MX][MX];
ll I[MX], FI[MX], F[MX];
int A[MX], sz = 0;
string S;
ll ans = 1;
int N, K;
int pr[75] = {};

int sum = -1, t = 2;

void update()
{
	if( N < sum ) return;
	int cnt = 0, red = 0, blue = 0;
	for(char c : S){
		if( c == 'r' ){
			if( red < sz) red++;
			else cnt -= cnt>0;
		}
		else{
			if( blue < red && A[blue] >= 2 ) cnt += A[blue++]-2;
			else cnt -= cnt>0;
		}
	}
	if(cnt || red != sz || A[blue] >= 2) return;

	ll m = F[sz];
	for(int i = 0; i < sz; i++) pr[A[i]] += 1;
	for(int i = 0; i <= A[0]; i++){
		if(pr[i]) m = m * FI[pr[i]] % MM;
		pr[i] = 0;
	}

	ans = (ans + C[t+N-1][N-sum] * m) % MM;
}

void dfs(int K, int mx){
	if( K == 0 ) return;
	for(int i = mx; i >= 1; i--){
		A[sz++] = i;
		t += i >= 2 ? 2 : 0;
		sum += i == 1 ? 2 : i*2-2;

		update();
		dfs(K-i, min(i, K-i));

		A[--sz] = 0;
		t -= i >= 2 ? 2 : 0;
		sum -= i == 1 ? 2 : i*2-2;
	}
}

int main()
{
	F[0] = FI[0] = 1;
	I[1] = 1;
	for(int i = 2; i < MX; i++) I[i] = (MM-I[MM%i]) * (MM/i) % MM;
	for(int i = 1; i < MX; i++) F[i] = F[i-1] * i % MM;
	for(int i = 1; i < MX; i++) FI[i] = FI[i-1] * I[i] % MM;
	scanf("%d%d", &N, &K);
	for(int i = 0; i < MX; i++){
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MM;
	}
	cin >> S;
	dfs(K, K);
	printf("%lld\n", ans);
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
const int N = 200010;
struct BIT{
	ll bit[200100];
	void add(int i,int x){
		i++;
		while(i<=N){
			bit[i]+=x;
			i += i&-i;
		}
	}
	ll sum(int i){
		i++;
		ll ret=0;
		while(i>0){
			ret+=bit[i];
			i -= i&-i;
		}
		return ret;
	}
}bit;
int n;
int a[200100];
vector<int> zip;
int main(){
	cin >> n;
	for(int i=0;i<n;i++)cin >> a[i];
	for(int i=0;i<n;i++)zip.pb(a[i]);
	sort(all(zip));
	for(int i=0;i<n;i++)a[i]=lower_bound(all(zip),a[i])-zip.begin();
	ll ans  = 0ll;
	for(int i=0;i<n;i++){
		ans += i-bit.sum(a[i]);
		bit.add(a[i],1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6020
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int N=nextInt();
		int A[]=new int[N];
		int b=0;
		long ans=0;
		for(int i=0;i<N;i++){
			A[i]=nextInt();
		}
		Arrays.sort(A);
		for(int i=0;b<N;b++){
			if(b==0)
				ans+=0;
			else
				ans+=A[N-1-i];
			if(b%2==1)
				i++;
		}
		System.out.println(ans);
	}
	static boolean isOK(int index,int key,ArrayList<Integer>a){
		if (a.get(index) >= key) return true;
	    else return false;
	}
	static int binary_search(int key,ArrayList<Integer> a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;

	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 40388
def P(s):
 R,P,*L=[0]*28
 for i in range(D):t=I[i+D][0]-1;P+=s-(i+1-L[t])*C[t];R+=I[i][t]-P;L[t]=i+1
 return R
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
for d,q in I[D-~D:]:I[d-1+D][0]=q;print(P(sum(C)))

Measured memory_bytes: 90612
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    ll cnt = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if (i % 2 == 0 && a % 2 == 1) {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    string next;
    next.push_back( A[ 0 ] );
    
    while( true )
    {
        if( next == "a" )
        {
            if( A.empty() )
            {
                cout << "A" << endl;
                break;
            }
            next = *A.begin();
            A.erase( A.begin() );
        }
        if( next == "b" )
        {
            if( B.empty() )
            {
                cout << "B" << endl;
                break;
            }
            next = *B.begin();
            B.erase( B.begin() );
        }
        if( next == "c" )
        {
            if( C.empty() )
            {
                cout << "C" << endl;
                break;
            }
            next = *C.begin();

            C.erase( C.begin() );
        }
    }
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll a,b,c,d,e,f,g,h;

int main(void){
	cin>>a>>b;
	c=(25*a+1)/2;
	d=10*b;
	e=25*(a+1)/2;
	f=10*(b+1);
	g=max(c,d);
	h=min(e,f);
	cerr<<g<<","<<h<<endl;
	if(g>=h){
		cout<<-1<<endl;
	}else{
		cout<<g<<endl;
	}
	return 0;
}

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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define N 3001

const int  mod =1e9+7;
int n;
string s;
int dp[N][N];
void solve(){

    dp[n][0]=(s[n-2]=='>') ? 1 : 0;
    dp[n][1]=(s[n-2]=='<') ? 1 : 0;
    
    for(int i=n-1;i>=2;i--){

        int total=n-i+1;
        for(int g=0;g<=total;g++){
            
            if(g==0){
                dp[i][g]=0;
                if(s[i-2]=='<') continue;

                for(int j=1;j<=total;j++) dp[i][g]=(dp[i][g]+dp[i+1][total-j])%mod;
            }
            else{
                if(s[i-2]=='<')
                    dp[i][g]=(dp[i][g-1]+dp[i+1][g-1])%mod;
                else
                    dp[i][g]=(mod+dp[i][g-1]-dp[i+1][g-1])%mod;
            }
            
        }

    }

    
    
}

int32_t main(){

    cin>>n;
    cin>>s;
    solve();
    
    int ans=0;
    for(int i=n-1;i>=0;i--) ans=(ans+dp[2][i])%mod;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 49728
N = int(input())
li = [int(x) for x in input().split()]

counter = {
        0: 0,
        1: 0,
        2: 0,
        3: 0,
        }

for i in range(len(li)):
    li[i] = li[i] % 4
    counter[li[i]] += 1

if counter[2] == 0:
    zeroes = counter[0]
    nonzeroes = N - zeroes
    if zeroes >= nonzeroes or zeroes + 1 == nonzeroes:
        print("Yes")
        exit(0)
    else:
        print("No")
        exit(0)
else:
    zeroes = counter[0]
    nonzeroes = N - zeroes - counter[2]
    if zeroes >= nonzeroes:
        print("Yes")
        exit(0)
    else:
        print("No")
        exit(0)





Measured memory_bytes: 14252
#include<iostream>
#include<vector>
using namespace std;
bool check(vector<int>,int);
int main(){	
	int n,num[1001][5],score[1001]={0};
	bool bo=false;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>num[i][0]>>num[i][1]>>num[i][2];
	}
	for(int i=0;i<3;++i){
		for(int j=0;j<n;++j){
			for(int k=0;k<n;++k){
				if(j==k){
					continue;
				}
				if(num[j][i]==num[k][i]){
					bo=true;
				}
			}
			if(!bo){
				score[j]+=num[j][i];
			}
			bo=false;
		}
	}
	for(int i=0;i<n;++i){
		cout<<score[i]<<endl;
	}
	return 0;	
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
int lcs[3456][3456];
int main()
{
	fastScan;
	string s,t;cin>>s>>t;
	int l1=s.length(),l2=t.length();
	for(int i=1;i<=l1;i++)
	{
		for(int j=1;j<=l2;j++)
		{
			if(s[i-1]==t[j-1])
				lcs[i][j]=lcs[i-1][j-1]+1;
			else
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
		}
	}
	string ans="";
	int i=l1,j=l2;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			ans+=s[i-1];
			i--;
			j--;
		}
		else if(lcs[i-1][j]>lcs[i][j-1])
			i--;
		else
			j--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<nl;
}


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

int ans = 0;

char f(char c){
	if( c == ')' )
		return '(';
	if( c == '(')
		return ')';
	if( c == ']' )
		return '[';
	if( c == '[')
		return ']';
	if( c == '}' )
		return '{';
	if( c == '{')
		return '}';
	return c;
}

bool is_iwi(string s){
	if( s.size() < 3 ) return false;
	int cnt = 0;
	for(int i=2 ; i < s.size() ; i++ ){
		if( s[i-2] == 'i' && s[i-1] == 'w' && s[i] == 'i' ){
			cnt++;
		}
	}
	if( cnt == 1 ) return true;
	return false;
}

bool is_line_symmetry(string s){
	if( s.size() % 2 == 1 && s[ s.size()/2 ] == '(' || s[ s.size()/2 ] == ')' ){
		return false;
	}
	if( s.size() % 2 == 1 && s[ s.size()/2 ] == '[' || s[ s.size()/2 ] == ']' ){
		return false;
	}
	if( s.size() % 2 == 1 && s[ s.size()/2 ] == '{' || s[ s.size()/2 ] == '}' ){
		return false;
	}
	for(int i=0 ; i < s.size()/2 ; i++ ){
		if( f(s[i]) != s[s.size()-i-1] ){
			return false;
		}
	}
	return true;
}

void solve(const string& s_, string s, int pos){
	if( pos == s_.size() ){
		if( is_iwi(s) && is_line_symmetry(s) ){
			ans = max( ans , (int)s.size() );
		}
		return ;
	}
	solve( s_ , s , pos+1 );
	s.push_back( s_[pos] );
	solve( s_ , s , pos+1 );
}

int main(){
	string s;
	cin >> s;
	solve( s , "" , 0 );
	cout << ans << endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL dp[410][410] = {};
LL acc[410] = {};
VL a;

LL rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(l+1 == r) return dp[l][r] = 0;

    LL res = LINF;
    for(int i = l+1; i < r; i++){
        chmin(res,rec(l,i)+rec(i,r)+acc[r]-acc[l]);
    }
    return dp[l][r] = res;

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    a.resize(N);
    REP(i,N) cin >> a[i];
    memset(dp,-1,sizeof(dp));
    //REP(i,410) dp[i][i] = 0;
    REP(i,N){
        acc[i+1] = acc[i] + a[i];
    }

    cout << rec(0,N) << endl;
    

}


Measured memory_bytes: 1664
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// nがあり、nの数だけの整数の入力
			long n = sc.nextLong();
			List<Long> xn = new ArrayList<>();
			for (long i = 0; i < n; i++) {
				xn.add(sc.nextLong());
			}

			long result = Long.MAX_VALUE;
			for (int i = 1; i <= 1000; i++) {
				long wk = 0;
				for (Long x : xn) {
					wk = wk + (x - i) * (x - i);
				}
				if (result > wk) {
					result = wk;
				} else {
					break;
				}
			}

			// 出力(整数)
			System.out.println(result);
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Measured memory_bytes: 21844
N = int(input())

S = input()

S_re = "".join(list(reversed(S)))

left = []
right = []

now = 0
for i in range(N):

    left.append(now)

    if S[i] == "W":
        now += 1

now = 0
for i in range(N):

    right.append(now)

    if S_re[i] == "E":
        now += 1

right.reverse()


ans = N
for i in range(N):

    ans = min(ans, left[i] + right[i] )
        

print (ans)


Measured memory_bytes: 21460
#include <iostream>
//#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
    ll a, b, c, d;
    int flug(0);
    cin >> a >> b >> c;
    d = c - a - b;
    if (d > 0) {
        if (d * d > 4 * a * b) {
            flug = 1;
        }
    }
    if (flug == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const ll tot_mask = (1<<18);
ll dp[tot_mask][51];
int solve()
{
	ll n;cin>>n;
	vi a(n),b(n);
	ll big = -1;
	rep(i,0,n) cin>>a[i],big=max(big,a[i]);
	rep(i,0,n) cin>>b[i],big=max(big,b[i]);
	rep(i,0,tot_mask) rep(j,0,51) dp[i][j]=inf;
	dp[0][0]=0;
	ll mask = 1<<n;
	rep(w,0,mask)
	{
		ll pos = __builtin_popcount((unsigned int)w);
		rep(last_el,0,big+1)
		{
			// whatis(dp[w][last_el]);
			ll d=0;
			rep(i,0,n)
			{
				if(((w>>i)&1)==0)
				{
					ll val = b[i];
					if((abs(i-pos))%2==0) val=a[i];
					// cout<<val<<" "<<i<<"\n";
					if(val>=last_el)
					{
						dp[w|(1<<i)][val] = min(dp[w|(1<<i)][val],dp[w][last_el]+d); 
						// whatis(dp[w|(1<<i)][val]);
					}
					d++;
				}
			}
		}
	}
	ll ans = inf;
	rep(i,0,big+1) ans=min(ans,dp[mask-1][i]);
	if(ans==inf) ans=-1;
	cout<<ans<<"\n"; 
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

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

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 104704
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char c;
  
  cin >> c;
  
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int a[4],b[4],h,bl;
	while(scanf("%d %d %d %d\n%d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		h=0;bl=0;
		for(int i=0;i<4;i++){
			if(a[i]==b[i])h++;
			else for(int j=0;j<4;j++)if(a[i]==b[j])bl++;
		}
		cout<<h<<" "<<bl<<endl;
	}
}

Measured memory_bytes: 0
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin - 1; end <= i; i--)		// repeat reverse

#endif

int main(void)
{
	ll x, a;
	cin >> x >> a;
	ll ans = (x < a) ? 0 : 10;

	cout << ans;
	return 0;
}


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

using namespace std;

long long myatoll(char c) {
    return (long long)atoi(&c);
}

long long P_is_not_2_5(long long N, long long P, const string& S) {
    map<long long, long long> residual;
    residual.insert(make_pair(0LL, 1LL));
    long long pow10 = 1;
    long long curr = 0LL;
    for (long long i = N - 1; i >= 0; --i) {
        //int s = atoi(S.substr(i, 1).c_str());
        //int m = (s * pow10 + curr) % P;
        //if (residual.count(m) == 0) {
        //    residual.insert(make_pair(m, 0LL));
        //}
        //residual[m] += 1;
        //curr = m;
        long long x = (curr + pow10 * (long long)atoi(S.substr(i, 1).c_str())) % P;
        if (residual.count(x) == 0) {
            residual.insert(make_pair(x, 1LL));
        }
        else {
            residual[x] += 1;
        }
        curr = x;
        pow10 *= 10;
        pow10 %= P;
    }
    long long ans = 0;
    for (auto it : residual) {
        long long n = it.second;
        if (n >= 2) {
            ans += n * (n - 1) / 2;
        }
    }
    return ans;
}

long long P_is_2_or_5(long long N, long long P, const string& S) {
    long long ans = 0LL;
    for (long long i = 0; i < N; ++i) {
        long long c = myatoll(S[i]);
        if (c % P == 0) {
            ans += i + 1;
        }
    }
    return ans;
}

void Main() {
    long long N, P;
    cin >> N >> P;
    string S;
    cin >> S;

    long long ans = 0LL;
    if (P == 2LL || P == 5LL) {
        ans = P_is_2_or_5(N, P, S);
    }
    else {
        ans = P_is_not_2_5(N, P, S);
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000000000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    int ans = 1, quan[n+1];
    fill(quan, quan+n+1, 2);
    quan[1] = 1;
    for (int q = 2; q <= n; q++){
        for (int q1 = q*2; q1 <= n; q1 += q){
            ++quan[q1];
        }
        ans += q*quan[q];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 81760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,m,c,ans=0;cin>>n>>m>>c;
  vector<int> b(m);
  rep(i,m)cin>>b[i];
  int cnt=0;
  rep(j,n){
    ans=c;
    rep(i,m){
    	int x;cin>>x;ans+=x*b[i];
    }
    if(ans>0)cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	VV a(n, V(10));
	rep(i, n) rep(j, 10) {
		cin >> a[i][j];
	}
	VV pro(n, V(11));
	rep(i, n) rep(j, 11) {
		cin >> pro[i][j];
	}
	int ans = -Inf;
	// cout << ans << endl;
	for (int bit = 1; bit < (1 << 10); bit++) {
		V count(n, 0);
		int tmp = 0;
		rep(i, n) rep(j, 10) {
			if (1 & (bit >> j) && a[i][j]) count[i]++;
		}
		rep(i, n) {
			tmp += pro[i][count[i]];
		}
		chmax(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

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

  ll a;
  vector<ll> A;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }

  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  priority_queue <ll> pque;
  queue<ll> que;

  for (int i = 0; i < N; ++i) {
    que.push(A[i]);
  }

  ll ans = 0;

  while (!que.empty()) {
    ll v = que.front();
    que.pop();

    if (!pque.empty()) {
      ll m = pque.top();
      pque.pop();

      ans += m;
    }

    if (ans == 0) {
      pque.push(v);
    } else {
      pque.push(v);
      pque.push(v);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 9504
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
bool Tmax[100005];
bool Amax[100005];
int N;
ll T[100005],A[100005],Tmx=0,Amx=0;
int main(void)
{
  ll ans=1;
  memset(Tmax,true,sizeof(Tmax));
  memset(Amax,true,sizeof(Amax));
  cin >> N;
  for (int i = 0; i < N; ++i)
    {
      cin >> T[i];
      if(Tmx==T[i])
	{
	  Tmax[i]=false;
	}
      else
	{
	  Tmx=T[i];
	}
    }
  for (int i = 0; i < N; ++i)
    {
      cin >> A[i];
    }
  for (int i = N-1; i >= 0; i--)
    {
      if(Amx==A[i])
	{
	  Amax[i]=false;
	}
      else
	{
	  Amx=A[i];
	}
    }
  for (int i = 0; i < N; ++i)
    {
      if((Tmax[i] && Amax[i]) &&T[i]!=A[i])
	{
	  ans=0;
	}
      else if((Tmax[i] && A[i]<T[i]) || (Amax[i] && T[i]<A[i]))
	{
	  ans=0;
	}
      else
	{
	  ll Tcand,Acand;
	  if(Tmax[i])
	    {
	      Tcand=1;
	    }
	  else
	    {
	      Tcand=T[i];
	    }
	  if(Amax[i])
	    {
	      Acand=1;
	    }
	  else
	    {
	      Acand=A[i];
	    }
	  ans=(ans*min(Tcand,Acand))%MOD;
	}
	
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 277;
int n;
char s[N];
vector<pii> a[N];

int main()
{
	startTime = (double)clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d %s", &n, s);
//	n = 8;
//	for (int i = 0; i < (1 << n); i++)
//		s[i] = '1';
//	s[(1 << n) - 1] = '0';

	if (s[0] == '0') {
		printf("Impossible\n");
		return 0;
	}
	for (int i = 0; i < (1 << n); i++)
		for (int j = 0; j < (1 << n); j++) {
			if (s[i] == '0' && s[j] == '1' && ((i & j) == i)) {
				printf("Impossible\n");
				return 0;
			}
		}
	for (int i = 0; i < n; i++) {
		int mask = 1 << i;
		for (int j = 0; j <= i + 1; j++)
			a[mask].push_back(mp(j, 0));
		a[mask].push_back(mp(i + 1, 1));
		a[mask].push_back(mp(i, 1));
		for (int j = i; j >= 0; j--)
			a[mask].push_back(mp(j, 0));
	}
	for (int mask = 1; mask < (1 << n); mask++) {
		if (!a[mask].empty()) continue;
		int p = 0;
		while(((mask >> p) & 1) == 0) p++;
		p = 1 << p;
		int q = mask ^ p;
		a[mask].push_back(mp(0, 0));
		for (int i = 1; i < (int)a[p].size(); i++)
			a[mask].push_back(a[p][i]);
		for (int i = 1; i < (int)a[q].size(); i++)
			a[mask].push_back(a[q][i]);
		for (int i = (int)a[p].size() - 2; i >= 0; i--)
			a[mask].push_back(a[p][i]);
		for (int i = (int)a[q].size() - 2; i >= 0; i--)
			a[mask].push_back(a[q][i]);
	}
	vector<pii> ans;
	ans.push_back(mp(0, 0));
	for (int i = 0; i < (1 << n); i++) {
		if (s[i] == '1') continue;
		bool ok = true;
		for (int j = 0; j < i; j++) {
			if ((j & i) == j)
				ok &= s[j] == '1';
		}
		if (!ok) continue;
		for (int j = 1; j < (int)a[i].size(); j++)
			ans.push_back(a[i][j]);
	}
	printf("Possible\n");
	printf("%d\n", (int)ans.size() - 1);
	for (pii t : ans)
		printf("%d %d\n", t.first, t.second);

	return 0;
}


Measured memory_bytes: 2428
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
# import sys
# sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)

def main():



    n = int(input())
    s = input()
    ans = 0
    for i in range(n - 2):
        # print(s[i:i+3])
        if s[i:i + 3] == "ABC":
            ans += 1
    print(ans)
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))

    # g = lcm(a[0], a[1])
    # for i in range(2, n):
    #     g = lcm(g, a[i])
    # if g // 2 > m:
    #     print(0)
    #     exit()
    # print(g)
    # print(math.ceil(m//g + 0.5))



    


if __name__ == '__main__':
    main()


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a * b % 2 >= 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n,m,x,c[15],a[15][15], ans=INF;
    cin>>n>>m>>x;
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++){
        int count[15]={}, money=0;
        rep(j,n){//使う本
            if(i&(1<<j)){
                money+=c[j];
                rep(k,m){
                    count[k]+=a[j][k];
                }
            }
        }
        bool check=true;
        rep(j,m){
            if(count[j]<x)check=false;
        }
        if(check){
            ans=min(ans,money);
        }
    }
    if(ans!=INF)cout<<ans;
    else cout<<"-1";
    return 0;
}


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

bool f(int x){
    int keta = 0;
    while(x){
        keta++;
        x /= 10;
    }
    return keta % 2 == 1;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(f(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632