akhauriyash/Code-Regression huggingface dataset:
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
// using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;

//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define bug2(v1,v2)               cerr<<#v1<<" = "<<(v1)<< ' ' << #v2<<" = "<<(v2)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod = 1000000007;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return (((a+mod)%mod)*(b+mod)%mod)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline ll modInverse(ll n, ll p){ return power(n, p-2)%p; }

/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
void stArt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}
void eNd()
{
	#ifndef ONLINE_JUDGE
  	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  	#endif
}

//////////////////// start /////////////////////////////////
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];
ll q, lst[MAX], ans[MAX];
vpll Q[MAX];
 
ll tree[MAX];
 
void update(ll idx, ll val){ 
    idx++;
    while(idx <= MAX-2){ 
        tree[idx] += val;
        idx += idx & (-idx); 
    } 
} 
 
ll query(ll idx){
    idx++;
    ll sum = 0;
    while(idx > 0){ 
        sum += tree[idx];
        idx -= idx & (-idx); 
    } 
    return sum; 
}

int main()
{
 
stArt();
fast
//cout << setprecision(15) << fixed;

	cin >> n >> q;
	fr(i,1,1+n) cin >> a[i];
	fr(i,0,q)
	{
		cin >> l >> r;
		Q[r].pb(l,i);
	}
	fr(i,1,1+n)
	{
		update(i,1);
		if(lst[a[i]]) update(lst[a[i]],-1);
		lst[a[i]] = i;
		for(auto it : Q[i]){
			ans[it.S] = query(i)-query(it.F-1);
		}
	}
	fr(i,0,q) cout << ans[i] << khtm;



 eNd();
  return 0;
 
}


Measured memory_bytes: 56024
A,B,C,X,Y = map(int,input().split())
min_xy = min(X,Y)
max_xy = max(X,Y)
ans1 = 2*C*min_xy + A*(X-min_xy)+B*(Y-min_xy)
ans2 = A*X+B*Y
ans3 = 2*C*max_xy
print(min(ans1,ans2,ans3))

Measured memory_bytes: 9028
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())



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

ll X,Y,Z,K;
ll pmax = 30000000000;
vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {



  ll N;
  string S;

  cin >> N;
  cin >> S;



  vint ruib(N+1,0);
  vint ruiw(N+1,0);

  rep(i,N){
    if(S[i]=='.'){
      ruiw[i+1]=ruiw[i]+1;
      ruib[i+1]=ruib[i];
    }else{
      ruib[i+1]=ruib[i]+1;
      ruiw[i+1]=ruiw[i];
    }
  }

  ll ans=N;

  rep(i,N+1){
    ll tmp;
    tmp=ruib[i]-ruib[0] + ruiw[N]-ruiw[i];

    ans=min(ans,tmp);
  }

  cout << ans << endl;

}

















//


Measured memory_bytes: 3716
package main

import (
	"fmt"
)

func main() {
	var n, p int
	var s string
	fmt.Scanf("%d %d", &n, &p)
	fmt.Scanf("%s", &s)
	r := []rune(s)
	ans := 0
	if p == 2 || p == 5 {
		for i, d := range r {
			if int(d-'0')%p == 0 {
				ans += i + 1
			}
		}
	} else {
		m := make(map[int]int, p)
		mod := 0
		base := 1
		for i := n - 1; i >= 0; i-- {
			m[mod]++
			mod = (int(r[i]-'0')*base + mod) % p
			ans += m[mod]
			base = base * 10 % p
		}
	}
	fmt.Printf("%d\n", ans)
}


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

void solve(){
  int X;
  int A,B;
  cin >> X ;
  for (A=-118;A<120;A++){
    for (B=-119;B<119;B++){
      if (pow(A,5.0)-pow(B,5.0)==X){
	cout << A << " " << B << endl;
	goto OUT;
      }
    }
  }
 OUT:;
}

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


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

int main(){
    long long int n;
    cin >> n;
    vector<long long int> capacity(5);
    for(int i=0; i<5; i++){
        cin >> capacity[i];
    }
    sort(capacity.begin(),capacity.end());
    cout <<  (n-1) / capacity[0] + 5 << endl;
    return 0;
}

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

