akhauriyash/Code-Regression huggingface dataset:
#pragma region // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion // }}}

void main() {
    int w,h;
    R(h,w);
    vector<LL> p(h), q(w);
    REP(i,h) R(p[i]);
    REP(i,w) R(q[i]);
    sort(RALL(p));
    sort(RALL(q));
    h++; w++;
    LL ans=0, tot=(LL)h*w-1;
    while ( tot ) {
        if ( SZ(q)==0 || (SZ(p) && p.back()<q.back()) ) {
            LL x=p.back();
            p.pop_back();
            ans+=x*w;
            tot-=w;
            h--;
        } else {
            LL x=q.back();
            q.pop_back();
            ans+=x*h;
            tot-=h;
            w--;
        }
    }
    W(ans);
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}


Measured memory_bytes: 4880
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int[] b = new int[a];
		int[] d = new int[a];
		long ans = 1;
		int judge=0;
		b[0]=0;
		for(int i = 0 ; i < a; i++){
			d[i] = sc.nextInt();
			b[d[i]]++;
			if(b[d[i]]==2 && d[i]!=0){
					judge++;
				}
		}
		if((a/2!=judge) || (a%2==1 && b[0]==0)){
			System.out.println(0);
			return;
		}
			for(int i = 0; i < a; i++){
				
				ans*=b[d[i]];
				ans%=1000000007;
				b[d[i]]--;
			}
		System.out.println(ans);
	}
}

Measured memory_bytes: 60648
#include <iostream>

using namespace std;

int main(){
int a;
cin>>a;
int v[109]={};
v[0]=1;
for(int i=0;i<=100;i++){
v[i+4]|=v[i];
v[i+7]|=v[i];
}
if(v[a])cout<<"Yes\n";
else cout<<"No\n";
}

Measured memory_bytes: 256
def lower_bound(l, r, val):
    while r - l > 1:
        mid = (r + l) // 2
        if sum[mid] <= val:
            l = mid
        else:
            r = mid
    return l


def get_sum(l, r):
    return sum[r] - (0 if l == 0 else sum[l - 1])


def search(l, r):
    mid = lower_bound(l, r + 1, get_sum(l, r) / 2 + (0 if l == 0 else sum[l - 1]))
    for i in range(mid - 2, mid + 3):
        if l <= i and i + 1 <= r:
            yield get_sum(l, i), get_sum(i + 1, r)


N = int(input())
A = list(map(int, input().split()))

tmp = 0
sum = [0 for i in range(N)]

for a, b in enumerate(A):
    tmp += b
    sum[a] = tmp

ans = tmp

for ind in range(1, N - 2):
    for l1, r1 in search(0, ind):
        for l2, r2 in search(ind + 1, N - 1):
            t = l1, r1, l2, r2
            ans = min(ans, max(t) - min(t))

print(ans)


Measured memory_bytes: 90232
//Priyanshu Kumar : IIIT Allahabad
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define sz size()
#define ln length()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) printf("%d",n)
#define pin(n) printf("%d\n",n);
#define pl(n) printf("%lld",n)
#define pln(n) printf("%lld\n",n);
inline ll gcd(ll x,ll y){return x%y==0?y:gcd(y,x%y);}
inline ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
inline ll powmod(ll a,ll b,ll mod) 
{
	ll res=1;
	a%=mod; 
	assert(b>=0); 
	for(;b;b>>=1)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
	}
	return res;
}
inline ll mulmod(ll a, ll b, ll c)
{
	if(!b)return 0;
	ll x = mulmod(a, b/2, c);
	if (b & 1)return (x+x+a)%c;
	return (x+x)%c;
}

int main()
{
    deque <int> q;
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ind;
    if(n%2 == 0)
    {
        q.pb(a[0]);
        q.push_front(a[1]);
        ind = 2;
    }
    else
    {
        q.pb(a[0]);
        ind = 1;
    }
    for(int i=ind;i<n;i+=2)
    {
        q.pb(a[i]);
        if((i+1) < n)
            q.push_front(a[i+1]);
    }
    deque <int>::iterator it;
    for(it = q.begin();it!=q.end();++it)
    {
        cout<<*it<<" ";
    }
    cout<<endl;
	return 0;
}


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

