akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	cin >> n;
	double t,a;
	cin >> t >> a;
	double ans=1e9;
	int index=0;
	for(int i=1;i<=n;i++){
		double h;
		cin >> h;
		if(ans>fabs(a-(t-h*0.006))){
			ans=fabs(a-(t-h*0.006));
			index=i;
		}
	}
	cout << index << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(void)
{
  ll n, k; cin >> n >> k;
  ll ans = 0;
  if(k == 1) {
    ans = 0;
  } else {
    ans = n - k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// :)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	int bal = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'S')
			bal++;
		else
		if (bal > 0) {
			bal--;
			n-=2;
		}
	}
	cout << n << "\n";
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int n; cin >> n;
  rep(i,100000){
    if(108*i/100 == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdlib>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;

bool cmpf(const P &l, const P &r)
{
    return l.first > r.first;
}

bool cmps(const P &l, const P &r)
{
    return l.second < r.second;
}

int main()
{
    int n, m;
    int x;
    P a[100010];
    cin >> n >> m;
    REP(i, m)
    {
        cin >> a[i].second >> a[i].first;
    }

    sort(a, a + m);

    x = -1;
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        //cout << a[i].first << " " << a[i].second << endl;
        if (a[i].second > x)
        {
            x = a[i].first - 1;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________
template <typename T = long long, const int sz = 5 * 10000000> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO<int> io;
int n, m, k,i;
constexpr int MAX = 1e9 + 1;
constexpr int N = 200010;
int a[N], b[N];
int nn,now,ans;
main() {
    n = io.read(), m = io.read(), k = io.read();
    nn = n;
    rep(i, n) {
        a[i + 1] = io.read() + a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while(*io.now && *io.now <= 32) io.now++;
                while('0' <= *io.now and *io.now <= '9') io.now++;
            }
            break;
        }
    }
    rep(i, m) {
        b[i + 1] = io.read() + b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = nn;
    ans = now;
    for(i = 1; i <= m; i++) {
        while(b[i] + a[now] > k) now--;
        ans = max(ans, i + now);
    }
    io.write(ans);
}


Measured memory_bytes: 7704
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
using namespace std;
int num(int a, int b, int c) {
	return abs(b - a) + abs(c - b);
}
signed main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		ans += tmp - 1;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
const int MAX_V = 1000000;
int main() {
    int i,k,v,c[MAX_V+1];
    int prime[MAX_V+1];
    for(i = 2; i < MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i < MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;
            }
        }
    }
     while(scanf("%d",&v)!=EOF){
        for(i=2;i<=v;i++){
            int isprime=prime[i];
            c[i+1]=c[i]+isprime;
        }
        printf("%d\n",c[v+1]);
    }
    return 0;
}

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

int main(){
    int a,b;
    char op;
    bool isValid = true;
    
    
    while(isValid){
        cin >> a >> op >> b;

        switch(op){
            case '+':
                cout << a + b << endl;
                break;
            case '-':
                cout << a - b << endl;
                break;
            case '*':
                cout << a * b << endl;
                break;
            case '%':
                cout << a % b << endl;
                break;
            case '/':
                cout << a / b << endl;
                break;
            default:
                isValid = false;
                break;
        }
    }
}


Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





ll f(ll n){
    ll res = 0;
    for(ll i = n - n % 4; i <= n; i++){
        res ^= i;
    }
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << (f(b) ^ f(a) ^ a) << endl;
}


Measured memory_bytes: 256
// frogs.cpp
#include<iostream>
#include<cstring>
using namespace std;

int main(){

int n;
cin >>n;
int arr[n];
for(int i=0;i<n;i++) cin>> arr[i];
int dp[n];
memset(dp,0,sizeof(dp));
dp[0] = 0;
int ans = 0;

// cout << dp[0] << " ";
for(int i = 1;i<n;i++){
	// cout << "i "<<i <<endl;
	if(i-2 >=0)
	dp[i] =  min(abs(arr[i-2]  - arr[i]) + dp[i-2] , abs(arr[i-1]  -arr[i]) + dp[i-1]);
	else{
		dp[i] = abs(arr[i-1] - arr[i]) + dp[i-1];
	}
	// ans +=dp[i];

	// cout << dp[i] << " ";
}
// cout << endl;

cout << dp[n-1]<< endl;



return 0;
}

Measured memory_bytes: 4380
N = int(input())
B = list(map(int, input().split(" ")))

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)


Measured memory_bytes: 38256
#include <iostream>
//#include <algorithm>
//#include <string>
#define ll long long
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll cuo=0;
    ll arr[101];
    for (ll i = 1; i <n+1 ; ++i) {
        cin>>arr[i];
    }
    for (ll i = 1; i <n+1 ; ++i) {
        if(arr[i]%2!=0&&i%2!=0){
            cuo++;
        }
    }
    cout<<cuo<<endl;
}