string calc(string s){
  map<int, char> mp;
  for(int i = 0 ; i < 26 ; i++) mp[i] = 'A' + i;

  string ret = "";
  int cnt = 0;
  for(int i = 0 ; i < (int)s.size() ; i++){
    if(s[i] == '+') cnt++;
    if(s[i] == '-') cnt--;
    
    if(s[i] == '[' || s[i] == ']') ret += s[i];
    
    if(s[i] == '?'){
      ret += 'A';
      cnt = 0;
    }
    
    if(isalpha(s[i])){
      int n = (s[i] - 'A') + cnt;
      n %= 26;
      if(n < 0) n += 26;
      ret += 'A' + n;      
      cnt = 0;
    }    
  }
  return ret;
}

string solve(string s){
  stack<int> st;
  for(int i = 0 ; i < (int)s.size() ; i++){
    if(s[i] == '[') st.push(i);
    if(s[i] == ']'){
      int from = st.top(); st.pop();
      int to = i;
      
      string t = "";
      for(int j = from ; j <= to ; j++)
	if(isalpha(s[j])) t += s[j];

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

      for(int j = from, cnt = 0 ; j <= to ; j++) 
	if(isalpha(s[j])) s[j] = t[cnt++];
    }
  }
  string t = "";
  for(int i = 0 ; i < (int)s.size() ; i++)
    if(isalpha(s[i])) t += s[i];
  return t;
}

