akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;


#define Seg_Max_N (1<<18) 

using Value = long long int ;
const Value ini = 0;
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N){
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value unite(const Value al, const Value ar) {
		return al + ar;
	}
	// update k th element
	void update(int k, Value a) {
		 k += N - 1;
		dat[k] += a;
		
		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = unite(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return  unite(al, ar);
	}
};
int main() {
	int N, Q; cin >> N >> Q;
	segtree seg(N);
	for (int i = 0; i < Q; ++i) {
		int a, b, c; cin >> a >> b >> c;
		if (!a) {
			b--;
			seg.update(b, c);
		}
		else {
			long long int ans = seg.query(b-1, c);
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{
	lli n,m;
	cin>>n>>m;
	lli sum=0;
	for(int i=0;i<m;i++)
	{
		lli x;
		cin>>x;
		sum+=x;
	}
	n-=sum;
	if(n<0)
		cout<<-1;
	else
		cout<<n;

}



Measured memory_bytes: 3636
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>

using ::std::cin;
using ::std::cout;
using ::std::endl;
using ::std::string;
using ::std::vector;

using int64 = long long;

constexpr int64 P = 1000000007;

struct FiniteField {
  int64 x;
  FiniteField(int64 input_x) : x(input_x) {}
  inline FiniteField operator+ (FiniteField o) {
    return *this + o.x;
  }
  inline FiniteField operator+ (int64 o) {
    return FiniteField((x + o) % P);
  }
  inline FiniteField operator* (FiniteField o) {
    return *this * o.x;
  }
  inline FiniteField operator* (int64 o) {
    return FiniteField((x * o) % P);
  }
  inline void operator*= (FiniteField o) {
    *this *= o.x;
  }
  inline void operator*= (int64 o) {
    x = (x * o) % P;
  }
};

struct Edge {
  int from;
  int to;
};

vector<vector<Edge>> ReadUndirectedGraph(int n, int m, bool is_one_indexed=false) {
  vector<vector<Edge>> graph(n);
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    if (is_one_indexed) {
      v1--;
      v2--;
    }
    graph[v1].push_back(Edge({v1, v2}));
    graph[v2].push_back(Edge({v2, v1}));
  }
  return graph;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<Edge>> graph = ReadUndirectedGraph(n, n - 1, true);

  std::function<FiniteField(int, int, int)> solve =
      [k, &graph, &solve](int v, int parent, int depth) {
    int numChildren = graph[v].size() - (depth > 0 ? 1 : 0);
    if (numChildren == 0) return FiniteField(1);
    int numColors = k - 1 - (depth > 0 ? 1 : 0);
    if (numColors < numChildren) return FiniteField(0);
    FiniteField ans = FiniteField(1);
    for (int i = 0; i < numChildren; i++) {
      ans *= numColors - i;
    }
    for (const auto& e : graph[v]) {
      if (e.to == parent) continue;
      ans *= solve(e.to, v, depth + 1);
    }
    return ans;
  };
  auto solution = solve(0, -1, 0) * k;
  cout << solution.x << endl;
}

Measured memory_bytes: 12800
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    #0から他の頂点へ
    def BellmanFord(N, M, edges):
        #N頂点，M辺，edgesのリスト
        inf=10**20
        d = [inf] * N
        d[0] = 0

        for i in range(N-1):
            for (u, v, c) in edges:
                if to[u] and to[v] and rto[u] and rto[v]:
                    if d[u] + c < d[v]:
                        d[v] = d[u] + c

        
        #何処かの最短距離がまだ更新されるか確認
        for (u, v, c) in edges:
            if to[u] and to[v] and rto[u] and rto[v]:
                if d[u] + c < d[v]:
                    return None#負の閉路
                
        return d[N-1]
    
    N,M,P=MI()
    edges=[]
    adj1=[[]for _ in range(N)]
    adj2=[[]for _ in range(N)]
    for _ in range(M):
        a,b,c=MI()
        a-=1
        b-=1
        c-=P
        edges.append([a,b,-1*c])
        adj1[a].append(b)
        adj2[b].append(a)
        
    ################
    #BFSで使う点を選択．
    import queue
    q=queue.Queue()
    
    to=[0]*N
    to[0]=1
    rto=[0]*N
    rto[-1]=1
    
    q.put(0)
    while not q.empty():
        v=q.get()
        for nv in adj1[v]:
            if to[nv]==0:
                to[nv]=1
                q.put(nv)
                
    q.put(N-1)
    while not q.empty():
        v=q.get()
        for nv in adj2[v]:
            if rto[nv]==0:
                rto[nv]=1
                q.put(nv)
        
    
    ################
    
    ans=BellmanFord(N,M,edges)
    
    if ans==None:
        print(-1)
    elif ans>=10**10:
        print(-1)
    else:
        print(max(-1*ans,0))
    
        

main()


Measured memory_bytes: 81584
_h, w = gets.split.map(&:to_i)
_n = gets.to_i
a = gets.split.map(&:to_i)
l = []

a.each_with_index { |e, idx| l.concat(Array.new(e, idx + 1)) }

l.each_slice(w).with_index do |e, idx|
  puts idx.even? ? e.join(' ') : e.reverse.join(' ')
end

Measured memory_bytes: 3836
money500 = int(input())
money100 = int(input())
money50  = int(input())
goal     = int(input())

result = 0

for x in range(money500 + 1):
    for y in range(money100 + 1):
        for z in range(money50 + 1):
            if x * 500 + y * 100 + 50 * z == goal: result += 1

print(result)

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

char str[10000];

int main () {
	
	long long n,k=26; scanf ("%lld",&n);
	int len=1;
	while (k<n) {
		n-=k;
		k*=26;
		len++;
	}
	n--;
	for (int i=1;i<=len;i++) {
		k/=26;
		str[i]='a'+n/k;
		n%=k;
	}
	str[len+1]='\0';
	printf ("%s",str+1);
	
	return 0;
}


Measured memory_bytes: 1732
from sys import stdin
import sys
import math
import random
from decimal import Decimal
import itertools as it


N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i-K] >= A[i]:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 33000
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
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);
}


