akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=200005, inf=1e18;
vector<ll> adj[N];
ll tr[4*N], lazy[4*N], ans[N], val[N];
ll combine(ll x,ll y){return max(x,y);}
void lazify(ll node,ll l,ll r){
	if(lazy[node]){
		tr[node]+=lazy[node];
		if(l!=r){
			lazy[node<<1]+=lazy[node];
			lazy[node<<1|1]+=lazy[node];
		}
	}
	lazy[node]=0;
}
void update(ll node,ll l,ll r,ll a,ll b,ll val){
	lazify(node,l,r);
	if(b<l || r<a || l>r)return;
	if(a<=l and r<=b){
		tr[node]+=val;
		if(l!=r){
			lazy[node<<1]+=val;
			lazy[node<<1|1]+=val;
		}
		return;
	}
	ll mid=(l+r)/2;
	update(node<<1,l,mid,a,b,val);
	update(node<<1|1,mid+1,r,a,b,val);
	tr[node]=combine(tr[node<<1],tr[node<<1|1]);
}
void assign(ll node,ll l,ll r,ll id,ll val){
	lazify(node,l,r);
	if(l==r){
		tr[node]=val;
		return;
	}
	ll mid=(l+r)/2;
	if(l<=id and id<=mid)
		assign(node<<1,l,mid,id,val);
	else
		assign(node<<1|1,mid+1,r,id,val);
	tr[node]=combine(tr[node<<1],tr[node<<1|1]);
}
ll query(ll node,ll l,ll r,ll a,ll b){
	lazify(node,l,r);
	if(l>b || a>r || l>r)return -inf;
	if(a<=l and r<=b)return tr[node];
	ll mid=(l+r)/2;
	return combine(query(node<<1,l,mid,a,b),query(node<<1|1,mid+1,r,a,b));
}
void dfs(ll node,ll p){
	ll prv=query(1,1,N,val[node],val[node]);
	ll cur=max(0LL,query(1,1,N,1,val[node]-1))+1;
	ans[node]=max(cur,query(1,1,N,1,N));
	assign(1,1,N,val[node],cur);
	for(auto i : adj[node])
		if(i!=p)
			dfs(i,node);
	assign(1,1,N,val[node],prv);
}
void solve(){
	ll n, u, v, cnt=0;
	cin>>n;
	set<ll> seta;
	map<ll,ll> rnk;
	rep(i,1,n+1){
		cin>>val[i];
		seta.insert(val[i]);
	}
	for(auto i : seta)
		rnk[i]=++cnt;
	rep(i,1,n+1)
		val[i]=rnk[val[i]];
	rep(i,1,n){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs(1,0);
	rep(i,1,n+1){
		if(i>1)cout<<"\n";
		cout<<ans[i];
	}
}	
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 55516
#include <iostream>

using namespace std;

int main()
{
    int N,A;
    cin>> N>>A;
    int L=A;
    int R=A+N-1;
    int eat;
    if (R<=0)
        eat = R;
    else if (L>=0)
        eat = L;
    else
        eat =0;
    int ans =(R+L)*(R-L+1)/2-eat;
    cout<< ans<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int probB(){
    int S,AA,BB;
    scanf("%d", &S);
    AA=S/100;
    BB=S%100;
    if(1<=AA && AA<=12){
        if(1<=BB && BB<=12){printf("AMBIGUOUS\n");}
        else{printf("MMYY\n");}
    }
    else{
        if(1<=BB && BB<=12){printf("YYMM\n");}
        else{printf("NA\n");}
    }
    
    
    
    return 0;
}


int main(){
    probB();
    return 0;
}

Measured memory_bytes: 128
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]+c[i]*(d-last[i])*(d-last[i]-1)//2 for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

def score(T):
    last=[-1]*26
    v=0
    for d in range(D):
        v+=s[d][T[d]-1]
        last[T[d]-1]=d
        for i in range(26):
            v-=c[i]*(d-last[i])
    return v

v0=max(score(dt)+10**6,0)

for _ in range(6):
    for d in range(1,D):
        y=-1
        newdt=dt+[]
        for i in range(26):
            if dt[d]!=i+1:
                newdt[d]=i+1
                v1=max(score(newdt)+10**6,0)
                if v0<v1:
                    y=i+1
                    v0=v1
        if y!=-1:
            dt[d]=y

for i in dt:
    print(i)

Measured memory_bytes: 75884
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk,q;
  map<string,int> m;
  int c,x;
  string key;
  //cout << "hoge" << endl;
  map<string,int>::iterator it;
  map<string,int>::iterator lit,rit;  
  cin >> q;


  for(ii=0;ii<q;ii++){
    cin >> c ;
    //cout << c << endl;
    if(c == 0){
      cin >> key >> x;
      //m.insert_or_assign(make_pair(key,x));
      m.erase(key);
      m.insert(make_pair(key,x));
    }
    else if(c==1){
      cin >> key;

      it = m.find(key);

      //cout << key << endl;
      if(it != m.end()){
          cout << m[key] << endl;
      }
      else{
        cout << 0 << endl;
      }


    }
    else if(c==2){
      cin >> key;
      m.erase(key);
    }
    else if(c==3){
      string l,r;
      pair<string,int> p;
      cin >> l >> r;

      it = m.lower_bound(l);
      
      while(it != m.end()){
        p = *it;
        if(p.first >= l && p.first <= r){
          cout << p.first << " " << p.second << endl;
        }
        if(p.first > r){
          break;
        }
        it++;
      }
    }
    //cout << key << endl;
  }

  
  return 0;
  
}