int main(){
  string s;
  while(cin >> s){
    if(s == ".") break;
    s = calc(s);
    cout << solve(s) << endl;
  }
  
  return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

int dp[222222][5];

signed main() {
  int N, A[222222];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= 4; j++) {
      dp[i][j] = 1e9;
    }
  }
  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    int prv = dp[i][0];
    for (int j = 0; j <= 4; j++) {
      chmin(prv, dp[i][j]);
      int diff;
      if (j == 0 || j == 4) {
        diff = A[i];
      } else if (j == 1 || j == 3) {
        diff = A[i] == 0 ? 2 : A[i] % 2;
      } else {
        diff = (A[i] + 1) % 2;
      }
      chmin(dp[i+1][j], prv + diff);
    }
  }

  int ans = 1e9;
  for (int j = 0; j <= 4; j++) {
    chmin(ans, dp[N][j]);
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
	int n=0,d[100];
	int sum;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = i + 1;j < n  ;j++){
			sum += d[i]*d[j];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int t, n;
    int price[] = {6000, 4000, 3000, 2000};

    while (scanf("%d%d\n", &t, &n) != EOF) {
        printf("%d\n", price[t-1] * n);
    }
    return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int maxn = 2e5+5;
const ll inf = 1e18;
int n, m;
vector<int> L[maxn];
vector<pair<int,int>> R[maxn];
ll st[4*maxn], lazy[4*maxn];

void push(int pos, int l, int r){
	if (lazy[pos] != 0){
		st[pos] += lazy[pos];
		if (l < r){
			lazy[2*pos] += lazy[pos];
			lazy[2*pos+1] += lazy[pos];
		}
		lazy[pos] = 0;
	}
}

void upd(int ql, int qr, ll v, int pos = 1, int l = 0, int r = n){
	push(pos, l, r);
	if (qr < ql or l > qr or r < ql) return;
	if (ql <= l && r <= qr) {
		lazy[pos] += v;
		push(pos, l, r);
		return;
	}
	int mid = (l+r)/2;
	upd(ql, qr, v, 2*pos, l, mid);
	upd(ql, qr, v, 2*pos+1, mid+1, r);
	st[pos] = max(st[2*pos], st[2*pos+1]);
}

ll query(int ql, int qr, int pos = 1, int l = 0, int r = n){
	push(pos, l, r);
	if (qr < ql or r < ql or l > qr) return -inf;
	if (ql <= l && r <= qr) return st[pos];
	int mid = (l+r)/2;
	return max(query(ql, qr, 2*pos, l, mid), query(ql, qr, 2*pos+1, mid+1, r));
}

void debug_tree(int curpos){
	printf("ST at pos %d:\n", curpos);
	for(int i = 1; i<=n; i++) printf("%lld%c", query(i, i), " \n"[i==n]);
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i<m; i++){
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		L[l].emplace_back(x);
		R[r].push_back({l, x});
	}
	ll ans = 0;
	for(int i = 1; i<=n; i++){
		for(int x: L[i]) upd(0, i-1, x);
		ll mx = query(0, i-1);
		ans = max(ans, mx);
		upd(i, i, mx);
		for(pair<int,int>&p: R[i]) upd(0, p.first-1, -p.second);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 33900
fun main() {
    val (h, w, k) = readInts()

    val grid = MutableList(h) { readLn() }
    val black = grid.map { it.count { ch -> ch == '#' } }.sum()

    fun remBlack(rowsChosen: Int, colsChosen: Int): Int {
        var rem = black
        for (i in grid.indices) {
            for (j in grid[i].indices) {
                val painted = ((1 shl i) and rowsChosen > 0) || ((1 shl j) and colsChosen > 0)
                if (painted && grid[i][j] == '#') rem--
            }
        }
        return rem
    }

    var ans = 0

    for (i in 0 until (1 shl h)) {
        for (j in 0 until (1 shl w)) {
            if (remBlack(i, j) == k) ans++
        }
    }

    println(ans)
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 37252
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int []A = new int[N];
			
			ArrayList<ArrayList<SG>> L = new ArrayList<ArrayList<SG>>();
			for(int i = 0;i<N;i++) {
				ArrayList<SG> list = new ArrayList<SG>();
				A[i] = scan.nextInt();
				for(int j = 0;j<A[i];j++) {
					list.add(new SG(scan.nextInt(),scan.nextInt()));
				}
				L.add(list);
			}
			
			int max = 0;
			
			
			for(int i = 0;i<(int)Math.pow(2, N);i++) {
				
				int []usohon = new int[N];
				int shoujiki = 0;
				
				for(int j = 0;j<N;j++) {
					if((1&i>>j)==1) {
						usohon[j]=1;
						shoujiki++;
					}
				}
				
				int ok = 1;
				
				outside: for(int j = 0;j<N;j++) {
					if(usohon[j]==0)continue;
					for(int z = 0;z<A[j];z++) {
						if(usohon[L.get(j).get(z).x-1]!=L.get(j).get(z).y) {
							ok=0;
							break outside;
						}	
					}
				}
				
				if(ok==1&&max<shoujiki) max =shoujiki;

			}
			
			System.out.println(max);
			
		}
	}
	
	static class SG{
		int x;int y;
		SG(int X ,int Y){x = X;y = Y;}
	}
		

}


Measured memory_bytes: 24916
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE

bool solve(int N, const vector<int>& H) {
    int cur = H[N-1];
    for (int i = N-2; i >= 0; --i) {
        //debug(i, cur, H[i]);
        if (cur < H[i]-1) return false;
        cur = min(cur, H[i]);
    }
    return true;
}

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

    int N; cin >> N;
    vector<int> H(N);
    for (int& h : H) cin >> h;

    cout << (solve(N, H) ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 640
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
d = []

n.times do |i|
  d << [1, a[i]]
end
m.times do
  b, c = gets.chomp.split.map(&:to_i)
  d << [b, c]
end

d.sort_by! {|_, y| y }
res = 0
while n > 0 && !d.empty?
  b, c = d.pop
  cnt = [b, n].min
  res += cnt * c
  n -= cnt
end
puts res

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  return ret;
}

int main() {
  mll m;

  ll N;
  scanf("%lld", &N);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;

    m[v]++;
  }

  ll ans = 0;

  for (ll i = 0; i < N; i++) {
    ll v = list[i];
    auto d = divisor(v);

    bool plus = true;
    for (auto e : d) {
      ll count = m[e];

      if (e == v) {
        if (count >= 2) {
          plus = false;
          break;
        }
      } else {
        if (count >= 1) {
          plus = false;
          break;
        }
      }
    }
    if (plus) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 33300
# -*- coding: utf-8 -*-

N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0 for x in range(N+1)]

