akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n;
    while(cin>>n){
        int dp[3][n];
        memset(dp, 0, sizeof dp);

        vvi act(3, vi(n));

        int a,b,c;
        for(int i=0; i<n; i++){
            cin>>act[0][i]>>act[1][i]>>act[2][i];
        }

        for(int i=0; i<3; i++)
            dp[i][0] = act[i][0];

        for(int i=1; i<n; i++){
            for(int ac=0; ac<3; ac++){
                if(ac==0)
                    dp[ac][i] = act[ac][i] + max(dp[1][i-1], dp[2][i-1]);
                else if(ac==1)
                    dp[ac][i] = act[ac][i] + max(dp[0][i-1], dp[2][i-1]);
                else if(ac=2)
                    dp[ac][i] = act[ac][i] + max(dp[0][i-1], dp[1][i-1]);
            }
        }

        cout<<max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1]))<<endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<string> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	for (int p = 0; p < n - m + 1; ++p) {
		for (int i = 0; i < n; ++i) {
			bool elf = true;
			for (int j = p; j < m + p; ++j) {
				if (a[j].substr(0, m) != b[j - p]) elf = false;
			}
			if (elf) {
				puts("Yes");
				return 0;
			}
			rep(k, n) rotate(a[k].begin(), a[k].begin() + 1, a[k].end());
		}
	}

	puts("No");

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

using bs=bitset<2000>;

int N;
// r l            l r
bs leftwin[2000],rightwin[2000];
bs G[2000];
signed main(){
    cin>>N;
    for(int i=1;i<N;i++){
        string s;cin>>s;
        for(int j=0;j<i;j++){
            if(s[j]=='1')G[i][j]=1;
            else G[j][i]=1;
        }
    }


    for(int i=0;i<N;i++)leftwin[i][i]=rightwin[i][i]=1;
    for(int len=2;len<=N;len++){
        for(int i=0;i+len<=N;i++){
            int j=i+len-1;

            if((rightwin[i+1]&leftwin[j]&G[i]).count())leftwin[j][i]=1;
            if((rightwin[i]&leftwin[j-1]&G[j]).count())rightwin[i][j]=1;
        }
    }

    cout<<(rightwin[0]&leftwin[N-1]).count()<<endl;
    return 0;
}

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

int main(){
    int r,c, sum=0;
    cin>>r>>c;
    vector<vector<int>> hyou(r+1, vector<int>(c+1) );
    rep(i,r){
        sum=0;
        rep(j,c){
            cin>>hyou[i][j];
            sum+=hyou[i][j];
            
        }
        hyou[i][c]=sum;
    }
    rep(i,c+1){
        sum=0;
        rep(j, r){
            sum+=hyou[j][i];
        }
        hyou[r][i]=sum;
    }
    
    rep(i,r+1){
        rep(j,c+1){
            if(j==c) cout<<hyou[i][j];
            else cout<<hyou[i][j]<<" ";
        }
        cout<<endl;
    }
    
    
    
}


