akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

[[maybe_unused]] static auto __x = [](){ios_base::sync_with_stdio(0); cin.tie(0);};

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

    int res = 0;
    while (h > 0) {
        h -= a;
        ++res;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
        int n, x;
        cin >> n >> x;
        int pos = 0;
        int l;
        int ans = 1;
        for(int i=0;i<n;i++){
                cin >> l;
                pos += l;
                if(pos <= x){
                        ans++;
                }
        }

        cout << ans << endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int H, W, SH, SW;
    cin >> H >> W >> SH >> SW;

    if (H%SH == 0 && W%SW == 0) {
        cout << "No" << endl;
    } else {
        int sum = 0;
        cout << "Yes" << endl;

        if (W%SW == 0) {
            rep(h, H) {
                rep(w, W) {
                    int tmp = (h+1)%SH == 0 ? -(1000 * (SH-1) + 1) : 1000;
                    cout << (w>0 ? " " : "") << tmp;
                    // cout << (w>0 ? " " : "") << (w%SW != 0 ? -1000 : 1000 * (SW - 1) - 1);
                    sum += tmp;
                }
                cout << endl;
            }
        } else {
            rep(h, H) {
                rep(w, W) {
                    int tmp = (w+1)%SW == 0 ? -(1000 * (SW-1) + 1) : 1000;
                    cout << (w>0 ? " " : "") << tmp;
                    // cout << (w>0 ? " " : "") << (w%SW != 0 ? -1000 : 1000 * (SW - 1) - 1);
                    sum += tmp;
                }
                cout << endl;
            }
        }
        assert(sum > 0);
    }
}