D[0] = 0
for i in range(1, N+1):
    D[i] = D[i-1] + L[i-1]

a = [x for x in D if x <= X]
ans = len(a)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int r,g,b;
cin >> r >> g >> b;
int ans = g*10+b;
if(ans%4==0) {
  cout << "YES" <<endl;
} else {
  cout << "NO" << endl;
}
return 0;
}


Measured memory_bytes: 256
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
_A = [abs(a) for a in A]
if len([1 for a in A if a < 0]) % 2 == 0:
  print(sum(_A))
else:
  _A = sorted(_A)
  print(sum(_A[1:])-_A[0])


Measured memory_bytes: 14332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		DFS dfs=new DFS();

		dfs.abc125_B();

	}
}

class DFS{

	int N;
	int[] Value;
	int[] Cost;

	public void abc125_B(){

		Scanner sc=new Scanner(System.in);

		N=sc.nextInt();

		Value=new int[N];
		Cost=new int[N];

		for(int i=0;i<N;i++)	Value[i]=sc.nextInt();

		for(int i=0;i<N;i++)	Cost[i]=sc.nextInt();

		int ans=DFS_do(0,0,0);

		System.out.println(ans);

		sc.close();
	}

	public int DFS_do(int n,int value,int cost) {

		if(n==this.N) return value-cost;

		int ret0=DFS_do(n+1,value,cost);
		int ret1=DFS_do(n+1,value+Value[n],cost+Cost[n]);

		return Math.max(ret0, ret1);

	}

}


Measured memory_bytes: 22228
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = INT_MAX;
const long long LINF = LLONG_MAX;
const long long N = 2e6+1;
 
typedef long long ll;
typedef long double ld;  
 
void test_case()
{
    ll n, m ,i, j, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    f(i,0,n)
    {
        cin >> a[i];
        if(i)
            a[i]+= a[i-1];
    }
    f(i,0,m)
    {
        cin >> b[i];
        if(i)
            b[i]+=b[i-1];
    }
    ll st1 = 0, st2 = 0, ans = 0, tot = 0;
    ll x = upper_bound(all(b), k)-b.begin();
    ans = x;
    f(i,0,n)
    {
        ll req = k-a[i];
        ll x = 0;
        if(req > 0)
            x = upper_bound(all(b), req)-b.begin();
        if(req >= 0)
            ans = max(ans, i+1+x);
    }
    cout << ans << '\n';
 
}
 
int32_t main()
{
    IOS(); 
     
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(),s.end());
  int ans = 1;
  rep(i,n-1){
    if(s[i] != s[i+1]) ++ans;
  }
  if(ans == 3) puts("Three");
  else puts("Four");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef vector<int> vi;
vector <int> s;
int main(){
 
 
	int N;
	cin >> N;
	vi x;
	vi y;
	vi z;
	rep(i,N){
		int a;
		cin >> a;
		if(i % 2 == 0){
			x.pb(a);
		}
		else{
			y.pb(a);
		}
		z.pb(a);
	}
	sort(all(x));
	sort(all(y));
	sort(all(z));
	int cnt = 0;
	rep(i,z.size()){
		if(i % 2 == 1)continue;
		int d = *lower_bound(all(x),z[i]);
		if(d != z[i]){
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int a,b,c,d;cin>>a>>b>>c>>d;
    int t = c/b;
    if(c%b != 0)t++;
    int s = a/d;
    if(a%d!=0)s++;
    if(t<=s) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static bool[] dk;

    static bool Kirai(int n)
    {
	string s = n.ToString();
	for (int i = 0; i < s.Length; i++)
	{
	    int x = (int) (s[i] - '0');
	    if (dk[x]) return true;
	}
	return false;
    }

    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0]; int k = tmp[1];

	dk = new bool[10];
	var t = ReadIntArray();
	for (int i = 0; i < k; i++) dk[t[i]] = true;
	
	for (int i = n; i < 99999; i++)
	{
	    if (!Kirai(i))
	    {
		WriteLine(i);
		break;
	    }
	}
    }
}



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