Measured memory_bytes: 27828
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main(){
    int H,W,N;
    cin >> H >> W >> N;
    int count = 0;
    int mx,mn;
    mx = max(H,W);
    mn = min(H,W);
    int ans;
    
    for(int i = 1;i <= mn;i++){
        ans = mx*i;
        count++;
        if(ans >= N){
            break;
        }
    }
    cout << count << endl;

    
}


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

int main() {
  int K;
  string S;
  cin>>K>>S;
  if(K<S.size()){
    rep(i,K){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
  else{
    cout<<S<<endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;int main(){int n,y;cin>>n>>y;if(y%1000==0&&y>=n*1000){y/=1000;int k=(2*(y-n)+8)/9;if((y-n)/4>=k&&y/5>=k){cout<<y-n-4*k<<" "<<9*k-2*(y-n)<<" "<<y-5*k<<endl;return 0;}}cout<<"-1 -1 -1\n";return 0;}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
mod = int(1e9)+7

def solve():
    n=int(input())
    if n<3:
        print(0)
        return
    dp=[0]*2001
    dp[3]=dp[4]=dp[5]=1
    for i in range(6,n+1):
        dp[i]=(dp[i-1]+dp[i-3])%mod
    print(dp[n])
    


    
if __name__=="__main__":
    solve()





Measured memory_bytes: 9188
n = int(input())
l = int((len(str(n))+1)/2)
s = 0
for i in range(1,l):
  s += 10**(2*i-1)-10**(2*i-2)
k = len(str(n))
if k == l*2:
  s += 10**(2*l-1)-10**(2*l-2)
else:
  s += n+1-10**(2*l-2)
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long


int main(){
    lint n, m, v, p; cin >> n >> m >> v >> p;
    vector<lint> a;
    rep(i, n){
        lint x; cin >> x;
        a.push_back(x);
    }
    sort(all(a), greater<lint>());

    lint res = p;
    lint sum = 0;
    for(int i = p; i < n; i++){
        if(a[i] + m < a[p-1]) break;
        sum += a[i-1];
        lint check = m*n + a[i]*(i-p+1) - sum;
        if(check >= m * v){
            res++;
        }
        else break;
    }

    cout << res << endl;
}

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

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

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || i == n - 1) continue;
    if (p[i - 1] < p[i] && p[i] < p[i + 1]) cnt++;
    if (p[i - 1] > p[i] && p[i] > p[i + 1]) cnt++;
  }
  cout << cnt << endl;
}

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

// vector<ll> divisor(ll n) {
//     vector<ll> ret;
//     for (ll i = 1; i * i <= n; i++) {
//         if (n % i == 0) {
//             ret.push_back(i);
//             if (i * i != n) ret.push_back(n / i);
//         }
//     }
//     sort(ret.begin(), ret.end()); // 昇順に並べる
//     return ret;
// }

int main() {
    /*変数定義，入力*/
    ll X;
    cin >> X;
    ll a =0;
    ll b; 
    while(a < 1000000000){

        for (ll i = 1; i * i <= X; i++) {
            if (X % i == 0) {
                b = a - X/i;
                if(a*a*a*a*a - b*b*b*b*b== X){
                    cout << a << " " << b << endl;
                    return 0;
                }
                if (i * i != X){
                    b = a - X/(X/i);
                    if(a*a*a*a*a - b*b*b*b*b== X){
                        cout << a << " " << b << endl;
                        return 0;
                    }
                }
            }
        }

        a += 1;
    }

    /*終了*/
    return 0;
}




Measured memory_bytes: 3636
(N, K) = (int(i) for i in input().split())
s = input()

count = 0
for i in range(1, N):
    if s[i-1:i+1] == 'LR' or s[i-1:i+1] == 'RL':
        count += 1

if count > K * 2:
    print(N - count + K * 2 - 1)
else:
    print(N - 1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long double ans = 0;
  for (int i = 0; i < N; i++) {
    long double A;
    cin >> A;
    ans += 1. / A;
  }
  ans = 1. / ans;
  cout << fixed << setprecision(12) << ans << '\n';
  return 0;
}


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

char fi[10][10];
char fic[10][10];

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

    rep(i,h) rep(j,w) cin>>fi[i][j];

    int ans=0;
    rep(bith,1<<h){
        rep(bitw,1<<w){
            rep(i,h) rep(j,w) fic[i][j]=fi[i][j];
            rep(i,h){
                if(bith & 1<<i){
                    rep(j,w) fic[i][j]='r';
                } 
            }
            rep(j,w){
                if(bitw & 1<<j){
                    rep(i,h) fic[i][j]='r';
                } 
            }
            int cnt=0;
            rep(i,h){
                rep(j,w){
                    if(fic[i][j]=='#') cnt++;
                }
            }
            if(cnt==k) ans++;
        }
    }

    cout<<ans<<endl;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  vector< pair<int, int> > bas;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    bas.push_back({b,a});
  }
  sort(bas.begin(), bas.end());
  ll t=0;
  for(int i=0;i<n;i++){
    t += bas[i].second;
    if(t>bas[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x[n],m=1000000000;
  for(int i=0;i<n;i++)cin>>x[i];
  int c,d;
  for(int i=0;i<n;i++){
    int j,a=0,b=0;
    for(j=0;j<=i;j++)a+=x[j];
    for(int k=j;k<n;k++)b+=x[k];
    if(m>abs(a-b)){
      m=abs(a-b);
      c=a;
      d=b;
    }
  }
  //cout<<endl<<"a="<<c<<" "<<"b="<<d<<endl;
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, w;
	cin >> n >> w;
	vector<pair<int, int>> a(n);
	for(auto i = 0; i < n; ++ i){
		cin >> a[i].first >> a[i].second;
	}
	vector<long long> dp(w + 1);
	for(auto i = 0; i < n; ++ i){
		static vector<long long> dp_next(w + 1);
		dp_next = dp;
		for(auto j = w - a[i].first; j >= 0; -- j){
			ctmax(dp_next[j + a[i].first], dp[j] + a[i].second);
		}
		swap(dp, dp_next);
	}
	cout << *max_element(dp.begin(), dp.end());
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N,M;
    cin >> N >> M;
    int dp[N+1];
    dp[0]=1;
    int flag[N+1];
    memset(flag, 0, sizeof(flag));
    for(int i=0; i<M; i++){
        int tmp;
        cin >> tmp;
        flag[tmp]=1;
    }
    if(flag[1]==0) dp[1]=1;
    else dp[1]=0;

    for(int i=2; i<=N; i++){
        if(flag[i]==1) dp[i]=0;
        else dp[i]=(dp[i-1]+dp[i-2])%1000000007;
    }
    
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
h, w, k = map(int, input().split())

field = [input() for _ in range(h)]


ans = 0
for bit_h in range(2**h):
    for bit_w in range(2**w):
        count = 0
        use_h = []
        for i in range(h):
            if (bit_h >> i) & 1:
                use_h.append(field[i])

        for j in range(w):
            if (bit_w >> j) & 1:
                for line in use_h:
                    if line[j] == "#":
                        count += 1

        if count == k:
            ans += 1

print(ans)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int d,c[26],s[400][26],t[400];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>d;
    rep(i,26)cin>>c[i];
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int score=0;
    vector<pair<int,pair<vector<int>,vector<int>>>>last={{0,{vector<int>(26,-1),{}}},{0,{vector<int>(26,-1),{}}}};
    rep(i,d){
        vector<pair<P,int>>ma={{{-INF,-1},-1},{{-INF,-1},-1}};
        rep(j,26){
            rep(l,2){
            int score=s[i][j];
            int memo=last[l].se.fi[j];
            last[l].se.fi[j]=i;
            rep(k,26)score-=c[k]*(i-last[l].se.fi[k]);
            last[l].se.fi[j]=memo;
            ma.pb({{score,j},l});
            sort(all(ma),greater<>());
            ma.resize(2);
            }
        }
        vector<pair<int,pair<vector<int>,vector<int>>>>next;
        for(auto p:ma){
            vector<int>v=last[p.se].se.fi;
            vector<int>u=last[p.se].se.se;
            v[p.fi.se]=i;
            u.pb(p.fi.se);
            next.pb({last[p.se].fi+p.fi.fi,{v,u}});
        }
        sort(all(next));
        last=next;
    }
    for(auto i:last[0].se.se)cout<<i+1<<endl;
    return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
int main(void){
    int num;
    scanf("%d",&num);
    int a=1,gt=0;
    while(num>=a){
        if(num-a+1<=a*9){
            gt+=(num-a+1);
        }else{
            gt+=(a*9);
        }
        a*=100;
    }
    printf("%d\n",gt);
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := do(a, b)

	fmt.Println(ans)
}

func do(a, b int) string {
	if (a*b)%2 == 0 {
		return "Even"
	} else {
		return "Odd"
	}
}


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

// MY TOOLS
#define let long long int
#define async ios_base::sync_with_stdio(false);cin.tie(NULL);
#define then ;
//
vector<let> slimes( 402, 0 ) ;
vector<let> cumSum( 402, 0 ) ;
let Sum( let l, let r ){
	let Ans = 0 ;
	if( l == 0 ) Ans = cumSum[r] ;
	else Ans = cumSum[r] - cumSum[l-1] ;
	return Ans ;
}

// main
// write your code here
int main(){
	async ;
	let N, cost = 0 then cin >> N ;
	
	for( int i = 0 ; i < N ; i++ ){ 
		cin >> slimes[i] ;  
	}
	// init cumSum
	cumSum[0] = slimes[0] ;
	for( int i = 1 ; i < N ; i++ ){
		cumSum[i] = slimes[i] + cumSum[i-1] ;
	}
	//



	let dp[N+1][N+1] ;
	memset( dp, 0, sizeof(dp) ) ;
	
	for( int i = 1 ; i < N ; i++ ){
		for( int j = i-1 ; j >= 0 ; j-- ){
			for( int k = j ; k < i ; k++ ){
				let cSum1 = Sum( j, k ) , cSum2 = Sum( k+1, i ) ;
				let tCost1 = dp[j][k], tCost2 = dp[k+1][i] ;
				dp[j][i] = min( (dp[j][i] == 0) ? LLONG_MAX : dp[j][i] , tCost1+tCost2+cSum1+cSum2 ) ;
			}
		}
	}
	cout << dp[0][N-1] ;
    return 0 ;
}

Measured memory_bytes: 4896
s = input()

if s == 'ooo':
    print(1000)
elif s == 'oox' or s == 'oxo' or s == 'xoo':
    print(900)
elif s == 'oxx' or s == 'xox' or s == 'xxo':
    print(800)
else:
    print(700)

Measured memory_bytes: 8896
// template version 1.14
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  string s,t;cin>>s>>t;
  string ans="";
  rep(i,n){
    ans += s[i];
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

ll n;
ll ans=0;
void dfs(ll t,vector<int> c){
    if(t>n){
        // judge
        return;
    }
    if(c[0]==1&&c[1]==1&&c[2]==1)++ans;
    t*=10;
    vector<int> c_c = c;
    c_c[0]=1;
    dfs(t+7,c_c);
    c_c[0] = c[0];
    c_c[1]=1;
    dfs(t+5,c_c);
    c_c[1] = c[1];
    c_c[2]=1;
    dfs(t+3,c_c);
    c_c[2] = c[2];
}

int main(){
    cin >> n;
    dfs(0,vector<int>(3,0));
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split.to!(int[]);
	auto N = data[0], Q = data[1];
	auto S = readln.split[0];
	
	int[] _ACstarts;
	auto cnt = 0;
	while ( cnt < S.length-1 ) {
		if (S[cnt] == 'A') {
			if (S[++cnt] == 'C') _ACstarts ~= cnt-1;
			else --cnt;
		} 
		++cnt;
	}
	auto ACstarts = _ACstarts.assumeSorted();
	
	int[] ls, rs;
	foreach (i; 0 .. Q) {
		data = readln.split.to!(int[]);
		ls ~= data[0]-1, rs ~= data[1]-1;
	}
	
	foreach (i; 0 .. Q) {
		auto l = ls[i], r = rs[i];
		ACstarts.upperBound(l-1).lowerBound(r).length.writeln;
	}
	
}

Measured memory_bytes: 4988
#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 len = S.size();

    ll ans = 0;
    for (int bit = 0; bit < (1 << (len - 1)); bit++)
    {

        ll sum = 0;
        ll tmp = 0;
        for (int i = 0; i < len - 1; ++i)
        {
            if (bit & (1 << i))
            {
                tmp *= 10;
                tmp += S[i] - '0';
                sum += tmp;
                tmp = 0;
            }
            else
            {
                tmp *= 10;
                tmp += S[i] - '0';
            }
        }
        tmp *= 10;
        tmp += S[len - 1] - '0';
        sum += tmp;
        ans += sum;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<n;i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
 
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int 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;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}
 


 
int main(){
	//in_o();
	int64 dp[100];
	dp[0]=2;dp[1]=1;
	FOR(i,2,100){
		dp[i]=dp[i-1]+dp[i-2];
	}
	int n;
	cin>>n;
	cout<<dp[n]<<endl;
	return 0;
}


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

template <class Monoid>
class SegmentTree {
 private:
  using S = typename std::vector<Monoid>::size_type;
  using F = std::function<Monoid(Monoid, Monoid)>;
  S size;
  std::vector<Monoid> nodes;
  const Monoid identity;
  const F operate;

 public:
  SegmentTree(S n, const Monoid& identity, const F& operate) : identity(identity), operate(operate) {
    size = 1;
    while (size < n) size *= 2;
    nodes.assign(2 * size, identity);
  }
  void Update(S i, const Monoid& x) {
    i += (size - 1);
    nodes[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      nodes[i] = operate(nodes[2 * i + 1], nodes[2 * i + 2]);
    }
  }
  Monoid Query(S begin, S end, S i = 0, S b = 0, S e = 0) {
    if (e == 0) e = size;
    if (e <= begin || end <= b) return identity;
    if (begin <= b && e <= end) return nodes[i];
    return operate(Query(begin, end, 2 * i + 1, b, (b + e) / 2), Query(begin, end, 2 * i + 2, (b + e) / 2, e));
  }
};

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

  vector<SegmentTree<int>> v(26, SegmentTree<int>(n, 0, [](int a, int b) { return a + b; }));
  for (int i = 0; i < n; i++) v[s[i] - 'a'].Update(i, 1);

  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int i;
      char c;
      cin >> i >> c;
      i--;
      v[s[i] - 'a'].Update(i, 0);
      v[c - 'a'].Update(i, 1);
      s[i] = c;
    } else if (t == 2) {
      int l, r;
      cin >> l >> r;
      l--;
      int m = 0;
      for (auto& e : v) m += e.Query(l, r) > 0;
      cout << m << endl;
    }
  }
}


Measured memory_bytes: 111620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 10000000
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	int s;
	cin >> s;
	int x = ceil(sqrt(s));
	cout << 0 << " " << 0 << " " << x << " " << 1 << " " << x * x - s << " " << x << endl;
	return 0;
}