Measured memory_bytes: 3164
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define N 100005
vi par(N);
vi unionrank(N);
void init(int n)
{
    rep(i, n)
    {
        par[i] = i;
        unionrank[i] = 0;
    }
}
int root(int x)
{
    if (par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = root(par[x]);
    }
}
void unite(int x, int y)
{
    x = root(x);
    y = root(y);
    if (x == y)
    {
        return;
    }
    if (unionrank[x] < unionrank[y])
    {
        par[x] = y;
    }
    else
    {
        par[y] = x;
        if (unionrank[x] == unionrank[y])
        {
            unionrank[x]++;
        }
    }
}
bool same(int x, int y)
{
    return root(x) == root(y);
}
int main()
{
    int n, m;
    cin >> n >> m;
    init(n);
    vi a(n);
    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
    }
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        unite(a, b);
    }
    int ans = 0;
    rep(i, n)
    {
        if(a[i]==i){
            ans++;
        }
        else{
            if(same(a[i],i)){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define F 	first
#define S 	second


int main() {
	int N, W;
	int w[110], v[110];
	ll dp[2][100010];
	int curr = 0, prev = 1;

	scanf("%d%d", &N, &W);
	for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

	for (int i = 0; i <= W; i++)
		dp[curr][i] = i >= w[0]? v[0] : 0;

	for (int i = 1; i < N; i++) {
		swap(curr, prev);
		for (int j = 0; j <= W; j++) {
			dp[curr][j] = j < w[i]? dp[prev][j] : max(dp[prev][j], 
									dp[prev][j - w[i]] + (ll) v[i]);
		}
	}

	cout << dp[curr][W] << '\n';
	return 0;
}

Measured memory_bytes: 1792
#!python3

from collections import defaultdict

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())

    ans = 0
    dp = [0]*N
    for i, ai in enumerate(A):
        x = i + ai
        if x < N:
            dp[x] += 1
        x = i - ai
        if x >= 0:
            ans += dp[x]

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 33908
#include<bits/stdc++.h>
using namespace std;
int a[300000],A[300000];
int main(void)
{
	int n,q,x,y;
	int i;
	int cnt;
	int w;
	int s;
	
	
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		A[i]=a[i];
	}
	
	sort(A,A+n);
	cnt=0;
	for(i=0;i<n;i++){
		if(a[i]==A[i]) cnt++;
	}
	if(cnt==n){
		cout<<0<<endl;
		return  0;
	}
	
	cin>>q;
	for(i=0;i<q;i++){
		cin>>x>>y;
		
		x--; y--;
		
			if(a[x]==A[x]) cnt--;
			if(a[y]==A[y]) cnt--;
			swap(a[x],a[y]);
			if(a[x]==A[x]) cnt++;
			if(a[y]==A[y]) cnt++;
			if(cnt==n){
				cout<<i+1<<endl;
				return 0;
			}
		
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 5520
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
typedef long long int ll;
#define FOR(i,a,n) for(int i=a;i<n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
#define pos std::pair<int,int>
const int INF = 1LL << 30;
const int INF_ = 0 - INF;
const ll LLINF = 1LL << 60;
int main() {
	int a, b, c, d, e;
	char s,s2;
	std::cin >> s>>s2;
	if (s < s2)std::cout << "<" << std::endl;
	else if (s == s2)std::cout << "=" << std::endl;
	else std::cout << ">" << std::endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int dp[100][1000];
int main(){
    int a,b,c;
    int n;
    int ax[1000],bx[1000],cx[1000],r[1000];
    int w[500];
    while(true){
    for(int i=0;i<500;i++)
        w[i]=2;
    cin>>a>>b>>c;
    if(a==0&&b==0&&c==0)
        break;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ax[i]>>bx[i]>>cx[i]>>r[i];
    for(int i=0;i<n;i++){
        if(r[i]==1){
            w[ax[i]-1]=1;
            w[bx[i]-1]=1;
            w[cx[i]-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        if(r[i]==0){
            if(w[ax[i]-1]==1&&w[bx[i]-1]==1&&w[cx[i]-1]!=1)
                w[cx[i]-1]=0;
            if(w[ax[i]-1]==1&&w[cx[i]-1]==1&&w[bx[i]-1]!=1)
                w[bx[i]-1]=0;
            if(w[bx[i]-1]==1&&w[cx[i]-1]==1&&w[ax[i]-1]!=1)
                w[ax[i]-1]=0;
        }
    }
    for(int i=0;i<a+b+c;i++)
        cout<<w[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1176
import sys
for e in sys.stdin:
 for i in'0123456789'[(e[0]=='X')*(e[1]!='+')or('+X'in e)*('+X='not in e):]:
  l,r=e.replace('X',i).split('=')
  if eval(l)==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5620
#include <cstdio>
#include <iostream>
using namespace std;
int x,y,z;
int main()
{
    scanf("%d%d%d",&x,&y,&z);
    swap(x,y);
    swap(x,z);
    printf("%d %d %d\n",x,y,z);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
// #include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <chrono>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr ll LL2_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = { { typeid(int), "%d" },
{ typeid(ll), "%lld" },
{ typeid(double), "%lf" },
{ typeid(char), "%c" } };

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
// static boost::dynamic_bitset<> scan(char trueValue = 'o');

int main(int argc, char *argv[]) {
	 //INFILE();
	 
	ll a, b, c;
	cin >> a >> b >> c;

	cout << (a * b) / 2 << endl;
	return 0;
}

template <class T> static void scan(vector<T> &v) {
	auto tFormat = scanType[typeid(T)];
	for (T &n : v) {
		scanf(tFormat, &n);
	}
}

static void scan(vector<string> &v, bool isWord) {
	if (isWord) {
		for (auto &n : v) {
			cin >> n;
		}
		return;
	}

	int i = 0, size = static_cast<int>(v.size());
	string s;
	getline(cin, s);

	if (s.size() != 0) {
		i++;
		v[0] = s;
	}

	for (; i < size; ++i) {
		getline(cin, v[i]);
	}
}

//static boost::dynamic_bitset<> scan(char trueValue) {
//	string s;
//	getline(cin, s);
//
//	if (s.size() == 0) {
//		getline(cin, s);
//	}
//
//	for_each(begin(s), end(s),
//		[trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
//	return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
//}


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

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a/g * b;
}

void solve(){
    ll n, m; cin >> n >> m;
    string s, t;
    cin >> s;
    cin >> t;

    if(s[0] != t[0]) cout << -1 << endl;
    else{
        ll l = lcm(n, m);
        ll g = gcd(n, m);
        ll i = 0;
        bool flag = true;
        while(i*n/g < n && i*m/g < m){
            if(s[i*n/g] != t[i*m/g]) flag = false;
            i++;
        }
        if(flag) cout << l << endl;
        else cout << -1 << endl;
    }

}

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

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

#define IS_DEBUG true

#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl

void sortIncrease(vector<int> &array);
void sortDecrease(vector<int> &array);

int main()
{
  int N;
  cin >> N;
  vector<int> A;
  int sumA = 0;
  int sumB = 0;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sortDecrease(A);
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
      sumA += A[i];
    else
      sumB += A[i];
  }
  RESULT_OUTPUT(sumA - sumB);
  
  
  if (IS_DEBUG)
  {
    int end;
    cin >> end;
  }
  return 0;
}

void sortIncrease(vector<int> &array)
{
  int size = array.size();
  for(int i = 0; i < size; i++)
  {
    for(int j = i + 1; j < size; j++)
    {
      if(array[i] > array[j])
      {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
      }
    }
  }
}

void sortDecrease(vector<int> &array)
{
  int size = array.size();
  for(int i = 0; i < size; i++)
  {
    for(int j = i + 1; j < size; j++)
    {
      if(array[i] < array[j])
      {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int H,W,N;
	cin>>H>>W>>N;
	
	int k = max(H,W);
	
	cout<<(N+k-1)/k<<endl;
	
	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<list>

int main(){
    std::list <int> List{};
    int q;
    int inst1,inst2;
    std::list<int>::iterator it = List.end();//カーソルが一番後ろってやつ?

    std::cin>>q;
    
    for(int i=0;i<q;i++){
        std::cin>>inst1;
        switch (inst1){
            case 0:{//insert
                std::cin>>inst2;
                it=List.insert(it,inst2);//iteratorで値を挿入。itに要素がinst2のものを格納
                break;
            }
            case 1:{//moveカーソルを後方にdだけ移動させる
                std::cin>>inst2;
                std::advance(it,inst2);//iteartor itの参照をinst2 回おこなう
                break;
            }
            case 2:{//erase
                it = List.erase(it);//eraceで削除された次の要素を指す。そのようなものがない場合end()を返す
                break;
            }
        }
    }

    for(int i:List)
        std::cout<< i<< std::endl;
    return 0;
}


Measured memory_bytes: 18564
#include <bits/stdc++.h>
using namespace std;
int a[100];

int main() {
	int n, sum = 0;
	cin>>n;
 	for(int i=0;i<n;i++)cin>>a[i];
 	for(int i=0;i<n-1;i++)
    	for(int j=i+1;j<n;j++) {
        	sum += (a[i] * a[j]);
        }
    printf("%d\n", sum);
}

Measured memory_bytes: 256
var n,h,next,i,count,max:int64;
begin
read(n);
read(h);
max:=0;
for i := 1 to n-1 do
begin
read(next);
if h>=next then inc(count)
else 
begin 
 if max <= count then max:=count;
 count:=0;
end;
h:=next
end;
if count >= max then max:=count;
write(max)
end.

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

using namespace std ;

const int MAX = 7 ;

char arr[MAX][MAX] ;
int n , m , k ;

int ans = 0 ;

void solve2(int idx , int mask2 , int mask)
{
	if(idx == m)
	{
		int cnt = 0 ;
		for(int i = 0 ; i < n ; ++i)
		{
			if((mask & (1 << i)))
				continue ;
			for(int j = 0 ; j < m ; ++j)
			{
				if((mask2 & (1 << j)))
					continue ;
				cnt += (arr[i][j] == '#') ;
			}
		}
		if(cnt == k)
			ans++ ;
		return ;
	}
	solve2(idx+1 , mask2 , mask) ;
	solve2(idx+1 , mask2 | (1 << idx) , mask) ;
}

void solve1(int idx , int mask)
{
	if(idx == n)
	{
		solve2(0 , 0 , mask) ;
		return ;
	}
	solve1(idx+1 , mask) ;
	solve1(idx+1 , mask | (1 << idx)) ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>k ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = 0 ; j < m ; ++j)
			cin>>arr[i][j] ;
	}
	solve1(0 , 0) ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}



int main(){
    string s;
    cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '1') ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    def update(self, k, x):
        k += self.N0 - 1
        ################################################################
        self.data[k] = x
        ################################################################
        while k:
            k = (k - 1) // 2
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    def query(self, left, right):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        ################################################################
        
        while L < R:
            if L & 1:
                res = self.segfunc(res, self.data[L - 1])
                L += 1
            if R & 1:
                R -= 1
                res = self.segfunc(res, self.data[R - 1])
            L >>= 1
            R >>= 1
        
        ################################################################
        return res


def solve():
    N = int(rl())
    h = list(map(int, rl().split()))
    a = list(map(int, rl().split()))
    
    dp = [0] * (N + 1)
    seg_tree = SegmentTree(dp, max, 0)
    for i in range(N):
        hi = h[i]
        seg_tree.update(hi, seg_tree.query(0, hi) + a[i])
    ans = seg_tree.query(0, N + 2)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 112380
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	int i,j,n,f;
	string s1,s2;

	cin>>n;
	
	while(n--){
		cin>>s1>>s2; f=0;
		if(s1.size()<s2.size())swap(s1,s2);

		for(i=0;i<s2.size();i++){s1[i+s1.size()-s2.size()]+=s2[i]-'0';}

		for(i=s1.size()-1;i>0;i--){
			if(s1[i]>'9'){s1[i]-=10; s1[i-1]++;}
		}

		if(s1[0]>'9'){s1[0]-=10;f++;}

		if(s1.size()+f<=80){
			if(f) cout<<"1";
			cout<<s1;
		}
		else cout<<"overflow";

		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
S=input()
N=len(S)+1
cnt=0

# 「<」 がここから左に何個連続しているか
small_left=[1 if S[0]=="<" else 0]
# 「>」 がここから右に何個連続しているか
large_right=[1 if S[-1]==">" else 0]

for i in range(1,len(S)):
  if S[i]=="<":
    small_left.append(small_left[-1]+1) 
  else:
    small_left.append(0) 
    
for i in range(len(S)-2,-1,-1):
  if S[i]==">":
    large_right.append(large_right[-1]+1) 
  else:
    large_right.append(0) 
large_right = large_right[::-1]
#print(large_right,small_left)

cnt += large_right[0]
for i in range(1,N-1):
  cnt += max(large_right[i], small_left[i-1])
cnt += small_left[-1]

print(cnt)

Measured memory_bytes: 31900
package main

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

func main() {
	fsc := NewFastScanner()
	X, T := fsc.NextInt(), fsc.NextInt()
	res := IntMax(0, X-T)
	fmt.Println(res)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
 

n = int(input())
tmp=input()
a = int(tmp.split(" ")[0])
b = int(tmp.split(" ")[1])
tmp=input()
p=[int(k) for k in tmp.split()]
p.sort()
x=[0,0,0]

j=int(len(p))
k=0
for k in range(j):
    if p[k]>a:
        break
x[0]=k

p.reverse()
k=0
for k in range(j):
    if p[k]<=b:
        break
x[2]=k
x[1]=j-x[0]-x[2]

print(min(x))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b;
  cin >> a;
  cin >>b;
  
  if(a<=b){
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
  
   return 0;
}


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

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

  int N, M;
  cin >> N >> M;

  vector<tuple<int, int, int>> YPi(M);
  for (int i = 0; i < M; i++) {
    int P, Y;
    cin >> P >> Y;
    YPi.at(i) = make_tuple(Y, P, i);
  }

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

  vector<int> cnt(N + 1, 1);

  vector<pair<int, int>> ans(M);
  for (int i = 0; i < M; i++) {
    ans.at(get<2>(YPi.at(i))) = make_pair(get<1>(YPi.at(i)), cnt.at(get<1>(YPi.at(i)))++);
  }

  for (int i = 0; i < M; i++) {
    cout << setw(6) << setfill('0') << ans.at(i).first;
    cout << setw(6) << setfill('0') << ans.at(i).second << endl;
  }
}

Measured memory_bytes: 3840
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        m: i64,
        a: [String; m],
    }
    let mut ans = n;
    for ai in a.iter() {
        ans = ans - ai.parse::<i64>().unwrap();
    }
    if ans < 0 {
        println!("-1")
    } else {
        println!("{:?}", ans)
    }
}


Measured memory_bytes: 2492
n = int(input())
a = list(map(int, input().split()))
a.sort()
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return (a*b)//gcd(a, b)
llcm = 1
for i in a:
    llcm = lcm(llcm, i)
ans = 0
for i in a:
    ans += (llcm-1)%i
print(ans)

Measured memory_bytes: 9240
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define N 1000000
#define N2 1000
#define N_PRIME 78500

int
main(int argc, char** argv)
{
	bool f[N + 1];
	int prime[N_PRIME];
	int n_prime;
	int n;
	int i, j;

	for (i = 0; i <= N; ++i)
		f[i] = true;

	n_prime = 0;
	for (i = 2; i <= N2; ++i)
	{
		if (f[i])
		{
			prime[n_prime++] = i;
			for(j = i + i; j <= N; j += i)
				f[j] = false;
		}
	}

	for (; i <= N; ++i)
	{
		if (f[i])
			prime[n_prime++] = i;
	}

	while (scanf("%d", &n) != EOF)
	{
		for (i = 0; i < n_prime && prime[i] <= n; ++i)
			;

		printf("%d\n", i);
	}

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  vector<string> vec = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  for(int i = 0; i+1 < vec.size(); i++) {
    if(s == vec.at(i)) {
      cout << vec.at(i+1) << endl;
    }
  }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n, m;
  cin >> n >> m;

  vector<pair<long, long>> arc(n - 1 + m);

  vector<vector<long>> arc_from_node_i(n);
  vector<vector<long>> arc_to_node_i(n);

  vector<long> a(n - 1 + m);
  vector<long> b(n - 1 + m);
  for (int i = 0; i < n - 1 + m; i++) {
    cin >> a[i] >>  b[i];
    a[i]--;
    b[i]--;

    arc_from_node_i[a[i]].push_back(b[i]);
    arc_to_node_i[b[i]].push_back(a[i]);
  }

  for (int i = 0; i < n; i++) {
    cerr << i  + 1 << "  :";
    for (auto v : arc_from_node_i[i] ) {
      cerr << v + 1 << ",";
    } cerr << endl;
  }


  long rootnode = 0;
  for (int i = 0; i < n; i++) {
    if (arc_to_node_i[i].size() == 0)rootnode = i;
  }

  cerr << "root : " << rootnode + 1 << endl;

  vector<long> ans(n, -10);


  // vector<vector<long>> childnode(n);
  // vector<long> lic;

  // for (int i = 0; i < n; i++) {
  //   if (arc_from_node_i[i].size() ==0)lic.push_back(i);
  // }



  ans[rootnode] = -1;



  vector<long> arctt_node_num(n, 0);
  for (int i = 0; i < n; i++) {
    arctt_node_num[i] = arc_to_node_i[i].size();
  }

  vector<long> li;
  for (auto v : arc_from_node_i[rootnode]) {
    if (arctt_node_num[v] == 1) {
      ans[v] = rootnode;
      li.push_back(v);
    } else {
      arctt_node_num[v]--;
    }
  }


  while (li.size() > 0) {
    vector<long> li2;
    for (auto v : li) {
      for (auto i : arc_from_node_i[v]) {
        if (arctt_node_num[i] == 1) {
          ans[i] = v;
          li2.push_back(i);
        } else {
          arctt_node_num[i]--;
        }
      }
    }
    // li = li2;
    li.clear();
    for (auto v : li2) {
      li.push_back(v);
    }
  }


  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << endl;
  }


}




















Measured memory_bytes: 16512
# -*- coding: utf-8 -*-

N = int(input())
str_list = [input() for x in range(N)]
str_sort = sorted(str_list, key=lambda x: int(x.split()[1]), reverse=True)
str_sort2 = sorted(str_sort, key=lambda x: x.split()[0])

for x in str_sort2:
    print(str_list.index(x)+1)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cassert>
#include <ctime>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define all(x) (x).begin(), (x).end()

#ifdef LOCAL
#define dbg(x) cerr << #x " = " << x << endl;
#define idbg(x) #x " = " << x
#include "pretty_print.h"
#else
#define dbg(x)
#define idbg(x) ""
#endif

#ifdef _WIN32
#  define LLD "%I64d"
#else
#  define LLD "%lld"
#endif

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

template <typename T> T sqr(T x) { return x * x; }
template <typename T> T abs(T x) { return x < 0? -x : x; }
template <typename T> T gcd(T a, T b) { return b? gcd(b, a % b) : a; }
template <typename T> bool chmin(T &x, const T& y) { if (x > y) { x = y; return true; } return false; }
template <typename T> bool chmax(T &x, const T& y) { if (x < y) { x = y; return true; } return false; }


int main(int /* argc */, char** /* argv */)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef LOCAL
    assert(freopen("inp", "r", stdin));
    assert(freopen("out", "w", stdout));
    #endif

    int n;
    while (cin >> n && n != -1) {
        n += 1;
        vector<ll> a(n);
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }

        vector<ll> l(n + 1, 0);
        vector<ll> r(n + 1, 0);
        for (int i = n - 1; i >= 0; --i) {
            l[i] = (l[i + 1] + 1) / 2 + a[i];
            r[i] = r[i + 1] + a[i];
        }
        ll x = 1;
        bool ok = l[0] <= x && x <= r[0];
        ll ans = x;
        for (int i = 1; i < n; ++i) {
            x = min(x * 2, r[i]);
            ok &= l[i] <= x;
            ans += x;
            x -= a[i];
        }
        cout << (ok? ans : -1) << endl;
    }

    cerr << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec" << endl;
    return 0;
}


Measured memory_bytes: 5572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int cnt[][][] = new int[5][4][11];
		for(int i=1;i<5;i++) 
			for(int j=1;j<4;j++) 
				for(int k =1;k<11;k++) 
					cnt[i][j][k]=0;
		
		try {
			int N = Integer.parseInt(br.readLine()); 
			String tmp;
			while((tmp = br.readLine()) != null) {
				List<String> line = Arrays.asList(tmp.split("\\s"));
				int b = Integer.parseInt(line.get(0));
				int f = Integer.parseInt(line.get(1));
				int r = Integer.parseInt(line.get(2));
				int v = Integer.parseInt(line.get(3));
				cnt[b][f][r] += v;
				
			}
			br.close();
		}catch(IOException e) {
			e.printStackTrace();
		}

		for(int i=1;i<5;i++) { 
			for(int j=1;j<4;j++) { 
				for(int k =1;k<11;k++) { 
					System.out.printf(" %d", cnt[i][j][k]);
				}
				System.out.print("\n");
			}
			if(i != 4) System.out.print("####################\n");			
		}
					
	}
}



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

int main(){
  int N,T;cin>>N>>T;
  vector<pair<int,int>> A;
  for(int i=0;i<N;i++){
    int c,t;cin>>c>>t;
    A.push_back(make_pair(c,t));
  }
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i).second<=T){
      ans=A.at(i).first;
      break;
    }
  }
  if(ans==0) cout<<"TLE"<<endl;
  else cout<<ans<<endl;
}
    


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    reverse(s.begin(),s.end());
    vector<int> a(n+5);
    rep(i,n)a[i]=s[i]-'0';
    int up=0;
    rep(i,n){
        up=9*a[i]+up;
        a[i]=up%10;
        up/=10;
    }
    if(up)a[n]+=up;;
    int sum=0;
    rep(i,n)sum+=a[i];
    int ans=0;
    while(1){
        int i=0;
        while(a[i]==9){
            sum-=9;
            a[i]=0;
            ++i;
        }
        ++sum;
        ++a[i];
        ++ans;
        if(sum<=ans)break;
    }
    cout<<(ans+8)/9<<endl;

    return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359