#define ARRAY_MAX 100005
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

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




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


/******************************************************************************************/

vector<int> G[ARRAY_MAX];

ll dfs(ll k, ll now, ll from) {

	ll col;

	if (from == -1) {
		col = k-1;
	}
	else
	{
		col = k-2;
	}

	if (k < G[now].size()) {
		return 0;
	}

	ll cnt = 1;
	for (auto itr : G[now]) {

		//塗り方
		if (itr == from)continue;
		cnt *= col;
		col--;
		cnt %= MOD;
	}

	for (auto itr : G[now]) {

		//塗り方
		if (itr == from)continue;
		
		cnt *= dfs(k, itr,now);
		cnt %= MOD;
	}
	return cnt;
}


int main() {

	ll n, k;
	cin >> n >> k;

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

	ll ans = k * dfs(k, 0, -1);
	ans %= MOD;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11520
#include<cstdio>
#include<utility>
#include<algorithm>

using namespace std;

pair<int,int> P[200000];
int asc_max[200000];

int main() {
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        int t;
        scanf("%d", &t);
        P[i] = pair<int,int>(t, i);
    }
    sort(P, P+N);
    asc_max[N-1]= N-1;
    for(int i = N-2; i >= 0; --i) {
        if(P[i].second > P[i+1].second) {
            asc_max[i] = i;
        }
        else {
            asc_max[i] = asc_max[i+1];
        }
    }
    int max = N;
    for(int i = 0; i < N; ++i) {
        int num = N - (asc_max[i]-i)-1;
        if(max > num) max = num;
    }
    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 2560
// Gaurav Aggarwal

/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.end(),0)
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/

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

typedef long long ll;
typedef pair<ll,ll> ipair;
typedef pair<long,long> lpair;
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define mod 1000000007
#define PI 3.141592653589793238462643383279502884 
#define debug1(a) cout<<a<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug_arr(a,n) {for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}}
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define beg_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {a[i] = 0;}

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

