akhauriyash/Code-Regression huggingface dataset:
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    String S;

    AtCoder(FastScanner sc) {
        S = sc.next();
    }

    void solve(PrintWriter out) {
        int ans = 0;
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            if (c == '+') {
                ans++;
            } else {
                ans--;
            }
        }
        out.println(ans);
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22996
//==========================================
// ABC138c
//
// 2019/08/18
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0; i<n; i++) cin >> v[i];

  sort(v.begin(), v.end());

  double ans=0;
  for(int i=0; i<n; i++)
  {
    ans += v[i];
    if(i!=0) ans /= 2;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    rep(i,n+1) cin >> a[i];
    rep(i,n) cin >> b[i];

    ll save=0;
    rep(i,n+1){
        save += min(a[i]+a[i+1],b[i]);
        a[i+1] -= max(0,b[i]-a[i]);
        if(a[i+1]<0) a[i+1]=0;
    }

    cout << save << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, d;
  cin >> n >> d;
  cout << (n+2*d+1-1)/(2*d+1) << endl;
}

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

bool rsorts(char a,char b){
	return a > b;
}
int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),rsorts);
	int n = min(s.length(),t.length()),i;
	for(i=0;i<n;i++){
		if(s[i] < t[i]){
			cout << "Yes" << endl;
			return 0;
		}
		if(s[i] > t[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	if(t.length() <= s.length())
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int main() {
	int n, a, b; cin >> n >> a >> b;
	if ((b - a + 1) % 2 == 0) cout << "Borys" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int n, m;

    std::cin >> n >> m;

    if (m == n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using pi = pair<int,int>;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

void setIO(string name = ""){
    freopen((name+".in").c_str(), "r", stdin); 
    freopen((name+".out").c_str(), "w", stdout);
}

int main(){
 	ios_base::sync_with_stdio(0); cin.tie(0); 
	// setIO();
    int cnt{};
	int r,g,b,k; cin >> r >> g >> b >> k;

    while(r>=g)
    {
        cnt++; g*=2;
    }

    while(g>=b){
        cnt++; b*=2;
    }

    cout << (cnt<=k?"Yes":"No") << "\n";

    




}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using LL = long long;
const LL MOD = 1e9+9;
using namespace std;

struct UnionFind{
    std::vector<LL> data;

    UnionFind(int n){
        data.assign(n, -1);
    }

    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(data[x] > data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }

    int find(int k){
        if(data[k] < 0) return k;
        return data[k] = find(data[k]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
    LL size(int i){
        return -data[find(i)];
    }
};

int main(){
    LL N,M;cin >> N >> M;
    vector<pair<LL,LL>> E;
    for(int a = 0;a < M;a++){
        int b,c;cin >> b >> c;
        E.push_back(make_pair(b-1,c-1));
    }
    UnionFind Uni(N);
    vector<LL> ans;
    LL v = (N*(N-1))/2;
    for(int a = M -1;a >= 0;a--){
        ans.push_back(v);
        if(Uni.same(E.at(a).first,E.at(a).second))continue;
        LL ins = (Uni.size(E.at(a).first)*Uni.size(E.at(a).second));
        Uni.unite(E.at(a).first,E.at(a).second);
        v -=  ins;
    }
    //ans.back() = v;
    reverse(ans.begin(),ans.end());
    //sort(ans.begin(),ans.end());
    for(int a = 0;a < ans.size();a++){
        cout<<ans.at(a)<<endl;
    }
}


Measured memory_bytes: 5488
//****** @ mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fast_pow(ll x, ll y, ll p);


void solve() {
  ll n,m;cin>>n>>m;
  ll mx=n*m;
  ll a[mx][mx];
  char S[n][m];
  ll dx[4]={1,-1,0,0};
  ll dy[4]={0,0,1,-1};
  for(ll i=0;i<n;i++)for(ll j=0;j<m;j++){
    cin>>S[i][j];
  }
for(ll i=0;i<mx;i++)for(ll j=0;j<mx;j++){
  if(i==j)a[i][j]=0;
  else a[i][j]=INT_MAX;
}


  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
      if(S[i][j]=='#')continue;
      for(ll k=0;k<4;k++){
        ll nx=i+dx[k],ny=j+dy[k];
        if(nx<0 || nx>=n || ny<0 || ny>=m || S[nx][ny]=='#')continue;
        a[i*m+j][nx*m+ny]=a[nx*m+ny][i*m+j]=1;
      }
    }
  }
  ll ans=0;
  for(ll k=0;k<mx;k++){
    for(ll i=0;i<mx;i++){
      for(ll j=0;j<mx;j++){
        if(a[i][k]+a[k][j]<a[i][j]){
            a[i][j]=a[i][k]+a[k][j];
        }
      }
    }
  }
  for(ll i=0;i<mx;i++){
  for(ll j=0;j<mx;j++)
    if(a[i][j]<INT_MAX)
    ans=max(ans,a[i][j]);
  }
  cout<<ans;
  
}

 
int main()
{
    IOS;
    ll test=1;
    //cin>>test;
    while(test--){
        solve();
    }
    return 0;
}
ll fast_pow(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}


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



// int main()
// {
    
//    int n,m,sum=0;
//    cin>>n>>m;
//    int a[n];
//    for (int i = 0; i < n; ++i)
//    {
//        cin>>a[i];
//        sum+=a[i];
//    }
//    sort(a,a+n);
//    if(a[n-m]>=(sum/4)/m)
//    {
//     cout<<"Yes"<<endl;
//    }
//    else
//    {
//     cout<<"No"<<endl;
//    }
// }

typedef long long ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll ans=n%k;
    ans=min(ans,k-ans);
    cout<<ans<<endl;
}


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

const int N = 3333;

typedef pair<int,int> pii;

#define mp make_pair
#define fr first
#define sc second

int dp[N][N];
pii pp[N][N];

char s[N], t[N];

int main()
{
  
  scanf("%s %s", s + 1, t + 1);
  int n = strlen(s+1);
  int m = strlen(t+1);
  
  for(int i = 1; i <= n;++i)
    for(int j = 1; j <= m;++j)
    {
      if(s[i] == t[j])
        dp[i][j] = max({dp[i-1][j-1] + 1, dp[i-1][j], dp[i][j-1]});
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if(s[i] == t[j])
      {
        dp[i][j] = dp[i-1][j-1] + 1;
        pp[i][j] = mp(i-1, j-1);
        
        if(dp[i-1][j] > dp[i][j-1] && dp[i-1][j] > dp[i][j])
          dp[i][j] = dp[i-1][j], pp[i][j] = mp(i-1, j);
        if(dp[i][j-1] > dp[i-1][j] && dp[i][j-1] > dp[i][j])
          dp[i][j] = dp[i][j-1], pp[i][j] = mp(i, j - 1);
      }else
      {
        if(dp[i-1][j] > dp[i][j-1])
          dp[i][j] = dp[i-1][j], pp[i][j] = mp(i-1, j);
        else dp[i][j] = dp[i][j-1], pp[i][j] = mp(i, j - 1);
      }
    }
  
  cerr << dp[n][m] << endl;
  
  string ans = "";
  pii cur = mp(n,m);
  while(cur.fr)
  {
    pii nxt = pp[cur.fr][cur.sc];
    if(s[cur.fr] == t[cur.sc])
      ans += s[cur.fr];
    cur  = nxt;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, x; cin >> n >> x;
  int pos = 0, count = 1;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    pos += t;
    if (pos <= x) count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<P,int> PI;
typedef pair<int, P> S;
map<P, vector<PI>> G;
map<P, int> dist;
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int p, q, c;
		cin >> p >> q >> c;
		p--; q--;
		G[P(p, c)].emplace_back(P(q, c), 0);
		G[P(q, c)].emplace_back(P(p, c), 0);
		G[P(p, -1)].emplace_back(P(p, c), 1);
		G[P(p, c)].emplace_back(P(p, -1), 0);
		G[P(q, -1)].emplace_back(P(q, c), 1);
		G[P(q, c)].emplace_back(P(q, -1), 0);
	}
	priority_queue<S, vector<S>, greater<S>> Q;
	Q.push(S(0, P(0, -1)));
	dist[P(0, -1)] = 0;
	while (!Q.empty()) {
		S s = Q.top(); Q.pop();
		if (dist[s.second] < s.first) continue;
		for (auto e : G[s.second]) {
			int cost = s.first + e.second;
			if (dist.find(e.first) == dist.end() || dist[e.first] > cost) {
				dist[e.first] = cost;
				Q.push(S(cost, e.first));
			}
		}
	}
	if (dist.find(P(N - 1, -1)) == dist.end()) {
		cout << -1 << endl;
	}
	else {
		cout << dist[P(N - 1, -1)] << endl;
	}
}

Measured memory_bytes: 91952
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 2019;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int t = 0,ans=0;
	string s;
	cin >> s;
	map<int,int>ma;
	ma[0] = 1;
	for (int i = s.size() - 1; i >= 0; i--) {
		t += (s[i]-'0') * modpow(10, s.size()-1 - i);
		t %= 2019;
		if (!ma.count(t)) {
			ma[t] = 1;
		}
		else {
			ma[t]++;
		}
	}
	for (auto p : ma) {
		auto k = p.first;
		auto v = p.second;
		ans += v * (v - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3756
s = list(input())
c = len(s) -2

for i in range(c,0,-1):
    lst = [x for idx, x in enumerate(s) if idx <= i]
    for ix in range(1, len(lst)+1):
        if lst[0:ix] == lst[ix:len(lst)]:
            print(len(lst))
            break
    else:
        continue
    break


Measured memory_bytes: 3060
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define endl '\n'


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int n, k;
        string s;
        in >> n >> k >> s;
        s[k-1] += 32;
        out << s << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    for(ll &x : a)
        cin >> x;
    for(ll &x : b)
        cin >> x;

    for(int i = 1; i < n; i++)
        a[i] += a[i - 1];
    for(int i = 1; i < m; i++)
        b[i] += b[i - 1];


    int total = 0;
    for(int i = 0; i < n; i++)
        if(a[i] <= k)
            total = i + 1;
    for(int i = 0; i < n; i++)
    {
        //read [0, i] books from top of A
        int read_a = i + 1;
        ll time_a = a[i];
        if(time_a > k)
            break;

        ll left = k - time_a;

        int lo = 0, hi = m - 1;
        int pos = -1;
        while(lo <= hi)
        {
            int mid = (lo + hi) / 2;
            if(b[mid] <= left)
                pos = mid, lo = mid + 1;
            else
                hi = mid - 1;
        }
        if(pos == -1)
            continue;

        int read_b = pos + 1;
        // cout << i << ": " << read_a << " " << read_b;
        total = max(total, read_a + read_b);
    }
    for(int i = 0; i < m; i++)
        if(b[i] <= k)
            total = max(total, i + 1);
    for(int i = 0; i < m; i++)
    {
        //read [0, i] books from top of B
        int read_b = i + 1;
        ll time_b = b[i];
        if(time_b > k)
            break;

        ll left = k - time_b;

        int lo = 0, hi = n - 1;
        int pos = -1;
        while(lo <= hi)
        {
            int mid = (lo + hi) / 2;
            if(a[mid] <= left)
                pos = mid, lo = mid + 1;
            else
                hi = mid - 1;
        }
        if(pos == -1)
            continue;

        int read_a = pos + 1;
        // cout << i << ": " << read_a << " " << read_b;
        total = max(total, read_a + read_b);
    }

    cout << total;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 6360
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int V,E,a,b,c;cin>>V>>E;
  vector<vector<int>> dp(1<<V,vector<int>(V,INF)),dist(V,vector<int>(V,INF));
  REP(i,0,E){
    cin>>a>>b>>c;
    dist[a][b]=c;
  }
  dp[0][0]=0;
  REP(s,1,(1<<V))REP(v,0,V){
    if(s&(1<<v)){
      REP(j,0,V){
        dp[s][v]=min(dp[s][v],dp[s&~(1<<v)][j]+dist[j][v]);
      }
    }
  }
  // debug(dp)
  int ans=(dp[(1<<V)-1][0]==INF?-1:dp[(1<<V)-1][0]);
  print(ans)

}



Measured memory_bytes: 7788
N = [int(s) for s in raw_input().split(" ")][0]
A = [int(s) for s in raw_input().split(" ")]
B = [int(s) for s in raw_input().split(" ")]
C = [int(s) for s in raw_input().split(" ")]

res = sum(B)
for i in xrange(N):
    # res += B[A[i]-1]
    if i > 0 and A[i] == A[i-1]+1:
        # print(A[i], C[A[i-1]-1])
        res += C[A[i-1]-1]
print(res)

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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;

const int N = 1e5 + 100;

char s[N];
int a[N];
int ans[N];
int n;

bool ok()
{
	int i;
	for (i = 2; i < n; i++)
	{
		ans[i] = ans[i - 1] ^ ans[i - 2] ^ a[i - 1];
	}
	
	bool res = true;
	if (ans[0] != ans[n - 2] ^ ans[n - 1] ^ a[n - 1])
	{
		res = false;
	}
	
	if (ans[1] != ans[0] ^ ans[n - 1] ^ a[0])
	{
		res = false;
	}
	
	return res;
}



int main()
{
	USE_IOSTREAM;
	cin >> n;
	cin >> s;
	int i, j;
	for (i = 0; i < n; i++)
	{
		a[i] = s[i] == 'o' ? 0 : 1;
	}

	bool flag = false;
	for (i = 0; i < 2 && !flag; i++)
	{
		ans[0] = i;
		for (j = 0; j < 2; j++)
		{
			ans[1] = j;
			if (ok())
			{
				flag = true;
				break;
			}
		}
	}
	
	if (flag)
	{
		for (i = 0; i < n; i++)
		{
			cout << (ans[i] ? 'W' : 'S');
		}
		cout << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1280
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
using namespace std;

const vector<pair<
	pair<int,int>,
	vector<vector<int>>
>>pattern={
	{{13,3},{
		{0,0,1,0,0},
		{0,1,1,1,0},
		{1,1,1,1,1},
		{0,1,1,1,0},
		{0,0,1,0,0},
	}},
	{{9,2},{
		{1,1,1},
		{1,1,1},
		{1,1,1},
	}},
	{{5,1},{
		{0,1,0},
		{1,1,1},
		{0,1,0},
	}},
};

vector<vector<int>>m(10);
vector<pair<pair<int,int>,int>>v;
void dfs(int pat,int y,int x,int N,int d,int s){
	if(d==N){
		if(s==0){
			for(auto &e:v)printf("%d %d %d\n",e.first.first,e.first.second,e.second);
			exit(0);
		}
	}
	if(s<(N-d)*5 || (N-d)*pattern[pat].first.first<s)return;
	for(;pat<pattern.size();pat++,y=x=0)if(pattern[pat].first.first<=s){
		for(;y<=10-pattern[pat].second.size();y++,x=0){
			for(;x<=10-pattern[pat].second[0].size();x++){
				for(int dy=0;dy<pattern[pat].second.size();dy++){
					for(int dx=0;dx<pattern[pat].second[0].size();dx++){
						if(m[y+dy][x+dx]<pattern[pat].second[dy][dx])goto fail;
					}
				}
				for(int dy=0;dy<pattern[pat].second.size();dy++){
					for(int dx=0;dx<pattern[pat].second[0].size();dx++){
						m[y+dy][x+dx]-=pattern[pat].second[dy][dx];
					}
				}
				v[d]=make_pair(
					make_pair(x+pattern[pat].second[0].size()/2,y+pattern[pat].second.size()/2),
					pattern[pat].first.second
				);
				dfs(pat,y,x,N,d+1,s-pattern[pat].first.first);
				for(int dy=0;dy<pattern[pat].second.size();dy++){
					for(int dx=0;dx<pattern[pat].second[0].size();dx++){
						m[y+dy][x+dx]+=pattern[pat].second[dy][dx];
					}
				}
				fail:;
			}
		}
	}
}

int main(){
	int N,y,x,s=0,z;
	scanf("%d",&N);
	for(y=0;y<10;y++){
		m[y].resize(10);
		for(x=0;x<10;x++)scanf("%d",&m[y][x]),s+=m[y][x];
	}
	v.resize(N);
	dfs(0,0,0,N,0,s);
}

Measured memory_bytes: 1044
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main(){
  int H, W;


  while(cin>>H>>W && H!=0 && W!=0){
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        cout<<"#";
        }
        cout<<endl;
      }
      cout<<endl;
    }
}

Measured memory_bytes: 3096
n,k=map(int,input().split())
a=list(map(int, input().split()))
iti=1
count=0
sokuseki=[0]*n
while True:
    iti=a[iti-1]
    count+=1
    if sokuseki[iti-1]:
        m,r=divmod(k-count,count-sokuseki[iti-1])
        count+=(count-sokuseki[iti-1])*m
    sokuseki[iti-1]+=count
    if count==k:
        print(iti)
        exit()

Measured memory_bytes: 32380
#include <bits/stdc++.h> 
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    long long q(1);//cin>>q;
    while(q--){
        char a;cin>>a;
        cout<<(char)(a+1);
    }
    return 0;
}

Measured memory_bytes: 3608
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())

for i in range(n):
    some_input = list(map(str, input().split()))
    if some_input[0] == 'S':
        cards[0][int(some_input[1]) - 1] = True
    elif some_input[0] == 'H':
        cards[1][int(some_input[1]) - 1] = True
    elif some_input[0] == 'C':
        cards[2][int(some_input[1]) - 1] = True
    else:
        cards[3][int(some_input[1]) - 1] = True

for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)


Measured memory_bytes: 5612
import java.io.BufferedInputStream


const val YES = "Yes"
const val NO = "No"

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    fun iterateTokens(): Iterator<String> {
        val reader = BufferedInputStream(System.`in`).bufferedReader()
        val iterator = reader.lineSequence()
                .map { it.split(" ") }
                .reduce { left, right -> left + right }
                .iterator()
        return iterator
    }
    val N = readLine()!!.toLong()
    val AB = Array<Pair<Long, Long>>(N.toInt(), {
        val (a, b) = readLine()!!.split(" ").map{ it.toLong() }
        Pair(a, b)
    })
    solve(N, AB)
}

fun solve(N: Long, AB: Array<Pair<Long, Long>>){
    val n = N.toInt()
    val ab = AB.sortedBy{ it.second }
    var time = 0L
    for ( i in 0 until n){
        time += ab[i].first
        if (time > ab[i].second){
            println(NO)
            return
        }
    }
    println(YES)
    return
}



Measured memory_bytes: 135712
#include <iostream>

int main() {
  std::string s;
  std::cin >> s;
  std::string ans = "AKIHABARA";
  auto p = s.begin();
  auto q = ans.begin();
  while (p < s.end() && q < ans.end()) {
    if (*p == *q) {
      ++p;
      ++q;
    } else if (*q == 'A') {
      ++q;
    } else {
      std::cout << "NO" << std::endl;
      return 0;
    }
  }
  if (q == ans.end() && p == s.end()) {
    std::cout << "YES" << std::endl;
  } else if (q < ans.end() && *q == 'A' && q + 1 == ans.end()) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int nxt[100005][17];
int N , L , Q;
int x[100005];
int main()
{
	//freopen("In.txt" , "r" , stdin);
	ios_base::sync_with_stdio(0);
	cin >> N;
	for(int i = 0; i < N; i++)
		cin >> x[i];
	cin >> L >> Q;
	for(int i = 0; i < N; i++)
		nxt[i][0] = (upper_bound(x , x + N , x[i] + L) - x) - 1;
	for(int i = 1; i <= 16; i++)
	{
		for(int j = 0; j < N; j++)
		{
			nxt[j][i] = nxt[nxt[j][i - 1]][i - 1];
		}
	}
	while(Q--)
	{
		int a , b;
		cin >> a >> b;
		a--;b--;
		if(a > b)
			swap(a , b);
		int ans = 0;
		for(int i = 16; i >= 0; i--)
		{
			if(nxt[a][i] < b)
			{
				ans += (1 << i);
				a = nxt[a][i];
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}


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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans = N / (A + B) * A;
  N %= A + B;
  if (N > A)
    ans += A;
  else
    ans += N;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,sum[1000],aum,aumi,x,z,n,m,a[1000],b,k;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d",&b);
			for(j=1;j<=n;j++){
				if(a[j]<=b){
				break;
			}
		}
		sum[j]++;
	}
	aum=-1;
	for(i=1;i<=n;i++){
		if(aum<sum[i]){
			aum=sum[i];
			aumi=i;
		}
	}
	printf("%d\n",aumi);
	return 0;
}


Measured memory_bytes: 2132
import numpy as np
from functools import *
from decimal import Decimal
import sys
sys.setrecursionlimit(100000)



def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def acinput():
    return list(map(Decimal, input().split(" ")))


a,b=acinput()

print(int(a*b))

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

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

  res = n%k;
  cout << min(res,abs(res-k)) << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string r, g;
  cin >> r >> g;
  
  char tmp = r[0];
  r[0] = r[2];
  r[2] = tmp;

  if(r == g)
  	cout << "YES" << endl;
  else
  	cout << "NO" << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>


int main(){
  	int a,b;
  
  scanf("%d %d",&a,&b);
  
  if((a*b)%2){
  	printf("Odd");
  }else{
  	printf("Even");
  }
  return(0);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<utility>//swapでaとbの値を入れ替える
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
int max(int a, int b) {
	if (a > b)return a;
	return b;
}


int main() {
	ll n, w;
	cin >> n >> w;
	vector<ll> a(n), b(n);
	ll x = 0,y=0;
	rep(i, 0, n) {
		cin >> a[i] >> b[i];
		x += b[i];
		y += a[i];
	}
	vector<vector<ll>> dp(n + 1, vector<ll>(x + 1, y));
	dp[0][0] = 0;
	rep(i, 0, n) {
		rep(j, 0, x + 1) {
			if (j-b[i] >= 0)dp[i + 1][j] = min(dp[i+1][j], dp[i][j-b[i]] + a[i]);
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	ll ans = 0;
	rep(i, 0, x + 1) {
		if (dp[n][i] <= w)ans = i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 80256
# -*- coding: utf-8 -*-
"""
Basic Data Structures - Priority Queue
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_2_C&lang=jp

"""
from heapq import heappop, heappush

n, q = map(int, input().split())
pq = [[] for _ in range(n)]
for _ in range(q):
    op, t, x = (input() + ' 1').split()[:3]
    if op == '0':
        heappush(pq[int(t)], int(x)*-1)
    elif op == '1':
        if pq[int(t)]:
            print(pq[int(t)][0]*-1)
    else:
        if pq[int(t)]:
            heappop(pq[int(t)])



Measured memory_bytes: 13192
#include <bits/stdc++.h>
using namespace std;
long long dp[3001][3001][2];
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    vector<long long> arr(n);
    for (auto &i: arr)
        cin >> i ;
    for (int i=0; i<n; i++)
        for (int r = 0, c = i;  c<n ; r++, c++){
            if (i==0)
                dp[r][c][0] = arr[r];
            else if (i==1)
                dp[r][c][0] = max(arr[r], arr[c]), dp[r][c][1] = min(arr[r], arr[c]);
            else {
                long long first = arr[c]+dp[r][c-1][1], second = arr[r]+dp[r+1][c][1];
                if (first==second)
                    dp[r][c][0] = first, dp[r][c][1] = max(dp[r+1][c][0], dp[r][c-1][0]);
                else if (first>second)
                    dp[r][c][0] = first, dp[r][c][1] = dp[r][c-1][0];
                else dp[r][c][0] = second, dp[r][c][1] = dp[r+1][c][0];
            }
        }
    cout << dp[0][n-1][0]-dp[0][n-1][1] << "\n";
}

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

int main() {

  long long int n;
  string s;
  cin >> n >> s;

  long long int r = 0;
  long long int b = 0;

  for ( long long int i = 0; i < n; i++ ) {
    if ( s[i] == 'R' ) r++;
    if ( s[i] == 'B' ) b++;
  }

  if ( r > b ) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int m,f,r;
		int x[][] = new int[51][3];
		int i = 0;
		while(true){
			m = stdIn.nextInt();
			f = stdIn.nextInt();
			r = stdIn.nextInt();
			if ((m==-1)&&(f==-1)&&(r==-1)) {
				break;
			} else {
				x[i][0] = m;
				x[i][1] = f;
				x[i][2] = r;
				i++;
			}
		}
		stdIn.close();
		for(int j=0;j<i; j++) {
			//中間試験、期末試験のいずれかを欠席した場合成績は F。
			if(x[j][0]==-1 ||x[j][1]==-1) {
				System.out.println("F");
			//中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
			} else if((x[j][0] + x[j][1]) >=80) {
				System.out.println("A");
			//中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
			} else if((x[j][0] + x[j][1]) >=65) {
				System.out.println("B");
			//中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
			} else if((x[j][0] + x[j][1]) >=50) {
				System.out.println("C");
			//中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
			} else if((x[j][2]) >=50) {
				System.out.println("C");
			} else if((x[j][0] + x[j][1]) >=30) {
				System.out.println("D");
			} else {
			//中間試験と期末試験の合計点数が 30 未満ならば成績は F。
				System.out.println("F");
			}
		}
	}
}



Measured memory_bytes: 26288
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	char s[300005];
	scanf("%s", s);
	int i;
	int e[300005], w[300005];
	w[0] = 0;
	for (i = 0;i < n;i++)
	{
		if (s[i] == 'W')
			w[i + 1] = w[i] + 1;
		else
			w[i + 1] = w[i];
	}
	e[n] = 0;
	for (i = n - 1;i >= 0;i--)
	{
		if (s[i] == 'E')
			e[i] = e[i + 1] + 1;
		else
			e[i] = e[i + 1];
	}
	int ans = 500005;
	for (i = 0;i < n;i++)
		if (ans > w[i] + e[i + 1])
			ans = w[i] + e[i + 1];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int main(){
	int a,b,c,d,n,x;
	while(cin >> n){
		x=0;
		for(a=0;a<10;a++)
		for(b=0;b<10;b++)
		for(c=0;c<10;c++)
		for(d=0;d<10;d++)
		if(a+b+c+d==n) x++;
		
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: "List[int]", B: "List[int]"):
    ab = [[A[i],B[i]] for i in range(N)]

    t = 0
    ab = sorted(ab, key=lambda x:x[1])
    for i in range(N):
        t += ab[i][0]
        if(t > ab[i][1]):
            print(NO)
            exit()
        
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int()] * (N)  # type: "List[int]" 
    B = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 42756
import java.util.Scanner;

public class Main {
    int[] as;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        as = new int[4];
        String s = sc.nextLine();
        char[] cs = s.toCharArray();
        for (int i = 0; i < 4; i++) {
            as[i] = cs[i] - '0';
        }
    }

    private void solve() {
        StringBuilder sb = new StringBuilder();
        char[][] ops = {
                {'+', '+', '+'},
                {'+', '+', '-'},
                {'+', '-', '+'},
                {'+', '-', '-'},
                {'-', '+', '+'},
                {'-', '+', '-'},
                {'-', '-', '+'},
                {'-', '-', '-'}
        };
        int[] ans = new int[8];
        for (int i = 0; i < 8; i++) {
            char[] op = ops[i];
            int ret = as[0];
            for (int j = 1; j < 4; j++) {
                if (op[j-1] == '+') {
                    ret += as[j];
                }
                else {
                    ret -= as[j];
                }
            }
            if (ret == 7) {
                sb.append(as[0]);
                for (int j = 1; j < 4; j++) {
                    sb.append(op[j-1]);
                    sb.append(as[j]);
                }
                sb.append("=7");
                break;
            }
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const string b = "Brown";
const string a = "Alice";

void solve(long long X, long long Y) {
  if (X + Y <= 1) {
      cout << b << endl;
      return;
  }
  if (abs(X - Y) <= 1) {
      cout << b << endl;
  } else {
      cout << a << endl;
  }
}

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

  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  solve(X, Y);
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll x, y;
	cin >> x >> y;
	ll v = x;

	ll ans = 0;
	while (v <= y) {
		v *= 2;
		ans++;
	}

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


Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            for (int i = 0; i < 5; i++)
            {
                if (x[i] == 0)
                {
                    Console.WriteLine(i + 1);
                    break;
                }
            }
        }
    }
}


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

// 0-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

struct data {
  long long l, r, a;
};

long long n, m;
map<long long, vector<data>> mp;

long long solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    long long l, r, a;
    cin >> l >> r >> a;
    --l, --r;
    mp[r].push_back({l, r, a});
  }

  cout << solve() << endl;
  return 0;
}

long long solve() {
  auto f = [](long long l, long long r) {
    return max(l, r);
  };
  auto g = [](long long l, long long r) { return l + r; };
  auto h = [](long long l, long long r) { return l + r; };
  SegmentTreeLaze<long long, long long> dp(n, f, g, h, 0,
                                           0);
  for(int i = 0; i < n; ++i) {
    dp.update(i, i + 1, dp.query(0, i + 1));
    long long mpsize = mp[i].size();
    for(int j = 0; j < mpsize; ++j)
      dp.update(mp[i][j].l, i + 1, mp[i][j].a);
  }
  return dp.query(0, n);
}


Measured memory_bytes: 32384
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[1005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int sum=0;
	sort(a+1,a+n+1);
	for(int i=n;i>=n-k+1;i--)
	sum+=a[i];
	printf("%d\n",sum);
	return 0;
} 

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll A, B, C, D, E, F;

int main() {
    cin >> A >> B >> C >> D >> E >> F;
    ll ans1 = 0, ans2 = 0;
    double tmp = 0;
    REP(i, 31) REP(j, 31) REP(k, 101) REP(l, 101) {
        ll sum = A * i * 100 + B * j * 100 + C * k + D * l;
        if(sum > F) continue;
        if(C * k + D * l > (A * i + B * j) * E || C * k + D * l > (F - A * i * 100 - B * j * 100))
            continue;
        double den = ((double)C * k + D * l) / (double)sum;
        if(den >= tmp) {
            tmp = den;
            ans1 = sum;
            ans2 = C * k + D * l;
        }
    }
    cout << ans1 << " " << ans2 << "\n";
}

Measured memory_bytes: 256
s=input()
t=input()
n=len(s)
m=len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])
ans=''
a=n
b=m
while a>0 and b>0:
  if dp[a][b]==dp[a-1][b]:
    a-=1
  elif dp[a][b]==dp[a][b-1]:
    b-=1
  else:
    a-=1
    b-=1
    ans=s[a]+ans
print(ans)

Measured memory_bytes: 119772
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin >> A[i];

	int sum = 0;
	for(int i=0; i<N; i++) sum += A[i];

	int diff = abs(sum-N*A[0]);
	int idx = 0;
	for(int i=1; i<N; i++) {
		int d = abs(sum-N*A[i]);
		debug(i, d);
		if(d < diff){
			diff = d;
			idx = i;
		}
	}

	cout << idx << endl;

	return 0;
}


Measured memory_bytes: 256