akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    using namespace std;
     
    #define       pb(a)             push_back((a))
    #define       mp(a,b)           make_pair((a),(b))
    #define       REP(a,b)          for(ll i=(a);i<(b);i++)
    #define       REP2(a,b)         for(ll j=(a);j<(b);j++)
    #define       REPE(a,b,c,d)     REP(a,b)for(ll j=(c);j<(d);j++)
    #define       REPV(a,b,c)       for(ll (a)=b;(a)<(c);(a)++)
    #define       IREP(a,b)         for(ll i=(a);i>=(b);i--)
    #define       IREP2(a,b)        for(ll j=(a);j>=(b);j--)
    #define       IREPV(a,b,c)      for(ll (a)=b;(a)>=(c);(a)--)
    #define       all(v)            (v).begin(),(v).end()
    #define       Trvs(c)           for (auto it = (c).begin(); it != (c).end(); it++)
    #define       INF               INT_MAX
    #define       sz(x)             x.size()
    #define       flash             ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define       F                 first
    #define       S                 second
    #define       MOD               1000000007
     
    using         ll     = long long;
    using         vi     = vector<int>;
    using         vvi    = vector<vi>;
    using         vll    = vector<ll>;
    using         vvll   = vector<vll>;
    using         vb     = vector<bool>;
    using         vd     = vector<double>;
    using         vs     = vector<string>;
    using         pii    = pair<int, int>;
    using         pll    = pair<ll, ll>;
    using         pdd    = pair<double, double>;
    using         vpii   = vector<pii>;
    using         vvpii  = vector<vpii>;
    using         vpll   = vector<pll>;
    using         vvpll  = vector<vpll>;
    using         vpdd   = vector<pdd>;
    using         vvpdd  = vector<vpdd>;
     
     
    ll gcd(ll a,ll b){
    	if(b==0)return a;
    	return gcd(b,a%b);
    }
    ll lcm(ll a,ll b){
     
    	return a*b/gcd(a,b);
    }
     
    ll ceeel(ll n,ll a){
    	if(n%a==0) return n/a;
    	return n/a +1;
    }
    ll power(ll x, ll y){
    	ll ans=1;
    	REP(0,y){
    		ans*=x;
    	}
    	return ans;
    }
     
    void solve(){
    	ll n; cin >> n;
    	vll a(n,0); REP(0,n)cin >> a[i];
    	// REP(0,n)cout<<i<<" - "<<a[i]<<" ";
    	ll mini = a[0];
    	ll ans = 1;
    	REP(1,n){
// cout<<i<< "df"<<endl;
    		if(a[i]<= mini){
    			
    			// cout<<a[i]<<endl;
    			mini = a[i];
    			ans++;
    		}
    	}
    	cout<<ans;

 }
     
     
    	
     
     
    int main(){
     
    	flash
    	
    	
    	
    	//ll t;cin>>t;while(t--)
    	solve();
     
     
    	return 0;
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      
      int n,K;
      cin>>n>>K;
      int a[n+1];      // a[i]= height of stone i
      for(int i=1;i<=n;i++) cin>>a[i];
      int min_cost[n+1]; // min_cost[i] -> minimum cost to reach at position i	
      for(int i=1;i<=n;i++) min_cost[i]=1e9;
      min_cost[1]=0;
      for(int i=2;i<=n;i++)
      {
          for(int k=1;k<=min(i-1,K);k++)
      	  min_cost[i]=min(min_cost[i],min_cost[i-k]+abs(a[i]-a[i-k]));
      }
      
      cout<<min_cost[n]<<endl;	
  }




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int n; cin >> n;
    int d = n%10;
    if(d ==3){
        cout << "bon" << endl;
    }
    else if(d == 0 || d == 1 || d == 6 || d == 8){
        cout << "pon" << endl;
    }
    else cout << "hon" << endl;
}


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