int main() {
    ll N,A,r=0;
    cin >> N;
    vector<ll> t(N);
    rep(i,N) {
        cin >> A;
        t.at(i) = A-(i+1);
    }
    sort(t.begin(), t.end());

    if(N%2)
        rep(i,N)
            r += abs(t.at(i)-t.at(N/2));
    else {
        ll r1,r2;
        rep(i,N) {
            r1 += abs(t.at(i)-t.at(N/2-1));
            r2 += abs(t.at(i)-t.at(N/2));
        }
        r = min(r1,r2);
    }

    cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;

int toM(string t) {
	int h = atoi(t.substr(0, 2).c_str());
	int m = atoi(t.substr(3, 2).c_str());
	return h * 60 + m;
}

struct Data {
	string day;
	int m;
	char c;
	string name;
};

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

	int n;
	while(cin >> n, n) {
		map<string, vector<Data> > D;
		for(int i = 0; i < n; i++) {
			string d, m, name;
			char c;
			cin >> d >> m >> c >> name;
			Data data = Data{ d, toM(m), c, name };
			D[d].push_back(data);
		}

		map<string, int> sum;
		for(auto& p : D) {
			map<string, vector<int> > in, out;
			for(Data& data : p.second) {
				if(data.c == 'I') {
					in[data.name].push_back(data.m);
				}
				else {
					out[data.name].push_back(data.m);
				}
			}

			vector<int> gin = in["000"], gout = out["000"];
			for(auto& a : in) {
				string name = a.first;
				if(name == "000") continue;
				for(int i = 0; i < a.second.size(); i++) {
					for(int j = 0; j < gin.size(); j++) {
						int l = max(in[name][i], gin[j]);
						int r = min(out[name][i], gout[j]);
						sum[name] += max(0, r - l);
					}
				}
			}
		}

		int ans = 0;
		for(auto& p : sum) {
			ans = max(ans, p.second);
		}

		cout << ans << endl;
	}
}

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

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

int main() {
    int N=0;
    cin >> N;

    vector<ll> h(100010);
    rep(i, N) cin >> h.at(i);

    vector<ll> dp(100010, INF);

    dp.at(0) = 0;
    rep(i, N){
        if(i >= 1) chmin(dp.at(i), dp.at(i-1) + (ll)abs(h.at(i) - h.at(i-1)));
        if(i >= 2) chmin(dp.at(i), dp.at(i-2) + (ll)abs(h.at(i) - h.at(i-2)));
    }

    cout << dp.at(N-1) << endl;

}




Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{

    int W,H,x,y,r;


    public void input(){
	Scanner scan = new Scanner(System.in);
	W = scan.nextInt();
	H = scan.nextInt();
	x = scan.nextInt();
	y = scan.nextInt(); 
	r = scan.nextInt();



    }
    public void output(){
 
	if((x - r)< 0  || (x + r)> W){
	    System.out.println("No");
	} else if((y + r)< 0 || (y + r)> H){
	    System.out.println("No");
	} else{
	    System.out.println("Yes");       
	}
      



    }
    public static void main(String[] args){
	Main  p = new Main();
	p.input();
	p.output();
    }
}
 

Measured memory_bytes: 26344
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    ll K,N;
    cin >> K >> N;
    vector<ll> a(N);
    rep(i,N){
        cin >> a.at(i);
        }
    ll m=0;
    rep(i,N-1){
        ll b=a.at(i+1)-a.at(i);
        if(b>=m){
            m=b;
        }
    }
    ll c=K-a.at(N-1)+a.at(0);
    if(c>=m){
        m=c;
    }

    cout << K-m << endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

template <typename T>
T my_pow_with_mod(T x, int a, T mod = 1e9 + 7)
{
    ll ans = 1;
    ll b = x;
    int status = 1;
    while (status)
    {
        if (a & 1)
            ans *= b;
            ans %= mod; 
        a = a >> 1;
        b = b * b;
        b %= mod;
        if (a == 0)
            status = 0;
    }
    return ans;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int m, n;
    cin >> m >> n;
    cout << my_pow_with_mod(m, n) << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int cst[3];
    cin >> cst[0] >> cst[1] >> cst[2];
    sort(cst, cst+3);
    cout << cst[0] + cst[1] << "\n";
    return 0;
}

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