const int N = 1e5 + 1;
vector<pair<int,int> > graph[N];

void bfs(int n, int s, int ans[]) {
    ans[s] = 1;
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        // cout<<v<<" source\n";
        for(pair<int,int> b: graph[v]) {
            if(ans[b.first] == 0) {
                int w = b.second;
                if(w & 1) {
                    if(ans[v] == 1)
                        ans[b.first] = 2;
                    else
                        ans[b.first] = 1;
                }
                else {
                    ans[b.first] = ans[v];
                }
                // cout<<b.first<<"\n";
                q.push(b.first);
            }
        }
    }
}


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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    cin>>n;
    for(int i=0;i<n-1;++i) {
        int u,v,w;
        cin>>u>>v>>w;
        graph[u-1].push_back(make_pair(v-1,w));
        graph[v-1].push_back(make_pair(u-1,w));
    }

    int ans[n] = {0};

    bfs(n,0,ans);

    for(int i=0;i<n;++i) {
        cout<<ans[i]-1<<"\n";
    }

    return 0;
}

Measured memory_bytes: 6784
N = int(input())
s_list = []
for i in range(N):
    s = int(input())
    s_list.append(s)
ans = sum(s_list)
if ans%10!=0:
    print(ans)
else:
    s_list.sort()
    for i in s_list:
        tmp = ans - i
        if tmp%10!=0:
            ans = tmp
            print(ans)
            exit()
            break
if i == s_list[-1]:
    print(0)

Measured memory_bytes: 3060
import java.util.*;

public class Main {          
    
    static int N;
    static char[] cs;    
    
    public static void main(String[] args){           
        
         Scanner sc = new Scanner(System.in);
   
         N = sc.nextInt();         
         
         String S = sc.next();
         
         cs = S.toCharArray();
    
         for(int i = 0;i < 2;i++){
            for(int j = 0;j < 2;j++){
                
                int a[] = new int[N];  
                
                a[0] = i;
                a[1] = j;
                 
                if(cal(a)){                                                                                    
                     for(int k = 0;k < N;k++){
                         if(a[k] == 1){
                             System.out.print("S");
                         }else{
                             System.out.print("W");                             
                         }
                     }
                     System.out.println();
                     return;
                }                                                   
                 
            }
         }           
         
         System.out.println(-1);
         
  }    
    
   static boolean cal(int[] a){
       
            for (int i = 2; i < N; i++) {
                if (cs[i - 1] == 'o') {
                    if (a[i - 1] == 1) {
                        a[i] = a[i - 2];
                    } else {
                        a[i] = a[i - 2] ^ 1;
                    }
                } else {
                    if (a[i - 1] == 1) {
                        a[i] = a[i - 2] ^ 1;
                    } else {
                        a[i] = a[i - 2];
                    }
                }
            }

            if (a[0] == 1) {
                if (cs[0] == 'o') {
                    if (a[1] != a[N - 1]) return false;
                }
                if (cs[0] == 'x') {
                    if (a[1] == a[N - 1]) return false;
                }
            } else {
                if (cs[0] == 'o') {
                    if (a[1] == a[N - 1]) return false;
                }
                if (cs[0] == 'x') {
                    if (a[1] != a[N - 1]) return false;
                }
            }

            // check n-1
            if (cs[N - 1] == 'o') {
                if (a[N - 1] == 1) {
                    return a[N - 2] == a[0];
                } else {
                    return a[N - 2] != a[0];
                }
            } else {
                if (a[N - 1] == 1) {
                    return a[N - 2] != a[0];
                } else {
                    return a[N - 2] == a[0];
                }
            }            
    }                              
}