Measured memory_bytes: 256
# 標準入力
k = gets.chomp.to_i
a, b = gets.split.map(&:to_i)
# p k,a,b

# 判定
ans = "NG"
m = a % k
(a - m).step(b, step = k).each do |i|
  if a <= i && i <= b then
    ans = "OK"
    break
  end
end

# 解答
puts ans

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  unordered_map<int, int>mp;
  int n, m;
  cin >> n >> m;
  mp[0] = 1;
  ll ans = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    sum += x;
    sum %= m;
    ans += mp[sum];
    mp[sum]++;            
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3724
import itertools
import sys
import math

sys.setrecursionlimit(10**9)

def comb(n, r):
    mod = 10**9 + 7
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * pow(i+1, mod-2, mod) % mod
    return res

def main():
    N, a, b = map(int,input().split())

    # print(comb(10**5,5000,10**9+7))
    nCa = comb(N,a)
    nCb = comb(N,b)

    _, ans = divmod(2**N-1 - nCa - nCb,10**9+7)
    print(ans)

if __name__ == "__main__":
  main()


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'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'};
//cout<<""<<endl;
int main(){
 int N,M;cin>>N>>M;vi a(M),b(M);
  vb A(N+1),B(N+1);
  rep(i,M){
    
    cin>>a[i]>>b[i];
    if(a[i]==1)A[b[i]]=true;
    if(b[i]==N)B[a[i]]=true;
  }
  bool ok=false;
  rep(i,N+1){
    if(A[i] &&B[i])ok=true;
  }
  
  
  if(ok)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  
    
}