int main(){
    int n;
    long long int c;
    cin >> n >> c;
    long long int x[n];
    int v[n];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> v[i];
    }
    long long int maxt[n], maxh[n], maxt2[n], maxh2[n];
    long long int sum;
    long long int sushisumt[n], sushisumh[n];
    for(int i = 0; i < n; i++){
        if(i == 0) sushisumt[i] = v[i];
        else sushisumt[i] = sushisumt[i-1] + v[i];
        sum = sushisumt[i] - x[i];
        if(i == 0){
            if(sum >= 0) maxt[i] = sum;
            else maxt[i] = 0;
        }
        else{
            if(maxt[i-1] < sum) maxt[i] = sum;
            else maxt[i] = maxt[i-1];
        }
        sum = sushisumt[i] - 2*x[i];
        if(i == 0){
            if(sum >= 0) maxt2[i] = sum;
            else maxt2[i] = 0;
        }
        else{
            if(maxt2[i-1] < sum) maxt2[i] = sum;
            else maxt2[i] = maxt2[i-1];
        }
    }
    for(int i = n-1; i >= 0; i--){
        if(i == n-1) sushisumh[i] = v[i];
        else sushisumh[i] = sushisumh[i+1] + v[i];
        sum = sushisumh[i] - (c - x[i]);
        if(i == n-1){
            if(sum >= 0) maxh[i] = sum;
            else maxh[i] = 0;
        }
        else{
            if(maxh[i+1] < sum) maxh[i] = sum;
            else maxh[i] = maxh[i+1];
        }
        sum = sushisumh[i] - 2*(c - x[i]);
        if(i == n-1){
            if(sum >= 0) maxh2[i] = sum;
            else maxh2[i] = 0;
        }
        else{
            if(maxh2[i+1] < sum) maxh2[i] = sum;
            else maxh2[i] = maxh2[i+1];
        }
    }
    long long int max = 0;
    long long int t;
    for(int i = 0; i < n; i++){
        if(i == n-1) t = maxt[i];
        else t = maxt[i] + maxh2[i+1];
        if(t > max) max = t;
    }
    for(int i = 0; i < n; i++){
        if(i == 0) t = maxh[i];
        else t = maxh[i] + maxt2[i-1];
        if(t > max) max = t;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n;
 sc(n);
 ll cnt=2*(n/11);
 n%=11;
 if(n>6)cnt++;
 if(n>0)cnt++;
 pr(cnt);
return 0;}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const long long mod = 1000000007;

int N, K;

long long P(int n, int k) {
    long long ret = 1;
    for (int i=n; i>n-k; --i) {
        ret = (ret * i) % mod;
    }
    return ret;
}

long long dfs(vector<vector<int>> &to, int u, int prev) {
    long long ans;
    if (prev == -1) {
        ans = P(K-1, (int)to[u].size());
    } else {
        ans = P(K-2, (int)to[u].size()-1);
    }
    for (int v: to[u]) {
        if (v == prev) continue;
        ans *= dfs(to, v, u);
        ans %= mod;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    cin >> N >> K;

    vector<vector<int>> to(N);
    for (int i=0; i<N-1; ++i) {
        int a, b;
        cin >> a >> b;
        to[a-1].push_back(b-1);
        to[b-1].push_back(a-1);
    }

    cout << (K * dfs(to, 0, -1)) % mod << endl;

    return 0;
}

Measured memory_bytes: 11648
#include <stdio.h>

int main(void){
  int i, N;
  int cnt_ac = 0;
  int cnt_wa = 0;
  int cnt_tle = 0;
  int cnt_re = 0;
  char S[3];

  scanf("%d", &N);
  for( i = 0; i < N; i++ ){
    scanf("%s", S);
    if( strncmp(S, "AC", 2) == 0){
      cnt_ac++;
    }
    if( strncmp(S, "WA", 2) == 0){
      cnt_wa++;
    }
    if( strncmp(S, "TLE", 3) == 0){
      cnt_tle++;
    }
    if( strncmp(S, "RE", 2) == 0){
      cnt_re++;
    }
  }

  printf("AC x %d\n", cnt_ac);
  printf("WA x %d\n", cnt_wa);
  printf("TLE x %d\n", cnt_tle);
  printf("RE x %d\n", cnt_re);

return 0;

}


Measured memory_bytes: 1732
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }


int main() {
	int a[110]; minit(a, 0);
	int in, maxl = 0;
	while (cin>>in) { a[in]++; maxl = max(maxl, a[in]); }
	for_(i, 0, 110) if (a[i]==maxl) cout << i << endl;
	return 0;
}

Measured memory_bytes: 1164
package main

import (
        "bufio"
        "fmt"
        "os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
        defer writer.Flush()

        var x, ans int64
        ans = 0
        scanf("%d", &x)

        if x >= 11 {
                p := (x / 11) * 2
                x -= 11 * (p / 2)
                ans += p
        }
        if x >= 7 {
                ans += 2
        } else if x > 0 {
                ans += 1
        }
        printf("%d\n", ans)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;


int wlim = 100010;

void push(vector<P>& res, const P& p) {
    if (res.size() == 0 || p.second > res[(int)res.size() - 1].second) {
        res.push_back(p);
    }
}

vector<P> update(const vector<P>& lis, int v, int w) {
    int sz = lis.size();
    int p1 = 0, p2 = 0;
    vector<P> res;
    while (p1 < sz || p2 < sz) {
        if (p2 == sz) {
            push(res, lis[p1]);
            ++p1;
        }
        else if (p1 == sz) {
            if (lis[p2].first + w >= wlim) break;
            push(res, { lis[p2].first + w, lis[p2].second + v });
            ++p2;
        }
        else {
            if (lis[p1].first < lis[p2].first + w) {
                push(res, lis[p1]);
                ++p1;
            }
            else if (lis[p1].first > lis[p2].first + w) {
                push(res, { lis[p2].first + w, lis[p2].second + v });
                ++p2;
            }
            else {
                push(res, { lis[p1].first, max(lis[p1].second, lis[p2].second + v) });
                ++p1;
                ++p2;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> v(n), w(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i] >> w[i];
    }
    int q;
    cin >> q;
    vector<vector<P>> que(n, vector<P>());
    for (int i = 0; i < q; ++i) {
        int u, l;
        cin >> u >> l;
        --u;
        que[u].push_back({ l, i });
    }
    int lm = 1 << 12;
    vector<vector<P>> vs(lm);
    vs[0] = { { 0, 0 } };
    vector<int> ans(q);
    for (int i = 0; i < n; ++i) {
        if (i < lm) {
            vs[i] = update(vs[(i - 1) / 2], v[i], w[i]);
            for (auto& p : que[i]) {
                int ma = 0;
                for (auto& j : vs[i]) {
                    if (j.first <= p.first) {
                        ma = max(ma, j.second);
                    }
                }
                ans[p.second] = ma;
            }
        }
        else {
            int a = i;
            vector<P> lis = { { 0, 0 } };
            while (a >= lm) {
                lis = update(lis, v[a], w[a]);
                a = (a - 1) >> 1;
            }

            for (auto& p : que[i]) {
                int l = p.first;
                int k = (int)vs[a].size() - 1;
                int ma = 0;
                for (int j = 0; j < (int)lis.size(); ++j) {
                    while (k >= 0 && lis[j].first + vs[a][k].first > l) {
                        --k;
                    }
                    if (k < 0) break;
                    ma = max(ma, lis[j].second + vs[a][k].second);
                }
                ans[p.second] = ma;
            }
        }
    }
    for (auto& i : ans) {
        cout << i << '\n';
    }
    return 0;
}


Measured memory_bytes: 96084
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>

#define BIG 998244353
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;


int main() {
    long a,b,t;
    cin >> a >> b >> t;
    long sum = 0;
    for(int i = a;i <= t;i += a){
        sum += b;
    }
    cout << sum << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    reverse(all(v));
    ll ans = v[0];
    for(ll i=1; i<=(n-2)/2;i++){
        ans += v[i]*2;
    }
    if((n-1)%2 == 0){
        ans += v[(n-2)/2 + 1];
    }
    // priority_queue<ll> pq;
    // pq.push(v[0]);
    // pq.push(v[1]);
    // ans += v[0];
    // ll M, M2;
    // for(ll i = 2; i < n; i++){
    //     M = pq.top();
    //     pq.pop();
    //     M2 = pq.top();
    //     ans += M2;
    //     pq.push(M);
    //     pq.push(v[i]);
    // }
    cout << ans << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    a[0]=0;
    for(int i=0;i<n;i++){
        cin>>a[i+1];
        a[i+1]-=1;
        a[i+1]+=a[i];
        a[i+1]%=k;
    }
    ll ans=0;
    map<ll,int> mp;
    for(int i=0;i<=n;i++){
        if(i>=k)mp[a[i-k]]--;
        ans+=mp[a[i]];
        mp[a[i]]++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

ll f(ll x) {
	return x * x;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int d;
	while (cin >> d) {
		ll n = 600/d;
		ll ans = 0;
		REP(i, n) {
			ll x1 = i * d, x2 = (i+1) * d;
			ans += d * f(x1);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3072
def examA():
    A = LI()
    A.sort()
    ans = A[1] + max(A[1]-1,A[0])
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 10488
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int i = 1;
        while (sc.hasNext()) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
			
            System.out.println(String.format("Case %d: %d", i, n));
            i++;
        }

	}
}

Measured memory_bytes: 55228
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
	sc.Scan()
	return sc.Text()
}

func main()  {
	var N, M int
	fmt.Scan(&N, &M)

	inputs := strings.Split(readLine(), " ")

	sum := 0

	for i := 0; i < N; i++{
		num, _ := strconv.Atoi(inputs[i])
		sum += num
	}

	count := 0
	MFloat := float32(M)

	for i := 0; i < N; i++ {
		num, _ := strconv.Atoi(inputs[i])
		numFloat := float32(num)

		if numFloat >= (float32(sum) / (4.0 * MFloat)){
			count = count + 1
		}
	}

	if count >= M {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


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

in_flag = True
for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            in_flag = True
        else:
            in_flag = False
            break
    else:
        pass

if in_flag:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline

def main():
    N,M = map(int,input().split())
    a = list(map(int,input().split()))
    
    dp = [False for _ in range(M+1)]

    for i in range(M+1):
        for num in a:
            if i-num<0:
                continue
            if dp[i-num] == False:
                dp[i] = True

    if dp[M]:
        print("First")
    else:
        print("Second")
   
if __name__ == "__main__":
    main()


Measured memory_bytes: 3864
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		IN:for(int i = 0; i < t; i++) {
			ArrayList<Integer> R = new ArrayList<Integer>();
			ArrayList<Integer> G = new ArrayList<Integer>();
			ArrayList<Integer> B = new ArrayList<Integer>();
			int[] list = new int[9];
			for(int j = 0; j < 9; j++) {
				list[j] = sc.nextInt();
			}
			for(int j = 0; j < 9; j++) {
				String in = sc.next();
				if(in.equals("R")) R.add(list[j]);
				if(in.equals("G")) G.add(list[j]);
				if(in.equals("B")) B.add(list[j]);
			}
			int count = 0;
			boolean A1 = true;
			
			Collections.sort(R);
			Collections.sort(G);
			Collections.sort(B);
			for(int j = 0; j < R.size(); j++) {
				A1 = true;
				for(int k = j; k < j + 2; k++) {
					if(k+1 >= R.size()) {
						A1 = false;
						break;
					}
					if(R.get(k) != R.get(k+1)) {
						A1 = false;
						break;
					}
				}
				if(A1) {
					R.remove(j);
					R.remove(j);
					R.remove(j);
					j -= 1;
					count++;
				}
			}
			
			for(int j = 0; j < G.size(); j++) {
				A1 = true;
				for(int k = j; k < j + 2; k++) {
					if(k+1 >= G.size()) {
						A1 = false;
						break;
					}
					if(G.get(k) != G.get(k+1)) {
						A1 = false;
						break;
					}
				}
				if(A1) {
					G.remove(j);
					G.remove(j);
					G.remove(j);
					j -= 1;
					count++;
				}
			}
			
			for(int j = 0; j < B.size(); j++) {
				A1 = true;
				for(int k = j; k < j + 2; k++) {
					if(k+1 >= B.size()) {
						A1 = false;
						break;
					}
					if(B.get(k) != B.get(k+1)) {
						A1 = false;
						break;
					}
				}
				if(A1) {
					B.remove(j);
					B.remove(j);
					B.remove(j);
					j += 2;
					count++;
				}
			}
			for(int j = 0; j < R.size(); j++) {
				if(R.contains(R.get(j)+1) && R.contains(R.get(j) + 2)) {
					count++;
					R.remove(new Integer(R.get(j)+2));
					R.remove(new Integer(R.get(j)+1));
					R.remove(new Integer(R.get(j)));
					j = -1;
				}
			}
			for(int j = 0; j < G.size(); j++) {
				if(G.contains(G.get(j)+1) && G.contains(G.get(j) + 2)) {
					count++;
					G.remove(new Integer(G.get(j)+2));
					G.remove(new Integer(G.get(j)+1));
					G.remove(new Integer(G.get(j)));
					j = -1;
				}
			}
			for(int j = 0; j < B.size(); j++) {
				if(B.contains(B.get(j) + 1) && B.contains(B.get(j) + 2)) {
					count++;
					B.remove(new Integer(B.get(j)+2));
					B.remove(new Integer(B.get(j)+1));
					B.remove(new Integer(B.get(j)));
					j = -1;
				}
			}

			
			if(count == 3) {
				System.out.println(1);
			}
			else {
				System.out.println(0);
			}
			
			
			
			
			
			
		}
	}
}

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

int main(){
    ll x, l = 1, r = 1e9, ans;
    scanf("%lld", &x);
    while (l <= r){
        ll mid = (l+r)/2;
        if ((mid*(mid+1))/2 >= x){
            ans = mid;
            r = mid-1;
        }
        else
            l = mid+1;
    }

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


Measured memory_bytes: 256
h=int(input())
w=int(input())
n=int(input())

if h>w:
    if n%h==0:
        print(n//h)
    else:
        print((n//h)+1)
else:
    if n%w==0:
        print(n//w)
    else:
        print((n//w)+1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a * b << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}
string str;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> str;
	if(str[2] == str[3] && str[4] == str[5])
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int dp[301][301][301];
string s;
int K;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s >> K;
    F0Rd(i,sz(s)) F0Rd(j,sz(s)) if (i+j < sz(s)) F0Rd(k,K+1) {
        dp[i][j][k] = max(dp[i+1][j][k],dp[i][j+1][k]);
        if (s[i] == s[sz(s)-1-j]) {
            if (i == sz(s)-1-j) dp[i][j][k] = max(dp[i][j][k],dp[i+1][j+1][k]+1);
            else dp[i][j][k] = max(dp[i][j][k],dp[i+1][j+1][k]+2);
        }
        else if (k < K) dp[i][j][k] = max(dp[i][j][k],dp[i+1][j+1][k+1]+2);
    }
    cout << dp[0][0][0];
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 106752
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans = (n+x-1)/x*t;
    cout << ans << endl;

    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef pair< int, int > pii;

class UnionFind {
private:
	vector< int > data;
	int g_cnt;
	
public:
	UnionFind(int n) : data(n, -1), g_cnt(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		--g_cnt;
		
		return 1;
	}
	
	bool sameSet(int x, int y) {
		return root(x) == root(y);
	}
	
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	
	int getGroupNum() {
		return g_cnt;
	}
};

struct Edge {
	int u, v, c;
	Edge(int _u, int _v, int _c) : u(_u), v(_v), c(_c) {}
	bool operator < (const Edge& e) const {
		return c < e.c;
	}
};

int N, M;
vector< pii > vh;
bool vis[222];
vector< Edge > edges;

void solve() {
	sort(vh.begin(), vh.end(), greater< pii >());
	sort(edges.begin(), edges.end());
	
	int ans = 0, visc = 0;
	UnionFind uf(N);
	
	for_(i,0,N) {
		vis[vh[i].second] = 1;
		++visc;
		
		while (i < N-1 && vh[i].first == vh[i+1].first) {
			++i;
			vis[vh[i].second] = 1;
			++visc;
		}
		
		for_(j,0,M) {
			Edge e = edges[j];
			
			if (vis[e.u] && vis[e.v] && !uf.sameSet(e.u, e.v)) {
				uf.unionSet(e.u, e.v);
				ans += e.c;
			}
		}
		
		int g_cnt = uf.getGroupNum();
		
		if (g_cnt != N - visc + 1) {
			uf = UnionFind(N);
			ans = 0;
		}
		
		if (g_cnt == 1) break;
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> N >> M, N) {
		memset(vis, 0, sizeof(vis));
		vh.clear();
		
		for_(i,0,N) {
			int h; cin >> h;
			vh.push_back(pii(h, i));
		}
		
		edges.clear();
		for_(i,0,M) {
			int a, b, c; cin >> a >> b >> c;
			--a; --b;
			edges.push_back(Edge(a, b, c));
		}
		
		solve();
	}
	
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
typedef pair<int, int> ii;

long long pw[20], d, cnt;

int mymap1[20];
int mymap2[20];

void backtrack(int pos, int lim, long long D, long long ways, long long newsum1){
    if(pos == lim / 2 + 1){
        if(D == 0){
            if(lim % 2 != 0)
                cnt += ways * 10;
            else
                cnt += ways;
        }
        return ;
    }
    for(int i = -9; i <= 9; i++){
        long long newsum = ((pw[lim - pos] - pw[pos - 1]) * i) / newsum1;
        if((D - newsum) % 10) continue;
        if(pos == 1)
            backtrack(pos + 1, lim, (D - newsum)/10, ways * mymap1[i + 9], newsum1 * 10);
        else
            backtrack(pos + 1, lim, (D - newsum)/10, ways * mymap2[i + 9], newsum1 * 10);
    }
}
signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> d;
    for(int i = 1; i <= 9; i++){
        for(int j = 0; j <= 9; j++)
            mymap1[j - i + 9]++;
    }
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j <= 9; j++)
            mymap2[j - i + 9]++;
    }
    pw[0] = 1;
    for(int i = 1; i <= 18; i++)
        pw[i] = pw[i - 1] * 10;
    for(int i = 2; i <= 18; i++)
        backtrack(1, i, d, 1, 1);
    cout << cnt << "\n";
}
/*
63
*/


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int Q=in();
	map<string,int> M;
	REP(i,Q){
		int q=in();
		if(q==1){
			string key=in<string>();
			out(M.find(key)!=M.end()?M[key]:0);
		}
		else if(q==2){
			M.erase(in<string>());
		}
		else if(q==3){
			auto start = M.lower_bound(in<string>());
			auto end = M.upper_bound(in<string>());
			while(start!=end){
				out(start->first,start->second);
				++start;
			}
		}
		else{
			string key=in<string>();
			M[key] = in();
		}
	}
	return 0;
}


Measured memory_bytes: 25948
#include <bits/stdc++.h>
#define N 100010
#define ff first
#define ss second 
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

map<int,bool> mp;
int ans=0;

int main() {
	
	int n;
	cin>>n;
	for (int i=0,x;i<n;i++){
		scanf("%d",&x);
		if (mp[x]==false){
			mp[x]=true;
			ans++;
		}
		else{
			mp[x]=false;
			ans--;
		}
	}	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,l,r,sum;
  cin >> N;
  sum=0;
  for(int i=0;i<N;i++){
    cin >> l;
    cin >> r;
    sum+=(r-l)+1;
  }
  cout << sum << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

//ll searchCenter(ll border, ll a, ll b) {
//    ll i = a + 1;
//
//    while (((i + 1) * (i + 1)) < border) {
//        i++;
//    }
//    return i;
//}

ll searchCenter(ll border, ll a, ll b) {
    ll floor = a + 1;
    ll ceil = b;
    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        if (mid * mid <=border) {
            floor = mid;
        } else {
            ceil = mid;
        }
    }
    return floor;

}


ll searchPair(ll border, ll center, ll b) {
    ll i = center - 1;
    while ((center * (i + 1)) < border) {
        i++;
    }
    if (i == b) i--;
    return i;
}

int main() {

//    ifstream myfile("C:\\Users\\riku\\Downloads\\06.txt");
//    ofstream outfile("..\\log.txt");

    ll q;
//    myfile >> q;
    cin >> q;

    rep(i, q) {
        ll a, b;
        cin >> a >> b;
//        myfile >> a >> b;
        if (a > b) {
            swap(a, b);
        }

        ll border = a * b;

        ll center = searchCenter(border, a, b);
        ll pair = searchPair(border, center, b);

        ll left = pair - 1;
        ll right = center - 2;

        ll ans = right + left;
        if (center == b && pair == a) {

        } else {
            ans++;
        }

        if (center + 1 == pair - 1) {
            ans--;
        }

//        outfile << ans << endl;
        cout << ans << endl;

    }

//    outfile.flush();
//    outfile.close();
}

Measured memory_bytes: 256
n, x = map(int, input().split(" "))
m = [0 for i in range(n)]
sum = 0
for i in range(n):
    m[i] = int(input())
m.sort()
for i in range(n):
    x -= m[i]
    sum += 1
sum += (x//m[0])
print(sum)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 2000000000000000005L;

    void solve() {
        String s = "0" + in.next();
        int n = s.length();
        int[][] dp = new int[n + 1][2];
        dp[0][1] = 0xfffffff;
        for (int i = 0; i < n; i++) {
            dp[i + 1][0] = 0xfffffff;
            dp[i + 1][1] = 0xfffffff;
            int c = s.charAt(n - 1 - i) - '0';
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 2; k++) {
                    int d = ((j + 10) - c - k) % 10;
                    int e = j < c + k ? 1 : 0;
                    dp[i + 1][e] = Math.min(dp[i + 1][e], dp[i][k] + j + d);
                }
            }
        }
        out.println(dp[n][0]);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


Measured memory_bytes: 70492
#include<iostream>
#include<memory>
#include <vector>
#include <string>
#include<sstream>

using namespace std;

int bubblesort(vector<int> &vec){
    int counts_swap{0};
    int flag = 1;
    for (int i = 0; flag; i++){
        flag = 0;
        for (int j = vec.size()-1; j >= i + 1; j--){
            if (vec[j-1] > vec[j]){
                swap(vec[j], vec[j-1]);
                counts_swap++;
                flag = 1;
            }
        }
    }
    return counts_swap;
}


int main(){
    int N, i, j;
    cin >> N;
    vector<int> vec(N);
    int val;
    for(i = 0; i < N; i++){
        cin >> val;
        vec[i] = val;
    }

    int c;
    c = bubblesort(vec);
    /*
    for (i = 0; i < vec.size(); i++){
        if (i > 0 ) cout << " ";
        cout << vec[i];
    }
    */
    for(int i=0;i<N;i++) cout<<vec[i]<<" \n"[i==N-1];
    cout << c << endl; 
    /*
    while(cin >> val){
        vec[]
    }
    */

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
 string s;
  cin >> s;
  string t;
  cin >> t;
  int n = s.size();
  int m = t.size();
  vector <vector <pair<int,pair<int,int>>>> dp(n + 1,vector <pair<int,pair<int,int>>>(m + 1,{0,{-1,-1}}));
  //ll largestLen = 0,index = -1;
  for(int i = 1;i <= n;i++){
  	for(int j = 1;j <= m;j++){
      if(s[i - 1] == t[j - 1]){
         //cout << dp[i - 1][j - 1].first + 1 << endl;
      	dp[i][j] = {dp[i-1][j-1].first + 1,{i-1,j-1}};
      }
      int maxSize = max(dp[i][j].first,max(dp[i-1][j].first,dp[i][j-1].first));
      if(maxSize == dp[i - 1][j].first){
          dp[i][j] = dp[i - 1][j];
      }
      else if(maxSize == dp[i][j- 1].first){
          dp[i][j] = dp[i][j - 1];
      }
      //cout << i << " " << j << " " << dp[i][j].first << " " << dp[i][j].second << endl;
    }
  }
  int i = n,j = m;
  string ans;
  while(dp[i][j].second.first != -1){
      int x = dp[i][j].second.first;
      int y = dp[i][j].second.second;
      ans += s[x];
      i = x;
      j = y;
  }
  reverse(ans.begin(),ans.end());
  cout << ans;
 return 0;
}

Measured memory_bytes: 105984
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    cin >> a;
    if(a == 1) cout << "Hello World" << endl;
    else if (a == 2) {
        int b, c;
        cin >> b >> c;
        cout << b + c << endl;
    }
}

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

string rotation(string s){
  char tmp=' ';
  tmp=s[s.size()-1];
  for(int i=s.size()-1;i>0;--i){
    s[i]=s[i-1];
  }
  s[0]=tmp;
 
  return s;
}

int main() {
  string S,T;
  cin>>S>>T;
  
  bool ans=false;
  for(int i=0;i<S.size();++i){
    if(S==T)
      ans=true;
    
    S=rotation(S);
  }
  
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256