typedef long long ll;
#define PB push_back

const ll MOD = 1000000007;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n, k; cin >> n >> k;
	if (k > n) cout << 1;
	else {
		ll ans = 0;
		for (ll i = k; i <= n + 1; ++i) {
			ll min=(i-1)*i/2;
			ll max = n*(n + 1)/2;
			ll hh=(n-i)*(n-i+1)/2;
			if(n-i+1<0) hh=0;
			max-=hh;
			ans+=max-min+1;
			ans%=MOD;
		}
		cout << ans;
	}
}

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

int main() {
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> priceA(A),priceB(B),waribiki(3*M);
  
  for (int i = 0; i < A; i++) {
    cin >> priceA.at(i);
  }
  for (int i = 0; i < B; i++) {
    cin >> priceB.at(i);
  }
  for (int i = 0; i < 3*M; i++) {
    cin >> waribiki.at(i);
  }
  int sum = 0;
  int PRICE = 0;
   for (int i = 0; i < M; i++) {
     if (i == 0) {
       PRICE = priceA.at(waribiki.at(0)-1)+priceB.at(waribiki.at(1)-1)-waribiki.at(2);
       continue;
     }
     sum = priceA.at(waribiki.at(3*i)-1)+priceB.at(waribiki.at(3*i+1)-1)-waribiki.at(3*i+2);
     if (sum < PRICE) {
       PRICE = sum;
     }
   }
  
  sort(priceA.begin(), priceA.end());
  sort(priceB.begin(), priceB.end());
  
  int ans = 0;
  ans = priceA.at(0) + priceB.at(0);
  if (PRICE < ans) {
    cout << PRICE <<endl;
  }
  else {
    cout << ans <<endl;
  }
     
     
}


Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
const int inf = 1e9;
const int mod = 1e9+7;