int main() {
    string S;
    cin >> S;

    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
 {
     string S;
     getline(cin,S);
     if(S == "Sunny")
     {
         cout<<"Cloudy"<<endl;
     }
      if(S == "Cloudy")
     {
         cout<<"Rainy"<<endl;
     }
      if(S == "Rainy")
     {
         cout<<"Sunny"<<endl;
     }

     return 0;
 }


Measured memory_bytes: 256
def dfs(u, g, visited):
    # all visited
    if sum(visited) == len(visited):
        return 1

    res = 0
    for v in g[u]:
        if visited[v]:
            continue

        visited[v] = True
        # print("{} -> {}".format(u, v), visited)
        res += dfs(v, g, visited)
        visited[v] = False

    return res


def solve():
    [N, M] = [int(x) for x in input().split()]

    import collections
    g = collections.defaultdict(list)

    for i in range(M):
        a, b = [int(x) for x in input().split()]
        g[a-1].append(b-1)
        g[b-1].append(a-1)

    visited = [False] * N
    visited[0] = True

    ans = dfs(0, g, visited)
    return ans


def main():
    print(solve())


if __name__ == '__main__':
    main()





Measured memory_bytes: 3316
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define repn(i,a,b) for (int i=(a);i>=(b);i--)
#define repq(i,a,b) for (int i=(a);i<(b);i++)
#define pa pair<int,int>
#define be begin()
#define en end()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll modInverse(ll a, ll m) 
{ ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0; while (a > 1){ ll q = a / m; ll t = m; m = a % m, a = t; t = y; y = x - q * y; x = t; } 
    if (x < 0) x += m0; return x; 
}
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;}
    return res;

}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int >v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    ll n;
    cin>>n;
    
    vector<int>v;string result="";
    while (--n >= 0)
    {
        result = (char)('a' + n % 26 ) + result;
        n /= 26;
    }
    cout<<result;
    
}

int main() 
{ 
    


    solve();

        
    
    
    return 0; 
} 

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
#define F first
#define S second
int N,L;
P T[100003];
int s[100003];
int main(){
  scanf("%d %d",&N,&L);
  for(int i=0;i<N;i++){
    scanf("%d",&T[i].F);
    T[i].S=i+1;
  }
  sort(T,T+N);
  int res = 0;
  for(int i=N-1;i>-1;i--){
    s[T[i].S]=max(s[T[i].S-1],s[T[i].S+1])+(L-T[i].F);
    //    printf("%d %d %d\n",T[i].F,T[i].S,s[T[i].S]);
    res = max(res,s[T[i].S]);
  }
  printf("%d\n",res);
}

Measured memory_bytes: 2360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  if(N < 357) {
    cout << 0 << endl;
    return 0;
  }
  
  int ans = 0;
  string s = "357";
  while(stoi(s) <= N) {
    if(count(all(s),'3')>0 && count(all(s),'5')>0 && count(all(s),'7')>0) ans++;
    int k = s.size()-1;
    while(true) {
      if(s[k] == '3') {
        s[k] = '5';
        break;
      }
      if(s[k] == '5') {
        s[k] = '7';
        break;
      }
      if(s[k] == '7') {
        if(k > 0) k--;
        else {
          s = '3' + s;
          break;
        }
      }
    }
    for(int i=k+1; i<(int)(s.size()); i++) s[i] = '3';
  }
  cout << ans << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define INF 9999999999