Measured memory_bytes: 1664
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if a*500 + b*100 + c*50 == X:
                count +=1
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    long long N;
    std::cin >> N;

    if (N % 2 == 0) { std::cout << N << std::endl; }else{
        std::cout << 2 * N << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
class PriorityQueue
  attr_reader :size

  def initialize(order: :asc)
    @size = 0
    @nodes = []
  end

  def empty?
    @size.zero?
  end

  def push(node)
    index = size
    @size += 1

    while index > 0
      parent = (index - 1) / 2

      break if @nodes[parent].last <= node.last

      @nodes[index] = @nodes[parent]
      index = parent
    end

    @nodes[index] = node
  end

  alias_method :<<, :push

  def pop
    node = @nodes.first
    root = @nodes[size - 1]
    @size -= 1
    index = 0

    while index * 2 + 1 < @size
      left = 2 * index + 1
      right = left + 1

      if right < size && @nodes[right].last < @nodes[left].last
        left = right
      end

      break if @nodes[left].last >= root.last

      @nodes[index] = @nodes[left]
      index = left
    end

    @nodes[index] = root
    node.first
  end

  def top
    @nodes.first
  end
end

N = gets.to_i
A = gets.split.map(&:to_i)

front = PriorityQueue.new
front_sum = 0

back = PriorityQueue.new(order: :desc)
back_sum = 0

N.times do
  v = A.shift
  front.push([v, v])
  front_sum += v

  w = A.pop
  back.push([w, -w])
  back_sum += w
end

f_sums = [front_sum]
b_sums = [back_sum]

A.each do |a|
  if front.top[0] < a
    front_sum -= front.pop
    front.push([a, a])
    front_sum += a
  end

  f_sums << front_sum
end

A.reverse_each do |a|
  if back.top[0] > a
    back_sum -= back.pop
    back.push([a, -a])
    back_sum += a
  end

  b_sums << back_sum
end

puts f_sums.zip(b_sums.reverse).map { |a, b| a - b }.max



Measured memory_bytes: 45716
import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 7516
n = int(input())
aaa = map(int, input().split())

length = 0
lengths = []
for a in aaa:
  length += a
  lengths.append(length)
  
diffs = []
for l in lengths:
  diff = abs(l - (length - l))
  diffs.append(diff)
    
print(min(diffs))

Measured memory_bytes: 27596
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int q, n; scanf("%d%d", &q, &n);
	std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];
	
	int sum = 0;
	std::vector<int> X(n), Y(n);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n / 2; j++) {
			if(s[i][j] != s[i][n - j - 1]) X[i]++;
			if(s[j][i] != s[n - j - 1][i]) Y[i]++;
		}
		sum += X[i] + Y[i];
	}
	
	int ans = (sum == 0);
	for(int i = 0; i < q - 1; i++) {
		int k; scanf("%d", &k);
		while(k--) {
			int x, y; scanf("%d%d", &x, &y); x--; y--;
			
			{ // X
				int before = (s[x][y] != s[x][n - y - 1]);
				int after  = 1 - before;
				X[x] += after - before;
				sum += after - before;
			}
			{ // Y
				int before = (s[x][y] != s[n - x - 1][y]);
				int after  = 1 - before;
				Y[y] += after - before;
				sum += after - before;
			}
			if(s[x][y] == '1') s[x][y] = '0';
			else s[x][y] = '1';
		}
		ans += (sum == 0);
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;

int main()
{
    long N;
    cin >> N;
    vector<long> A(N);
    rep(i, 0, N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    rep(i, 0, N - 1)
    {
        if (A[i] == A[i + 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize(2)

#include<bits/stdc++.h>
#define mp			make_pair
#define rep(i,n)	for(int i=0;i<n;i++)
#define BINF		0x7fffffff
#define INF			0x3f3f3f3f
#define LINF		3223372036854775807
#define END(s)		{cout<<s;return 0;}
#define CON(s)		{cout<<s;continue;}
#define BRE(s)		{cout<<s;break;}
#define pb			push_back
//#define int			long long
#define All(a)		a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a)		(int)a.size()
#define F			first
#define S			second
const bool debug=1;
const bool files=0;
using namespace std;

int cnt[2];
bool dp[2][800];
int col[800];
bool has[800][800];
int n,m;

void dfs(int now,int c){
	col[now]=c;
	cnt[c]++;
	rep(i,n){
		if(has[now][i]){
			if(col[i]==-1){
				dfs(i,(!c));
			} else if(col[i]==col[now]){
				cout<<"-1";
				exit(0);
			}
		}
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n){
		col[i]=-1;
		rep(j,n){
			has[i][j]=(i!=j);
		}
	}
	rep(i,m){
		int x,y;
		cin>>x>>y;
		x--;y--;
		has[x][y]=has[y][x]=false;
	}
	dp[0][0]=1;
	rep(i,n){
		if(col[i]!=-1) continue;
		cnt[0]=cnt[1]=0;
		dfs(i,0);
		rep(j,n){
			dp[1][j]=0;
		}
		rep(j,n){
			if(!dp[0][j]) continue;
			dp[1][j+cnt[0]]=dp[1][j+cnt[1]]=1;
		}
		rep(j,n){
			dp[0][j]=dp[1][j];
		}
	}
	for(int i=n/2;i>=0;i--){
		if(dp[0][i]){
			cout<<((i*(i-1)+(n-i)*(n-i-1))/2);
			return 0;
		}
	}
	assert(false);
	return 0;
}

Measured memory_bytes: 768
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N,M;
vi C(1e5+10);
int ans;

signed main(){

    in(N,M);
    rep(i,M){
        int l,r;
        in(l,r);
        l--;
        C[l]++;
        C[r]--;
    }

    rep(i,C.size()-1){
        C[i+1]+=C[i];
    }

    //showlr(C,0,5);
    rep(i,C.size()){
        if(C[i]==M) ans++;
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#define ll long long
using namespace std;
bool mx[1003][1003], flag[10004];
ll a[1003], b[1003], ans[1003][1003];
ll prime[10004];
ll gcd(ll x, ll y){
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y){
	if (x == 0 || y == 0)
		return x + y;
	return x / gcd(x, y) * y;
}
int main(){
	int prime_cnt = 0;
	for (int i = 2; i <= 10000; ++ i){
		if (! flag[i])
			prime[++ prime_cnt] = i;
		for (int j = 2; i * j <= 10000; ++ j){
			flag[i * j] = true;
			if (i % j == 0)
				break;
		}
	}
	int n;
	cin >> n;
	if (n == 2){
		cout << "4 7" << endl << "23 10" << endl;
		return 0;
	}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j)
			if (i % 2 == j % 2)
				mx[i][j] = true;
	int cnt = 0;
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j)
			if (! mx[i][j]){
				//if (! a[i + j])
					//a[i + j] = prime[++ cnt];
				//if (! b[i - j + n])
					//b[i - j + n] = prime[++ cnt];
				//ans[i][j] = a[i + j] * b[i - j + n];
				ans[i][j] = prime[(i + j) / 2] * prime[(i + n + 1 - j) / 2 + n];
			}
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= n; ++ j)
			if (mx[i][j])
				ans[i][j] = lcm(lcm(ans[i - 1][j], ans[i + 1][j]), lcm(ans[i][j - 1], ans[i][j + 1])) + 1;
	for (int i = 1; i <= n; ++ i){
		for (int j = 1; j <= n; ++ j)
			cout << ans[i][j] << " ";
		cout << endl;
	}
}


Measured memory_bytes: 9472
import sys

n = int(input())
v = list(map(int,input().split()))

a1 = {}
a2 = {}
for i in range(n) :
  a = v[i]
  if i%2 == 0 :
    if a in a1 :
      a1[a] += 1
    else :
      a1[a] = 1
  else :
    if a in a2 :
      a2[a] += 1
    else :
      a2[a] = 1

a1_s = sorted(a1.items(), key = lambda x : x[1], reverse = True)
a2_s = sorted(a2.items(), key = lambda x : x[1], reverse = True)

ans = n
for i in range(min(2,len(a1_s))) :
  for j in range(min(2,len(a2_s))) :
    if a1_s[i][0] == a2_s[j][0] :
      continue
    ans = min(ans,n-a1_s[i][1]-a2_s[j][1])

if len(a1_s) == 1 and len(a2_s) == 1 and ans == n :
  ans = n//2

print(ans)

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

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s==t){
            cout << "Yes" << endl;
            return 0;
        }
    string ret=s;
    ret[0]=s[n-1];
    rep(i,n-1){
        ret[i+1]=s[i];
    }
    s=ret;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
    std::string sa, sb, sc;
    std::cin >> sa >> sb >> sc;

    std::string::iterator head[3] = {sa.begin(), sb.begin(), sc.begin()};
    std::string::iterator tail[3] = {sa.end(), sb.end(), sc.end()};
    char turn = *head[0]++;
    while (true)
    {
        if (head[turn - 'a'] != tail[turn - 'a'])
        {
            turn = *head[turn - 'a']++;
        }
        else
        {
            std::cout << static_cast<char>(turn - 'a' + 'A') << std::endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a)
  {
    cin >> i;
  }
  int count = 0;
  bool b = false;
  while (true)
  {
    for (int &i : a)
    {
      if (i % 2 == 1)
      {
        b = true;
        break;
      }else{
        i /= 2;
      }
    }
    if (b)
      break;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}

int main() {
	ll A,B,N;
  	cin >> A>> B>>N;
  	ll ans;
  	if(A == 1) cout << 0 << endl;
  	else if(B == 1) cout << 0 << endl;
  	else{
    	if(B > N) ans = (A*N)/B - A*(N/B);
      	else ans = (A*(B-1))/B;
      	cout << ans << endl;
    }
}

Measured memory_bytes: 3680
N, K = map(int, input().split())
*A, = map(int, input().split())
A.sort()

S = sum(A)
candidates = []
for i in range(1, int(S**0.5)+1):
    if S%i:continue
    a, b = i, S//i
    
    candidates.append(a)
    if a!=b:
        candidates.append(b)
candidates.sort()

ans = 0
for d in candidates:
    rems = []
    rems_size, rems_sum = 0, 0

    for i in A:
        if i%d:
            rems.append(i%d)
            rems_size += 1
            rems_sum += i%d

    rems.sort()

    a = 0
    for i, j in enumerate(rems[:-1], start=1):
        a += j
        b = d*(rems_size-i)-(rems_sum-a)
        if max(a, b)<=K:
            ans = max(ans, d)
    if not rems:
        ans = max(ans, d)

print(ans)

Measured memory_bytes: 42220
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;

int main() {
    long A,B; cin >> A >> B;
    bitset<40> A_bitset = bitset<40>(A-1), B_bitset = bitset<40>(B);
    string A_bit_str = A_bitset.to_string(), B_bit_str = B_bitset.to_string();

    char A_xor, B_xor;
    string result_bit_str = "";
    for (int i=0; i<40; i++) {
        if (i==40-1) {
            A_xor = ( (char)A_bit_str[40-1] !=  (char)A_bit_str[40-2] ? '1' : '0' );
            B_xor = ( (char)B_bit_str[40-1] !=  (char)B_bit_str[40-2] ? '1' : '0' );
        } else {
            A_xor = ( (char)A_bit_str[i] == '1' and (char)A_bit_str[40-1] == '0' ? '1' : '0' );
            B_xor = ( (char)B_bit_str[i] == '1' and (char)B_bit_str[40-1] == '0' ? '1' : '0' );
        }
        result_bit_str += ( A_xor != B_xor ? '1' : '0' );
    }

    bitset<40> result_bit(result_bit_str);
    long result = result_bit.to_ulong();
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}

#define REP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000+7)

int main() {
    int A, B , C;
    cin >> A >> B >> C;
    cout << max(0, C - (A-B)) << endl;
}


Measured memory_bytes: 888
big_int = 10 ** 9

N, M, X = map(int, input().split())

L = [0 for i in range(N)]
for i in range(N):
  L[i] = tuple(map(int, input().split()))

def foo(i):
  t = i
  T = [0 for j in range(M+1)]
  for j in range(N):
    for k in range(M+1):
      T[k] += L[j][k] * (t%2)
    t //= 2
  for k in range(1,M+1):
    if T[k] < X:
      return big_int
  return T[0]
  
ans = big_int

for i in range(2**N):
  ans = min(ans, foo(i))
  
if ans == big_int:
  print(-1)
else:
  print(ans)

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

int n, k, a;
std::vector<std::pair<int, int>> vec;
std::map<int, int> m;
int num_kind = 0;

int main() {
    std::cin >> n >> k;
    for (int i = 0; i < n; i++) {
        std::cin >> a;
        m[a]++;
    }
    for (auto e: m) {
        num_kind++;
        vec.push_back(e);
    }
    if (num_kind <= k) {
        std::cout << 0 << std::endl;
        return 0;
    }
    std::sort(vec.begin(), vec.end(), [](std::pair<int, int> a, std::pair<int, int> b) {
            if (a.second == b.second) {
                return a.first < b.first;
            }
            return a.second < b.second;
            });
    int sum = 0;
    for (int j = 0; j < num_kind - k; j++) {
        sum += vec[j].second;
    }
    std::cout << sum << std::endl;
}


Measured memory_bytes: 11768
N = int(input())
# DPだと思ったけど、2次元じゃなくて1次元だった
# けんちょんさん曰く、1次元でできないときに2次元で考える
sixes = [6 ** i for i in range(1, 7)]
nines = [9 ** i for i in range(1, 6)]
coin = [1] + sixes + nines
INF = 10**6
dp = [INF] * 100010
dp[0] = 0  # dp[i]:i円引き出すのに必要な回数
for money in range(1, N + 1):
    dp_candidate = []
    for coin_ in coin:
        if money < coin_:
            continue
        else:
            dp_candidate.append(dp[money-coin_] + 1)
    dp[money] = min(dp_candidate)
print(dp[N])


Measured memory_bytes: 3956
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.a();
  var b = o.a();
  var h = o.r(n);
  var ok = Math.ceil(1e9/b), ng = 0;
  a -= b;
  while(ok-ng > 1){
    var m = ok+ng >> 1;
    if(solve(m,n,a,b,h))ok = m;
    else ng = m;
  }
  return ok;
}
function solve(m,n,a,b,h){
  var k = m;
  for(var i = 0; i < n; i++){
    var t = h[i]-m*b;
    if(t <= 0)continue;
    k -= Math.ceil(t/a);
    if(k < 0)return;
  }
  return 1;
}

Measured memory_bytes: 28000
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_FLOAT(): return float(INPUT())
def MULTIPLE_FLOAT_LIST(): return list(map(float, INPUT().split()))
def MULTIPLE_FLOAT_MAP(): return map(float, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

A, B = MULTIPLE_INT_MAP()

print((A*3 + B) // 2)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);
        if (Character.isUpperCase(c)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }

}

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

int main(){
  int N, K; cin >> N >> K;
  int cnt = 0;
  for(int i = 1; i <= N; i = i + 2){
    //cout << i << " ";
    cnt++;
  }
  //cout << endl;
  //cout << cnt << endl;
  if(cnt >= K){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }    
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
Q=int(input())

Val=[0 for _ in range(10**5+1)]
Sout=0
for a in A:
    Val[a]+=1
    Sout+=a

LL=[[] for _ in range(Q)]
for i in range(Q):
    out=0
    B,C=map(int,input().split())
    LL[i]=Sout+(C-B)*Val[B]
    Val[C]+=Val[B]
    Val[B]=0
    Sout=LL[i]
for ll in LL:
    print(ll)

Measured memory_bytes: 21308
N, M = map(int, input().split())
r = [[] * N for i in range(N)]
reached = [0] * N
reached[0] = 1
count = 0

def dfs(now):
    global count
    if all(reached):
        count += 1
    for next in r[now]:
        if reached[next] == 0:
            reached[next] = 1
            dfs(next)
            reached[next] = 0

for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    r[a].append(b)
    r[b].append(a)

dfs(0)

print(count)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int n = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < n; i++) {
      list.add(sc.nextInt());
    }
    int a = x;
    int b = x;
    for(int i = x; i >= x - 200; i--) {
      if(!list.contains(i)) {
        a = i;
        break;        
      }
    }
    for(int i = x; i <= x + 200; i++) {
      if(!list.contains(i)) {
        b = i;
        break;        
      }
    }
    int ans = a;
    if(Math.abs(a - x) > Math.abs(b - x)) ans = b;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35840
/***
*	author  :_shamim
*	created : 05.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)          

using namespace std;

ll i,j,temp;

int main()
{_
	
	int n,cnt;
	cin>>n;

	ll arr[n],divisibility[n];
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	for(i=0;i<n;i++){
		cnt =0;
		while(arr[i]%2==0){
			arr[i]/=2;
			cnt++;
		}
		divisibility[i]= cnt;
	}
	sort(divisibility,divisibility+n);
	cout<<divisibility[0]<<endl;


	return 0;
}

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

/*
 * ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_B
 */

using namespace std;

const int MAX_N = 100;

int n;
int d[MAX_N];
int f[MAX_N];
vector<int> adjlist[MAX_N];

int dfs(const int id, int timestamp) {
    if (d[id - 1] > 0) {
        return timestamp;
    }

    timestamp++;
    d[id - 1] = timestamp;
    for (int i = 0; i < (int) adjlist[id - 1].size(); i++) {
        timestamp = dfs(adjlist[id - 1][i], timestamp);
    }
    timestamp++;
    f[id - 1] = timestamp;

    return timestamp;
}

int main(void) {
    cin >> n;

    for (int i = 0; i < n; i++) {
        int id, m;
        cin >> id >> m;
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            adjlist[id - 1].push_back(x);
        }
    }

    int timestamp = 0;
    for (int i = 0; i < n; i++) {
        int id = i + 1;
        timestamp = dfs(id, timestamp);
    }

    for (int i = 0; i < n; i++) {
        int id = i + 1;
        cout << id << " " << d[id - 1] << " " << f[id - 1] << endl;
    }

    return 0;
}



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

using namespace std;

int main() {
    //freopen("D.INP","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    priority_queue<int, vector<int>, greater<int>> q;
    priority_queue<pair<int, int>> o;
    cin >> n >> m;

    while (n--) {
        int t;
        cin >> t;
        q.push(t);
    }

    while (m--) {
        int b, c;
        cin >> b >> c;
        o.push({c, b});
    }

    while (!o.empty() && q.top() < o.top().first) {
        int b, c;
        b = o.top().second;
        c = o.top().first;
        o.pop();
        while (b-- && q.top() < c)
            q.pop(), q.push(c);
    }

    long long ans = 0;
    while (!q.empty())
        ans += 1ll * q.top(), q.pop();
    cout << ans << '\n';

    return 0;
}


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

string hsy,crz;

void start()
{
	getline(cin,hsy);
    getline(cin,crz);
}


int main() 
{
    start();
    
    sort(hsy.begin(),hsy.end());
    sort(crz.begin(),crz.end(),greater<char>());
    
    if(hsy<crz) 
	{
		cout<<"Yes"<<endl;
	}
    else 
	{
		cout<<"No"<<endl;
	}
 
    return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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<class Monoid> struct SegTree {
    using Func = function<Monoid(Monoid, Monoid)>;
    const Func F;
    const Monoid UNITY;
    int SIZE_R;
    vector<Monoid> dat;

    SegTree(int n, const Func f, const Monoid& unity) : F(f), UNITY(unity) { init(n); }
    void init(int n) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2;
        dat.assign(SIZE_R * 2, UNITY);
    }

    /* set, a is 0-indexed */
    void set(int a, const Monoid& v) { dat[a + SIZE_R] = v; }
    void build() {
        for (int k = SIZE_R - 1; k > 0; --k)
            dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* update a, a is 0-indexed */
    void update(int a, const Monoid& v) {
        int k = a + SIZE_R;
        dat[k] = v;
        while (k >>= 1) dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }

    /* get [a, b), a and b are 0-indexed */
    Monoid get(int a, int b) {
        Monoid vleft = UNITY, vright = UNITY;
        for (int left = a + SIZE_R, right = b + SIZE_R; left < right; left >>= 1, right >>= 1) {
            if (left & 1) vleft = F(vleft, dat[left++]);
            if (right & 1) vright = F(dat[--right], vright);
        }
        return F(vleft, vright);
    }
    inline Monoid operator [] (int a) { return dat[a + SIZE_R]; }

    /* debug */
    void print() {
        for (int i = 0; i < SIZE_R; ++i) {
            cout << (*this)[i];
            if (i != SIZE_R - 1) cout << ",";
        }
        cout << endl;
    }
};


int main() {

    int N;
    cin >> N;
    vi h(N);
    REP(i, N) cin >> h[i];

    SegTree<ll> st(N + 1, [](ll a, ll b) {return max(a, b); }, 0);

    ll ans = 0;
    ll a;
    REP(i, N) {
        cin >> a;
        ll A = st.get(0, h[i]);
        if (st.get(h[i], h[i] + 1) < A + a) {
            st.update(h[i], A + a);
            chmax(ans, A + a);
        }
    }

    cout << ans << endl;

#ifdef _MSC_VER
    system("PAUSE");
#endif

    return 0;
}

Measured memory_bytes: 5120
using System;
                        class Program
                         {
                                static void Main(string[] args)
                                {
                            　　long n,a,b;
                                    string[] str = Console.ReadLine().Split(' ');
                                    n = long.Parse(str[0]);
                                    a = long.Parse(str[1]);
                                  	b = long.Parse(str[2]);
                                  
                                  if(((b - a) % 2) == 0)
                                  {
                                    Console.Write((b - a) / 2);
                                  }
                                  else
                                  {
                                    Console.Write((b - a) / 2 + 1 + Math.Min((a - 1),(n - b)));
                                  }
                                }
                         }

Measured memory_bytes: 11092
import sys
a,b,c = map(int, sys.stdin.readline().rstrip("\n").split())
k = int(sys.stdin.readline().rstrip("\n"))
t = 0
while a >= b:
    b *= 2
    t += 1
while b >= c:
    c *= 2
    t += 1
if t <= k:
    print('Yes')
else:
    print('No')

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


int main() {
  int n, m;
  cin >> n >> m;
  set<int> a;
  for(int i = 1; i*i <= m; i++) {
    if(m%i!=0) continue;
    a.insert(i);
    a.insert(m/i);
  }
  for(int i = m/n; i > 0; i--) {
    if(a.count(i)) {
      cout << i << endl;
      return 0;
    }
  }
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> value(n);
    rep(i, n) cin >> value.at(i);
    rep(i, n) {
        int temp;
        cin >> temp;
        value.at(i) -= temp;
        if(value.at(i) > 0) ans += value.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)


using namespace std;
using ll = long long;

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n,k=0;
    cin >> n;
    int a[n];
    rep(i,n)
    {
        cin >> a[i];
        if(a[i]%2==0)
        {
            if(a[i]%3!=0 && a[i]%5!=0) k++;
        }
    }
    if(k==0) cout << "APPROVED" << endl;
    else cout << "DENIED"<< endl;


    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;
use std::str::FromStr;
use std::cmp::Reverse;

type Error = Box<dyn std::error::Error>;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct Scanner {
    buff: Vec<String>,
    pos: usize,
}


impl Scanner {
    pub fn new() -> Self {
        Scanner {
            buff: Vec::new(),
            pos: 0,
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        while self.buff.len() <= self.pos {
            self.pos = 0;
            self.buff = read_line().split_whitespace().map(|s| s.to_owned()).collect();
        }

        let result = self.buff[self.pos].parse::<T>();
        self.pos += 1;
        result.ok().unwrap()
    }

    pub fn next_line(&mut self) -> String {
        let result  = read_line().trim().to_owned();
        self.buff.clear();
        self.pos = 0;

        result
    }

    pub fn next_vec<T: FromStr>(&mut self) -> Vec<T> {
        self.buff.clear();
        self.pos = 0;
        read_line().trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect()
    }
    
    pub fn next_line_chars(&mut self) -> Vec<char> {
        let result  = read_line().trim().chars().collect();
        self.buff.clear();
        self.pos = 0;

        result
    }
}


fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.next();
    let k: i64 = sc.next();
    let mut ps: Vec<usize> = sc.next_vec();
    for i in 0..n {
        ps[i] -= 1;
    }
    let ps = ps;
    let cs: Vec<i64> = sc.next_vec();

    let mut ans = -2_000_000_000i64;

    for i in 0..n {
        let mut count = 0;
        let mut tmp = 0;
        let mut memo = vec![0; n];
        let mut v = i;
        while count < k {
            if memo[v] > 0 {
                let sz = count + 1 - memo[v];
                let mut s = 0;
                let mut w = v;
                for _j in 0..sz {
                    w = ps[w];
                    s += cs[w];
                }
                // eprintln!("dbg2: {} {} {} {}", i, v, sz, s);
                if s > 0 {
                    tmp += (cmp::max(k - count - sz as i64, 0) / sz) * s;
                    count += cmp::max(k - count - sz as i64, 0) / sz * sz;
                    for _j in 0..k - count {
                        w = ps[w];
                        tmp += cs[w];
                        ans = cmp::max(tmp, ans);
                    }
                }
                break;
            }
            memo[v] = count + 1;
            v = ps[v];
            tmp += cs[v];
            ans = cmp::max(tmp, ans);
            count += 1;
            // eprintln!("dbg: {} {} {} {}", i, count, v, tmp);
        }
    }
    println!("{}", ans);
}


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


class dice{
    public:
    int face[7];
    string name;
    
    dice(){
    }
    
    void north(){
        face[6] = face[0];
        face[0] = face[1];
        face[1] = face[5];
        face[5] = face[4];
        face[4] = face[6];
       
    }
    
    void south(){
        face[6] = face[0];
        face[0] = face[4];
        face[4] = face[5];
        face[5] = face[1];
        face[1] = face[6];
    }
    
    void east(){
        face[6] = face[0];
        face[0] = face[3];
        face[3] = face[5];
        face[5] = face[2];
        face[2] = face[6];
    }
    
     void west(){
        face[6] = face[0];
        face[0] = face[2];
        face[2] = face[5];
        face[5] = face[3];
        face[3] = face[6];
    }
    

};



bool equal(dice d1, dice d2){
    for(int j = 0; j < 4; j++){
        for(int k = 0; k<4; k++){
            if(d1.face[1] == d2.face[1]){
                break;
            }
            d1.south();
        }
        d1.east();
    }    
    for(int k = 0; k<4; k++){
        if(d1.face[0] == d2.face[0]){
            if((d1.face[2] == d2.face[2]) && (d1.face[3] == d2.face[3]) && (d1.face[4] == d2.face[4]) && (d1.face[5] == d2.face[5])){
                return true;
            }
        }
        d1.east();
    }
    return false;        
            
}


int main(){
    dice d1;
    dice d2;
    for(int i = 0; i < 6; i++){
        cin >> d1.face[i];
        //cout << d1.face[i] << endl;
    }
    for(int i = 0; i < 6; i++){
        cin >> d2.face[i];
        //cout << d1.face[i] << endl;
    }
    if(equal(d1, d2)){
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    
    return 0;
}


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

int main() { 
  long long  l,r;
  cin >> l >> r;
  int ans = 2019;
  bool flag = false;

 int ml = l % 2019; //cout << "ml:" << ml << endl;
 int mr = r % 2019; //cout << "mr:" << mr << endl;

 if (ml == 0 || mr ==0) ans = 0;

 for(long long i=l; i<r; i++){

   for(long long j=i+1; j<=r; j++){

     //cout << "i:" << i << endl;
    // cout << "j:" << j << endl;

     int tmp;
     tmp = (i*j) % 2019; 
     //cout << "tmp:" << tmp << endl;

     ans = min(tmp, ans); 
    // cout << "ans:" << ans << endl;

     if(ans == 0) {
       flag = true;
       break;
     }
   }

   if(flag == true) break;

 }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        int n = ReadInt();
        int k = ReadInt();
        int[] a = ReadInt(n).ToArray();
        for (int i = k; i < n; i++)
        {
            Console.WriteLine(a[i] > a[i - k] ? "Yes" : "No");
        }
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
}


Measured memory_bytes: 58268
N=int(input())
KEY = 'MARCH'

d={}
for i in KEY:
	d[i]=0

for i in range(N):
	t = input()[0]
	if t in KEY:
		d[t]+=1

ans=0
for i in range(3):
	for j in range(i+1,4):
		for k in range(j+1,5):
			ans+=d[KEY[i]]*d[KEY[j]]*d[KEY[k]]

print(ans)

Measured memory_bytes: 3064
from collections import defaultdict


def solve(pre_is_positive, a_list):
    total = 0
    ans = 0
    for a in a_list:
        total += a
        if pre_is_positive and total >= 0:
            ans += abs(total) + 1
            total = -1
        elif not pre_is_positive and total <= 0:
            ans += abs(total) + 1
            total = 1
        pre_is_positive = total > 0
    return ans


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    print(min(solve(True, a_list), solve(False, a_list)))


if __name__ == "__main__":
    main()


          




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

using ll = long long;

constexpr ll INF = 1e18;
constexpr ll M = 1e9 + 7;

struct edge {
    int u, v;
    double cost;
    bool operator<(edge const& e) const {
        return cost < e.cost;
    }
};

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) {
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<double> x(N), y(N);
    vector<edge> es;
    union_find uf(N);
    for(int i=0; i<N; ++i) {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    for(int i=0; i<M; ++i) {
        int p, q;
        cin >> p >> q;
        p--; q--;
        double d = hypot(x[p] - x[q], y[p] - y[q]);
        sum += d;
        es.push_back(edge{p, q, -d});
    }
    sort(es.begin(), es.end());
    for(auto& e : es) {
        if(uf.unite(e.u, e.v)) {
            sum += e.cost;
        }
    }
    cout << fixed << setprecision(10) << sum << endl;
}


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

void solve(long long N, long long M, long long C, std::vector<long long> B, std::vector<std::vector<long long>> A){
  int total = 0;

  for (int i=0;i<N;i++) {
    int sum = 0;
    for (int j = 0;j<M;j++) {
      sum += A[i][j] * B[j];
    }
    if (sum + C > 0) {
      total += 1;
    } else {
      continue;
    }
  }

  cout << total << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, C, std::move(B), std::move(A));
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  ll n;
  cin>>n;
  
  vector<ll> A(3*n);
  rep(i,3*n) cin>>A[i];

  sort(ALL(A),greater<int>());
  
  ll sum=0;
  for(int i=1;i<=n;i++){
    sum+=A[2*i-1];
  }
  
  cout<< sum <<endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

const int M = 1e9 + 7;

int mod( int m ,int mod = M) {
   m %= mod;
   return (m + mod) % mod;
}

int power(int x,int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res * x);
      y = y / 2;
      x = mod(x * x);
   }
   return mod(res);
}

int32_t main() {
	boost;
	int n;
	cin >> n;
	vector < int > a(n);
	for(int &i : a)
		cin >> i;
	int  ans = 0;
	sort(a.begin(), a.end());
	for(int i = 0; i < n; i++) {
		int cur = mod((n - i - 1) * power(2, n - i - 2));
		cur = mod(cur + power(2, n - i - 1));
		cur = mod(cur * power(2, i));
		ans = mod(ans + mod(cur * a[i]));	
	}
	ans = mod(ans * power(2, n));
	cout << ans << endl;
} 

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean chmax ( llong &a, llong b ) { return a<b ? a=b, true : false; }
    boolean chmin ( llong &a, llong b ) { return b<a ? a=b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        int a, b, c;
        read a >> b >> c;
        echo a * b / 2 fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int dp[2][2005];
int main() {
	int n, z, w;
	scanf("%d%d%d", &n, &z, &w);
	vector<int> A(n + 1);
	for (int i = 1; i <= n; ++i) scanf("%d", &A[i]);
	A[0] = w;
	for (int i = n; i >= 1; --i) {
		dp[0][i] = dp[1][i] = abs(A[n] - A[i - 1]);
		for (int j = i + 1; j <= n; ++j) {
			dp[0][i] = max(dp[0][i], dp[1][j]);
			dp[1][i] = min(dp[1][i], dp[0][j]);
		}
	}
	printf("%d\n", dp[0][1]);
}


Measured memory_bytes: 256