akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

/*--------------------------------------------*/
/* 0 : insert                                 */
/* 1 : getMax                                 */
/* 2 : deleteMax                              */
/*--------------------------------------------*/

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

  std::vector< priority_queue<int> > p_que(n);
  int order;
  int t, num;

  for(int i=0; i<q; ++i){
    cin >> order >> t;

    if(order == 0){
      cin >> num;
      p_que[t].push(num);
    }
    else if(order == 1 && !p_que[t].empty()){
      cout << p_que[t].top() << endl;
    }
    else if(order == 2 && !p_que[t].empty()){
      p_que[t].pop();
    }
  }

  return 0;
}


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

long long n;
vector<long long> a;

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, lst, l, m, r;
  if(n % 2 == 0) {
    for(int i = 0; i < n / 2; ++i) {
      ans += 2 * (a[n - 1 - i] - a[i]);
      if(i == n / 2 - 1) ans -= a[n - 1 - i] - a[i];
    }
  }
  else {
    lst = (n - 3) / 2;
    for(int i = 0; i < lst; ++i)
      ans += 2 * (a[n - 1 - i] - a[i]);
    l = a[lst];
    m = a[lst + 1];
    r = a[lst + 2];
    ans += max(2 * r - m - l, r + m - 2 * l);
  }
  return ans;
}


Measured memory_bytes: 1400
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b=0,c,d;cin>>a>>b>>c;
  rep(i,b)cout<<c<<" ";
  if(c!=1e9)rep(i,a-b)cout<<c+1<<" ";
  else rep(i,a-b)cout<<1<<" ";
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    lli gcd=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;++i) {
        for(int j=1;j<=n;++j) {
            for(int k=1;k<=n;++k) {
                int x=__gcd(i,j);
                gcd+=__gcd(x,k);
            }
        }
    }

    cout<<gcd<<endl;

    // (det)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
wab = gets.chomp.split.map {|s| s.to_i }

if wab[1]+wab[0]<wab[2]
  puts wab[2]-(wab[1]+wab[0])
elsif wab[2]+wab[0]<wab[1]
  puts wab[1]-(wab[2]+wab[0])
else
  puts 0