Measured memory_bytes: 31380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll MOD=1000000007;
const ll MAX=1200000;
ll n,fin,fac[MAX],use[MAX],cum[MAX],sum;
ll power(ll x,ll y){
    if(y==0) return 1;
    ll t=power(x,y/2);
    if(y%2) return t*t%MOD*x%MOD;
    return t*t%MOD;
}
ll comb(ll x,ll y){
    return fac[x]*power(fac[y],MOD-2)%MOD*power(fac[x-y],MOD-2)%MOD;
}
int main(){
    scanf("%lld",&n);
    fac[0]=1;
    for(ll i=1;i<=n;i++) fac[i]=fac[i-1]*i%MOD;
    for(ll i=(n+1)/2;i<=n-1;i++) use[i]=comb(i-1,2*i-n)*fac[i]%MOD*fac[n-1-i]%MOD;
    for(ll i=(n+1)/2;i<=n-1;i++) cum[i]=use[i]-use[i-1]+MOD,sum+=(cum[i]*i)%MOD,sum%=MOD;
    printf("%lld\n",sum);

}


Measured memory_bytes: 20736
n = gets.chomp.to_i
#a = gets.chomp.split().map(&:to_i)

hash = {}
hash.default = 0
n.times do
  s = gets.chomp
  if 'MARCH'.include? s[0]
    hash[s[0]] += 1
  end
end

if hash.size < 3
  puts 0
elsif hash.size == 3
  v = hash.values
  puts v[0] * v[1] * v[2]
elsif hash.size == 4
  v = hash.values
  puts v.combination(3).map{|a,b,c| a*b*c}.inject(:+)
elsif hash.size == 5
  v = hash.values
  puts v.combination(3).map{|a,b,c| a*b*c}.inject(:+)
end

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

#define ll long long
#define pb push_back
#define ins insert
#define mp make_pair
#define pii pair<int, int>
#define pil pair<int, ll>
#define pib pair<int, bool>
#define SET(a, c) memset(a, c, sizeof(a))
#define MOD 1000000007
#define enld endl
#define endl "\n"
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define found(u, val) u.find(val) != u.end()

#include <string>
#include <vector>
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
//#include <algorithm>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <cmath>
//#include <cstring>
//#include <sstream>
//#include <stack>
//#include <queue>

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

    int n, k;
    cin >> n >> k;
    int ar[n + 1];
    int dp[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> ar[i];
        dp[i] = 1e9 + 5;
    }

    dp[n] = 0;
    dp[n - 1] = 0;
    ar[n] = ar[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        // cout << i << endl;
        for (int j = 1 + i; j <= min(i + k, n - 1); j++) {
            // cout << "   " << j << endl;
            dp[i] = min(abs(ar[i] - ar[j]) + dp[j], dp[i]);
        }
        // cout << "-- " << dp[i] << endl;
    }

    cout << dp[0];
}

Measured memory_bytes: 4484
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

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