Measured memory_bytes: 3548
/* ex3_2 melo */
#include <stdio.h>
int main(void){
    int N, n;
    scanf("%d",&N);
    n = N%10;
    switch(n){
        case 2:case 4:case 5:case 7:case 9://2または4または5または7または9であった場合
        printf("hon\n");
        break;
        case 0:case 1:case 6:case 8://0,1,6,8のいずれかであった場合
        printf("pon\n");
        break;
        case 3:printf("bon\n");//3であった場合
        break;
        default:fprintf(stderr, "unexpected N value:%d¥n", N);return 1;//他の場合

    }
    return 0;
    

}

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

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i=0;i<ty-sy;i++) cout << 'U';
    for(int i=0;i<tx-sx;i++) cout << 'R';
    for(int i=0;i<ty-sy;i++) cout << 'D';
    for(int i=0;i<tx-sx;i++) cout << 'L';
    cout << 'L';
    for(int i=0;i<=ty-sy;i++) cout << 'U';
    for(int i=0;i<=tx-sx;i++) cout << 'R';
    cout << 'D';
    cout << 'R';
    for(int i=0;i<=ty-sy;i++) cout << 'D';
    for(int i=0;i<=tx-sx;i++) cout << 'L';
    cout << 'U';
    cout << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  if ((N - 1) * (N - 2) / 2 < K) {
    cout << "-1" << endl;
    return 0;
  }

  int M = N * (N - 1) / 2 - K;
  cout << M << endl;

  rep (i, N) REP (j, i + 1, N) {
    if (K > 0 && j + 1 != N) K--;
    else {
      cout << i + 1 << ' ' << j + 1 << endl;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n,k=0,m=0;
	cin>>n;	
	if(n<105)
	{cout<<0<<endl;;
	return 0;}
	else
	for(int i=1;i<=n;i=i+2)
	{k=0;
	for(int j=1;j<=i/2;j++)
		{if(k==7)
		{m++;
			break;}
		if(i%j==0)
		k++;}}
		cout<<m<<endl;
}

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

using namespace std;

int main(){
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        vector<int> k(n);
        for(int i=0;i<n;++i)cin>>k[i];
        string s;
        cin>>s;
        string ans="";
        int kc=0;
        for(auto c:s){
            if(kc>=n)kc=0;
            int lc=c-'a';
            int uc=c-'A';
            int tkc=k[kc];
            if(0<=lc&&lc<=25){//小文字
                if(tkc<=lc)ans+=(char)('a'+lc-tkc);
                else {
                    lc+=26;
                    if(tkc<=lc){
                        ans+=(char)('A'+lc-tkc);
                    }
                    else{
                        lc+=26;
                        ans+=(char)('a'+lc-tkc);
                    }
                }
            }
            else{//大文字
                if(tkc<=uc)ans+=(char)('A'+uc-tkc);
                else {
                    uc+=26;
                    if(tkc<=uc){
                        ans+=(char)('a'+uc-tkc);
                    }
                    else{
                        uc+=26;
                        ans+=(char)('A'+uc-tkc);
                    }
                }
            }
            ++kc;
        }
        for(auto i:ans)cout<<i;
        cout<<endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}

int main() {
  ll n, ans = 0;
  cin >> n;

  ans = modpow(10, n) - modpow(9, n) * 2;
  while (ans < 0) ans += mod;
  ans %= mod;
  ans += modpow(8, n);
  ans %= mod;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pair;

const int Nmax = 2e5 + 5;
const int inf = 2e9;

int n, ans, i, a[Nmax], d[Nmax];
int main()
{
 //   freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i];

    for(i=1; i<=n; ++i)
    {
        d[a[i]] = d[a[i]-1] + 1;
        ans = max(d[a[i]], ans);
    }

    cout << n - ans << '\n';
    return 0;
}


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

int N, a[105];

int main(void) {

	cin >> N;

	for (int i = 1; i <= N; i++) { cin >> a[i]; }

	long long int ans = 999999999;

	for (int k = -100; k <= 100; k++) {
		long long int sum = 0;
		for (int i = 1; i <= N; i++) {
			sum += (a[i] - k)*(a[i] - k);
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
s = input()

a = 0
for i in range(0,len(s)):
    if s[i] == 'A':
        a = i
        break

b = 0
for i in reversed(range(0, len(s))):
    if s[i] == 'Z':
        b = i
        break

print((b - a) + 1)

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

int main()
{
    int N;
    long step;
    cin >> N;
    vector<int> h(N);
    step = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> h.at(i);
    }
    for (int i = 0; i < N - 1; i++)
    {
        if (h.at(i) > h.at(i + 1))
        {
            step += h.at(i) - h.at(i + 1);
            h.at(i + 1) = h.at(i);
        }
    }
    cout << step << endl;
    return (0);
}


Measured memory_bytes: 4008
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

void sout(string* a, string* b) {
	if (*a > * b) {
		string c = *a;
		*a = *b;
		*b = c;
	}
}

int combination(int n, int k) {
	if (n > k && k > 0) {
		return (combination(n - 1, k) + combination(n - 1, k - 1));
	}
	else
		return 1;
}

template<class InputIterator, class UnaryPredicate>
bool all_of(InputIterator first, InputIterator last, UnaryPredicate pred) {
	while (first != last) {
		if (!pred(*first)) return false;
		++first;
	}
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(n);
	for (int i = 0; i < m; i++) {
		cin >> a.at(i) >> b.at(i);
		c.at(a.at(i) - 1)++;
		c.at(b.at(i) - 1)++;
	}
	for (int i = 0; i < n; i++) {
		cout << c.at(i) << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)

def gcd(a, b):
    if a == 0:
        return b
    else:
        return gcd(b % a, a)

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


a, b, c, d = map(int, input().split())
u = b - a + 1
x = b // c - (a - 1) // c
y = b // d - (a - 1) // d
xy = b // lcm(c, d) - (a - 1) // lcm(c, d)
ans = u - x - y + xy
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main()
{
  long N,K,a;
  scanf("%ld%ld",&N,&K);
  a = N-K;
  if (a<0)
    a *= -1;
  if (a >= N)
  {
    printf("%ld",N);
    return(0);
  }
  else if (N >= K)
  {
    N %= K;
    a = N - K;
    if (a < 0)
      a *= -1;
    if (a >= N)
    {
      printf("%ld",N);
      return(0);
    }
    else
    {
      printf("%ld",a);
      return (0);
    }
  }
  else
  {
    N = K - N;
    N %= K;
    //printf("%d",N);
    //printf("%d",K);
    a = N-K;
    if (a < 0)
      a *= -1;
    if (a >= N)
    {
      printf("%ld",N);
      return(0);
    }
    else
    {
      printf("%ld",a);
      return (0);
    }
  }
}

Measured memory_bytes: 128
max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def solve(R,C,rcv):

    rows = [list() for _ in range(R)]
    for r,c,v in rcv:
        rows[r-1].append((c-1,v))

    dp = [0]*C

    for row in rows:
        row.sort()
        row.append((C,0))
        ri = 0
        c,v = row[ri]

        t1 = 0
        t2 = 0
        t3 = 0
        for j in range(C):
            if c == j:
                t3 = max2(t2+v,t3)
                t2 = max2(t1+v,t2)
                t1 = max2(dp[j]+v,t1)
                ri += 1
                c,v = row[ri]
            
            dp[j] = max(t3,t2,t1,dp[j])

    return dp[-1]




if __name__ == '__main__':
    R,C,K = map(int,readline().split())
    m = map(int,read().split())
    print(solve(R,C,zip(m,m,m)))

Measured memory_bytes: 119996
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b;
  cin >> a >> b;
  cout << a-b+1 << endl;
}


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

int main(){
    long long int a,b,c,d,e,f,g,h,i;
    cin >> a >> b >> c >>d;
    e = a * c;
    f = a * d;
    g = b * c;
    h = b * d;
    vector<long long int> kusa(4);
    kusa.at(0) = e;
    kusa.at(1) = f;
    kusa.at(2) = g;
    kusa.at(3) = h;
    sort(kusa.begin(),kusa.end());
    cout << kusa.at(3);
    
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    double R;
    cin>>R;
    cout << setprecision(10) <<  R * 2 * 3.141592 << endl;
}

Measured memory_bytes: 3788
#include<stdio.h>
int main()
{
  int N;
  scanf("%d",&N);
  int flag=0;
  if(N%10==7){
    flag=1;
  }
  else{
    N=N/10;
    if(N%10==7){
      flag=1;
    }
    else{
      N=N/10;
      if(N%10==7){
        flag=1;
      }
    }
  }
  if(flag==1){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int a[3];cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES";
	else cout<<"NO";
}


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

int N;
long long ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    int left = 0;
    for (int i = 0; i < N; i++)  {
        int x;
        cin >> x;
        if (left && x) {
            ans ++;
            x --;
        }
        ans += x / 2;
        left = x % 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    rep(i,N) {
        ll temp = a[i];
        reps(j, i + 1, N) {
            temp += a[j];
            a.push_back(temp);
        }
    }
    vector<vector<bool> > can_use(2, vector<bool>(N * (N + 1) / 2, true));
    ll ans = 0;
    Rrep(i,41){
        ll num = 0;
        rep(j, N * (N + 1) / 2){
            if(can_use[0][j] && (a[j]>>i)&1){
                ++num;
                can_use[1][j] = true;
            }else{
                can_use[1][j] = false;
            }
        }
        if(num >= K){
            swap(can_use[0], can_use[1]);
            ans += (1LL<<i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6316
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            var res = new int[s.Length];
            for(var i = 0; i < s.Length; i++)
            {
                res[i] = s[i]=='a' ? 0 : 'z' - s[i] + 1;
            }

            var ans = new StringBuilder();
            for (var i = 0; i < s.Length - 1; i++)
            {
                if (res[i] <= K)
                {
                    ans.Append('a');
                    K -= res[i];
                }
                else
                {
                    ans.Append(s[i]);
                }
            }

            if (res[s.Length - 1] <= K)
            {
                int r = (K - res[s.Length - 1]) % 26;
                char a = (char)('a' + r);
                ans.Append(a);
            }
            else
            {
                char a = (char)(s[s.Length - 1] + K);
                ans.Append(a);
            }


            Console.WriteLine(ans);

           
            

            //Console.Out.Flush();

        }
    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 12384
S = input()
T = input()
m = len(T)
for i in range(len(S)-len(T)+1):
    s = S[i:len(T)+i]
    d = 0
    for j in range(len(T)):
        if s[j] != T[j]:
            d += 1
    m = min(m, d)
print(m)


Measured memory_bytes: 67648
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
from itertools import permutations
X = permutations(list(range(1, N+1)))
for i, x in enumerate(X):
    x = list(x)
    if x == P:
        p = i
    if x == Q:
        q = i
print(abs(p-q))



Measured memory_bytes: 40300
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  for( i=1; i<=n; i++ ) {
    if( i%3==0 ) {
    	printf(" %d",i);
    } else if ( i%10==3 ) {
    	printf(" %d",i);
    } else if ( i%100>=30 && i%100<40 ) {
    	printf(" %d",i);
    } else if ( i%1000>=300 && i%1000<400 ) {
    	printf(" %d",i);
    } else if ( i%10000>=3000 && i%10000<4000 ) {
    	printf(" %d",i);
    }
  }
  printf("\n");
  return(0);
}

Measured memory_bytes: 600
import java.util.Scanner;
class Main{
    Scanner sc = new Scanner(System.in);
	
	int a;
	int b;
	int c;
	
	void bc2(){
		a = sc.nextInt();
	    b = sc.nextInt();
		c = sc.nextInt();
		
		if(a<b && b<c && a<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

	public static void main(String[]agrs){
			new Main().bc2();
	}
}

Measured memory_bytes: 17156
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    switch (n % 10)
    {
    case 3:
        printf("bon\n");
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        printf("pon\n");
        break;
    default:
        printf("hon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 2056
package main

import "fmt"

func main() {
  var A, B int
  fmt.Scan(&A, &B)
  
  if A >= 13 {
    fmt.Println(B)
  } else if 6 <= A && A <= 12 {
    fmt.Println(B / 2)
  } else {
    fmt.Println(0)
  }
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){

  int a, b, c, tmp;
  scanf("%d%d%d",&a,&b,&c);
  if ( b > c ){
  tmp = b; b = c; c = tmp;
  }

  if (a > b){
  tmp = a; a = b;  b = tmp;
  }

  if (b > c){
  tmp = b; b = c; c = tmp;
  }

    printf("%d %d %d\n", a, b, c);
 

 
  
  
  return 0;
}



Measured memory_bytes: 2100
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0

z=a[0]+a[1]-x
if z>0:
  ans+=z
  a[1]-=z
  if a[1]<0:
    a[0]-=abs(a[1])
    a[1]=0

for i in range(n-1):
  z=a[i]+a[i+1]-x
  if z>0:
    ans+=z
    a[i+1]-=z
    if a[i+1]<0:
      a[i]-=abs(a[i+1])
      a[i+1]=0

print(ans)

Measured memory_bytes: 85476
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	int A, B, M;
	cin >> A >> B >> M;
	
	vector<int> a(A);
	rep(i, A) cin >> a[i];

	vector<int> b(B);
	rep(i, B) cin >> b[i];

	vector<int> x(M);
	vector<int> y(M);
	vector<int> c(M);

	rep(i, M) cin >> x[i] >> y[i] >> c[i];

	int sum = *min_element(all(a)) + *min_element(all(b));

	rep(i, M)
	{
		sum = min(sum, a[x[i] - 1] + b[y[i] - 1] - c[i]);
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int j=0;j<n;j++){
		int dat[4];
		cin>>dat[0]>>dat[1]>>dat[2];
		for(int i=0;i<3;i++){
			if(dat[i]*dat[i]==dat[0]*dat[0]+dat[1]*dat[1]+dat[2]*dat[2]-dat[i]*dat[i]){
				cout<<"YES"<<endl;
				i=4;
			}
			if(i==2){
				cout<<"NO"<<endl;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int base = 400;
    int answer =8;
    for(int g=0;g<8;g++)
    {
        base = base + 200; 
        if(n<base)
        {
            break;
        }
        answer --;
    }
    cout<<answer<<endl;
    //system("PAUSE");



}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
using namespace std;
typedef long long ll;



int main() {
	ll n,m,a,ans=0,sum=0;
	map<ll, ll> mp;
	cin >> n>>m;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += a;
		sum = sum % m;
//		cout << sum << endl;
		mp[sum]++;
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
	//	cout << itr->first << " " << itr->second << endl;
		ans += itr->second*(itr->second -1) / 2;
	}
	cout << ans+mp[0];
	return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define vint vector<int>


int main(){
	int x,t;
	cin >> x >>t;
	
	cout << max(0,x-t) << endl;
	
	return 0;
}

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

int main()
{
	int K, S;
	cin >> K >> S;
	int cont = 0;

	for (int X = 0; X <= K; X++)
	{
		
		for (int Y = 0; Y <= K; Y++)
		{
			
				int Z = S - X - Y;

				if (Z >= 0 && Z <= K)
					cont++;
			
		}
		
	}
	cout << cont;

	return 0;
}

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

char s[200001];

using namespace std;

int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  if (d < c) {
    bool flg = false;
    for (int i = a - 1; i < b - 1; i++) {
      if (s[i] == '#' && s[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
    for (int i = b - 2; i < d - 1; i++) {
      if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
        flg = true;
      }
      if (s[i] == '#' && s[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
    for (int i = d - 2; i < c - 2; i++) {
      if (s[i] == '#' && s[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
    if (flg) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  } else {
    for (int i = a - 1; i < c - 1; i++) {
      if (s[i] == '#' && s[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
    for (int i = b - 1; i < d - 1; i++) {
      if (s[i] == '#' && s[i + 1] == '#') {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
    return 0;
  }
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;cin >> n;
  vector<int> hoge(n);
  rep_i(i, n){
    cin >> hoge[i];
  }

  int ans;
  int tmp;
  rep_i(i, n){
    if(hoge[i] == i + 1){
      if(i == 0){
        tmp = hoge[i];
        hoge[i] = hoge[i+1];
        hoge[i + 1] = tmp;
      }else if(i == n - 1){
        tmp = hoge[i];
        hoge[i] = hoge[i - 1];
        hoge[i - 1] = tmp;
      }else{
        tmp = hoge[i];
        hoge[i] = hoge[i+1];
        hoge[i + 1] = tmp;
      }
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  string S;
  int K;
  cin>>S>>K;
  int N=S.size();
  vector<string> p;
  for(int i=1;i<=K;i++){
    for(int j=0;j<=N-i;j++){
      string a=S.substr(j,i);
      p.push_back(a);
    }
  }
  sort(p.begin(), p.end());
  int a=0;
  K--;
  while(K>0){
    if(p.at(a)!=p.at(a+1)){
      K--;
    }
    a++;
  }
  cout<<p.at(a)<<endl;

}




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

using namespace std;

int main()
{
  int n; cin >> n;
  char str[1000][110];
  int size[1000];

  for (int i = 0;i<n;i++)
  {
    cin >> str[i];
    size[i] = strlen(str[i]) - 1;
  }

  for (int i = 0; i < n-1; i++)
  {
    for (int k = i+1; k < n;k++)
    {
      if (strcmp(str[i] , str[k]) == 0)
      {
        cout << "No" << endl; 
        return 0;
      }
    }
  }

  for (int i = 1;i<n;i++)
  {
    if (str[i][0] != str[i-1][size[i-1]])
    {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	map<ll, int> ct;
	ll off = 0;
	ll ans = 0;
	int i, n;
	cin >> n;
	vector<ll> a(n);
	for(i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(i = n - 1; i >= 0; i--) {
		if(a[i] == 0) {
			ans++;
		}
		ans += ct[-a[i] - off];
		off += a[i];
		ct[a[i] - off]++;
		
	}
	cout << ans << '\n';
	return 0;	
}


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

int main()
{
    long long int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    long long int max=a[0];
    long long int dai=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]<max)
        {
            dai =dai + (max-a[i]);
        }
        else
        {
          max =a[i];
        }
        
    }
    cout<<dai;
    return 0;
}

Measured memory_bytes: 5124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

vector <int> E[100010];
int d[100010];

void dfs(int x, int fa = -1) {
	d[x] = 0;
	for(int e : E[x]) if(e != fa) {
		dfs(e, x);
		d[x] ^= (d[e] + 1);
	}
}

void solve(){
	int n; scanf("%d", &n);
	rep(i, n-1){
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y); E[y].pb(x);
	}
	dfs(1);
	puts(d[1] ? "Alice" : "Bob");
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
};


Measured memory_bytes: 12416
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    long n;
    cin >> n;
    long b,f,r,v;
    long x[4][3][10]={};
    F(i,0,n){
        cin >> b >> f >> r >> v;
        x[b-1][f-1][r-1]+=v;
    }
    F(i,0,4){
        F(j,0,3){
            F(k,0,10){
                cout << ' ' << x[i][j][k];
            }
            cout << endl;
        }
        if(i!=3){
            F(j,0,20) cout << '#';
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{ int kk,cnt=0,r=0;
 cin>>kk;
 string s;
 cin>>s;
 for(auto &i:s) { if(i=='R') r++;}
 for(int i=0;i<r;i++)
 { if(s[i]=='W') cnt++;
 }
 cout<<cnt;
   
 
 
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
bool solve() {
  long x1, v1, x2, v2; cin >> x1 >> v1 >> x2 >> v2;
  if (v1 <= v2) return false;
  long X = abs(x1 - x2);
  long V = v1 - v2;
  long T; cin >> T;
  return X <= V * T;
}
int main() {
  if (solve()) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(2,n):
    if max(p[i-2:i+1]) != p[i-1] and min(p[i-2:i+1]) != p[i-1]:
        count += 1
print(count)


Measured memory_bytes: 9160
#include <iostream>
using namespace std;
int main(void)
{
	int a,b;
	cin >> a >> b;
	if(a>b){
		cout << "a > b" << endl;
	}
	else if(a==b){
		cout << "a == b" << endl;
	}
	else{
		cout << "a < b" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 2 * b)
    {
        cout << "0" << endl;
        return 0;
    }
    cout << a - 2 * b << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), hyo(N+1, 1);
  REP(i, M){
    cin >> a[i] >> b[i];
    if(a[i] == 1){
      hyo[b[i]]*=2;
    }
    else if(b[i] == N){
      hyo[a[i]]*=3;
    }
  }
  REP(i, N){
    if(hyo[i+1] % 6 == 0){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

  return 0;
}

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

char S[200009];
char t[200009], d[200009];

int main() {
    int N, Q; scanf("%d%d",&N,&Q);
    scanf(" %s", S+1); S[0] = '0'; S[N+1] = '9';
    for(int i=0; i<Q; i++) scanf(" %c %c", &t[i], &d[i]);
    int l = 1, r = N, lf = N+1, rf = 0;
    while(l <= r) {
        int m = l+r >> 1;
        int now = m;
        for(int i=0; i<Q; i++) if(S[now] == t[i]) {
            if(d[i] == 'L') --now;
            if(d[i] == 'R') ++now;
        }
        if(S[now] == '0') l = m+1;
        else r = m-1, lf = m;
    }
    l = 1, r = N;
    while(l <= r) {
        int m = l+r >> 1;
        int now = m;
        for(int i=0; i<Q; i++) if(S[now] == t[i]) {
            if(d[i] == 'L') --now;
            if(d[i] == 'R') ++now;
        }
        if(S[now] == '9') r = m-1;
        else l = m+1, rf = m;
    }
    if(rf - lf + 1 <= 0) return !printf("0");
    else printf("%d", rf - lf + 1);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; long long k; cin >> n >> k;
	vector<int> a(n), f(n);
	for(int & v : a) cin >> v;
	for(int & v : f) cin >> v;
	sort(a.rbegin(), a.rend());
	sort(f.begin(), f.end());
	long long lo = 0, hi = (long long)1e12 + 100, ans = hi;
	while(lo <= hi){
		long long mid = (lo + hi)>>1;
		long long cons = 0;
		for(int i = 0; i < n; i++){
			long long up = mid / f[i];
			cons += max(0ll, a[i] - up);
		}
		if(cons <= k) ans = mid, hi = mid - 1;
		else lo = mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }

/**
 * @arg g is a digraph with possibly negative cost edges
 * @note LLONG_MIN for negative loops
 * @note LLONG_MAX for unreachable nodes
 */
vector<ll> bellman_ford_longest_path(int root, vector<vector<pair<int, ll> > > const & g) {
    int n = g.size();
    vector<ll> dist(n, LLONG_MAX);
    dist[root] = 0;
    REP (iteration, n - 1) {
        REP (i, n) if (dist[i] != LLONG_MAX) {
            for (auto edge : g[i]) {
                int j; ll cost; tie(j, cost) = edge;
                chmin(dist[j], dist[i] + cost);
            }
        }
    }
    REP (iteration, n - 1) {
        REP (i, n) if (dist[i] != LLONG_MAX) {
            for (auto edge : g[i]) {
                int j; ll cost; tie(j, cost) = edge;
                if (dist[i] == LLONG_MIN or dist[i] + cost < dist[j]) {
                    dist[j] = LLONG_MIN;
                }
            }
        }
    }
    return dist;
}

ll solve(int n, int m, ll p, vector<vector<pair<int, ll> > > & g) {
    REP (i, n) {
        for (auto & e : g[i]) {
            e.second = p - e.second;
        }
    }
    ll dist = bellman_ford_longest_path(0, g)[n - 1];
    if (dist == LLONG_MIN) return -1;
    return max(0ll, - dist);
}

int main() {
    int n, m; ll p; cin >> n >> m >> p;
    vector<vector<pair<int, ll> > > g(n);
    REP (i, m) {
        int a, b; ll c; cin >> a >> b >> c;
        -- a;
        -- b;
        g[a].emplace_back(b, c);
    }
    cout << solve(n, m, p, g) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-8;
const int MAX=5e5+10;
const ll mod=1e9+7;
int main()
{
	int i,a;
	char b[111];
	map<int,int> mp;
	for(i=0;i*i<=100100;i++) mp[i*i]=1;
	while(~scanf("%d%s",&a,b))
	{
		for(i=0;i<strlen(b);i++)
		{
			a*=10;
			a+=b[i]-'0';
		}
		if(mp[a]) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

char A[105];
bitset<105> chk;

int N, Ans;

int main() {
	scanf(" %s", A+1);
	N = strlen(A+1);
	Ans = N;

	for(int z = 'a', t; z <= 'z'; z++) {
		chk.reset(); t = 0;
		for(int i = 1; i <= N; i++)
			chk[i] = A[i] == z;
		for(int l = N; l; l--, t++) {
			bool flag = false;
			for(int i = 1; i <= l; i++)
				flag |= !chk[i];
			if(!flag) break;

			for(int i = 1; i < l; i++)
				chk[i] = chk[i] | chk[i+1];
		}
		if(t < Ans) Ans = t;
	}

	cout << Ans << endl;
	return 0;
}

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

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    int main(){
      int n;
      ll MOD = INF+7;
      cin>>n;
      VEC(int,a,n);
      sort(a.begin(),a.end());
      bool f = true;

      if(n%2 == 1){
        if(a[0] != 0)f = false;
        REP(i,1,n-1){
          int key = (i/2+i%2)*2;
          if(a[i] != key)f = false;
        }
        if(f){
          int ans = 1;
          rep(i,(n-1)/2)ans =ans*2%MOD;
          cout<<ans;
        }
        else cout<<0;
        return 0;
      }
      else{
        rep(i,n){
          int key = i/2+i/2+1;
          if(a[i] != key)f = false;
        }
        if(f){
          int ans = 1;
          rep(i,n/2){
            ans = ans*2%MOD;
          }
          cout<<ans;
        }
        else cout<<0;
        return 0;
      }
    }


Measured memory_bytes: 640
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

//ABC129_A
fun func() {
    val N = nextInt()
    val W = listOfInt()
    val sum = W.sum()!!
    var left = 0
    var ans = Int.MAX_VALUE
    for (n in 0 until N) {
        left += W[n]
        ans = Math.min(ans, Math.abs(left - (sum - left)))
    }
    println("${ans}")
}

fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 37696
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int ret1 = 0;
    int ret2 = 0;

    for(;;){
        int x, y, z;
        char c;
        if(!(cin >> x >> c >> y >> c >> z))
            break;
        if(x * x + y * y == z * z)
            ++ ret1;
        else if(x == y)
            ++ ret2;
    }

    cout << ret1 << endl << ret2 << endl;
}

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

ll MOD = 1e9 + 7;

ll powMod(ll x, ll k) {
  if (k == 0) return 1;
  if (k % 2 == 0)
    return powMod(x * x % MOD, k / 2);
  else
    return x * powMod(x, k - 1) % MOD;
}

ll p[100010];

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

  ll ret = 0;
  for (ll i = K; i >= 1; i--) {
    ll pm = powMod(K / i, N);
    for (ll j = 2; j * i <= K; j++) {
      pm = (pm + MOD - p[i * j]) % MOD;
    }
    ret = (ret + MOD + i * pm % MOD) % MOD;
    p[i] = pm;
  }
  cout << ret << endl;
}


Measured memory_bytes: 4360