const int nmax = 40, abmax = 10;
int a[nmax], b[nmax], c[nmax]; 
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main() {
    int N, ma, mb;
    cin >> N >> ma >> mb;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    for (int k = 0; k <= N; k++) {
        for (int ca = 0; ca <= nmax*abmax; ca++) {
            for (int cb = 0; cb <= nmax*abmax; cb++) {
                dp[k][ca][cb] = inf;
            }
        }
    }

    dp[0][0][0] = 0;

    for (int k = 0; k < N; k++) {
        for (int ca = 0; ca <= nmax*abmax; ca++) {
            for (int cb = 0; cb <= nmax*abmax; cb++) {
                if (dp[k][ca][cb] == inf) continue;
                dp[k+1][ca][cb] = min(dp[k+1][ca][cb], dp[k][ca][cb]);
                dp[k+1][ca+a[k]][cb+b[k]] = min(dp[k+1][ca+a[k]][cb+b[k]], dp[k][ca][cb]+c[k]);
            }
        }
    }

    int ans = inf;
    for (int ca = 1; ca <= nmax*abmax; ca++) {
        for (int cb = 1; cb <= nmax*abmax; cb++) {
            if (ca*mb == cb*ma) ans = min(ans, dp[N][ca][cb]);
        }
    }

    if (ans == inf) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25984
#include <stdio.h>
typedef long long ll;

void extgcd(ll a, ll b, ll *x, ll *y) {
  if(b) {
    extgcd(b, a % b, y, x);
    *y -= (a / b) * (*x);
  } else {
    *x = 1, *y = 0;
  }
}

int main(void) {
  ll a, b, x, y;
  scanf("%lld%lld", &a, &b);
  extgcd(a, b, &x, &y);
  printf("%lld %lld\n", x, y);
  return 0; 
} 


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

using namespace std;

void solve(ll N, vector<ll> p) {
    sort(p.begin(), p.end());
    ll sum = 0;
    for (int i = 0; i < N - 1; i++) sum += p[i];
    cout << p.back() / 2 + sum << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    vector<ll> p(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> p[i];
    }
    solve(N, p);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int N;
vector<int> H;
vector<int> H_s;    // ソート済み H
vector<int> val_to_ind[MAX_N]; // インデックスからの逆引き

signed main()
{
    cin >> N;
    H.assign(N, 0);
    REP(i, N) {
        cin >> H[i];
        H_s.push_back(H[i]);
        val_to_ind[H[i]].push_back(i);
    }
    SORT(H_s);

    int ans = 0;
    for(auto h : H_s) {
        int ind = val_to_ind[h][val_to_ind[h].size()-1];
        val_to_ind[h].pop_back();
        int val = H[ind];
        if(val <= 0) { continue; }
        // 左右に向かって val ぶん減らす
        for(int i = ind; i >= 0; --i) {
            if(H[i] <= 0) { break; }
            H[i] -= val;
        }
        for(int i = ind + 1; i < N; ++i) {
            if(H[i] <= 0) { break; }
            H[i] -= val;
        }
        ans += val;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
a = raw_input()
n, q = a.split(" ")
n = int(n)
q = int(q)
total = 0

queue = []
for i in range(n):
	queue.append(raw_input())
while (len(queue) > 0):
	b = queue.pop(0)
	p, t = b.split(" ")
	sa = int(t) - q
	if sa > 0:
		queue.append(p + " " + str(sa))
		total += q
	else:
		total += int(t)
		print (p + " " + str(total))

Measured memory_bytes: 10684
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m,x;



vi bt(12);

void setbit(ll i){
  ll tmp=1;
  for(ll j=0;j<12;j++){
    bt[j]=(i>>j)%2;
  }
}

int main(){
  ll ans=llMAX;
  cin >> n >> m>>x;

  
  vi c(n);
  vvi a(n, vi(m));

  REP(i,n){
    cin>>c[i];
    REP(j,m){
      cin>>a[i][j];
    }
  }



  ll nn=1<<n;

  for(ll i=0;i<nn;i++){
    setbit(i);
    ll cost=0;
    vi arg(m,0);
    for(ll j=0;j<n;j++){
      if (bt[j]==1){
        for(ll k=0;k<m;k++){
          arg[k]+=a[j][k];
        }
        cost+=c[j];
      }
    }

    int flag=0;
    for(ll k=0;k<m;k++){
      if (arg[k]<x)flag=1;
    }
    if (flag==0){
      ans=min(ans,cost);
    }

    
    
  }



  if (ans==llMAX){
    ans=-1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

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

    vector<int> C(N), S(N), F(N);
    rep(i, N) {
        cin >> C[i] >> S[i] >> F[i];
    }

    rep(i, N) {
        int now = 0;
        REP(j, i, N - 2) {
            now = max(now, S[j]);
            while (now % F[j]) now++;
            now += C[j];
        }
        cout << now << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x;
  cin>>n;
  vector<int>v(n);
  vector<int>::iterator it;
  for(int i=0;i<n;i++)
  cin>>v[i];
  int q;
  cin>>q;
  while(q--)
{
    cin>>x;

  // if(binary_search(v.begin(),v.end(),x))
  it= lower_bound(v.begin(),v.end(),x);
  if(it != v.end())
   cout<< lower_bound(v.begin(),v.end(),x)-v.begin()<<endl;
   else
    cout<<n<<endl;
}
return 0;
}



Measured memory_bytes: 3104
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

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

int main()
{
    int h, w; cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];

    rep(i, h) rep(j, w){
        if(s[i][j]=='#') continue;
        int t = 0;
        rep(k, 8){
            int x = i+dx[k];
            int y = j+dy[k];
            if(x < 0 || x >= h || y < 0 || y >= w) continue;
            if(s[x][y]=='#') t++;
        }
        s[i][j] = t + '0';
    }
    rep(i, h) cout << s[i] << endl;
    
    return 0;}

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

int main()
{
	int R=0;
	cin >> R;
	if (R<1200)
	{
		cout << "ABC" << endl;
	}else if (R<2800)
	{
		cout << "ARC" << endl;
	}else
	{
		cout << "AGC" << endl;
	}
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define push push_back
#define pop pop_back
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef string str;

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

#define EMAX 10000000

int cost[101][101];

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

    ll n=in();
    ll d[101];

    rep(i, n) {
        rep(j, n) {
            cost[i][j] = EMAX;
        }
        d[i] = EMAX;
    }

    rep(i, n) {
        int u=in<int>(), k=in<int>();
        rep(j, k) {
            int v=in<int>(), c=in<int>();
            cost[u][v] = c;
        }
    }

    // ノード0からの距離を調べる
    d[0] = 0;
    bool flag = true;
    while(flag) {
        flag=false;
        // 移動する方法のある全ノードからの，次のノードへの移動コストを考える
        rep(i, n) {
            if(d[i] != EMAX) {
                rep(j, n) {
                    if(i == j)
                        continue;
                    int next_c = d[i] + cost[i][j];

                    // 更新できる場合更新
                    if(d[j] > next_c) {
                        d[j] = next_c;
                        flag=true;
                    }
                }
            }
        }
    }

    rep(i, n) {
        cout << i << " " << d[i] << endl;
        // rep(j, n) {
        //     cout << cost[i][j] << " ";
        // }
        // cout << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3176
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    ans = [-1]*N
    for i in range(M):
        j,x = MI()
        j-=1
        if ans[j]!=-1 and ans[j]!=x:
            print(-1)
            return
        ans[j]=x
    
    if ans[0] == 0 and N!=1:
        print(-1)
        return
    if ans[0] == -1 and N==1:
        print(0)
        return
    non_zero = False
    for i in range(N):
        if ans[i]==-1:
            if non_zero:
                ans[i]=0
            else:
                ans[i]=1
                non_zero = True
        else:
            non_zero = True
    print(*ans,sep="")
if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
k,s = map(int,input().split())
ans = 0
#
if s <= k:
    for x in range(s + 1):
        for y in range (s - x + 1):
            ans += 1
elif (s > k) and (s <= 2*k):
    for x in range(k + 1):
        for y in range(s - x + 1):
            if y <= k and (s - x - y) <= k:
                ans += 1
else:
    for x in range(k + 1):
        for y in range(k + 1):
            if (s - x - y) <= k:
                ans += 1
#
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static long[] fact = new long[2000005];
    public static void main(String[] args) {
        long mod = 1000000007;
        calFact(mod);
        FastScanner fs = new FastScanner();
        int k = fs.nextInt();
        String s = fs.next();
        long n = s.length();
        long ans = 0;
        for(long i=n; i<=n+k; i++) {
            ans += calc(n+k, i, mod)*binpow(25, n+k-i, mod);
            ans %= mod;
        }
        System.out.println(ans);
    }

    private static long calc(long n, long i, long mod) {
        long res = fact[(int)n];
        long div = fact[(int)(n-i)]*fact[(int)i];
        div %= mod;
        div = binpow(div, mod-2, mod);
        return (res*div)%mod;
    }

    private static long binpow(long val, long deg, long mod) {
        if(deg == 0)
            return 1 % mod;
        if(deg%2 == 1) {
            return binpow(val, deg-1, mod) * val % mod; 
        }
        long res = binpow(val, deg >> 1, mod);
        return (res*res) % mod;
    }

    private static void calFact(long mod) {
        fact[0] = 1;
        for(int i=1; i<2000005; i++) {
            fact[i] = i * fact[i-1];
            fact[i] %= mod;
        }
    }

    static class FastScanner {
        BufferedReader br = null;
        StringTokenizer st;
    
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
    
        String next() {
            while(st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    
        double nextDouble() {
            return Double.parseDouble(next());
        }
    
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 68696
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define LL long long
LL A,B,C,D;
LL getn(LL L,LL R,LL D)
{
	LL P,S;
	if(L%D==0)P=L/D;
	else P=L/D+1;
	S=R/D;
	return S-P+1;
}
LL gcd(LL a,LL b)
{
	if(b==0)return a;
	return gcd(b,a%b);
}
int main()
{
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	printf("%lld",B-A+1-(getn(A,B,C)+getn(A,B,D)-getn(A,B,C*D/gcd(C,D))));
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<double> v(n);
    REP(i, n) cin >> v[i];

    sort(ALL(v));
    double now = v[0];
    FOR(i, 1, n) now = (now + v[i]) / 2.0;
    cout << fixed << setprecision(9) << now << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;
long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

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

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,j,H,W,cnt=0;
  cin>>H>>W;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        cnt++;
      }else{
      }
    }
  }
  if(cnt+1==H+W){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int M;
  cin >> M;
  for (int i=1; i<=M; i++){
    int P, X;
    cin >> P >> X;
    vector<int> vec_c(N);
    vec_c=vec;
    vec_c.at(P-1) = X;
    int sum = 0;
    for (int j=0; j<N; j++){
      sum += vec_c.at(j);
    }
    cout << sum << endl;  
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N, K, C; string S;
	cin >> N >> K >> C >> S;
	vector<int> dpl(N + 1), dpr(N + 1);
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'o') {
			dpl[i + 1] = (i < C ? 0 : dpl[i - C]) + 1;
		}
		dpl[i + 1] = max(dpl[i + 1], dpl[i]);
	}
	for (int i = N - 1; i >= 0; --i) {
		if (S[i] == 'o') {
			dpr[i] = (i >= N - C ? 0 : dpr[i + C + 1]) + 1;
		}
		dpr[i] = max(dpr[i], dpr[i + 1]);
	}
	vector<int> sum(N + 1);
	for (int i = -C; i <= N; ++i) {
		int l = max(i, 0);
		int r = min(i + max(C, 1), N);
		if (dpl[l] + dpr[r] >= K) {
			++sum[l];
			--sum[r];
		}
	}
	for (int i = 0; i < N; ++i) {
		sum[i + 1] += sum[i];
	}
	for(int i = 0; i < N; ++i) {
		if (S[i] == 'o' && sum[i] == 0) {
			cout << i + 1 << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 4228
// D - Redistribution
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

int main(){
	int S; cin>>S;
	int MOD = 1e9 + 7;
	vector<int64_t> C(S+1, 0);
	C[0] = 1;
	rp(n, 3, S+1) // n:[3,S]
		rp(i, 3, n+1){ // i:[3,n]
			C[n] += C[n-i];
			C[n] %= MOD;
		}
	cout<< C[S] <<endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;



int main() {
	long long N,K;
	cin >> N >> K;
	vector<int>A(N);  
	vector<int>SUM(N + 1);
	long long sum = 0; 
	SUM[0] = 0;
	for (long long n = 0;n<N;++n) {
		cin >> A[n];
		sum += A[n]; 
		sum %= K; 
		SUM[n + 1] = (sum + (n + 1) * K - (n + 1))%K;
	}
	map<int,int>mp;
	for (int n = 1;n < K;++n) {
		if (n<=N) {
			mp[SUM[n]]++;
		}
	}
	long long ans = 0;
	for (long long n = 0; n <= N; ++n) {
		ans += mp[SUM[n]];
		mp[SUM[n + 1]]--;
		if ((n + K) <= N) {
			mp[SUM[n + K]]++;
		}
	}
	cout << ans <<  endl;
	return 0;
}

Measured memory_bytes: 14296
#include <iostream>

int main(int argc, char const *argv[])
{
    int S;
    std::cin >> S;

    int hours = S / 3600;
    S %= 3600;
    int minutes = S / 60;
    int seconds = S % 60;

    std::cout << hours << ":" << minutes << ":" << seconds << std::endl;

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

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

    vector<int> h(n);
    REP(i,n){
        cin>>h[i];
    }
    sort(ALL(h));

    int d,d_min;
    REP(i,n-k+1){
        d=h[i+k-1]-h[i];
        if(i==0){
            d_min=d;
        }else{
            if(d<d_min){
                d_min=d;
            }
        }
    }

    cout<<d_min<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100001

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main(){
  int H,i,A[MAX];
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=H)
      printf("left key = %d, ",A[left(i)]);
    if(right(i)<=H)
      printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 608