int main(void) {
    int N, D;
    cin >> N >> D;
    int X;
    X = N/(2*D+1);
    if (N%(2*D+1) != 0) X++;
    cout << X << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = []
    for i in range(2):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        A_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dp = [[0]*N for i in range(2)]
    for i in range(2):
        for j in range(N):
            if i==0:
                if j==0: dp[i][j] = A_arr[i][j]
                else: dp[i][j] = dp[i][j-1] + A_arr[i][j]
            else:
                if j==0: dp[i][j] = dp[i-1][j]+A_arr[i][j]
                else: dp[i][j] = max(dp[i-1][j],dp[i][j-1])+A_arr[i][j]
    cnt = dp[-1][-1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
N = int(input())
p_list = []
for i in range(N):
    p = int(input())
    p_list.append(p)
for j in range(N):
    if max(p_list) == p_list[j]:
        p_list[j] = p_list[j] / 2
        break
print(int(sum(p_list)))


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		//		new Main().solveB();
		new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String[] stringS = new String[4];

		try {
			scanner = new Scanner(System.in);
			stringS = scanner.next().split("");

			int res = 0;
			for (int i = 0; i < stringS.length; i++) {
				if (stringS[i].equals("+")) {
					res++;
				} else if (stringS[i].equals("-")) {
					res--;
				}
			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int wkN = 0;
			int tmp = numN;
			while (tmp != 0) {
				wkN += tmp % 10;
				tmp /= 10;
			}

			System.out.println(numN % wkN == 0 ? "Yes" : "No");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int[] wk;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numK = scanner.nextInt();
			wk = new int[numN];

			for (int i = 0; i < wk.length; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);

			int res = 0;
			int wkN = numN;
			while (wkN > 0) {
				if (res == 0) {
					wkN = wkN - numK;
					res++;
				} else {
					wkN = wkN - (numK - 1);
					res++;
				}
			}
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int numN = 0;
		int numK = 0;
		int numS = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 51760
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(){
	int N,H,W;
    cin>>N;
    cin>>H;
    cin>>W;
    //vector<int> A,B;
    int cnt = 0;
    for(int i=0;i<N;i++){
        int t,w;
        cin>>t;
        cin>>w;
        if(t>=H && w>=W){
            cnt++;
        }
    }

    cout<<cnt<<endl;

	
	
}


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


int main()
{
    string S;
    cin >> S;
    if (S.size() % 2 == 1) {
        cout << "No" << endl;
    } else {
        bool ok = true;
        for (int i = 0; i < S.size(); i++) {
            if ((i % 2 == 0 && S[i] != 'h') || (i % 2 == 1 && S[i] != 'i')) {
                ok = false;
                break;
            }
        }
        if (ok) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
vector<pair<long long, long long> > prime_factorize(long long N) {
  vector<pair<long long, long long> > res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0; // 指数
 
        // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
 
        // その結果を push
    res.push_back({a, ex});
  }
 
    // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}
 
int main() {
  long long N;
  cin >> N;
  int score = 0;
  const auto &res = prime_factorize(N);
    
  for (auto p : res) {
    int k=1;
    
    while(1){
      int x = k*(k+1)/2;
      if (x>p.second){
        k-=1;
        break;
      }
      k+=1;
    }
    score+=k;
  }
  cout <<score << endl;
}

Measured memory_bytes: 3592
#素数を求めるプログラム
def isprime(x):
    if x <= 2:
        return True
    elif x % 2 == 0:
        return False
    else:
        i = 3
        while i <= int(x**0.5)+1:
            if x % i == 0:
                return False
            i += 2
        return True

#入力dataの挿入
input_number = int(input())
result_data = list()
for i in range(input_number):
    result_data.append(isprime(int(input())))

#処理の実行
print(sum(result_data))



Measured memory_bytes: 5740
N,W = map(int,input().split())

dic = {}
dic[0] = 0

for i in range(N):

    odic = dic.copy()

    w,v = map(int,input().split())

    for j in odic:

        if j + w not in dic and j+w <= W:
            dic[j+w] = odic[j] + v

        elif j+w <= W:
            dic[j+w] = max(odic[j]+v,dic[j+w])

ans = 0

for i in dic:
    ans = max(ans,dic[i])

print (ans)



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a[4];
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a,a+3);
  if(a[0]%2==0||a[1]%2==0||a[2]%2==0)cout<<0<<endl;
  else cout<<a[0]*a[1]<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long
#define pai 3.1415926535897932384626433832795028841971693
long long min(long long a, long long b){
    if(a < b) return a;
    else return b;
}
long long max(long long a, long long b){
    if(a < b) return b;
    else return a;
}
int main(){
 int x,y,a,b;
  scanf("%d %d",&x,&y);
  for(int a=0;a<=100;a++){
    for(int b=0;b<=100;b++){
  if(2*a+4*b==y && a+b==x){
    printf("Yes");
    return 0;
  }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n;
    cin >> n;
    set <string> s;
    string last = "";
    for(int i = 0; i < n; i++){
        string str;
        cin >> str;
        if(i > 0){
            if(str[0] != last[last.size() - 1]){
                cout << "No";
                return;
            }
        }
        last = str;
        s.insert(str);
    }
    if(s.size() == n) cout << "Yes";
    else cout << "No";
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> A){
    vll B;
    B.push_back(A[0]);
    for(ll i=1LL; i< N; i++){
        if(A[i]!= A[i-1])
            B.push_back(A[i]);
    }
    ll n = B.size();
    if(n <= 2){
        cout << 1 << endl; return;
    }
    ll cnt = 0;
    while(B.size()>1){
        n = B.size();
        if(B[n-2]<B[n-1]){
            while(B[n-2]<B[n-1]){
                B.pop_back();
                n = B.size();
            }
            if(B.size()>0)
                B.pop_back();
            cnt ++;
        }
        else{ //* B[n-1]>B[n-1]
            while(B[n-2]>B[n-1]){
                B.pop_back();
                n = B.size();
            }
            if(B.size()>0)
                B.pop_back();
            cnt ++;
        }
    }
    if(B.size())
        cnt++;
    cout << cnt << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2168
n = int(input())
a = input().split(' ')

b = [int(x) for x in a]

c = []
for i in range(n):
    c.append(0)

d=[]

for i in range(n):
    i = n - i
    s = 0
    for j in range(i*2,n+1,i):
     #   print(i,j)
        s = s + c[j-1]
    #print('i',i,'s',s,'b',b[i-1])
    if s%2 != b[i-1]:
        c[i-1] = 1
        d.append(i)

d=sorted(d)
print(len(d))
for i in range(len(d)):
    print(d[i],end=' ')

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

#define M 999997/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return key%(M-1)+1; }

int find(char str[]){
  int i=0;
  int j;
  long long key;
  key = getKey(str);
  while(1){
    j=(h1(key)+i*h2(key))%M;
    if( H[j][0]== '\0' || i == M ) return 0;
    if( strcmp(H[j],str) == 0 ) return 1;
    else i++;
  }
}

void insert(char str[]){
  int i = 0;
  int j;
  long long key;
  key = getKey(str);
  while( i != M ){
    j = (h1(key)+i*h2(key))%M;
    if( H[j][0] == '\0' ){
      strcpy(H[j],str);
      break;
    }
    else i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
def my_solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = abc[:x], abc[x:x + y], abc[x + y:]
    ab = sorted([_a + _b for _b in b for _a in a])[-k:]
    *abc, = map(str, sorted([_ab + _c for _c in c for _ab in ab], reverse=True)[:k])
    return "\n".join(abc)


def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = map(sorted, [abc[:x], abc[x:x + y], abc[x + y:]])
    ans = []
    for ia in range(1, x + 1):
        for ib in range(1, y + 1):
            for ic in range(1, z + 1):
                if ia * ib * ic <= k:
                    ans.append(a[x - ia] + b[y - ib] + c[z - ic])
                else:
                    break
    return "\n".join(list(map(str, sorted(ans, reverse=True)[:k])))


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))


Measured memory_bytes: 46380
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

char board[2010][2010];
int dist[2010][2010];
signed main() {
    int H, W; cin >> H >> W;
    queue< pair<int, int> > que;
    fill(dist[0], dist[H+1], INF);
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> board[i][j];
            if(board[i][j] == '#') {
                dist[i][j] = 0;
                que.emplace(i, j);
            }
        }
    }

    while(que.size()) {
        int x, y; tie(x, y) = que.front(); que.pop();
        for(int k=0; k<4; k++) {
            int nx = x + dx[k], ny = y + dy[k];
            if(nx < 0 or ny < 0 or nx >= H or ny >= W) continue;
            if(dist[nx][ny] > dist[x][y] + 1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.emplace(nx, ny);
            }
        }
    }

    int ans = 0;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 37044
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll K, A, B;
	
	cin >> K >> A >> B;

	ll rem_p = 1;
	ll rem_y = 0;

/*
	ll a = 139130666;
	ll b = 348728501;
	cout << a * b + 35897932 + 1 << endl;
	cout << "saf" << endl;
*/
	if (B - A > 2)
	{
		/*
		for(ll i = 1; i <= K; i++)
		{
			if (i == K)
			{
				rem_p++;
			}
			else
			{
				if (rem_y > 0)
				{
					rem_p += B;
					rem_y--;
				}
				else if (rem_p >= A)
				{
					rem_p -= A;
					rem_y++;
				}
				else
				{
					i = A - rem_p;
					rem_p = A;
				}
			}
			//cout << "rem_p=" << rem_p << "; rem_y=" << rem_y << endl;
		}
		*/
		ll gap = B - A;
		ll times = A - 1;
		if (times >= K)
		{
			cout << A << endl;
		}
		else
		{
			ll remain_t = K - times;

			if (remain_t & 0x01)
			{
				rem_p = A + gap * (remain_t >> 1) + 1;
			}
			else
			{
				rem_p = A + gap * (remain_t >> 1);
			}

			cout << rem_p << endl;
		}

		
	}
	else
	{
		cout << 1 + K << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
while True:
  try:
    n = int(input())
    results = []
    for i in range(10):
      for j in range(10):
        for k in range(10):
          for l in range(10):
            results.append( n == sum([i, j, k, l]) )
    print(len(list(filter(lambda x:x==True, results))))
  except:
    break


Measured memory_bytes: 5632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
s = input()
rgb = [0, 0, 0]
for i in range(n):
    if s[i] == 'R':
        rgb[0] += 1
    elif s[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1
ans = rgb[0] * rgb[1] * rgb[2]
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ans -= 1
print(ans)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


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

  if(n % 4 == 0 || n % 7 == 0 || n % 11 == 0)
  {
    cout << "Yes" << endl;
    return 0;
  }
  int tmp = n;
  
  while(tmp > 0)
  {
    if(tmp % 4 == 0 || tmp % 7 == 0 || tmp % 11 == 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    tmp -= 4;
  }

  tmp = n;
  
  while(tmp > 0)
  {
    if(tmp % 4 == 0 || tmp % 7 == 0 || tmp % 11 == 0)
    {
      cout << "Yes" << endl;
      return 0;
    }
    tmp -= 7;
  }

  cout << "No" << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<int,int>items[300001];
int Hcount[300001]={0},Wcount[300001]={0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int  H,W,M;
cin>>H>>W>>M;
set<pair<int,int>> present;

for(int i=0;i<M;i++)
{
   cin>>items[i].first>>items[i].second;
}

for(int i=0;i<M;i++)
{   
     items[i].first--;
     items[i].second--;
    Hcount[items[i].first]++;
    Wcount[items[i].second]++;
    present.insert({items[i].first,items[i].second});
}
int posH = max_element(Hcount,Hcount+H) - Hcount;
int posW = max_element(Wcount,Wcount+W) - Wcount;

int  ans = Hcount[posH] + Wcount[posW];
bool flag = false;
vector<int>Hpos,Wpos;
for(int i=0;i<H;i++)
{
      if(Hcount[i] == Hcount[posH])
      Hpos.push_back(i);
      
    
}
for(int i=0;i<W;i++)
{
      if(Wcount[i] == Wcount[posW])
      Wpos.push_back(i);
    
}
for(int i=0;i<Hpos.size();i++)
{
    for(int j=0;j<Wpos.size();j++)
    {
        if(present.find({Hpos[i],Wpos[j]}) == present.end())
           {flag =true;break;}    
      
    }
}
// cout<<flag<<endl;
// for(int i=0;i<H;i++)
// cout<<Hcount[i]<<' ';
// cout<<endl;
// for(int i=0;i<W;i++)
// cout<<Wcount[i]<<' ';
// cout<<endl;

if(!flag)
ans--;
cout<<ans<<endl;
return 0;
}

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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=10005;
vi x1,y2;
int dp1[2][4*N],dp2[2][4*N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  string s;
  int x,y;
  cin>>s>>x>>y;
  s+="T";
  while(sz(s) && s[0]=='F')
    s.erase(s.begin()),x--;
  int cnt=0,side=1;
  rep(i,0,sz(s))
    {
      if(s[i]=='T')
	{
	  if(cnt)
	    {
	      if(side) x1.pb(cnt);
	      else y2.pb(cnt);
	    }
	  side=1-side;
	  cnt=0;
	}
      else cnt++;
    }
  dp1[0][N]=1;
  int bit1=1;
  for(auto it:x1)
    {
      rep(i,-N,N)
	if(dp1[1-bit1][i+N])
	  dp1[bit1][i+it+N]=dp1[bit1][i-it+N]=1;
      rep(i,0,4*N)
	dp1[1-bit1][i]=0;
      bit1=1-bit1;
    }
  int bit2=1;
  dp2[0][N]=1;
  for(auto it:y2)
    {
      rep(i,-N,N)
	if(dp2[1-bit2][i+N])
	  dp2[bit2][i+it+N]=dp2[bit2][i-it+N]=1;
      rep(i,0,4*N)
	dp2[1-bit2][i]=0;
      bit2=1-bit2;
    }
  if(dp1[1-bit1][x+N] && dp2[1-bit2][y+N])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0 ;
}


Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	ll n, a, b;
	cin>>n>>a>>b;
	ll c = a - b;
	vector<ll> h(n);
	REP(i, n) cin>>h[i];
	ll lb = -1;
	ll ub = 1000000000;
	while(ub - lb > 1) {
		ll mid = ((lb + ub) / 2);
		ll cnt = mid;
		vector<ll> h2(n);
		REP(i, n) {
			h2[i] = h[i] - b * mid;
		}
		REP(i, n) {
			if(h2[i] > 0) {
				ll dec;
				if(h2[i] % c == 0) dec = h2[i] / c;
				else dec = h2[i] / c + 1;
				cnt -= dec;
			}
		}
		if(cnt >= 0) {
			ub = mid;
		} else {
			lb = mid;
		}
	}
	cout<<ub<<endl;
}



Measured memory_bytes: 1792
//
// Created by yuu on 2019-04-13.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>

using namespace std;


int main(void){
    int A,B;
    cin>>A>>B;
    int result;
    if(A-B>=2){
        result = A + A -1;
    }
    else if(B-A>=2){
        result = B + B -1;
    }else{
        result = A + B;
    }

    cout<<result<<endl;
    

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#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++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   string a,b;cin>>a>>b;
   int n = b.size();
   rep(i,n)cout<<a[i]<<b[i];
   if(a.size()>b.size())cout<<a[n];
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int a = N;
  int b = 0;

  for (int i = 0 ; i < 9; i++) {
    b += a % 10;
    a = a / 10; 
  }

  if ( N % b == 0 ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

    ll n, x, r = 1, s = 0;

    cin >> n >> x;

    vector < ll > v(n);

    forn(i, n)
        cin >> v[i];

    forn(i, n)
    {
        s += v[i];

        r += (s <= x);
    }

    cout << r << "\n";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

void bad()
{
    cout << "Impossible";
    exit(0);
}
void good()
{
    cout << "Possible";
    exit(0);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    sort(all(a));
    if (a[n - 1] != a[n - 2])
        bad();
    if (a[0] != (a[n - 1] + 1) / 2)
        bad();
    if (a[n - 1] % 2 == 0)
    {
        if (a[0] == a[1])
            bad();
    }
    else
    {
        if (n > 2 && a[0] == a[1] && a[1] == a[2])
            bad();
    }
    map <int, int> s;
    for (auto &i : a)
        s[i]++;
    for (int i = a[0] + 1; i < a[n - 1]; ++i)
        if (s[i] < 2)
            bad();
    good();
    return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main()
{
    ll a,b,c;

    cin >> a >> b >> c;

    if(a+b >= c){
        cout << "No" << endl;
        return 0;
    }
    unsigned long long int x;
    unsigned long long int y;
    x = 4*a*b;
    y = (c-(a+b)) * (c-(a+b));

    if(x < y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256