int main(){
  ll n, m, ans = 0;
  cin >> n >> m;
  if ( n >= (m / 2) ){
    ans = m / 2;
  }else{
    ans = n;
    m -= 2 * n;
    ans += m / 4;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9 + 7;

template <typename T>
struct DisjointSparseTable{
    function<T(T, T)> f;
    vector<vector<T>> v;

    DisjointSparseTable(vector<T>& inp, function<T(T, T)> f) : f(f){
        int n = inp.size();
        int b;
        for(b = 0; (1 << b) <= inp.size(); ++b);
        v.assign(b, vector<T>(n));
        for(int i = 0; i < n; ++i)
            v[0][i] = inp[i];
        for(int i = 1; i < b; ++i){
            int siz = 1 << i;
            for(int j = 0; j < n; j += siz << 1){
                int t = min(j + siz, n);
                v[i][t - 1] = inp[t - 1];
                for(int k = t - 2; k >= j; --k)
                    v[i][k] = f(inp[k], v[i][k + 1]);
                if(t >= n)
                    break;
                v[i][t] = inp[t];
                int r = min(t + siz, n);
                for(int k = t + 1; k < r; ++k)
                    v[i][k] = f(v[i][k - 1], inp[k]);
            }
        }
    }

    T get(int l, int r){
        if(l >= --r)
            return v[0][l];
        int p = 31 - __builtin_clz(l ^ r);
        return f(v[p][l], v[p][r]);
    }
};


signed main(){
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    DisjointSparseTable<int> d(a, [](auto x, auto y){return min(x, y);});
    for(int i = 0; i < n - l + 1; ++i)
        cout << d.get(i, i + l) << " \n"[i == n - l];
}



Measured memory_bytes: 88944
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_M = 100000;



int main(int argc, char *args[]) {
	int n; 
	string s;
	cin >> n;
	cin >> s;
	int dp[5001][5001];
	//すべてのi,jの組み合わせについて調べる
	for (int i = n - 1; i >= 0; i--) {
		for (int j = n - 1; j >= 0; j--) {
			if (s[i] != s[j]) dp[i][j] = 0;
			else dp[i][j] = dp[i + 1][j + 1] + 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= j)continue;
			int now = min(dp[i][j], j - i);
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 97920
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcount(x)
#define F first
#define S second

const int MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);

ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=MOD;while(k>0){if(k&1)ans=(ans*n)%MOD;n=(n*n)%MOD;k>>=1;}return ans%MOD;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// ****************************************************



int main()
{
    int n;
    cin>>n;
    int ans=0;
    string s;
    cin>>s;
    char prev=s[0];
    for(int i=0; i<n; i++)
    {
        if(s[i]!=prev)
        {
            ans++;
            prev=s[i];
        }
    }
    cout<<ans+1<<nl;
    return 0;
}


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

int main() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double PI = acos(-1);
  double dig_m = 6.0 * m * PI / 180.0;
  double dig_h = (0.5 * m + 30.0 * h) * PI / 180.0;

  double xh = cos(dig_h) * a, yh = sin(dig_h) * a;
  double xm = cos(dig_m) * b, ym = sin(dig_m) * b;
  double ans = sqrt((xh - xm) * (xh - xm) + (yh - ym) * (yh - ym));
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=998244353;
ll n,x,m;
ll a[100005];
ll y[100005];
ll ans[100005];
ll ANS;
ll s,e;
int main(void){
    cin>>n>>x>>m;
    a[0]=x;
    y[x]=0;
    ans[1]=x;
    //cout<<0<<" "<<x<<endl;
    for(int i=1;i<n;i++){
        a[i]=(a[i-1]*a[i-1])%m;
        if(y[a[i]]>0){
            //cout<<i<<endl;
            s=y[a[i]];
            e=y[a[i-1]];
            //cout<<s<<" "<<e<<endl;
            ANS=ans[i];
            n-=s;
            ANS+=((ans[e+1]-ans[s])*(n/(e-s+1)-1));
            n-=((n/(e-s+1))*(e-s+1));
            for(int j=s;j<s+n;j++){
                ANS+=(ans[j+1]-ans[j]);
            }
            cout<<ANS<<endl;
            return 0;
        }else{
            y[a[i]]=i;
        }
        ans[i+1]=ans[i]+a[i];
        //cout<<i<<" "<<a[i]<<endl;
    }
    cout<<ans[n]<<endl;
    
}


Measured memory_bytes: 5120
k=int(input())
n=50
a=[0]*n
cnt=k//n
rest=k%n
for i in range(n):
  a[i]=cnt+i
for i in range(rest):
  for j in range(n):
    if i==j:
      a[j]+=n
    else:
      a[j]-=1
print(50)
print(*a)

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

int main()
{
	int n;
	int power[ 10 ];
	power[ 0 ] = 1;
	for( int i = 1; i < 10; ++i ){
		power[ i ] = power[ i - 1 ] * 8;
	}

	while( cin >> n && n ){
		string ans;
		for( int i = 9; i >= 0; --i ){
			int d = n / power[ i ];
			n %= power[ i ];
			if( ans.empty() && d == 0 ) continue;
			if( d >= 4 ) ++d;
			if( d >= 6 ) ++d;
			ans += (char)( d + '0' );
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
// Aizu Vol0 0088: The Code A Doctor Loved
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *gets(char *);

char *c2d[32] = {
	/*A*/	"100101",
	/*B*/	"10011010",
	/*C*/	"0101",
	/*D*/	"0001",
	/*E*/	"110",
	/*F*/	"01001",
	/*G*/	"10011011",
	/*H*/	"010000",
	/*I*/	"0111",
	/*J*/	"10011000",
	/*K*/	"0110",
	/*L*/	"00100",
	/*M*/	"10011001",
	/*N*/	"10011110",
	/*O*/	"00101",
	/*P*/	"111",
	/*Q*/	"10011111",
	/*R*/	"1000",
	/*S*/	"00110",
	/*T*/	"00111",
	/*U*/	"10011100",
	/*V*/	"10011101",
	/*W*/	"000010",
	/*X*/	"10010010",
	/*Y*/	"10010011",
	/*Z*/	"10010000",
	/*Space*/	"101",
	/*'*/	"000000",
	/*,*/	"000011",
	/*-*/	"10010001",
	/*.*/	"010001",
	/*?*/   "000001"
};

int clen[32] = {
	/*A	"100101",*/		6,
	/*B	"10011010",*/	8,
	/*C	"0101",*/		4,
	/*D	"0001",*/		4,
	/*E	"110",*/		3,
	/*F	"01001",*/		5,
	/*G	"10011011",*/	8,
	/*H	"010000",*/		6,
	/*I	"0111",*/		4,
	/*J	"10011000",*/	8,
	/*K	"0110",*/		4,
	/*L	"00100",*/		5,
	/*M	"10011001",*/	8,
	/*N	"10011110",*/	8,
	/*O	"00101",*/		5,
	/*P	"111",*/		3,
	/*Q	"10011111",*/	8,
	/*R	"1000",*/		4,
	/*S	"00110",*/		5,
	/*T	"00111",*/		5,
	/*U	"10011100",*/	8,
	/*V	"10011101",*/	8,
	/*W	"000010",*/		6,
	/*X	"10010010",*/	8,
	/*Y	"10010011",*/	8,
	/*Z	"10010000",*/	8,
	/*Space	"101",*/	3,
	/*'	"000000",*/		6,
	/*,	"000011",*/		6,
	/*-	"10010001",*/	8,
	/*.	"010001",*/		6,
	/*? "000001"*/		6
};

int d2c[32] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
				'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
				'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '.', ',', '-',
				'\'', '?' };

int idx[130];

int main()
{
	char buf[150], *p;
	char ans[1000], *pa;
	int i, j, len;

#if 0
	for (i = 0; i < 32; i++) {
		if (clen[i] != strlen(c2d[i])) printf("Len? (%d)\n", i);
	}
#endif

	for (i = 0; i < 26; i++) idx['A'+i] = i;
	idx[' '] = i++;
	idx['\''] = i++;
	idx[','] = i++;
	idx['-'] = i++;
	idx['.'] = i++;
	idx['?'] = i++;

	while (gets(p = buf) != NULL) {
		pa = ans;
		while (*p) {
			i = idx[*p++];
			memcpy(pa, c2d[i], clen[i]);
			pa += clen[i];
		}
		len = pa - ans;
		if ((j = len % 5) > 0) {
			while (j++ < 5) *pa++ = '0', len++;
		}
		*pa = 0;

		for (pa = ans; *pa; ) {
			for (i = j = 0; i < 5; i++) {
				j <<= 1;
				if (*pa++ == '1') j |= 1;
			}
			putchar(d2c[j]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/


ll dp[5555*5555];

int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[3], b[3];
  
  for(i=0; i<3; i++) cin >> a[i];
  for(i=0; i<3; i++) cin >> b[i];
  
  
  //A->B
  dp[0]=0;
  for(i=0; i<N; i++) {
    chmax(dp[i+a[0]], dp[i]+b[0]);
    chmax(dp[i+a[1]], dp[i]+b[1]);
    chmax(dp[i+a[2]], dp[i]+b[2]);
    chmax(dp[i+1], dp[i]+1);
  }
  
  //B->A
  N=dp[N];
  memset(dp, 0, sizeof(dp));
  for(i=0; i<N; i++) {
    chmax(dp[i+b[0]], dp[i]+a[0]);
    chmax(dp[i+b[1]], dp[i]+a[1]);
    chmax(dp[i+b[2]], dp[i]+a[2]);
    chmax(dp[i+1], dp[i]+1);
  }
  
  pt(dp[N]);
}



Measured memory_bytes: 241408
/*input
 
*/
 
 
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll N = 1e6+5;
const ll mod=1e9+9; 
int solve()
{
	ll n,ans=0;cin>>n;
	vi a(n),b(n),c(n);
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>b[i];
	rep(i,0,n) cin>>c[i];

	ll last=-2;
	rep(i,0,n)
	{
		ans+=b[a[i]-1];
		if(a[i]==last+1) ans+=c[a[i]-2];
		last=a[i];
	}
	cout<<ans<<"\n";
	return 0;
}
 
int main()
{
	auto start = chrono::high_resolution_clock::now();
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	ll test_cases=1;
	// cin>>test_cases;
	while(test_cases--)
		solve();
 
	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main(){
	int a;
	cin >> a;
	for(int i=0; ;i++){
		if(i*1000<a) continue;
		else if(i*1000==a){
			cout << 0;
			return 0;
		}
		else{
			cout << i*1000-a;
			return 0;
		}
	}
}

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

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

  for (int i = 1; i < n + 1; i++) {
    a = i;
    if (a % 3 == 0) {
      printf(" %d", i);
    } else {
      do {
        if (a % 10 == 3) {
          printf(" %d", i);
          break;
        }
      } while (a /= 10);
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 1e5 + 10;
const int Log = 20;
const int Mod = 1e9 + 7;
const ll INF = 1e18;

vector<int> N[Max];

bool white[Max];
int child[Max];
bool seen[Max];
int par[Max];
int h[Max];

void DFS(int v)
{
	seen[v] = true;
	for(var u : N[v])
		if(!seen[u])
		{
			par[u] = v;
			h[u] = h[v] - 1;
			DFS(u);
			child[v]++;
		}
}

bool erased[Max];

int main()
{
	int n;cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int a , b;cin >> a >> b;
		N[a].pb(b);
		N[b].pb(a);
	}
	if(n == 2)
	{
		cout << "Second\n";
		return 0;
	}

	set<pair<int,int> > leafs;

	int root = -1;
	for(int i = 1; i <= n ; i++)
		if(N[i].size() >= 2)
			root = i;

	DFS(root);

	for(int i = 1; i <= n ; i++)
		if(N[i].size() == 1)
			leafs.ins({h[i] , i});

	bool win = false;
	while(leafs.size())
	{
		if(n == 2)
			break;
		if(n == 1)
		{
			win = true;
			break;
		}

		var v = *leafs.begin();
		//cout << v.S << '\n';
		leafs.erase(leafs.begin());
		var p = par[v.S];
		if(child[p] >= 2)
		{
			win = true;
			break;
		}
		var pp = par[p];

		if(pp)
		{
			child[pp]--;
			if(child[pp] == 0)
				leafs.ins({h[pp] , pp});
		}
		n -= 2;
	}
	if(win)
		cout << "First\n";
	else
		cout << "Second\n";
}



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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    set<string> s;
    for(i = 0; i < n; i++){
        string in; cin>>in;
        s.insert(in);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19116
#include<cstdio>

int main(){
    while(1){
        char str[1001];
        int sum = 0;

        scanf("%s",str);

        if(str[0] == '0'){
            break;
        }

        for (int i = 0; str[i] != '\0'; i++){
            sum += (str[i] - '0');
        }
        
        printf("%d\n",sum);
        
    }
    return 0;

}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++){
    cin >> a[i];
  }
  double mean=0;
  for (int i=0; i<N; i++){
    mean += a[i];
  }
  mean /= N;
  double dif = 1e9;
  int ans = -1;
  for (int i=0; i<N; i++){
    if (abs(mean-a[i])<dif){
      dif = abs(mean-a[i]);
      ans = i;
    }
  }
  // cout << mean << endl;
  cout << ans << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n,x,y,z = LI()
    po2 = [1<<i for i in range(x+y+z+1)]
    max = po2[x+y+z]
    ng = po2[x+y+z-1]|po2[y+z-1]|po2[z-1]
    dp = [[0 for i in range(max)] for i in range(n+1)]
    dp[0][0] = 1
    mask = max-1
    for i in range(n):
        for j in range(max):
            for k in range(1,11):
                t = j<<k|1<<(k-1)
                if t&ng != ng:
                    t &= mask
                    dp[i+1][t] += dp[i][j]
                    dp[i+1][t] %= mod
    ans = pow(10,n,mod)
    for i in range(max):
        ans -= dp[n][i]
        ans %= mod
    print(ans)


#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

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

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


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

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


int main() {

    int a, b;
    cin >> a >> b;

    char ac = '0' + a;
    char bc = '0' + b;

    string aw = "";
    for (int i = 0; i < b; i++) {
        aw += ac;
    }

    string bw = "";
    for (int i = 0; i < a; i++) {
        bw += bc;
    }

    if (aw > bw) {
        cout << bw << endl;
    } else {
        cout << aw << endl;
    }


}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main() {
	int a,b;
	scanf("%d", &a);
	scanf("%d", &b);
	if (a > 9||b>9) {
		printf("%d", -1);
	}
	else {
		int x;
		x = a * b;
		printf("%d", x);
	}
	
	
	
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[maxn];
int f[maxn][13];
int n;
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
		if(s[i]=='?'){
			for(int k=0;k<=9;k++)
				for(int j=0;j<13;j++)
					f[i][(j*10+k)%13]=(f[i][(j*10+k)%13]+f[i-1][j])%mod;
		}
		else{
			int k=s[i]-'0';
			for(int j=0;j<13;j++)
				f[i][(j*10+k)%13]=(f[i][(j*10+k)%13]+f[i-1][j])%mod;
		}
	writeln(f[n][5]);
	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int n;
  cin >> n;
  vector<int> t(n);
  for (int i = 1; i < n; i++) {
    int m;
    cin >> m;
    t[m-1]++;
  }

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

}


Measured memory_bytes: 4048
n = int(input())
a = list(map(int, input().split()))

st = set()
for i in range(1<<n):
    sm = 0
    for j in range(n):
        if(i & (1<<j)): sm += a[j]
        
    st.add(sm)

q = int(input())
m = list(map(int, input().split()))

for i in range(q):
    if(m[i] in st): print('yes')
    else: print('no')


Measured memory_bytes: 5652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[100100];
    cin >> n;
    int sum[100100];
    sum[0]=0;
    for(int i=0;i<n;i++)
    {
        cin >> a[i]; 
    }
    sum[1]=abs(a[1]-a[0]);
    for( int i=2 ;i<n;i++)
    {
        sum[i]=min((sum[i-1]+abs(a[i]-a[i-1])),(sum[i-2]+abs(a[i]-a[i-2])));
    }
    cout << sum[n-1] << endl;
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    string str;
    cin>>str;
    vector<vector<int> > vec(3);
    ll count=0;
    for(int i=0;i<n;++i)
    {
        int temp;
        if(str[i]=='R')
            temp=0;
        else if(str[i]=='G')
            temp=1;
        else
            temp=2;
        vec[temp].push_back(i);
    }
    
    for(int i=0;i<n;++i)
    {
        int temp1;
        if(str[i]=='R')
            temp1=0;
        else if(str[i]=='G')
            temp1=1;
        else
            temp1=2;
        for(int j=i+1;j<n;++j)
        {
            int temp2;
        if(str[j]=='R')
            temp2=0;
        else if(str[j]=='G')
            temp2=1;
        else
            temp2=2;
            if(temp1!=temp2)
            {
                int temp3;
                if(temp1==0&&temp2==1)
                temp3=2;
                if(temp2==0&&temp1==1)
                temp3=2;
                if(temp1==0&&temp2==2)
                temp3=1;
                if(temp2==0&&temp1==2)
                temp3=1;
                if(temp1==2&&temp2==1)
                temp3=0;
                if(temp2==2&&temp1==1)
                temp3=0;
                int index=upper_bound(vec[temp3].begin(),vec[temp3].end(),j)-vec[temp3].begin();
                if(index!=vec[temp3].size())
                {
                    int n1=vec[temp3].size();
                    int g=n1-index;
                    if(binary_search(vec[temp3].begin(),vec[temp3].end(),2*j-i))
                    g--;
                    count+=g;
                }
            }
        }
    }
    cout<<count<<"\n";

}


Measured memory_bytes: 3656
#include<cstdio>
const int N=105;
int n;char s[N];
int main() {
    scanf("%d",&n);
    scanf("%s",s);
    int l=0,r=0;
    for(int i=0;i<n;i++) s[i]=='R'?++l:++r;
    return !printf("%s",l>r?"Yes":"No");
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  ll n;
  cin >> n;
  vl a(5);
  rep (i, 5) cin >> a[i];
  sort(all(a));
  ll ans;
  if (n % a[0] == 0) ans = n / a[0];
  else ans = n / a[0] + 1;
  ans += 4;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n,ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];
ll train[1010][1010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, m, q;
	cin >> n >> m >> q;
	vector<ll>L(m), R(m);
	rep(i, m) {
		cin >> L[i] >> R[i];
		train[L[i]][R[i]]++;
	}
	for (ll i = 1;i <= n;++i) {
		for (ll j = 1;j <= n;++j) {
			train[i][j] += train[i - 1][j];
			train[i][j] += train[i][j - 1];
			train[i][j] -= train[i - 1][j - 1];
		}
	}
	vector<ll>a(q), b(q);
	rep(i, q) {
		cin >> a[i] >> b[i];
		ll ans = train[b[i]][b[i]] - train[b[i]][a[i] - 1] - train[a[i] - 1][b[i]] + train[a[i] - 1][a[i] - 1];
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 9728
#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;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 19;

int n, m, k;
void solve(int test)
{
  cin >> n;
  int ans = 0, cur = 0;
  int prev = -1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x <= prev) {
      ++cur;
    }
    else {
      cur = 0;
    }
    prev = x;
    ans = max(ans, cur);
  }
  cout << ans << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

using namespace std;

int main() {
	int k, n,num=1;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		num=min(num * 2, num + k);
	}
	cout << num << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.next();
    let s: Vec<char> = sc.next::<String>().chars().collect();

    let mut dp = vec![0; n + 1];
    // i文字打った時点でOXを打った回数の最大値
    for i in 0..n {
        dp[i + 1] = std::cmp::max(dp[i + 1], dp[i]);
        if i + 1 < n && ((s[i] == 'O' && s[i + 1] == 'X') || (s[i] == 'X' && s[i + 1] == 'O')) {
            dp[i + 2] = dp[i] + 1;
        }
    }
    println!("{}", dp[n]);
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
#define ll long long
#define r(i,a,b) for(register int i=a;i<=b;i++)
#define ID(c) ('0'<=(c)&&(c)<='9')
#define pb push_back
using namespace std;
const int N= 3333 ;
inline int qr()
{
	int x=0,f=1;char c=getchar();
	for(;!ID(c);c=getchar()) if(c=='-') f=-1;
	for(; ID(c);c=getchar()) x=(x<<3)+(x<<1)+(c^'0');
	return x*f;
}
int main()
{
	double a;
	cin>>a;
	if(a==0)	cout<<1<<endl;
	if(a==1)	cout<<0<<endl;
 	return 0;
 } 

Measured memory_bytes: 3772
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    println(problem124a(a, b))
}

fun problem124a(a: Int, b: Int): Int {
    return if (a == b) a + b else Math.max(a, b) * 2 - 1
}

Measured memory_bytes: 31516
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  char a, b; cin >> a>>b;
  if(a==b) cout << 'H'<< endl;
  else cout << 'D' << endl;
  return 0;
}

Measured memory_bytes: 3492
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
  int n=sc.nextInt();
  int a[]=new int[n];
  int b[]=new int[n];
  int c[]=new int [n];
  for(int i=0;i<n;i++)
  {
    a[i]=sc.nextInt();

    b[i]=sc.nextInt();

    c[i]=sc.nextInt();

  }
  int dp[][]=new int[n+1][3];
  for(int i=0;i<n;i++)
  {
    dp[i+1][0]=Math.max(dp[i][1],dp[i][2])+a[i];
    dp[i+1][1]=Math.max(dp[i][0],dp[i][2])+b[i];
    dp[i+1][2]=Math.max(dp[i][1],dp[i][0])+c[i];

  }
  System.out.println(Math.max(Math.max(dp[n][0],dp[n][1]),dp[n][2]));
}
}

Measured memory_bytes: 95356
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            map.put(i, new ArrayList<>());
        }

        for (int i = 0; i < N - 1; i++) {
            int v1 = sc.nextInt() - 1;
            int v2 = sc.nextInt() - 1;
            map.get(v1).add(v2);
            map.get(v2).add(v1);
        }

        long[][] dp = new long[N][2];
        int m = (int) 1e9 + 7;

        dfs(map, 0, -1, dp, m);


        System.out.println((dp[0][0] + dp[0][1]) % m);


    }

    public static void dfs(Map<Integer, List<Integer>> map, int cur, int parent, long[][] dp, int m) {
        dp[cur][0] = 1;
        dp[cur][1] = 1;

        for (int next : map.get(cur)) {
            if (next == parent) continue;
            dfs(map, next, cur, dp, m);
            dp[cur][0] *= dp[next][1];
            dp[cur][0] = dp[cur][0] % m;
            dp[cur][1] *= dp[next][0] + dp[next][1];
            dp[cur][1] = dp[cur][1] % m;
        }
    }
}


Measured memory_bytes: 122160
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::{min, max};

#[fastout]
fn main() {
    input! {
    a: i64,
    b: i64
    }
    let (ma, mi) = (max(a, b), min(a, b));
    let ans = if (ma - mi) % 2 == 0 {format!("{}", (ma - mi) / 2 + mi)} else {"IMPOSSIBLE".to_string()};
    println!("{}", ans);
}


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

int main() {
    int a, b;
    cin >> a >> b;

    if ((a > b || a == 1) && (a != b && b != 1 )) {
        cout << "Alice" << endl;
    }
    else if ((b > a || b == 1) && (a != b && a != 1)) {
        cout << "Bob" << endl;
    }
    else  {
        cout << "Draw" << endl;
    }
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, c, n;
  cin >> n >> a >> b;
  c = a + b;
  cout << (n / c) * a + min(n % c, a) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)
i1 = sorted_x[n//2-1]
i2 = sorted_x[n//2]

ans = []

for a in x:
  if a >= i2:
    ans.append(i1)
  else:
    ans.append(i2)
    
print(*ans, sep='\n')

Measured memory_bytes: 26016
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int h = sc.nextInt();
    		int w = sc.nextInt();
    		for(int i=0;i<h;i++) {
    			StringBuilder c = new StringBuilder(sc.next());
    			System.out.println(c);
    			System.out.println(c);
    		}
    	}
    }

Measured memory_bytes: 24276
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n;
std::string s;
long ans = 0;
//std::set<long> st[5005];

int main(){
    scanf("%ld", &n);
    std::cin >> s;
    /*
    for(long i = 0; i < n; i++){
        for(long j = i+1; j < n; j++){
            if(s[i] == s[j]){
                st[i].insert(j-i);
            }
        }
    }
    //*/
    for(long i = 1; i < n; i++){
        long res = 0;
        long cnt = 0;
        for(long j = 0; j < n; j++){
            if(s[j] == s[j+i]){
                cnt++;
            }else{
                res = std::max(res, cnt);
                cnt = 0;
            }
        }
        ans = std::max(ans, std::min(res, i));
    }
    printf("%ld\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int>mp;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        mp[a[i]]++;
    }
    int ans = 0;
    for (auto p: mp) {
        int x = p.first;
        int num = p.second;
        if(x > num) ans += num;
        else ans += num - x;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    ll n,m;
    cin>>n>>m;
    int a[m];
    ll s=0;
    fo(i,m)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(n-s>=0){
        cout<<n-s<<endl;
    }
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3640