int main(){
   int K,A,B;
   cin >> K;
   cin >> A>>B;

   int a = A/K;
   int b = B/K;
   int c = A%K;
   int d = B%K;

   if(b>a)
      cout << "OK" << endl;
   else {
      if(c==0 || d==0){
       cout << "OK" << endl;  
      }

      else {
         cout << "NG" << endl;
      }
   }
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    long long int i,j,k,l,inc,dec,t,r,mod=1000000007;
   	long long int c,d,e,s,ans=0,n,temp,m,p,x,y;
   	//cin>>t;
   	t=1;
   	while(t--)
   	{
   		cin>>n>>k;
   		long long int a[n],dp[n+1];
   		for(i=0;i<n;i++)
   		{
   			cin>>a[i];	
		}
		dp[0]=0;
		dp[1]=0;
		if(n>=2)
		dp[2]=abs(a[1]-a[0]);
		for(i=3;i<=n;i++)
		{
			dp[i]=INT_MAX;
			for(j=i-2;j>=0 && i-1-j<=k;j--)
			{
				dp[i]=min(dp[i],abs(a[i-1]-a[j])+dp[j+1]);
			}
			//dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2]);
		}
		cout<<dp[n]<<endl;
	}
   	
	
   return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
int main (void) {
    char ch[101];
    int abc[26]={};
    cin >> ch;
    for(int i=0;ch[i]!='\0';i++){
        abc[int(ch[i]-'a')]++;
    }
    for(int i=0;i<26;i++){
        if(abc[i]%2==1){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int num[11];

int main(){
	string s;
	while(cin >> s && s != "0"){
		for(int i = 0;i < 11; i++) num[i] = 0;
		int count = 0;
		for(int i = 0; i < s.size(); i++){
			int n[11];
			for(int j = 0; j < 11; j++) n[j] = 0;
			for(int j = 0; j < 11; j++){
				n[(j*10+(s[i]-'0'))%11] = num[j];
			}
			for(int j = 0; j < 11; j++){
				num[j] = n[j];
			}
			count += num[0];
			if(s[i] != '0') num[s[i] - '0']++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, ans=0;
	cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin >>a[i];
		while(a[i]%2==0)
		{
			ans++;
			a[i]/=2;
		}
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
ll k;
int n;
vector<ll> a;
vector<ll> f;
vector<pair<ll,ll>> p;
bool C(ll x){
  ll sum=0;
  rep(i,n){
    sum += max(p[i].first-x+p[i].second-1,(ll)0)/p[i].second;
  }
  return sum<=k;
}
ll upper(ll l,ll r){//条件を満たす中で最小のものを返す
  ll lb=l-1,ub=r+1;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    if(C(mid)) ub=mid;
    else lb=mid;
  }
  return ub;
}



int main()
{
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];  

  sort(a.begin(), a.end());
  sort(f.begin(), f.end());

  p.resize(n);
  rep(i,n){
    p[i]=make_pair(a[i]*f[n-i-1],f[n-i-1]);
  }

  ll inf=1e+12;
  cout << upper(0,inf) << "\n";
  
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    switch (N%10)
    {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
            break;
    }
}

Measured memory_bytes: 3584
#include <stdio.h>

#define MAX_N 20
#define MAX_B 50
#define MAX_C 50

int main(void) {
    int n;
    int as[MAX_N];
    int bs[MAX_B];
    int cs[MAX_C];

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        as[i] = x;
    }

    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        bs[i] = x;
    }

    for (int i = 0; i < n - 1; i++) {
        int x;
        scanf("%d", &x);
        cs[i] = x;
    }

    // first dish
    int prev = as[0];
    int score = bs[prev - 1];

    for (int i = 1; i < n; i++) {
        int current = as[i];
        score += bs[current - 1];
        if (current == prev + 1) {
            score += cs[prev - 1];
        }
        prev = current;
    }

    printf("%d\n", score);

    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

template <class T, class S>
using umap = std::unordered_map<T, S>;
using ll = long long;
using namespace std;

int main() {
    
    string s;

    cin >> s;

    if(s=="AAA" || s=="BBB"){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
/*
1
0
2
*/
int main()
{
    cr7
#ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif
    ll n, m;
    cin >> n >> m;
    ll h[n + 1] = {0};
    for (ll i = 1; i <= n; ++i) cin >> h[i];
    map<ll, vector<ll> > mp;
    for (ll i = 0; i < m; ++i) {
        ll arr1, arr2;
        cin >> arr1 >> arr2;
        mp[arr1].eb(arr2);
        mp[arr2].eb(arr1);
    }
    ll cnt = n;
    for (auto it : mp) {
        for (ll i = 0; i < it.second.size(); ++i) {
            if (h[it.first] <= h[it.second[i]]) {
                cnt--;
                break;
            }
        }
    }
    cout << cnt << "\n";
    return 0;
}

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


int main() {

    int n, m;

    cin >> n >> m;

    vector<int> v(n, -1);
    bool isTrue = true;

    for(int i = 0; i < m; ++i) {

        int k, num;
        cin >> k >> num;
        k--;

        if(v[k] != num && v[k] != -1)
            isTrue = false;
        

        v[k] = num;

        if(v[0] == 0 && n != 1)
            isTrue = false;

    }

    if(isTrue == false) {
        cout << "-1" << endl;
        return 0;
    }

    if(n == 1 && m == 0)
        v[0] = 0;

    for(int i = 0; i < n; ++i) {
        if(i == 0 && v[i] == -1) {
            cout << 1;
            continue;
        }

        if(v[i] == -1)
            cout << 0;
        else
            cout << v[i];
    
    }

    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll each[N];

void brute(int n) {
    for (int i = 1; i <= n; i++) {
        set<int> s;
        for (int mask = 0; mask < (1 << n); mask++) {
            if (__builtin_popcount(mask) != i) {
                continue;
            }
            int sum = 0;
            for (int j = 0; j < n; j++) {
                if (mask & (1 << j)) sum += (j + 1);
            }
            s.insert(sum);
        }
        cout << "PICK " << i << " out of " << n << " : " << s.size() << endl;
    }
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    ll n, k;
    cin >> n >> k;
//    brute(n);
    n++;
    int half = n / 2;
    each[1] = n;
    for (ll i = 2, x = n - 3; i <= half; i++, x -= 2) {
        each[i] = (each[i - 1] + x) % MOD;
    }
    each[n] = 1;
    ll x = 1, y = n - 1;
    while (x <= y) {
        each[y] = each[x];
        x++, y--;
    }
//    for (int i = 1; i <= n; i++) {
//        cout << each[i] << endl;
//    }
    ll ans = 0;
    for (int i = k; i <= n; i++) {
        ans += each[i];
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5084
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
using namespace std;

int N;
vector<vector<int>> to, weight;

const int INIT = -1;
vector<int> color;

void dfs(int pos)
{
    for (int i = 0; i < (int)to[pos].size(); i++) {
        int dst = to[pos][i];
        if (color[dst] != INIT)
            continue;

        color[dst] = color[pos] + weight[pos][i];
        color[dst] %= 2;

        dfs(dst);
    }
}

int main(void)
{
    cin >> N;

    to = vector<vector<int>>(N, vector<int>());
    weight = vector<vector<int>>(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;

        u--;
        v--;
        w %= 2;

        to[u].push_back(v);
        weight[u].push_back(w);

        to[v].push_back(u);
        weight[v].push_back(w);
    }

    
    color = vector<int>(N, INIT);
    color[0] = 0;

    //queue<int> task;
    //task.push(0);

    //while (task.empty() != true) {
    //    int src = task.front();
    //    task.pop();

    //    for (int i = 0; i < (int)to[src].size(); i++) {
    //        int dst = to[src][i];
    //        if (color[dst] != INIT)
    //            continue;

    //        color[dst] = (color[src] + weight[src][i]) % 2;

    //        task.push(dst);
    //    }
    //}

    dfs(0);

    for (int i = 0; i < N; i++)
        cout << color[i] << endl;

    return 0;
}


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

int main () {
  string s, t;
  cin >> s >> t;
  
  int counter = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

int main() {
  string s,t,u;
  int a,b;

  cin >> s >> t >> a >> b >> u;

  if(s == u)
    --a;

  if(t == u)
    --b;

  cout << a << " " << b;
  return 0;
}


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

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a % b);
}

int main(void){
    long long lcm, a, b, c, d, b_c, b_d, b_cd, b_tmp, a_c, a_d, a_cd, a_tmp, tmp, r = 0;
    cin >> a >> b >> c >> d;
    lcm = c * d / gcd(d, c);
    b_c = b / c;
    b_d = b / d;
    b_cd = b / lcm;
    b_tmp = b_c + b_d - b_cd;
    a_c = a / c;
    a_d = a / d;
    a_cd = a / lcm;
    a_tmp = a_c + a_d - a_cd;
    tmp = b_tmp - a_tmp;
    if (a % c == 0 || a % d == 0)
        tmp ++;

    r = b - a + 1  - tmp;



    cout << r << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

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

  ll N; std::cin >> N;
  if ( N % 2 == 1 ) std::cout << 0 << std::endl;
  else {
    ll cnt = 0;
    ll d = 10;
    while( N >= d ) {
      cnt += (N/d);
      d *= 5;
    }
    std::cout << cnt << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384