Measured memory_bytes: 1920
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INS(n) scanf("%s",s)
#define INF 10000000000
#define mod 1000000007
#define X 100000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;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;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

int main(void){
  ll n,a,b;
  INL(n);
  INL(a);
  INL(b);
  PRL(n/(a+b)*a+min(a,n%(a+b)));
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string a, b;
	int z;
	cin >> a >> b;
	a += b;
	z = stoi(a);
	if (z == static_cast<int>(sqrt(z)) * static_cast<int>(sqrt(z))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	static int TC;
	public static void main(String[] args) {
		TC = new Integer(sc.nextLine());
		for (int i = 0; i < TC; i++) {
			read();
			solve();
		}
	}
	
	static String A, B, C;
	static boolean read() {
		String[] ss = sc.nextLine().split(" ");
		if (ss.length == 3) {
			A = ss[0];
			B = ss[1];
			C = ss[2];
		} else {
			A = ss[0];
			B = "";
			C = ss[1];
		}
		return true;
		
	}

	static void solve() {
		int n = conv(B), dn = 0;
		int g = 0; boolean cnt = false;
		for (int i = 0; i < A.length(); i++) {
			if (cnt && A.charAt(i) != '.') g++;
			else {
				if (A.charAt(i) != '.' && A.charAt(i) != '0') {
					cnt = true;
					g++;
				}
			}
		}
		
		BigDecimal d = new BigDecimal(A), dx = null;
		if (d.compareTo(new BigDecimal("1")) > 0) {
			dx = new BigDecimal("0.1");
			dn = 1;
		} else {
			dx = new BigDecimal("10");
			dn = -1;
		}
		BigDecimal ub = new BigDecimal("9.999999999999999999999999"), lb = new BigDecimal("0.99999999999999999999999999");
		while (d.compareTo(ub) > 0 || d.compareTo(lb) < 0) {
			n += dn;
			d = d.multiply(dx);
		}
		
		String dd = d.toString().substring(0, g + 1);
		if (dd.charAt(dd.length() - 1) == '.') dd = dd.substring(0, dd.length() - 1);
		System.out.println(dd + " * 10^" + n + " " + C);
		
	}	
	
	static int conv(String s) {
		int ret = 0;
		if (s.equals("yotta")) {
			ret = 24; 
		} else if (s.equals("zetta")) {
			ret = 21; 
		} else if (s.equals("exa")) {
			ret = 18;
		} else if (s.equals("peta")) {
			ret = 15;
		} else if (s.equals("tera")) {
			ret = 12;
		} else if (s.equals("giga")) {
			ret = 9;
		} else if (s.equals("mega")) {
			ret = 6;
		} else if (s.equals("kilo")) {
			ret = 3;
		} else if (s.equals("hecto")) {
			ret = 2;
		} else if (s.equals("deca")) {
			ret = 1;
		} else if (s.equals("deci")) {
			ret = -1;
		} else if (s.equals("centi")) {
			ret = -2;
		} else if (s.equals("milli")) {
			ret = -3;
		} else if (s.equals("micro")) {
			ret = -6;
		} else if (s.equals("nano")) {
			ret = -9;
		} else if (s.equals("pico")) {
			ret = -12;
		} else if (s.equals("femto")) {
			ret = -15;
		} else if (s.equals("ato")) {
			ret = -18;
		} else if (s.equals("zepto")) {
			ret = -21;
		} else if (s.equals("yocto")) {
			ret = -24;
		}
		
		return ret;
	}
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int k, x;
  cin >> k >> x;
  for (int i = x - k + 1; i <= x + k - 1; i++) {
    if (i != x - k + 1) cout << ' ';
    cout << i;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if (z->key < x->key){
      x=x->left;
    }
    else
      x = x->right;
  }
  z->parent = y;
 
  if(y==NIL){
    root = z;
  }
  else if(z->key < y->key){
      y->left = z;
  }
  else y->right = z;
}

Node treeSearch(Node u, int k){
while(u != NIL){
    if(u->key == k){
        return u;
    }
    else if(u->key < k){
        u = u->right;
    }
    else {
        u = u->left;
    }
}
return NIL;
}
void inorder(Node u){
if (u !=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
}
void preorder(Node u){
    if(u !=NIL){
printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
    }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  Node t = NIL;
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'f' ){
      scanf("%d", &x);
       t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

map<int, int> m;
template<class T>
void prime_factorize(T n){
    T t = n;
    while(t!=1 && t%2==0){
        m[2]++;
        t /= 2;
    }
    for(T j=3;j*j<=t;j+=2){
        while(t!=1 && t%j==0){
            m[j]++;
            t/=j;
        }
    }
    if(t!=1) m[t]++;
}

int main()
{
    int n; cin >> n;
    FOR(i, 2, n+1) prime_factorize(i);
    ll ans = 1;
    for(auto p: m){
        ans *= 1+p.second;
        ans %= MOD;
    }

    pr(ans);
    return 0;}

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

int main(){
    int n,k;
    cin>>k>>n;
    int maxv=0,a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i>0){
            maxv=max(maxv,a[i]-a[i-1]);
        }
    }
    maxv=max(maxv,a[0]+k-a[n-1]);
    cout<<k-maxv<<endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int sum = 0;
  for(int i = 0;i < N; i++){
    int s,g;
    cin >> s >> g;
    sum+=g-s+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		int sum=0;
		for(int i=1;i<=n;i++)sum+=i;
		System.out.println(sum);
	}
}

Measured memory_bytes: 23892
/*
Read the question and constraints carefully .Take pen and paper and start solving.
write it down
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    int n,i,j,o,c,tot=0,k,o1,c1,f;

    cin>>n;

    string s;
    pair<int,string> p[n];

    rep(i,0,n)
    {
        cin>>s;
        p[i].second = s;

        tot += s.size();

        o1 = c1 = 0;

        int sum=0;
        for(j=o=0;j<s.size();++j)
        {
            sum+=(s[j]=='('?1:-1);
            c1=max(c1,-sum);
//            if(s[j]==')')
//            {
//                if(o==0)
//                    ++c1;
//                else
//                    --o;
//            }
//            else
//                ++o;

        }

        sum=0;
        for(j=s.size()-1,c=0;j>=0;--j)
        {
            sum+=(s[j]=='('?1:-1);
            o1=max(o1,sum);
//              if(s[j]=='(')
//              {
//                  if(c==0)
//                    ++o1;
//                  else
//                    --c;
//              }
//              else
//                  ++c;
        }


        if(o1==0)
            p[i].first = INT_MIN;
        else if(c1==0)
            p[i].first = INT_MAX;
        else if(o1>c1)
            p[i].first = INT_MAX-c1;
        else if(o1<c1)
            p[i].first = INT_MIN+o1;
        else
            p[i].first = 0;



    }

    sort(p,p+n,greater<pair<int,string>>());

     string ans(tot,'a');



    k=0;
    for(i=0;i<n;++i)
    {
        s = p[i].second;

        for(j=0;j<s.size();++j,++k)
        {
            ans[k] = s[j];
        }
    }


    //cout<<ans<<"\n";

    for(i=o=c=0;i<tot;++i)
    {
        if(ans[i]=='(')
            ++o;
        else
            --o;

        if(o<0)
        {
            cout<<"No";
            return 0;
        }
    }


    if(o==0)
        cout<<"Yes";
    else
        cout<<"No";


    return 0;
}


Measured memory_bytes: 43348