akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

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

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

    if (K >= N*2) {
        int ans = 0;
        REP(i, N) {
            if (V[i] > 0) ans += V[i];
        }
        cout << ans << endl;
        return 0;
    }

    if (K > N) {
        priority_queue<int, vi, greater<int> > pq;
        REP(i, N) pq.push(V[i]);

        REP(i,K-N) {
            pq.pop();
        }

        int ans = 0;
        while(!pq.empty()) {
            ans += pq.top(); pq.pop();
        }
        cout << ans << endl;
        return 0;
    }

    // 1<= K <= N
    vi VV = V;
    REP(i, N) VV.push_back(V[i]);

    int ans = 0;
    for (int len = K; len > 0; len--) {
        int rm = K - len;

        for (int i=N-len; i<=N; i++) {            
            deque<int> dq;
            for(int j=i; j<i+len; j++) {
                dq.push_back(VV[j]);
            }

            int sum = 0;                
            priority_queue<int, vi, greater<int> > lpq;
            for (int j = 0; j < len; j++) {
                int f = dq.front(); dq.pop_front();
                lpq.push(f);
                sum += f;
                dq.push_back(f);
            }
            ans = max(ans, sum);

            for(int r=0; r<rm && lpq.size()>0; r++) {
                int lo = lpq.top(); lpq.pop();
                sum -= lo;
                ans = max(ans, sum);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split())) 

s = 0
for i in range(1,n-1):
	if (p[i] < p[i-1] and p[i] > p[i+1]) or (p[i] < p[i+1] and p[i] > p[i-1]):
		s += 1
print(s)

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

int main() {
  long h = 0;
  long n = 0;
  long sum = 0;
  cin >> h >> n;
  vector <long> arr(n);
  for(int i = 0; i < n; i++){
  	cin >> arr[i];
  }
  for(long i = 0; i < n; i++){
    sum = sum + arr[i];
  }
  if(sum >= h){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

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

int main()
{
	int a, b, n, i=0;
	int ans[100];
	char op;
	
	do {
		cin >> a >> op >> b;
		if (op == '+')
			ans[i++] = a + b;
		else if (op == '-')
			ans[i++] = a - b;
		else if (op == '*')
			ans[i++] = a * b;
		else if (op == '/')
			ans[i++] = a / b;
	} while (op != '?');
	
	n = i;
	i = 0;

	while (i < n)
		cout << ans[i++] << endl;
	
	return 0;
}

Measured memory_bytes: 3032
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	ll n, a, b;
	cin >> n >> a >> b;
	if(!a) return cout << 0LL << '\n', 0;
	ll answer = n / (a + b) * a;
	n -= (a + b) * (answer / a);
	cout << answer + min(n, a) << '\n';
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	list <int> l;
	int n; cin>>n;
	int t; cin>>t;
	l.push_back(t);
	for (int i = 2; i <= n; ++i)
	{
		cin>>t;
		if(i %2 == 0)
			l.push_back(t);
		else
			l.push_front(t);	
	}
	if(n % 2 == 0){
		vector <int > v;
		for (list <int>:: iterator i = l.begin(); i !=  l.end() ; ++i)
		{
			v.push_back(*i);
		}
		for (int i = v.size() - 1; i >= 0; --i)
		{
			cout<<v[i]<<" ";
		}
	}
	else{
		for (list<int>::iterator i = l.begin(); i !=  l.end() ; ++i)
		{
			cout<<*i<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 9336
#include<stdio.h>
int n,a[50],ans;
main()
{
	scanf("%d",&n);for(register int i=0;i<n;++i)scanf("%d",a+i);
	for(register int i=0;i<n;++i)for(register int j=i+1;j<n;++j)ans+=a[i]*a[j];
	printf("%d",ans);
}

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

const int MAX = 100001;
const int MAX_N = (1<<18);
const int A = 1024;

ll V[MAX_N];
int W[MAX_N], S[MAX], L[MAX];
int N, Q;

ll dp[A+1][MAX+1] = {};

int main() {
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> V[i] >> W[i];
    }
    cin >> Q;
    for (int i=0; i<Q; i++){
        cin >> S[i] >> L[i];
    }

    int nw, w;
    ll nv, v;
    for (int k=1; k<=min(N, A); k++){
        nv = V[k-1]; nw = W[k-1];
        for (int w=0; w<MAX; w++){
            if (w >= nw && (dp[k][w] < dp[k/2][w-nw]+nv)){
                dp[k][w] = dp[k/2][w-nw] + nv;
            }
            if (dp[k][w] < dp[k/2][w]) {
                dp[k][w] = dp[k/2][w];
            }
        }
    }

    int s, l;
    for (int ind=0; ind<Q; ind++){
        s = S[ind]; l = L[ind];
        vector< pair<ll, int> > dp2 = {};
        while (s >= A){
            dp2.push_back({V[s-1], W[s-1]});
            s /= 2;
        }

        ll ans = dp[s][l];
        vector< pair<ll, int> > dp3 = {}, ndp = {};
        dp3.push_back({0ll, 0ll});
        for (auto NVW : dp2){
            nv = NVW.first; nw = NVW.second;
            ndp = {};
            for (auto VW : dp3) {
                v = VW.first; w = VW.second;
                if (w + nw <= l) {
                    ndp.push_back({v+nv, w+nw});
                    ans = max(ans, dp[s][l-(w+nw)]+ (v+nv));
                }
            }
            for (auto VW : ndp) {
                dp3.push_back(VW);
            }
        }
        cout << ans << "\n";
    }

}

Measured memory_bytes: 806664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int c = 1; c < n; c++) {
        for (int i = 1; i * i <= n - c; i++) {
            if ((n - c) % i == 0) {
                if (i * i == n - c) {
                    ans++;
                } else {
                    ans += 2;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>

#define INF 100000000
template<class T> inline bool chmax(T& a, T b)
{ if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b)
{ if (a > b) { a = b; return 1; } return 0; }

using namespace std;

int main(){
  int i,j,k,n,d,a[1005];
  double x=0;
  cin >>n;
  for(i=0;i<n;i++)cin >> a[i];

  for(i=0;i<n;i++){
    x += double(1.0/a[i]);
  }
  cout << 1/x<<endl;


  return 0;
}


Measured memory_bytes: 256
# coding:utf-8

def main():
    N = int(input())
    s = input()
    count1 = 0
    count2 = 0
    count3 = 0
    temp = ""
    patern3_white = [0]*N
    patern3_black = [0]*N
    patern3 = []
    if (not "." in s) or (not "#" in s):
        print(0)
        return

    for i in s:
        if i == ".":
            count1 += 1
        elif i == "#":
            count2 += 1

    for i in range(N-1):
        if i == 0:
            if s[0] == "#":
                patern3_white[0] = 1
                patern3_black[0] = count1
            else:
                patern3_white[0] = 0
                patern3_black[0] = count1-1
                
            patern3.append(patern3_white[0] + patern3_black[0])
        else :
            if s[i] == "#":
                patern3_white[i] = patern3_white[i-1]+1
                patern3_black[i] = patern3_black[i-1]
            else :
                patern3_white[i] = patern3_white[i-1]
                patern3_black[i] = patern3_black[i-1]-1
            patern3.append(patern3_white[i]+patern3_black[i])
    # print(patern3_black)
    # print(patern3_white)
    # print(patern3)
    # print()
    count3 = min(patern3)
    # print(count1)
    # print(count2)
    # print(count3)
    print(min(count1,count2,count3))

if __name__ == "__main__":
    main()

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

#define N 200100

struct Graph {
	struct Edge {
		int v, nxt;
	} e[N << 1];
	int head[N], cnt;
	
	inline void addedge(int u, int v) {
		e[++cnt] = (Edge){v, head[u]};
		head[u] = cnt;
	}

	int fa[N], dep[N];
	
	inline bool testdis(int u, int v) { // dis(u,v) >= 3 ?
		if (fa[u] == v || fa[v] == u || fa[fa[v]] == u || fa[fa[u]] == v || fa[u] == fa[v])
			return false;
		return true;
	}
	void dfs(int x, int f) {
		fa[x] = f;
		dep[x] = dep[f] + 1;
		for (int i = head[x]; i; i = e[i].nxt) if (e[i].v != f)
			dfs(e[i].v, x);
	}
} R, B;

int tar[N], safe[N];
void dfs(int x, int f) {
	if (R.dep[x] >= B.dep[x])
		return;
	safe[x] = true;
	for (int i = R.head[x]; i; i = R.e[i].nxt) if (R.e[i].v != f)
		dfs(R.e[i].v, x);
}

int main()
{
	//freopen("test.in", "r", stdin);
	int n, x, y;
	scanf("%d %d %d", &n, &x, &y);
	for (int i = 2, a, b; i <= n; i++) {
		scanf("%d %d", &a, &b);
		R.addedge(a, b);
		R.addedge(b, a);
	}
	for (int i = 2, a, b; i <= n; i++) {
		scanf("%d %d", &a, &b);
		B.addedge(a, b);
		B.addedge(b, a);
	}
	R.dfs(x, 0);
	B.dfs(y, 0);
	dfs(x, 0);
	for (int i = 1; i <= n; i++)
		for (int j = R.head[i]; j; j = R.e[j].nxt)
			if (B.testdis(i, R.e[j].v))
				tar[i] = tar[R.e[j].v] = true;
	
	for (int i = 1; i <= n; i++)
		if (safe[i] && tar[i]) {
			puts("-1");
			return 0;
		}
	int ans = 0;
	for (int i = 1; i <= n; i++)
		if (safe[i])
			ans = max(ans, max(R.dep[i], B.dep[i]) - 1);
	printf("%d\n", ans * 2);
}

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

bool check(double length, int K, vector<int> &logs) {
    int count = 0;
    for (auto log: logs) {
        count += (ceil((double)log / length) - 1);
        if (count > K) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, K;
    cin >> N >> K;    
    vector<int> logs;
    for (int i = 0; i < N; i++) {
        int log;
        cin >> log;
        logs.push_back(log);
    }

    int left = 1, right = pow(10,9);
    while (left <= right) {
        int mid = (left + right) / 2;
        if (check(mid, K, logs)) {
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
    cout << left << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());

  cout << a[0] + a[1] + 10 * a[2] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){

  int A[100],ans=0,a,b,i,j,minj;

  scanf("%d",&a);
  for(i=0;i<a;i++) scanf("%d",&A[i]);


  for(i=0;i<a;i++){
    minj=i;
    for(j=i;j<a;j++){
      if(j!=minj&&A[j]<A[minj])
          minj=j;
    }
    if(&A[i]!=&A[minj]){
       b=A[i];
       A[i]=A[minj];
       A[minj]=b;
       ans++;
      }
  }

  for(i=0;i<a;i++){
    printf("%d",A[i]);
    if(i<a-1) printf(" ");
    else printf("\n");
  }

  printf("%d\n",ans);
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;


    
    cout << (ll(1)<<M)*(M*1800+N*100) << endl;


    return 0;
    

}

Measured memory_bytes: 3632
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
typedef long long LL;
const int MD=1000000007;
int fac[4000010],inv[4000010],ti[4000010];
inline int pwr(int a,int x){
	int cur=1,res=1;
	while(x){
		if (x&cur){
			res=1ll*res*a%MD;
			x^=cur;
		}
		a=1ll*a*a%MD;
		cur<<=1;
	}
	return res;
}
inline int comb(int m,int n){
	if (n<m) return 0;
	if (n==m||!m) return 1;
	return 1ll*fac[n]*inv[m]%MD*inv[n-m]%MD;
}
inline void add(int &a,int b){
	a+=b;
	if (a>=MD) a-=MD;
}
int dp[2010][2010];
int main(void){
	fac[1]=inv[1]=ti[1]=1;
	for (int i=2;i<=4000000;++i){
		fac[i]=1ll*fac[i-1]*i%MD;
		ti[i]=-1ll*(MD/i)*(ti[MD%i])%MD;
		if (ti[i]<0) ti[i]+=MD;
		inv[i]=1ll*inv[i-1]*ti[i]%MD;
	}
	int n,m;
	scanf("%d%d",&n,&m);
	if (m==1){
		putchar('1');
		return 0;
	}
	dp[1][0]=1;
	for (int i=1;i<=n;++i){
		for (int j=0;j<=i;++j){
			int lftspc=n*m-i-j*(m-1)-1;
			if (j!=i) add(dp[i][j+1],1ll*dp[i][j]*comb(m-2,lftspc)%MD);
			if (i!=n) add(dp[i+1][j],dp[i][j]);
		}
	}
	printf("%d\n",1ll*dp[n][n]*fac[n]%MD);
	return 0;
}

Measured memory_bytes: 62080
#include <iostream>
#include <vector>
using namespace std;
string str;
vector<char> vec;
int main(void){
    // Your code here!
    cin >> str;
    vec.push_back(str[0]);
    for (int i = 1; i < str.length(); i++) {
        if (str[i] != str[i - 1]) vec.push_back(str[i]);
    }
    int len = vec.size();
    cout << len - 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1e9 + 7;
using namespace std;
int v[110] = {},done[110] = {};
int32_t main()
{
    IOS
    int n,ma = 0;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
    	cin >> v[i];
    }
    int rem = n;
    vector<int> sol;
    for(int i = 1;i <= n;i++)
    {
    	int j = n,y = 0;
    	for(;j >= 1;--j)
    	{
    		if(!done[j])
    		{
    			if(v[j] == rem-y)
    			{
    				sol.pb(v[j]);
    				done[j] = 1;
    				--rem;
    				break;
    			}
    			++y;
    		}
    	}
    	if(j == 0)
    	{
    		cout << -1 << '\n';
    		return 0;
    	}
    }
    reverse(sol.begin(),sol.end());
    for(auto i : sol)
    	cout << i << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>

#define int_inf 1000000000 //1e9
#define ll_inf  100000000000000000 //1e17

using namespace std;


int main(){
	int n;
	cin >> n;
	int sum=0;
	int n2=n;
	while(n2){
		sum += n2%10;
		n2 /= 10;
	}
	
	//cout << sum << endl;
	if(n%sum==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
long long int n,m,k,i,j=1;
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1,};

std::vector<int> tree[100010];
double wei,sio,noudo;
int d1[100005],dn[100005];
bool used[1005];
int kazu=0,v=0;
int a,b;


void iro1(int node,int num){
	d1[node] = num;
	for(int i=0;i<tree[node].size();i++){
		if(d1[tree[node][i]]!=0)continue;
		iro1(tree[node][i],num+1);
	}
}

void iron(int node,int num){
	dn[node] = num;
	for(int i=0;i<tree[node].size();i++){
		if(dn[tree[node][i]]!=0)continue;
		iron(tree[node][i],num+1);
	}
}

int main(){
	cin>>n;
	for(i=1;i<=n-1;i++){
		int a,b;
		cin>>a>>b;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	for(i=1;i<=n;i++){
		d1[i]=0;
		dn[i]=0;
	}
	iro1(1,1);
	iron(n,1);
	int fene=0,sunu=0;
	for(i=1;i<=n;i++){
		if(d1[i]>dn[i])sunu++;
		else fene++;
		//cout<<d1[i]<<" "<<dn[i]<<endl;
	}
	if(fene>sunu){
		cout<<"Fennec";
	}else{
		cout<<"Snuke";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 13568
import sys
import collections
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    dl = []
    for i in range(n):
        a = int(readline())
        d = collections.defaultdict(list)
        for j in range(a):
            x, y = list(map(int, readline().split()))
            d[x-1] += [y]
        dl.append(d)
    mt = 0
    for v in itertools.product([True, False], repeat=n):
        b = True
        for i, vv in enumerate(v):
            if vv:
                for kkk, vvv in dl[i].items():
                    if vvv[0] != v[kkk] :
                        b = False
        if b:
            mt = max(mt, v.count(True))
    print(mt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 45420
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c,d;
    long long int dump[4];
    cin>>a>>b>>c>>d;
    dump[0]=a*c;
    dump[1]=a*d;
    dump[2]=b*c;
    dump[3]=b*d;
    long long int n = sizeof(dump)/sizeof(dump[0]);
    sort(dump,dump+n,greater<long long int>());
    cout<<dump[0];
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
const ll MOD=1e9+7;

int main(){

	int a, b;
	cin >> a >> b;
	if(a>8 || b>8){
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main() {
	int n, a[100001], ans = 0, x;
	cin >> n;
	REP(i, 1, n + 1) {
		cin >> x;
		if (a[x] == i) ans++;
		a[i] = x;
	}
	cout << ans << endl;
}

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

const int INF = 1e8;

struct LazySegmentTree {
    int size;
    vector<int> node, lazy;

    LazySegmentTree(int n) {
        size = 1;
        while (size < n) size <<= 1;
        node.resize(2 * size, INF);
        lazy.resize(2 * size, -1);
        for (int k = 1; k <= n; k++) {
            node[k + size] = 0;
        }
        for (int k = size - 1; k > 0; k--) {
            node[k] = min(node[2 * k], node[2 * k + 1]);
        }
    }

    void eval(int k, int l, int r) {
        if (lazy[k] == -1) return;
        if (k < size) { // not a leaf
            lazy[2 * k] = lazy[k];
            lazy[2 * k + 1] = lazy[k] + (r - l) / 2;
        }
        node[k] = lazy[k];
        lazy[k] = -1;
    }

    void update(int a, int b, int x, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        eval(k, l, r);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = x + l - a;
            eval(k, l, r);
        } else {
            int m = (l + r) / 2;
            update(a, b, x, 2 * k, l, m);
            update(a, b, x, 2 * k + 1, m, r);
            node[k] = min(node[2 * k], node[2 * k + 1]);
        }
    }

    int query(int a, int b, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        eval(k, l, r);
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        int m = (l + r) / 2;
        int vl = query(a, b, 2 * k, l, m);
        int vr = query(a, b, 2 * k + 1, m, r);
        return min(vl, vr);
    }
};

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

    int H, W;
    cin >> H >> W;
    LazySegmentTree st(W + 1);
    for (int i = 0; i < H; i++) {
        int A, B;
        cin >> A >> B;
        int x = st.query(A - 1, A);
        st.update(A, B + 1, x + 1);
        int ans = i + 1 + st.query(0, W + 1);
        if (ans >= INF) cout << -1 << "\n";
        else cout << ans << "\n";
    }
}

Measured memory_bytes: 7412
def main():
    N = int(input())
    ans = 0
    for _ in range(N):
        x, u = input().split()
        x = float(x)
        if u == "JPY":
            ans += x
        else:
            ans += x * 380000.0
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll power(ll x,ll y)
{
    ll res=1;
  
    while(y>0)
    {
        if(y&1)
            res=res*x;
        res%=mod;
        y=y>>1;
        x=x*x;
        x%=mod;
    } 
    return res; 
}
ll inv(ll x)
{
    return power(x,mod-2);
}
void solve()
{
    ll n;
    ll x;
    cin>>n;
    ll sum=0;
    ll d=0;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        sum+=x;
        sum%=mod;
        d+=(x*x);
        d%=mod;
    }
    sum*=sum;
    sum%=mod;
    sum-=d;
    sum%=mod;
    sum+=mod;
    sum*=inv(2);
    sum%=mod;
    cout<<sum;

}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3656
def main():
    from sys import stdin
    import itertools
    n,m,x = map(int,stdin.readline().rstrip().split())
    mat = []
    for _ in range(n):
        temp = list(map(int,stdin.readline().rstrip().split()))
        mat.append(temp)
    
    sum = []
    for i in range(n+1):
        for l in itertools.combinations(mat,i):
            temp = [0]*(m+1)
            for k in range(m+1):
                for j in l:
                    temp[k]+=j[k]
            sum.append(temp)
    
    sum.sort(key=lambda x: x[0])
    for l in sum:
        ans = -1
        flag = True
        for j in l[1:]:
            if j < x:
                flag = False
                break
        
        if flag:
            ans=l[0]
            break
    
    print(ans)
main()

Measured memory_bytes: 11544
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll max_l = 0, sum_l = 0;
    for(int i = 0; i < n; ++i){
        ll l;
        cin >> l;
        max_l = max(max_l, l);
        sum_l += l;
    }
    cout << (sum_l > 2 * max_l ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a;
    cin >> a;
    vector<string> s = {"Christmas","Eve","Eve","Eve"};
    ll b = 0;
    for(int i = 25; i >= a; i--){
        if(b > 0)cout << " ";
        cout << s[b];
        b++;
    }

    
    return 0;
}

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

using namespace std ; 
int one =0, tow=0;
int done[1000001];
int H[1000001];
 int n ;
int calc(int step){
   if(step==n-1)return 0
   ;
   else if(step>=n) return 100000;
   if(done[step]!=-1)return done[step];

   int one =calc(step+1)+abs(H[step]-H[step+1]);
   int tow =calc(step+2)+abs(H[step]-H[step+2]);
   return done[step]=min(one,tow);
}
int main () { 
  
  cin>>n;
  memset(done ,-1,sizeof done);
  for(int i =0;i<n;i++){
    cin>>H[i];

  }
  cout<<calc(0);
  
  return 0;}

Measured memory_bytes: 14088
INF = float("inf")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

H, W = map(int, input().split())
S = [input() for _ in range(H)]

N = W * H
E = [[INF] * N  for _ in range(N)]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            for di, dj in dij:
                ni, nj = i + di, j + dj
                if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == ".":
                    E[W * i + j][W * ni + nj] = 1

from scipy.sparse.csgraph import floyd_warshall
A = floyd_warshall(E)
ans = int(max(max(a if a != INF else 0 for a in a) for a in A))

print(ans)

Measured memory_bytes: 22012
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) os << exchange(dlm, "\n") << x;
  return os;
}
struct Graph{
  using seen_t=int64_t; using ver_t=int32_t; using edge_t=pair<seen_t,ver_t>;
  const seen_t NO=1e18; vector<seen_t> seen;
  const ver_t NONE=-1; vector<ver_t> prev;
  vector<vector<edge_t>> edge;
  Graph(size_t n): seen(n,NO*2), prev(n,NONE), edge(n) {}

  void dijkstra(ver_t frm){
    seen[frm]=0;
    priority_queue<edge_t,vector<edge_t>,greater<edge_t>> que; que.push(make_pair(0,frm));
    ver_t u; seen_t alt;
    while(!que.empty()){
      u=que.top().second; que.pop();
      for(const auto& v:edge[u]){
        alt=seen[u]+v.first;
        if(seen[v.second]>alt){
          seen[v.second]=alt; prev[v.second]=u;
          que.push(make_pair(alt,v.second));
        }
      }
    }
  }
  // has negative => false
  bool bellmanford(ver_t frm){
    seen[frm]=0;
    seen_t alt;
    for(ver_t i=0; i<edge.size(); ++i){
      for(ver_t u=0; u<edge.size(); ++u){
        for(const auto& v:edge[u]){
          alt=seen[u]+v.first;
          if(seen[v.second]>alt){
            seen[v.second]=alt; prev[v.second]=u;
            if(i==edge.size()-1) return false;
          }
        }
      }
    }
    return true;
  }
  auto trace(ver_t frm, ver_t to){
    deque<ver_t> path(1,to);
    while(path[0]!=frm){
      path.push_front(prev[path[0]]);
    }
    return path;
  }
};
ostream& operator<<(ostream& os, const Graph& g){
  const auto* dlm="";
  for(const auto& x:g.seen){
    os<<exchange(dlm," ")<<(x>g.NO?"INF"s:to_string(x));
  }
  return os;
}
auto to_str(const Graph& g){
  string ret;
  const auto* dlm="";
  for(const auto& x:g.seen){
    (ret+=exchange(dlm," "))+=(x>g.NO?"INF"s:to_string(x));
  }
  return ret;
}
int32_t main(){
  ios::sync_with_stdio(false); cin.tie(0);
  // size_t n,m,r; cin>>n>>m>>r;
  size_t n,m; cin>>n>>m;
  Graph graph(n);
  int32_t s,t,d;
  for(size_t i=0; i<m; ++i){
    cin>>s>>t>>d;
    graph.edge[s].push_back(make_pair(d,t));
  }
  vector<string> ret(n);
  for(size_t i=0; i<n; ++i){
    fill(begin(graph.seen),end(graph.seen),graph.NO*2);
    if(!graph.bellmanford(i)){
      cout<<"NEGATIVE CYCLE\n"; return 0;
    }
    else ret[i]=to_str(graph);
  }
  cout<<ret<<endl;
}


Measured memory_bytes: 3372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5e5+7;

ll ans;
char s[N];
int n,sl[N],sr[N];

int main()
{
    cin>>(s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='>') sl[i]=i;
        else sl[i]=sl[i-1];
    }
    sr[n]=n;
    for(int i=n-1;i>=0;i--){
        if(s[i+1]=='<') sr[i]=i;
        else sr[i]=sr[i+1];
    }
    for(int i=0;i<=n;i++)
        ans+=max(i-sl[i],sr[i]-i);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4608
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
 
class DandA {
    static void Main(string[] args) {
        int[] kx = ReadLineIntArray();
        if ((kx[0] * 500) >= kx[1]) {
            Console.WriteLine("Yes");
        } else {
            Console.WriteLine("No");
        }
    }
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int n,k,s,a[5001],f[5001];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]=min(a[i],k),s+=a[i];
	sort(a+1,a+n+1);
	f[0]=1;
	for(int i=n;i>=1;i--)
	{
		bool bo=1;
		for(int j=max(k-s,0);j<k;j++)
		if(f[j]) {bo=0; break;}
		if(bo)
		{
			printf("%d\n",i);
			return 0;
		}
		for(int j=k;j>=a[i];j--) f[j]+=f[j-a[i]]; 
		s-=a[i];
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, K, Q;
int A[100001];

int ans[100001];

signed main()
{
	cin >> N >> K >> Q;

	REP(i, N) ans[i] = K - Q;
	REP(i, Q)
	{
		int a;
		cin >> a;
		ans[a - 1]++;
	}

	REP(i, N)
	{
		cout << ((ans[i] >= 1) ? "Yes" : "No") << endl;
	}
}




Measured memory_bytes: 1408
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int n,d[105][3];
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>d[i][1]>>d[i][2];
        d[i][0]=d[i][1]-d[i][2];
    }
    for(int i=3;i<=n;++i)
    {
        if(!d[i][0]&&!d[i-1][0]&&!d[i-2][0])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;
ll n,m;
ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }
ld dot(const P& a, const P& b) { return a.real()*b.real() + a.imag()*b.imag(); }

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps){
    auto c3 = [](const P &a, const P &b, const P &c){
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A*(B+C-A)*a + B*(C+A-B)*b + C*(A+B-C)*c) / (4*S*S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b){
        P c = (a + b) / (ld)2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c){
        return norm(a - c.pnt) <= c.rad*c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for(int i = 2; i < n; ++i){
        if(!in_circle(ps[i], c)){
            c = c2(ps[0], ps[i]);
            for(int j = 1; j < i; ++j){
                if(!in_circle(ps[j], c)){
                    c = c2(ps[j], ps[i]);
                    for(int k = 0; k < j; ++k){
                        if(!in_circle(ps[k], c)){
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  G g(n);
  for(int i=0;i<n;i++){
    ld x,y;cin>>x>>y;
    g[i] = P(x,y);
  }
  printf("%.15lf\n",(double)smallest_enclosing_disc(g).rad);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<ll>f(n+1);
  int div=1;
  while (div<=n) {
    int i=1;
    while (div*i<=n) {
      f[div*i]+=div*i;
      i++;
    }
    div++;
  }
  ll ans=0;
  for(int i=0 ; i<n+1 ; i++) {
    ans+=f[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 81416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n,x;
  cin>>n;
  vector<ll> v1[n+1];
  for(int i=2;i<=n;i++)
  {
    cin>>x;
    if(i!=x)
    v1[x].push_back(i);
  }
  for(int i=1;i<=n;i++)
  {
    cout<<v1[i].size()<<"\n";
  }
  return 0;
}


Measured memory_bytes: 14492
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		if (N == 1)
			return false;
		return cnt < 2;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		if (cnt == 1)
			A = Integer.parseInt(str);
		if (cnt == 2)
			B = Integer.parseInt(str);
	}

	int A;
	int B;

	public void solve() {
		if (N == 1)
			System.out.println("Hello World");
		else
			System.out.println(A + B);

	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n),f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(all(a));
    sort(all(f));
    reverse(all(f));
    ll l=-1,r=1e12+5;
    while(r-l>1){
        ll c=0;
        ll mid=(l+r)/2;
        rep(i,n){
            if (a[i]*f[i]<=mid) continue;
            ll u=mid/f[i];
            c+=a[i]-u;
        }
        if (c<=k) r=mid;
        else l=mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 3328
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int d = scanner.nextInt();
			Pair kazuyuki = new Pair(b, a);
			Pair takayuki = new Pair(d, c);
			boolean[][] map = new boolean[h + 2][w + 2];
			for (int i = 1; i <= h; i++) {
				for (int j = 1; j <= w; j++) {
					map[i][j] = scanner.nextInt() == 0;
				}
			}
			/*PriorityQueue<Pair> pq = new PriorityQueue<Pair>();*/
			Deque<Pair> pq = new ArrayDeque<Pair>();
			int dis = dist(takayuki, kazuyuki);
			pq.add(new Pair(takayuki.y, takayuki.x, kazuyuki.y, kazuyuki.x, 0,
					dis));
			String ans = "NA";
			boolean[][][][] mem = new boolean[h + 2][w + 2][h + 2][w + 2];
			mem[takayuki.y][takayuki.x][kazuyuki.y][kazuyuki.x] = true;
			while (!pq.isEmpty()) {
				Pair pair = pq.poll();
				if (pair.y == pair.dy && pair.x == pair.dx) {
					ans = String.valueOf(pair.cost / 2);
					break;
				}

				for (int i = 0; i < 4; i++) {
					int nty = pair.y + move[i][0];
					int ntx = pair.x + move[i][1];
					int nky = pair.dy + move[i][2];
					int nkx = pair.dx + move[i][3];
					if (!map[nty][ntx]) {
						nty = pair.y;
						ntx = pair.x;
					}
					if (!map[nky][nkx]) {
						nky = pair.dy;
						nkx = pair.dx;
					}
					if (mem[nty][ntx][nky][nkx])
						continue;
					mem[nty][ntx][nky][nkx] = true;
					int newdis = dist(new Pair(nty, ntx), new Pair(nky, nkx));
					pq.offer(new Pair(nty, ntx, nky, nkx, pair.cost + 2,
							pair.cost + 2 + newdis));
				}
			}
			System.out.println(ans);
		}
	}

	int[][] move = { { -1, 0, 1, 0 }, { 0, -1, 0, 1 }, { 1, 0, -1, 0 },
			{ 0, 1, 0, -1 } };

	int dist(Pair a, Pair b) {
		return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
	}

	class Pair implements Comparable<Pair> {
		int y;
		int x;
		int dy;
		int dx;
		int cost;
		int md;

		public Pair(int y, int x, int dy, int dx, int cost, int md) {
			super();
			this.y = y;
			this.x = x;
			this.dy = dy;
			this.dx = dx;
			this.cost = cost;
			this.md = md;
		}

		public Pair(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		@Override
		public String toString() {
			return "Pair [y=" + y + ", x=" + x + ", dy=" + dy + ", dx=" + dx
					+ ", cost=" + cost + ", md=" + md + "]";
		}

		@Override
		public int compareTo(Pair o) {
			if (this.md == o.md)
				return this.cost - o.cost;
			return this.md - o.md;
		}

	}
}

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


int main() {
 int x;
 cin >> x;
 
 while(true) {
  bool a = true;
  for(int i = 2; i < x; i++) {
   if(x % i == 0) {
    a = false;
    break;
    }}
    if (a ==true) {
    break;
    }
    x++;
}
cout << x;
}

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

using namespace std;

const int N = 205;

char s[N];
long long A[N];

struct linarBase {
    long long c[64];
    bool insert(long long x) {
        for(int i = 60; ~i; --i) if(x >> i & 1) {
            if(!c[i]) {
                c[i] = x;
                return true;
            } else {
                x ^= c[i];
            }
        }
        return false;
    }
    void init() {
        for(int i = 0; i <= 60; ++i)
            c[i] = 0;
    }
} B;

int main() {
    int Case, n;
    scanf("%d", &Case);
    while(Case--) {
        B.init();
        scanf("%d", &n);
        for(int i = 1; i <= n; ++i)
            scanf("%lld", &A[i]);
        scanf("%s", s + 1);
        bool flag = true;
        for(int i = n; i >= 1; --i) {
            if(B.insert(A[i]) && s[i] == '1') {
                flag = false;
            }
        }
        puts(flag ? "0" : "1");
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<int> cnt(n + 1, 0);
    int now = - 1;
    int tmp = 0;
    for (int i = 0; i < n; i++){
        if (a[i] != now){
            now = a[i];
            tmp = 1;
        }
        else tmp++;
        cnt[tmp]++;
    }
    vector<int> acc(n + 1, 0);
    for (int i = 1; i <= n; i++) acc[i] = acc[i - 1] + cnt[i];
    for (int i = 1; i <= n; i++){
        int ok = 0;
        int ng = n + 1;
        while (abs(ok - ng) > 1){
            int mid = (ok + ng) / 2;
            if (acc[mid] >= (long long)mid * i) ok = mid;
            else ng = mid;
        }
        cout << ok << endl;
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int D;
  cin >> D;
  string ans;
  if(D == 25) ans = "Christmas";
  else if(D == 24) ans = "Christmas Eve";
  else if(D == 23) ans = "Christmas Eve Eve";
  else ans = "Christmas Eve Eve Eve";
  cout << ans << endl;
  return 0;
}

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


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


int main(){
	li d;
	
	while(cin>>d){
		li res=0;
		repp(i,1,600/d){
			res+=i*i*d*d;
			//p3(600/d,d,res);
		}
		cout<<res*d<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1156