end



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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    vector<int> counter(1000100, 0);
    rep(i, n) {
        if (counter[a[i]] >= 2) continue;
        for (int mult = a[i]; mult < 1000100; mult += a[i]) {
            counter[mult]++;
        }
    }
    rep(i, n) {
        if (counter[a[i]] == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8004
#include<bits/stdc++.h>
#define fr first
#define sc second
#define ll long long


using namespace std;

#define sim template < class c

#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int cc[2020];

int main(){

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


    string s,t; cin >> s >> t;

    cout << ((s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]));

    return 0;
}


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

int N;
int a[110];
int b;
int op=0;

int main() {

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


for (int i=0;i<N;i++){
//cout<<"i"<<i<<endl;
    for (int j=i;j<N-1;j++){
    //cout<<"j"<<j<<endl;
    b=abs(a[i]-a[j+1]);
    //cout<<"b"<<b<<endl<<endl;
        if(op<b)op=b;
    }
}

cout <<op<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int x[400];

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    FOR(i,a,b-1) x[i] += 1;
    FOR(i,c,d-1) x[i] += 1;
    int ans = 0;
    REP(i,400) ans += (x[i] == 2);
    cout << ans << endl;

    return 0;
}

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

using namespace std;



int main() {

  string n;
  cin >> n;

  for(int i=0 ; i<3 ; i++){
    if(n[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
      
  }
  cout << "No" << endl;

  

 

  

  
  
  return 0;
}



Measured memory_bytes: 3624
def main():
    A, B, C = map(int, input().split())
    m = [A,B,C]
    m.sort(reverse=True)
    d = (m[0] - m[1]) + (m[0] - m[2])
    if d % 2 == 0:
        print(d//2)
    else:
        print((d//2)+2)

main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

long long dp[100000+10];
long long INF = 1LL << 32;


int main() {
  long long N, K;
  cin >> N >> K;
  vector<long long> h(N);
  for (long long i = 0; i < N; i++) {
    cin >> h[i];
    dp[i] = INF;
  }
  dp[0] = 0;
  for (long long i = 1; i < N; i++) {
    for (long long k = 1; k <= K; k++) {
      if (i-k >= 0) dp[i] = min(dp[i], dp[i-k]+abs(h[i]-h[i-k]));
    }
  }
  cout << dp[N-1] << endl;
}

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

int main() {
	long int X;
	cin >> X;
	int glad = 0;
	while (X>4) {
		if (X >= 500) {
			X -= 500;
			glad += 1000;
		}
		else {
			X -= 5;
			glad += 5;
		}
	}

	cout << glad;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll a, b, c;
  cin >> a >> b >> c;

  ll x = c - a - b;
  if (x > 0) {
    if (4 * a * b < x * x) {
      cout << "Yes" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3640
begin
	writeln('1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1');
end.


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

int main() {
  int n;
  cin >> n;
  ll a[n], l[n], r[n];
  rep(i, n) cin >> a[i];
  l[0] = a[0]; r[n-1] = a[n-1];
  rep(i, n-1) {
    l[i+1] = l[i] + a[i+1];
    r[n-2-i] = r[n-1-i] + a[n-2-i];
  }
  ll ans = 1e18;
  rep(i, n-1) ans = min(ans, abs(l[i] - r[i+1]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(n, k): Seq[Long] = io.StdIn.readLine().split(' ').map(_.toLong)

    val ops = for(_ <- 0 until n.toInt) yield {
      val Seq(a, b): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
      (a, b)
    }
    val opsSorted = ops.sorted

    var acc = 0.toLong
    var ans = 0
    opsSorted.foreach{ case (a, b) =>
        acc += b
        if (k <= acc && ans == 0){
          ans = a
        }
    }
    println(ans)
  }
}

Measured memory_bytes: 71280
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTapDance solver = new BTapDance();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTapDance {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            char[] ar = in.scanString().toCharArray();
            boolean flag = true;
            for (int i = 0; i < ar.length; i++) {
                if ((i & 1) == 0 && ar[i] == 'L') flag = false;
                if ((i & 1) == 1 && ar[i] == 'R') flag = false;
            }
            if (flag) out.println("Yes");
            else out.println("No");
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  SPEED;
  int n; cin >> n;
  vector<ll> a(n);
  vector<ll> dp(n, LLONG_MAX/2);
  rep(i, n) {
    ll p; cin >> p;
    a[i] = p*mod+n-1-i;
  }

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

  rep(i, n) {
    *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  }

  auto it = lower_bound(dp.begin(), dp.end(), LLONG_MAX/2);
  cout << distance(dp.begin(), it) << endl;

}

Measured memory_bytes: 1792
use itertools_num::ItertoolsNum;
use proconio::input;
use std::iter::once;

fn main() {
    input!(n: usize, m: usize, k: u64, a: [u64; n], b: [u64; m]);
    let b: Vec<u64> = once(0).chain(b.into_iter()).cumsum().collect();
    let mut j = m;
    println!(
        "{}",
        once(0)
            .chain(a.into_iter())
            .cumsum()
            .take_while(|&x: &u64| x <= k)
            .enumerate()
            .map(|(i, x)| {
                while 0 < j && k < x + b[j] {
                    j -= 1;
                }
                i + j
            })
            .max()
            .unwrap()
    );
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if(a == b)
        cout << c << endl;
    
    if(b == c)
        cout << a << endl;
    
    if(a == c)
        cout << b << endl;
    
    return 0;
}

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

int f(int n) {
    int keta = 0;
    while (n) {
        keta++;
        n /= 10;
    }
    return keta;
}


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

    int min = 10000000;

    for (int i = 1; i < sqrt(n) + 1; i++) {
        if (n%i == 0) {
            int x;
            x = max(f(i), f(n/i));
            if (x < min) min = x;
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 3532
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

vector<vector<int> > child;
vector<int> x;

pair<int, int> solve(int curr)
{
    vector<int> dp(x[curr]+1, INF);
    dp[0] = 0;
    for(int next : child[curr]){
        auto p = solve(next);
        if(p.first == -1)
            return make_pair(-1, -1);

        vector<int> nextDp(x[curr]+1, INF);
        for(int i=x[curr]; i>=0; --i){
            if(i + p.first <= x[curr])
                nextDp[i+p.first] = min(nextDp[i+p.first], dp[i] + p.second);
            if(i + p.second <= x[curr])
                nextDp[i+p.second] = min(nextDp[i+p.second], dp[i] + p.first);
        }
        dp.swap(nextDp);
    }

    int ans = *min_element(dp.begin(), dp.end());
    if(ans < INF)
        return make_pair(x[curr], ans);
    else
        return make_pair(-1, -1);
}

int main()
{
    int n;
    cin >> n;
    child.assign(n, vector<int>());
    x.resize(n);
    for(int i=1; i<n; ++i){
        int p;
        cin >> p;
        -- p;
        child[p].push_back(i);
    }
    for(int i=0; i<n; ++i)
        cin >> x[i];

    if(solve(0).first == -1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << "POSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 5752
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    int ans = 0;
    if(n % 2 == 0) {
        rep(i, n) {
            if(i < (n - 2) / 2) ans += 2 * a[i];
            else if(i == (n - 2) / 2) ans += a[i];
            else if(i == (n - 2) / 2 + 1) ans -= a[i];
            else ans -= 2 * a[i];
        }
    } else {
        int res1 = 0, res2 = 0;
        rep(i, n) {
            if(i < (n - 1) / 2) res1 += 2 * a[i];
            else if(i == (n - 1) / 2 || i == (n - 1) / 2 + 1) res1 -= a[i];
            else res1 -= 2 * a[i];
        }
        rep(i, n) {
            if(i < (n - 3) / 2) res2 += 2 * a[i];
            else if(i == (n - 3) / 2 || i == (n - 3) / 2 + 1) res2 += a[i];
            else res2 -= 2 * a[i];
        }
        ans = max(res1, res2);
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
long long a[N], ans, b[N];
int n, i;
int main(){
	cin>>n;
	for(i = 1; i <= n+1; i++) cin>>a[i];
	for(i = 1; i <= n; i++) cin>>b[i];
	for(i = 1; i <= n; i++){
		if(a[i] >= b[i]){
			a[i] -= b[i]; ans += b[i];
		}
		else{
            ans += a[i] + min(a[i+1], b[i] - a[i]);
			a[i+1] = max((long long) 0, a[i+1]+a[i]-b[i]); a[i] = 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
const int oo=214748364;
struct edges
{
	int to,next,f;
}edge[202020];
int first[20202],firstn[20202],now;
void adde1(int x,int y,int z)
{
	now++;
	edge[now].to=y;
	edge[now].f=z;
	edge[now].next=first[x];
	first[x]=now;
}
void adde(int x,int y,int z)
{
	adde1(x,y,z);
	adde1(y,x,0);
}
int S,T;
int dis[20202];
queue <int> q;
bool bfs()
{
	int p;
	memset(dis,-1,sizeof(dis));
	dis[S]=0;
	q.push(S);
	while(!q.empty())
	{
		p=q.front();
		q.pop();
		for(int e=first[p];e;e=edge[e].next)
			if(edge[e].f&&dis[edge[e].to]==-1)
			{
				dis[edge[e].to]=dis[p]+1;
				q.push(edge[e].to);
			}
	}
	for(int i=S;i<=T;i++)
		firstn[i]=first[i];
	return dis[T]!=-1;
}
int dfs(int p,int mi)
{
	if(p==T||mi==0)
		return mi;
	int ret=0,k;
	for(int &e=firstn[p];e;e=edge[e].next)
		if(edge[e].f&&dis[p]+1==dis[edge[e].to])
		{
			k=dfs(edge[e].to,min(mi,edge[e].f));
			ret+=k;
			mi-=k;
			edge[e].f-=k;
			edge[e^1].f+=k;
			if(mi==0)
				break;
		}
	return ret;
}
int num[111][111][2],nn;
int hx[4]={-1,0,0,1};
int hy[4]={0,-1,1,0};
char s[111][111];
int main()
{
	int h,w,ans=0;
	scanf("%d%d",&h,&w);
	memset(num,0,sizeof(num));
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	S=0;
	memset(first,0,sizeof(first));
	now=1;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
		{
			num[i][j][0]=++nn;
			if(s[i][j]=='.')
			{
				num[i][j][1]=++nn;
				adde(num[i][j][0],num[i][j][1],1);
			}
		}
	T=++nn;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(s[i][j]=='.')
				for(int k=0;k<4;k++)
					if(num[i+hx[k]][j+hy[k]][0])
						adde(num[i][j][1],num[i+hx[k]][j+hy[k]][0],oo);
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(s[i][j]=='X')
				adde(num[i][j][0],T,oo);
	for(int i=1;i<=h;i++)
		if(s[i][1]=='X'||s[i][w]=='X')
		{
			printf("-1\n");
			return 0;
		}
		else
		{
			adde(S,num[i][1][0],oo);
			adde(S,num[i][w][0],oo);
		}
	for(int j=1;j<=w;j++)
		if(s[1][j]=='X'||s[h][j]=='X')
		{
			printf("-1\n");
			return 0;
		}
		else
		{
			adde(S,num[1][j][0],oo);
			adde(S,num[h][j][0],oo);
		}
	while(bfs())
		ans+=dfs(S,oo);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ( (a + b) > (c + d) ) cout << "Left" << endl;
	else if ( (a + b) < (c + d) ) cout << "Right" << endl;
	else cout << "Balanced" << endl;
}

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

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

  int min = 10000;
  for(int i=0;i<N;i++){
    int c,t;
    cin >> c >> t;
    if(t <= T && c < min){
      min = c;
    }
  }

  if(min < 10000){
    cout << min << "\n";
  }else{
    cout << "TLE" << "\n";
  }

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i, n) cin >> a[i];
  sort(a, a+n);
  int ans = 0;
  rep(pos, a[n-1]+1) {
    int c = upper_bound(a,a+n,pos+1)-lower_bound(a,a+n,pos-1);
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n1 = list(map(int,input().split()))
n2 = list(map(int,input().split()))
a = "No"
for i in range(6):
    for j in range(4):
        n1 = [n1[0],n1[3],n1[1],n1[4],n1[2],n1[5]]
        if n1 == n2:
            a = "Yes"
    if i % 2 == 0:
        n1 = [n1[4],n1[0],n1[2],n1[3],n1[5],n1[1]]
    else:
        n1 = [n1[2],n1[1],n1[5],n1[0],n1[4],n1[3]]
print(a)


Measured memory_bytes: 5600
N=int(input())

T=[0]*9

S=list(map(int,input().split()))

for i in range(N):
    if S[i]<400:
        T[0]=1
    elif S[i]<800:
        T[1]=1
    elif S[i]<1200:
        T[2]=1
    elif S[i]<1600:
        T[3]=1
    elif S[i]<2000:
        T[4]=1
    elif S[i]<2400:
        T[5]=1
    elif S[i]<2800:
        T[6]=1
    elif S[i]<3200:
        T[7]=1
    else:
        T[8]+=1

goukeimin=0



for i in range(8):
    goukeimin+=T[i]
if goukeimin==0:
    print(1,sum(T))
else:
    print(goukeimin,sum(T))
        
        


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

int main(){
  double x1, x2, y1, y2, dis;

  cin >> x1 >> y1 >> x2 >> y2;
  dis = sqrt(pow(x2 - x1,2.0) + pow(y2 - y1,2.0));
  cout << fixed << dis <<endl;
  return 0;
}

Measured memory_bytes: 1280
// https://atcoder.jp/contests/agc034/tasks/agc034_b

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MODI (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (const auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s; // 置換対象の文字列
    ll ans = 0, pos = 0, cnt = 0;
    while (pos < s.length()) {
        if (s[pos] == 'A') {
            cnt++;
        } else if (s[pos] == 'B' && s[pos + 1] == 'C') {
            ans += cnt;
            pos++;
        } else {
            cnt = 0;
        }
        pos++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int in;
    int h, m, s;

    cin >> in;

    h = in / (60 * 60);
    m = in % (60 * 60) / 60;
    s = in % 60;

    printf("%d:%d:%d\n", h, m, s);

    return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    int n,h;
    cin >> n >> h;
    int a[n],b[n];
    int x = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        x = max(x,a[i]);
    }
    sort(b,b+n);
    
    for(int i = n-1; i >= 0; i--){
        if(h <= 0){
            break;
        }else if(x < b[i]){
            h -= b[i];
            ans++;
        }
    }
    if(h > 0){
        ans += ((h-1)/x);
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, ans = 15;
	for (int i = 0; i < 5; i++) {
		cin >> n;
		ans -= n;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3504
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
typedef tuple<ll,ll,ll,ll> T;
typedef pair<ll,ll> P;

string s;
int p;

P number(){
	if(s[p]>'9' || s[p]<'0')
		return P(0,99);
	int num=s[p]-'0';
	p++;
	if(s.size()<=p){
		if(num==0)
			return P(num,num);
		else
			return P(num,num*10+9);
	}else if('0'<=s[p] && s[p]<='9'){
		num=num*10+s[p]-'0';
		p++;
		return P(num,num);
	}else{
		return P(num,num);
	}
}

T read(){
	if(s.size()<=p)
		return T(0,99,0,99);
	P x;
	if(s[p]=='^' || s[p]=='_'){
		p+=2;
		if(s.size()<=p)
			x=P(0,99);
		else{
			char ex=s[p-2];
			int a,b,c,d;
			tie(a,b,c,d)=read();
			if(ex=='_'){
				x=P(min(a,c),min(b,d));
			}else if(ex=='^'){
				x=P(max(a,c),max(b,d));
			}
		}
	}else
		x = number();

	p++; // ,

	if(s.size()<=p)
		return T(x.first,x.second,0,99);
	P y;
	if(s[p]=='^' || s[p]=='_'){
		p+=2;
		if(s.size()<=p)
			y=P(0,99);
		else{
			char ex=s[p-2];
			int a,b,c,d;
			tie(a,b,c,d)=read();
			if(ex=='_'){
				y=P(min(a,c),min(b,d));
			}else if(ex=='^'){
				y=P(max(a,c),max(b,d));
			}
		}
	}else
		y = number();

	p++; // )
	return T(x.first,x.second,y.first,y.second);
}

P readf(){
	P top = number();
	if(top!=P(0,99))
		return top;

	p+=2;
	if(s.size()<=p)
		return P(0,99);
	char ex=s[p-2];
	int a,b,c,d;
	tie(a,b,c,d)=read();
	if(ex=='_'){
		return P(min(a,c),min(b,d));
	}else if(ex=='^'){
		return P(max(a,c),max(b,d));
	}
}



int main(){
	int Q;
	cin >> Q;
	for(int i=0;i<Q;i++){
		string base;
		cin >> base;
		for(int l=1;l<=base.size();l++){
			s=base.substr(0,l);
			p=0;
			int a,b;
			P result=readf();
			a=result.first;
			b=result.second;
			if(a==b){
				cout << a << " " << l << endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

int N;
vvi edges;

const int mod = 1e9+7;

ll mul(int a, int b){
    return (ll)a*b%mod;
}

ll add(ll a, ll b){
    return (a+b)%mod;
}

pii dfs(int node, int parent){
    ll smt_is_blk = 0;
    ll all_wht = 1;
    for(auto child:edges[node]){
        if(child!=parent){
            auto curr = dfs(child, node);
            ll wb = mul(all_wht, curr.second);
            ll ww = mul(all_wht, curr.first);
            ll bw = mul(smt_is_blk, curr.first + curr.second);
            all_wht = wb;
            smt_is_blk = add(bw, ww);
        }
    }
    return make_pair(all_wht, add(all_wht, smt_is_blk));
}

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

    cin>>N;
    edges.resize(N+1);
    Fo(i,1,N){
        int x,y;
        cin>>x>>y;
        edges[x].push_back(y);
        edges[y].push_back(x);
    }
    pii ans = dfs(1, -1);
    cout<<add(ans.first, ans.second)<<endl;
    
    return 0;
}

Measured memory_bytes: 12672
#include <iostream>
#include <vector>


#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;

signed main() {
    FAST_IO;

    int n;
    cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 4048
#include<stdio.h>
int main(void)
{
  int n,x;
  scanf("%d%d", &n, &x);
  int i, l, sum=0, c=1;
  for(i=0;i<n;i++){
    scanf("%d", &l);
    sum+=l;
    if(sum<=x) c++;
  }
  printf("%d", c);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define lli long long int
#include<vector>
#include<algorithm>
#define maxi 1000000007
#include<bits/stdc++.h>
int main(){
  lli i,n,t,u,sum=0,flag=0,j;
  cin>>n>>t;
  bool ok[n+1];
  memset(ok,true,n+1);
  vector<lli>dp(n+1);
  lli a;
  for(i=0;i<t;i++){
    cin>>a;
    ok[a]=false;
  }
  dp[0]=1;
  for(i=0;i<n;i++){
    for(j=i+1;j<=min(n,i+2);j++){
      if(ok[j]){
        dp[j]=dp[j]+dp[i];
        dp[j]%=maxi;
      }
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	string s;
	cin >> s;
	if (s.size() < 26) {
		bool used[26];
		for (int i = 0; i<26; ++i) {
			used[i] = 0;
		}
		for (char c : s) {
			used[c - 'a'] = 1;
		}
		int i = 0;
		while (used[i]) {
			++i;
		}
		cout << s << (char)('a' + i) << '\n';
	}
	else {
		vector<char> v;
		bool used[26];
		for (int i = 0; i<26; ++i) {
			used[i] = 1;
		}
		bool f = 0;
		for (int i = 25; i>=0; --i) {
			int q = s[i] - 'a';
			used[q] = 0;
			if (f) {
				v.pb(s[i]);
			}
			else {
				for (int j = q+1; j<26; ++j) {
					if (!used[j]) {
						v.pb('a' + j);
						f = 1;
						break;
					}
				}
			}
		}
		reverse(v.begin(), v.end());
		if (v.size() == 0) {
			printf("-1\n");
		}
		else {
			for (char c : v) {
				printf("%c", c);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){


int a,b,c,d;


double a2,b2,e;


scanf("%d %d",&a,&b);


c=a/b;


d=a%b;


a2=a;


b2=b;


e=a2/b2;


printf("%d %d %f\n",c,d,e);


return 0;


}

Measured memory_bytes: 636
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	ll N, M, X, Y;
	vector<ll> x, y;
	cin >> N >> M >> X >> Y;
	
	rep(i, 0, N){
		ll temp;
		cin >> temp;
		if (temp < X) continue;
		x.push_back(temp);
	}
	rep(i, 0, M){
		ll temp;
		cin >> temp;
		if (temp > Y) continue;
		y.push_back(temp);
	}
	bool xFlg = false;
	bool yFlg = false;
	rep(i, X+1, Y+1){
		rep(ii, 0, x.size()){
			if ((x[ii] >= i) || (x[ii] > Y)) xFlg = true;
		}
		rep(ii, 0, y.size()){
			if ((y[ii] < i) || (y[ii] <= X)) yFlg = true;
		}
		if (!xFlg && !yFlg){
			cout << "No War" << endl;
			return 0;
		}
		xFlg = false;
		yFlg = false;
	}
	cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
struct node{
	long long  a,b;
}sum[100005];
bool cmp(node a,node b)
{return a.a<b.a;}
int main()
{
	int n,m,i;long long ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	 cin>>sum[i].a>>sum[i].b;
	sort(sum+1,sum+n+1,cmp);
	for(i=1;i<=n;i++)
	 {if(m<sum[i].b){ans+=m*sum[i].a;break;}
	  ans+=sum[i].b*sum[i].a;
	  m-=sum[i].b;
	 }
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main()
{
	int N,L;
	cin >> N>>L;
	vector<string> S(N);

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

	sort(S.begin(), S.end());
	for_each(S.begin(), S.end(), [](string x) {
		cout << x;
	});
		
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,max;

	scanf("%d %d %d",&a,&b,&c);


	if(a>b){
		max=a;
		a=b;
		b=max;
	}
	if(b>c){
		max=b;
		b=c;
		c=max;
	}

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

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

	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, vector<int> > T;

llint D;
llint c[30], csum;
llint s[400][30];
vector<int> ans;
vector<T> vec;

inline llint score(vector<int> ans, int n)
{
	int last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 0; i < n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

inline void search(vector<int> &ret)
{
	llint cur = score(ret, D);
	for(int t = 0; t < 1; t++){
		llint x = rand() % D, y = rand() % D;
		swap(ret[x], ret[y]);
		llint nxt = score(ret, D);
		if(nxt < cur) swap(ret[x], ret[y]);
		else cur = nxt;
		
		x = rand() % D, y = rand() % 26;
		llint tmp = ret[x];
		ret[x] = y;
		nxt = score(ret, D);
		if(nxt < cur) ret[x] = tmp;
		else cur = nxt;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	ans.resize(D);
	for(int i = 0; i < D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i+1);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	search(ans);
	
	const int M = 100;
	llint res = score(ans, D);
	for(int i = 0; i < M; i++) vec.push_back(T(res, ans));
	
	for(int t = 0; t < 3500; t++){
		vector<T> nvec;
		for(int i = 0; i < vec.size(); i++){
			vector<int> tmp = vec[i].second;
			search(tmp);
			nvec.push_back(vec[i]);
			nvec.push_back(T(score(tmp, D), tmp));
		}
		sort(nvec.rbegin(), nvec.rend());
		nvec.resize(M);
		vec = nvec;
	}
	ans = vec.front().second;
	
	for(int i = 0; i < D; i++) cout << ans[i]+1 << endl;
	
	return 0;
}

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

void solve() {
    long long a;
    long double b;
    cin >> a >> b;
    long long c = round(b * 100);
    a *= c;
    a /= 100;
    cout << a;
}


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


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define maxn (int)2e5 + 8



int main(){
	Fio;
	int t = 1;
	//cin >> t;
	while(t--){
		int n, k;
		cin >> n >> k;
		int ans=0;
		while(n){
			n /= k;
			ans++;
		}

		cout << ans;

	}

	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 all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,l;cin>>n>>l;
  vector<int>vec(n);
  int cnt=0;
  rep(i,n){
    vec[i]=l+i;
    cnt+=vec[i];
  }
  int ans=1e9;
  rep(i,n){
    ans=min(ans,abs(vec[i]));
  }
  if(cnt>0)cout<<cnt-ans<<endl;
  else cout<<cnt+ans<<endl;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define M 1000000007
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int main()
{
    flash;
    //sieve();
    ll T=1,t,a,b,h,j;
    // cin>>T;
    while(T--)
    {
        cin>>a>>b>>h;
        cout<<(a+b)*h/2<<endl;
    }
}

Measured memory_bytes: 3664
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int n = 0;



string check(const string st) {
	int plus = 0;
	string nowst="";
	while (st.size()>n) {
		if (st[n] == '[') {
			n++;
			string ast(check(st));
			reverse(ast.begin(), ast.end());
			nowst+=(ast);
		}
		else if (st[n] == '-') {
			plus--;
			if (plus < 0)plus += 26;
			n++;
		}
		else if (st[n] == '+') {
			plus++;
			if (plus > 26)plus -= 26;
			n++;
		}
		else if (st[n] == ']') {
			n++;
			return nowst;
		}
		else if (isalpha(st[n])) {
			char ch = st[n] + plus;
			while (ch > 'Z')ch -= 26;
			while (ch < 'A')ch += 26;
			nowst.push_back(ch);
			plus = 0;
			n++;
		}
		else {
			assert(st[n] == '?');
			nowst.push_back('?');
			n++;
			plus = 0;
		}
	}
	return nowst;
}
int main() {
	while (1) {
		n = 0;
		string st; cin >> st;
		if (st == ".")break;
		string ans(check(st));
		for (int i = 0; i < ans.size(); ++i) {
			if (ans[i] == '?')ans[i] = 'A';
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h> 
using namespace std;
int ans;
int main(){
    std::ios::sync_with_stdio(false); 
    int a,b,c;
    cin>>a>>b>>c;
    int d[10001];
    for(int i=1;i<=a;++i){
    cin>>d[i];
    if(d[i]<b||d[i]>=c){
        ans++; 
    }
}
    cout<<ans<<endl; 
    return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int K;
    cin >> K;

    vector<string> sv;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j <= n && j < i + 8; j++) {
            sv.push_back(s.substr(i, j - i));
        }
    }

    sort(all(sv));
    sv.erase(unique(all(sv)), sv.end());

    put(sv[K - 1]);

    return 0;
}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        sum += a[i];
    }
    int ave = (int)((double)sum / (double) n + (sum > 0 ? 0.5 : -0.5));
    int ans = 0;
    rep(i, 0, n){
        ans += pow(a[i] - ave, 2);
    }
    o(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define inf 100000000001
#define ll long long
#define MOD 1000000007
using namespace std;


int main(){
    ll n, k;
    cin>>n>>k;
    ll arr[n];
    for(ll i =0;i<n;i++){
        cin>> arr[i];
    }
    vector<ll> dp(k+1);
    dp[0] = 1;
    for(ll i =0;i<n;i++){
        vector<ll> temp(k+5);
        for(ll j=k;j>=0;j--){ // for jth value , we can reach j+1 to j+arr[i] value
                            // so dp[j+1] to dp[j+ arr[i]] range, we will add dp[j]
            if(j+1<=k)temp[j+1] += dp[j];
            if(j+arr[i]+1<=k)temp[j+ arr[i]+1] -= dp[j];
        }
        for(ll j=1;j<=k;j++){
            temp[j]+= temp[j-1];
            dp[j] += temp[j];
            dp[j] %= MOD;
        }

    }

    cout << dp[k] << endl;

}


Measured memory_bytes: 1792
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (c).size()
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int main(){
fcin;
    ll a = 0 , k = 1 , i = 1;
    ll n;
    cin >> n;
    while(i<100000000){
        ll b = k*7 + a;
        if(b%n==0){
            cout << i;
            return 0;
        }
        b%=n;
        a=b;
        k*=10;
        k%=n;
        i++;
    }
    cout << "-1\n";

}

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

int main() {
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p, p + n);

  ll ans = 0;
  for (int i = 0; i < k; i++) {
    ans += p[i];
  }

  cout << ans << endl;
  return 0;
}


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

int main(void) {
 int h, w;
 cin >> h >> w;

 string board[50];

 for (int i = 0; i < h; ++i) cin >> board[i]; 
 const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
 const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 for (int i = 0; i < h; ++i) 
 {
 	for (int j = 0; j < w; ++j) 
    {
 		if (board[i][j] == '#') continue;

 		int num = 0;
 		for (int d = 0; d < 8; ++ d) 
    	{
 			const int ni = i + dy[d];
 			const int nj = j + dx[d];

 			if(ni<0 or h<=ni)continue;
 			if(nj<0 or w<=nj)continue;
 			if (board[ni][nj] == '#') num++;
 		}

 		board[i][j] = char(num + '0'); 
 	}
 }

 for (int i = 0; i < h; ++i) cout << board[i] << endl; 
 return 0;
 }

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

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> ans(N+1, -1);
    rep(i, 0, M){
        ll s, c;
        cin >> s >> c;
        if(s == 1 && c == 0){
            if(N == 1){
                if(ans[s] == -1 || ans[s] == 0){
                    ans[s] = c;
                }else{
                    cout << -1 << endl;
                    return 0;
                } 
            }else{
                cout << -1 << endl;
                return 0;
            }
        }else if(ans[s] == -1){
            ans[s] = c;
        }else if(ans[s] == c){
            continue;
        }else if(ans[s] != c){
            if(ans[s] == -1){
                ans[s] = c;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
    }

    if(N == 1 && ans[1] == -1){
        cout << 0 << endl;
        return 0;
    }

    if(ans[1] == -1) cout << 1;
    else cout << ans[1];

    rep(i, 2, N+1){
        if(ans[i] == -1) cout << 0;
        else cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256