akhauriyash/Code-Regression huggingface dataset:
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int n, cnt[64], ans;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1, x; i<=n; i++){
		cin>>x;
		for(int bit=0; bit<60; bit++) if((1LL<<bit)&x) cnt[bit]++;
	}
	for(int bit=0; bit<60; bit++) ans+=(cnt[bit]*(n-cnt[bit])%mod)*((1LL<<bit)%mod)%mod, ans%=mod;
	cout<<ans%mod;
}


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

typedef long long ll;

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

int main() {
	ll a, b;
	cin >> a >> b;
	ll ans = gcd(a, b);
	vector<int> answer;
	for (int i = 2; i <= sqrt(ans); i++) {
		if (ans % i == 0) {
			answer.push_back(i);
			do {
				ans = ans / i;
			} while (ans % i == 0);
		}
	}
	if (ans > 1) answer.push_back(ans);
	cout << (int)answer.size() + 1 << endl;
	
	return 0;
}

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

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS )
#define PI 3.141592653589793238
struct Point3D {
  double x, y, z;
  Point3D() {}
  Point3D(double x, double y, double z) : x(x), y(y), z(z) {}  
  Point3D operator+(Point3D p) { return Point3D(x+p.x, y+p.y, z+p.z); }
  Point3D operator-(Point3D p) { return Point3D(x-p.x, y-p.y, z-p.z); }
  Point3D operator*(double k) { return Point3D(x*k, y*k, z*k); }
  Point3D operator/(double k) { return Point3D(x/k, y/k, z/k); }
  
};

typedef Point3D Vector3D;

struct Segment3D {
  Point3D p1, p2;
  Segment3D() {}
  Segment3D(Point3D p1, Point3D p2) : p1(p1), p2(p2) {}
};
typedef Segment3D Line3D;

struct Sphere {
  Point3D c;
  double r;
  Sphere() {}
  Sphere(Point3D c, double r) : c(c), r(r) {}
};

double norm(Vector3D a) {
  return a.x*a.x+a.y*a.y+a.z*a.z;  
}

double abs(Vector3D a) {
  return sqrt(norm(a));
}

double dot(Vector3D a, Vector3D b) {
  return a.x*b.x+a.y*b.y+a.z*b.z;  
}

Vector3D cross(Vector3D a, Vector3D b) {
  return Vector3D(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);  
}

double getDistanceLP(Line3D l, Point3D p) {
  return abs(cross(l.p2-l.p1, p-l.p1)/abs(l.p2-l.p1));  
}

double getDistanceSP(Segment3D s, Point3D p) {
  if ( dot(s.p2-s.p1, p-s.p1) < 0.0 ) return abs(p-s.p1);
  if ( dot(s.p1-s.p2, p-s.p2) < 0.0 ) return abs(p-s.p2);
  return getDistanceLP(s, p);
}

bool intersectSC(Segment3D s, Sphere c) {
  double d = getDistanceSP(s, c.c);
  if ( d > c.r ) return 0;
  return !((abs(s.p1-c.c) <= c.r) && (abs(s.p2-c.c) <= c.r ));  
}

double calc(double b, Point3D a, Point3D e) {
  return b / (pow(a.x-e.x, 2) + pow(a.y-e.y, 2) + pow(a.z-e.z, 2));  
}

int main() {
  int N, M, R;
  while ( cin >> N >> M >> R, N ) {
    vector<Sphere> s(N);    
    for ( int i = 0; i < N; i++ ) {
      cin >> s[i].c.x >> s[i].c.y >> s[i].c.z >> s[i].r;      
    }
    vector<Point3D> p(M);
    vector<double> b(M);    
    for ( int i = 0; i < M; i++ ) {
      cin >> p[i].x >> p[i].y >> p[i].z >> b[i];      
    }
    Point3D E;
    cin >> E.x >> E.y >> E.z;

    vector<int> ps[M];    
    for ( int i = 0; i < M; i++ ) {
      Segment3D seg = Segment3D(E, p[i]);	  
      for ( int j = 0; j < N; j++ ) {
	if ( intersectSC(seg, s[j]) ) {
	  ps[i].emplace_back(j);	  
	}
      }
    }

    vector<double> sums(1<<M, 0);
    for ( int i = 0; i < (1<<M); i++ ) {
      for ( int j = 0; j < M; j++ ) {
	if ( !(i&(1<<j)) ) continue;
	sums[i] += calc(b[j], p[j], E);	
      }
    }
    
    double ans = 0;
    for ( int i = 0; i < (1<<M); i++ ) {
      int cnt = 0;
      vector<int> used(N, 0);
      for ( int j = 0; j < M; j++ ) {
	if ( !(i&(1<<j)) ) continue;
	// if ( ps[j].size() > R ) break;	
	for ( int k : ps[j] ) {
	  if ( used[k] ) continue;	  
	  cnt++;
	  used[k] = true;	    
	}      
	if ( cnt > R ) {
	  break;
	}
      }
      if ( cnt <= R ) ans = max(ans, sums[i]);      
    }

    printf("%.12lf\n", ans);    
  }
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int res=0,ans=0;
    string s;
    vector<char> data {'A','C','G','T'};
    bool check;
    cin >>s;
    for(int i=0;i<11;i++){
        check=false;
        for(int j=0;j<4;j++){
            if(s[i]==data[j]){
                check=true;
                break;
            }
        }
        //cout << res << endl;
        if(check){
            res++;
        }else{
            ans=max(ans,res);
            res=0;
        }
    }
    
    cout << ans << endl;
}

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

long long int gcd(long long int a, long long int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main(){
  long long int n, k;
  cin >> n >> k;
  if(n < k){
    if(n > k / 2) cout << abs(n - k) << endl;
    else cout << n << endl;
  } else {
    if(n % k == 0) cout << 0 << endl;
    else {
      if(n % k < k / 2) cout << n % k << endl;
      else cout << k - n % k << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
int main(){
    ll n;
    cin>>n;
    ll ans=1000000000005;
    for(ll i=1;i<=sqrt(n);i++){
        ll j=n/i;
        if(j*i==n) ans=min(ans,i+j-2);
    }
    cout<<ans<<"\n";
    return 0;
}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll A, B, K; cin >> A >> B >> K;

    if (A+K-1 >= B-K+1) {
        for (int i = A; i <= B; ++i) {
            cout << i << endl;
        }
        return 0;
    }

    for (int i = A; i < A+K; ++i) {
        cout << i << endl;
    }

    for (int i = B-K+1; i <= B; ++i) {
        cout << i << endl;
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

int par(vector<int> v, int n) {
  int num = 0;
  vector<int> array;
  rep(i, n) array.push_back(i+1);
  
  do {
    if(v == array) return num;
    else ++num;
  } while(next_permutation(array.begin(), array.end()));
}

int main() {
  int n; cin >> n;
  vector<int> a, b;
  rep(i, n) {
    int x; cin >> x;
    a.push_back(x);
  }
  rep(i, n) {
    int x; cin >> x;
    b.push_back(x);
  }
  cout << abs(par(a, n) - par(b, n)) << endl;
}


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

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

    string ans = "Good";
    for (int i = 0; i < (int)s.length()-1; ++i) {
        if (s[i] == s[i+1]) {
            ans = "Bad";
            break;
        }
    }
    cout << ans << endl;

}



Measured memory_bytes: 256
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(n)]
ab.sort()
cd.sort()
ans = 0
for i in cd:
    c, d = i
    flag = False
    cur = 0
    difference = float("inf")
    for i in range(n):
        a, b = ab[i]
        if a < c and b < d:
            if difference > d - b:
                difference = min(difference, d - b)
                flag = True
                cur = i
    if flag:
        ab[cur] = [float("inf"), float("inf")]
        ans += 1
print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int64_t a,b,x;

  cin >> a >> b >> x ;

  int64_t ans=0;

  if(x==1){ cout << b-a+1 << endl; return 0;}

  int64_t A=(a-1)/x+1,B=b/x+1;

  if(a==0) A=0;

  ans=B-A;
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    int n;
    int h[105];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> h[i];
    long long ans = 0;
    for (int nowh = 105; nowh >= 0; nowh--) {
        bool now = false;
        int num = 0;
        for (int x = 0; x < n; x++) {
            if (now) {
                if (h[x] <= nowh) {
                    num++;
                    now = false;
                }
            } else {
                if (h[x] > nowh)
                    now = true;
            }
        }
        if (now)
            num++;
        ans += num;
        // printf("nowh=%d, num=%d\n", nowh, num);
    }
    cout << ans;
}

Measured memory_bytes: 256
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())

for i in range(n):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:
        a[j][k]=0

ans=0
for i in range(3):
  if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
    ans=1
  elif a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
    ans=1

if a[1][1]==0 and a[2][2]==0 and a[0][0]==0:
  ans=1
elif a[0][2]==0 and a[1][1]==0 and a[2][0]==0:
  ans=1

if ans==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF=1000000000LL;
const ll MOD=1000000007LL;
const ll MAX=100010;
int main(){
	int n;
	while(cin>>n,n){
		vector<P> v;
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++){
				int h,m,s;
				scanf("%d:%d:%d",&h,&m,&s);
				int t=h*3600+m*60+s;
				if(j){
					v.pb(P(t,-1));
				}else{
					v.pb(P(t,1));
				}
			}
		}
		sort(v.begin(),v.end());
		int ans=0;
		int r=0;
		for(int i=0;i<2*n;i++){
			r+=v[i].second;
			ans=max(r,ans);
		}
		cout<<ans<<endl;
	}
	return 0;
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N;cin>>N;
    vint A(N);rep(i,N)cin>>A[i],A[i]--;

    int ans=0;
    rep(i,N){
        if(A[i]>i&&A[A[i]]==i)ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#累積和で計算量を減らすO(N)
N,K = gets.strip.split.map(&:to_i)
a = gets.strip.split.map(&:to_i)
s = Array.new(a.length+1)
s[0] = 0

0.upto(a.length-1) do |i|
  s[i+1] = s[i] + a[i]
end

ans = 0
(0..N-K).each  do |i|
  if ans < (s[i+K]-s[i]+K).to_f/2 then
    ans = (s[i+K]-s[i]+K).to_f/2
  end
end
puts ans

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

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 vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;

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

    int ans = 0;
    for (int fr = 0; fr <= N; fr++) {
        for (int bk = 0; fr + bk <= min(N, K); bk++) {
            vi get;
            for (int i = 0; i < N; i++) {
                if (i < fr || i >= N - bk)
                    get.push_back(v[i]);
            }

            sort(all(get), greater<int>());

            int ops = K - fr - bk;
            while (ops && !get.empty() && get.back() < 0) {
                get.pop_back();
                ops--;
            }

            int cand = 0;
            for (int v : get)
                cand += v;
            ans = max(ans, cand);
        }
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
template <typename T> istream &operator>>(istream &is, vector<T> &v) {
    for(T &in : v)
        is >> in;
    return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++)
        os << (i ? " " : "") << v[i];
    return os;
}
/*-------------------------------------------*/

int D;
int c[26];
int s[365][26];

void input() {
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(d, D) rep(i, 26) cin >> s[d][i];
}

int compute_score(const vector<int> &v) {
    int ret = 0;
    int last[26]{};
    rep(d, v.size()) {
        ret -= (d + 1 - last[v[d]]) * (d - last[v[d]]) / 2 * c[v[d]];
        ret += s[d][v[d]];
        last[v[d]] = d + 1;
    }
    rep(i, 26) ret -= (D + 1 - last[i]) * (D - last[i]) / 2 * c[i];
    return ret;
}

// 山登り法
vector<int> solve() {
    const double TL = 1.9;
    vector<int> ret(D);
    for(int &e : ret)
        e = rand() % 26;
    int score = compute_score(ret);
    while(clock() < TL * CLOCKS_PER_SEC) {
        int r = rand();
        int d = r % D;
        int q = r % 26;
        int old = ret[d];
        ret[d] = q;
        int new_score = compute_score(ret);
        if(score > new_score)
            ret[d] = old;
        else
            score = new_score;
    }
    return ret;
}

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

    input();

    srand((unsigned)time(NULL));

    auto ret = solve();
    for(int e : ret)
        cout << e + 1 << "\n";

    cerr << compute_score(ret) << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//################################################################
ll n;
ll a[1000005];
ll mem[1000005];

int main() {
    n = LLD();
    for (int i = 0; i < n; i++)a[i] = LLD();
    mem[0]=0;
    mem[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        mem[i]=min(abs(a[i]-a[i-1])+mem[i-1],abs(a[i]-a[i-2])+mem[i-2]);
    }
    printf("%lld",mem[n-1]);

}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define all(v)   v.begin(),v.end()
#define all(v) v.begin(),v.end()
#define meow ios::sync_with_stdio(0);cin.tie(0);
 
typedef long long int ll;
typedef unsigned long long int ull;
 
int main()
{
    meow;
    ll i,t,j,nl,cnt=0;
    string str;
    map<string,ll>m;
 
    cin>>t;
    while(t--)
    {
        cin>>str;
        m[str]++;
    }
    /* for(auto x:m)
     {
         cout<<x.first<<"  "<<x.second<<endl;
     }*/
    /*for(auto x:m)
        {
            v.push_back({x.second,x.first})
        }*/
	for(auto x : m)
	{
		cnt=max(cnt,x.second);
	}
 
//cout<<cnt<<"xxxxx"<<endl;
	for(auto x : m)
	{
		if(x.second==cnt)
		 cout<<x.first<<endl;
	}
}

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

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};

istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, k;
    cin >> n >> k;
    
    mint ans = 0;
    for (int i = k; i <= n+1; i++) {
        ll t = (ll)i*n - 2*sum(i-1) + 1;
        ans += t;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<set>
using namespace std;
#define endl '\n'
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long k,n,tmp=0,tmp2=0;
    cin>>k>>n;
    long long a[n];
    vector<int> v;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=1; i<n; i++){
        v.push_back(a[i]-a[i-1]);
    }
    for(int i=0; i<v.size(); i++)
        tmp+=v[i];
    v.push_back(k-tmp);
    sort(v.begin(), v.end());
    for(int i=0; i<v.size()-1; i++)
        tmp2+=v[i];
    cout<<tmp2;


}


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

int main(){
  int n,k,sum,summ;
  scanf ("%d %d",&n,&k);
  while(n){
    sum=0;
    summ=0;
    vector<int> a(n);
    for(int t=0;t<n;t++){
      scanf ("%d",&a[t]);
    }
    for(int t=0;t<k;t++){
      sum+=a[t];
    }
    summ=sum;
    for(int t=k;t<n;t++){
      sum=sum+a[t]-a[t-k];
      if(sum>summ){
        summ=sum;
      }
    }
    printf("%d\n",summ);
    scanf ("%d %d",&n,&k);
  }
}



Measured memory_bytes: 3388
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int A, B ,C;
	cin >> A >> B >> C;
	if (A > C&&C > B) {
		cout << "Yes";
	}else if(A < C && C<B){
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int64_t ans=0;
    rep(b,K+1,N+1){
        ans+=(N/b)*(b-K);
        ans+=max(0,N%b-K+1);
    }
    if(!K) ans-=N;

    cout<<ans<<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 < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    int N = 0;
    for(auto c : s) {
        N += c - '0';
        N %= 9;
    }
    if(N%9 == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

long a[55], b[55];
long f(int n, long x) {
	if (!x) return 0;
	if (!n) return 1;
	if (x < a[n - 1] + 2)
		return f(n - 1, x - 1);
	return b[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
}
int main() {
	int n;
	long x;
	cin >> n >> x;
	a[0] = b[0] = 1;
	for (int i = 0; i < n; i++) {
		a[i + 1] = a[i] * 2 + 3;
		b[i + 1] = b[i] * 2 + 1;
	}
	cout << f(n, x) << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    string s; cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
        return 0;
    }
    if(s == "Cloudy"){
        cout << "Rainy" << endl;
        return 0;
    }
    if(s == "Rainy"){
        cout << "Sunny" << endl;
        return 0;
    }

}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, k; cin >> n >> k;
  ll ans = k;
  REP(i, n-1) ans *= k-1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 1e6 + 1;
int dp[3000] , S;
int main(){	
	cin >> S;
	for (int i = 3; i <= S; ++i){
		if(++dp[i] >= M) dp[i] -= M;
		for (int j = 3; j <= S && i - j >= 3; ++j){
			dp[i] += dp[i-j];
			if(dp[i] >= M) dp[i] -= M;
		}
	}
	cout << dp[S] << endl;
	
	
		
}	

Measured memory_bytes: 3604
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;

fn main() {


  input! { 
         k: i32, 
         x: i32
    }

   let start = cmp::max(-1000000 , x-k+1);
   let end = cmp::min(1000000 , x+k-1);
   for item in start..end+1{
       println!("{}",item);
   }

}


Measured memory_bytes: 4352
import java.util.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args){
		Deque<Integer> S = new ArrayDeque<Integer>();
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] str = line.split(" ");
		for(String s : str){
			if(s.equals(""))
				break;
			if(s.equals("+")){
				int b = S.pop();
				int a = S.pop();
				S.push(a + b);
//				System.out.printf("%d + %d = %d\n", a, b, a+b);
			}else if(s.equals("-")){
				int b = S.pop();
				int a = S.pop();
				S.push(a - b);
//				System.out.printf("%d - %d = %d\n", a, b, a - b);
			}else if(s.equals("*")){
				int b = S.pop();
				int a = S.pop();
				S.push(a * b);
//				System.out.printf("%d * %d = %d\n", a, b, a * b);
			}else{
				S.push(Integer.parseInt(s));
//				System.out.printf("insert %d\n", Integer.parseInt(s));
			}
//			System.out.println(S);
		}
		sc.close();
		System.out.println(S.getFirst().intValue());

	}

}


Measured memory_bytes: 26176
<?php
	$stdin = trim(fgets(STDIN));
	$h = floor($stdin / (60 * 60));
	$m = floor($stdin % (60 * 60) / 60);
	$s = $stdin % (60 * 60) % 60;
	echo $h . ":" . $m . ":" . $s . PHP_EOL;

Measured memory_bytes: 15164
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


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


/*nまでの素数を列挙して配列に保持*/
vector<ll> Eratosthenes(ll n) {

	vector<ll> arr(n);
	for (ll i = 0; i < n; i++) {
		arr[i] = 1;
	}
	arr[0] = arr[1] = 0;
	for (ll i = 2; i < sqrt(n); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < n; j++) {
				arr[i * (j + 2)] = 0;
			}
		}
	}
	return arr;
}

int a[100005];

int main() {

	int n, t;
	cin >> n >> t;

	for (int i = 0; i < n; i++)
	{
		int l, r;
		cin >> l >> r;
		a[l]++;
		a[r]--;
	}

	int maxi = a[0];
	for (int i = 0; i <= t; i++)
	{
		a[i + 1] += a[i];
		maxi = max(maxi, a[i + 1]);
	}

	cout << maxi << endl;

	

	
	return 0;
}


Measured memory_bytes: 3484
const { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } = require("constants");

/**
 * main処理
 *
 * @param {*} lines
 */
const main = async (lines) => {
    let n;
    const a = [];

    // 以下読み取り
    for (let i = 0; i < lines.length; i++) {
        v = lines[i];

        if (v != "") { // 入力のある行のみ読み込む

            // 0行目でnの読み取り
            if (i == 0) {
                n = v;
            }

            if (i == 1) {
                const inputs = v.split(" ");
                for (let j = 0; j < inputs.length; j++) {
                    a[j] = Number(inputs[j]);
                }
                a.sort((a, b) => {
                    if (a > b) return -1;
                    if (a < b) return 1;
                    return 0;
                });
            }

        }
    }

    let sum = 0;
    for (let i = 0; i < n - 1; i++) {
        if (i == 0) {
            sum += a[i];
        } else {
            const b = Math.floor((i + 1) / 2);
            sum += a[b];
        }
    }
    console.log(sum);
}

/**
 * 入力を読み取る
 *
 */
const runWithStdin = async () => {
    let input = "";
    process.stdin.resume();
    process.stdin.setEncoding("utf8");

    process.stdin.on("data", v => {
        input += v;
    });
    process.stdin.on("end", () => {
        main(input.split("\n"));
    });
}
runWithStdin();

Measured memory_bytes: 57080
N, X = map(int, input().split())
L=[int(i) for i in input().split()] 
# N=4
# X=9
# L=[3,3,3]

a=0
count=1
for i in range(len(L)):
#     print(i)
#     print(L[i])
    a+=L[i]
#     print(a)
    if(a<=X):
#         print(a)
        count+=1
print(count)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main(){
	long long int i,T=1,N,A[100001];
	scanf ("%lld",&N);
	for (i=0;i<N;i++){
		scanf ("%lld",&A[i]);
		if (A[i]==0){
			printf("0\n");
			return 0;
		}
	}
	for (i=0;i<N;i++){
		if (A[i] <= 1000000000000000000/T){
			T *= A[i];
		}
		else{
			printf ("-1\n");
			return 0;
		}
	}
	printf ("%lld\n",T);
	return 0;
}

Measured memory_bytes: 2456
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n;
  cin>>n;
  long long int ans=1;
  for(long int i=0;i<n;i++){
    long long int a;
    cin>>a;
    if(ans!=-1){
      if(log10l(a)+log10l(ans)<19){
        if(a*ans<=1000000000000000000){
        ans=a*ans;
        }
        else{
        ans=-1;
      }
      }
      else{
        ans=-1;
      }
    }
    if(a==0){
      ans=0;
      break;
    }
  }
  cout<<ans<<endl;
}


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

int selectionSort(int A[], int N){
    int mini, minj;
    int sw = 0;
    for (int i = 0; i < N; i++){
        minj = i;
        for (int j = i; j < N; j++){
            if (A[j] < A[minj]) {minj = j;}
        }
        swap(A[i], A[minj]);
        if (minj != i) sw++;
    }
    return sw;
}

int main(){
    int N;
    int A[110];
    int sw;
    cin >> N;
    for (int i = 0; i < N; i++){ cin >> A[i]; }
    
    sw = selectionSort(A, N);
    for (int i = 0; i < N; i++){
        if(i){cout << " ";}
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}
    
            


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

struct edge { ll v, d, c; };

class Dijkstra {
public:
  struct edge { ll v, dist; };

  struct state {
    ll v, cost;
    bool operator>(const state s) const { return cost > s.cost; }
  };

  const ll INF = (1LL << 60);
  ll N;
  vector< vector<edge> > E;

  Dijkstra(ll n): N(n), E(n) {}

  void add_directed_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
  }

  void add_undirected_edge(ll u, ll v, ll d) {
    E[u].push_back((edge) { v, d });
    E[v].push_back((edge) { u, d });
  }

  vector<ll> shortest_path(ll S) {
    vector<ll> dp(E.size(), INF);
    priority_queue<state, vector<state>, greater<state> > q;
    q.push((state) { S, 0 });
    while(!q.empty()) {
      ll v = q.top().v, cost = q.top().cost;
      q.pop();
      if(dp[v] <= cost) continue;
      dp[v] = cost;
      REP(i, 0, E[v].size()) {
        ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
        if(dp[nv] > ncost) q.push((state) { nv, ncost });
      }
    }
    return dp;
  }
};

int main(void) {
  ll N, M;
  while(cin >> N >> M) {
    if(N == 0 && M == 0) break;

    Dijkstra dijkstra(N);
    vector< vector<edge> > E(N);
    REP(i, 0, M) {
      ll U, V, D, C;
      cin >> U >> V >> D >> C;
      U--;
      V--;
      E[U].push_back((edge) { V, D, C });
      E[V].push_back((edge) { U, D, C });
      dijkstra.add_undirected_edge(U, V, D);
    }

    vector<ll> dist = dijkstra.shortest_path(0);

    ll ans = 0;
    REP(i, 1, N) {
      ll x = (1LL << 60);
      for(edge &e: E[i]) {
        if(dist[e.v] + e.d == dist[i]) {
          x = min(x, e.c);
        }
      }
      ans += x;
    }

    cout << ans << endl;
  }
}



Measured memory_bytes: 6176
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>

using namespace std;

int main()
{
	int card[4][13];
	for(int j = 0; j < 4;++j) {
		for(int k = 0; k < 13;++k) {
			card[j][k] = 0;
		}
	}

	int c_num, rank;
	char mark;
	cin >> c_num;
	for(int i = 0; i < c_num; ++i) {
		cin >> mark >> rank;
		switch(mark) {
			case 'S':
				card[0][rank - 1] = 1;
				break;
			case 'H':
				card[1][rank - 1] = 1;
				break;
			case 'C':
				card[2][rank - 1] = 1;
				break;
			case 'D':
				card[3][rank - 1] = 1;
				break;
		}
	}

	for(int j = 0; j < 4;++j) {
		for(int k = 0; k < 13;++k) {
			if(card[j][k] == 0) {

				switch(j) {
					case 0:
						cout << 'S' << " ";
						break;
					case 1:
						cout << 'H' << " ";
						break;
					case 2:
						cout << 'C' << " ";
						break;
					case 3:
						cout << 'D' << " ";
						break;
				}
				cout << k + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

#define VMAX 100

struct OwnEdge
{
	int f, t, flow, cap,cost;
	OwnEdge(int f, int t, int flow, int cap,int cost) :f(f), t(t), flow(flow), cap(cap),cost(cost) {}
};

vector<OwnEdge> G[VMAX];
int h[VMAX], tod[VMAX], prevv[VMAX], preve[VMAX];

int solve(int n, int src, int dest, int F)
{
	int ans = 0;
	while (F > 0)
	{
		fill(tod, tod + VMAX, INF);
		priority_queue<pii, vector<pii>, greater<pii>> pq;
		tod[src] = 0;
		pq.push(make_pair(0, src));
		while (!pq.empty())
		{
			pii temp = pq.top();
			pq.pop();
			if (tod[temp.second] < temp.first)
			{
				continue;
			}
			for (int i = 0; i != G[temp.second].size(); i++)
			{
				if (G[temp.second][i].cap <= G[temp.second][i].flow)
				{
					continue;
				}
				if (tod[G[temp.second][i].t] + h[G[temp.second][i].t]>tod[temp.second] + h[temp.second] + G[temp.second][i].cost)
				{
					tod[G[temp.second][i].t] = tod[temp.second] + h[temp.second] + G[temp.second][i].cost - h[G[temp.second][i].t];
					prevv[G[temp.second][i].t] = temp.second;
					preve[G[temp.second][i].t] = i;
					pq.push(make_pair(tod[G[temp.second][i].t], G[temp.second][i].t));
				}
			}
		}

		if (tod[dest] == INF)
		{
			return -1;
		}

		for (int i = 0; i < n; i++)
		{
			h[i] += tod[i];
		}
		int td = F;
		for (int i = dest; i != src; i = prevv[i])
		{
			td = min(td, G[prevv[i]][preve[i]].cap - G[prevv[i]][preve[i]].flow);
		}
		F -= td;
		ans += td*h[dest];
		for (int i = dest; i != src; i = prevv[i])
		{
			G[prevv[i]][preve[i]].flow += td;
			G[i][G[prevv[i]][preve[i]].f].flow -= td;
		}
	}
	return ans;
}

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

	int V, E, F;
	cin >> V >> E >> F;

	for (int i = 0; i < E; i++)
	{
		int u, v, c, d;
		cin >> u >> v >> c >> d;

		int tus = G[u].size(), tvs = G[v].size();

		G[u].push_back(OwnEdge(tvs, v, 0, c, d));
		G[v].push_back(OwnEdge(tus, u, c, c, -d));
	}

	cout << solve(V, 0, V - 1, F) << endl;

	return 0;
}


Measured memory_bytes: 3272
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	const char R[11] = { 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'u', 'y' };

	string S;

	bool right[2];

	int Answer;

	vector<int> Ans;

	while (true)
	{
		Answer = 0;

		cin >> S;

		if (S == "#")
		{
			break;
		}

		for (int i = 0; i < S.size(); i++)
		{
			right[0] = right[1];

			right[1] = false;

			for (int j = 0; j < 11; j++)
			{
				if (S[i] == R[j])
				{
					right[1] = true;
				}
			}

			if (right[0] != right[1] && i != 0)
			{
				Answer++;
			}
		}

		Ans.push_back(Answer);
	}

	for (int i = 0; i < Ans.size(); i++)
	{
		cout << Ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
ll N,A,B,K;
ll kai[300001];
ll gya[300001];
ll nck[300001];
//
ll pow(ll x,ll n,ll mod){
  ll res=1;
  if(n>0){
    res=pow(x,n/2,mod);
    if(n%2==0){
      res=(res*res)%mod;
    }else{
      res=(((res*res)%mod)*x)%mod;
    }
  }
  return res;
}
//
ll inv(ll n,ll mod){
  return pow(n,mod-2,mod);
}
//
void nCk(ll n,ll mod){
    kai[n]=n;
    ROF(i,1,n){
      (kai[i]=kai[i+1]*i)%=mod;
    }
    gya[1]=inv(1,mod);
    FOR(i,2,n+1){
        (gya[i]=gya[i-1]*inv(i,mod))%=mod;
    }
    FOR(i,1,n){
        (nck[i]=kai[N+1-i]*gya[i])%=mod;
    }
    nck[0]=1;nck[n]=1;
}
int main(){
	cin>>N>>A>>B>>K;
	nCk(N,mod);
	ll ans=0;
	FOR(i,0,N+1){
		ll a=i;
		ll b=(K-a*A)/B;
		if(K==A*a+B*b&&0<=a&&a<=N&&0<=b&&b<=N){
			(ans+=nck[a]*nck[b])%=mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7296
n, k = list(map(int, input().split()))
s = input()

l = [0]
ans = 0

for i in range(1, n):
  if s[i-1]=="1" and s[i]=="0":
    l.append(i)
  if s[i-1]=="0" and s[i]=="1":
    l.append(i)

for i, e in enumerate(l):
  if s[e]=="0":
    if i+2*k>=len(l):
      ans = max(ans, n-e)
    else:
      ans = max(ans, l[i+2*k]-e)
  else:
    if i+2*k+1>=len(l):
      ans = max(ans, n-e)
    else:
      ans = max(ans, l[i+2*k+1]-e)
print(ans)

Measured memory_bytes: 7192
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	m := map[string]int{}
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		m[s]++
	}

	fmt.Println(len(m))
}


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

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

#ifdef __WIN32
#define LLFORMAT "I64"
#define Rand() ((rand() << 15) + rand())
#else
#define LLFORMAT "ll"
#define Rand() (rand())
#endif

using namespace std;

const int maxn = 2e5 + 10;

int n, f[maxn];

int main(int argc, char *argv[]) {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		int x;
		scanf("%d", &x);
		f[x] = f[x - 1] + 1;
	}
	int ans = n;
	for (int i = 1; i <= n; ++i) {
		ans = min(ans, n - f[i]);
	}
	printf("%d\n", ans);
	return 0;
}



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

int main(){
    ll N;
    cin >> N;
    map<char, ll> mp;
    rep(i, 0, N){
        char c; cin >> c;
        mp[c]++;
    }
    if(mp.size() == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
    return 0;
}

Measured memory_bytes: 256
/// by ztx
/// blog.csdn.net/hzoi_ztx
#include <bits/stdc++.h>
#define Rep(i,l,r) for(i=(l);i<=(r);i++)
#define rep(i,l,r) for(i=(l);i< (r);i++)
#define Rev(i,r,l) for(i=(r);i>=(l);i--)
#define rev(i,r,l) for(i=(r);i> (l);i--)
#define Each(i,v)  for(i=v.begin();i!=v.end();i++)
#define r(x)   read(x)
typedef long long ll ;
typedef double lf ;
int CH , NEG ;
template <typename TP>inline void read(TP& ret) {
    ret = NEG = 0 ; while (CH=getchar() , CH<'!') ;
    if (CH == '-') NEG = true , CH = getchar() ;
    while (ret = ret*10+CH-'0' , CH=getchar() , CH>'!') ;
    if (NEG) ret = -ret ;
}

#define  kN  200010LL
#define  t(p) e[0][p]
#define  n(p) e[1][p]
#define  s(u) st[u]

using namespace std;

int e[2][kN], st[kN], te = 0;
inline void Add(int u,int v) { te++;t(te)=v;n(te)=s(u);s(u)=te; }

int n, ind[kN], a[kN], nxt[kN];

int s[kN], top = 0;
set<int>S[kN];

void getnxt(int u) {
	if (nxt[u]) return;
	for(int p=s(u);p;p=n(p)) if (ind[t(p)]) {
		getnxt(nxt[u]=t(p)); break;
	}
}

bool check(int u,int U,int af,int aU) {
	int szorg, sznow, au, ret = true;
	szorg = S[u].size();
	S[u].insert(af);
	sznow = S[u].size();
	auto it = S[u].end(); it -- ;
	if (*it == S[u].size()-1) au = S[u].size();
	else {
		au = -1;
		for (auto v : S[u]) if (au ++ , au != v) break;
	}
	if (u==U && au!=aU) ret = false;
	if (ret==false || u==U) {
		if (sznow > szorg) S[u].erase(af);
		return ret;
	}
	ret = check(nxt[u],U,au,aU);
	if (sznow > szorg) S[u].erase(af);
	return ret;
}

int main() {
	int u, v, p, cnt;
    r(n);
    Rep (u,1,n) r(v), Add(u,v), ind[v] ++ ;
    Rep (u,1,n) if (!ind[u]) s[++top] = u;
    while (top) {
        u = s[top--];
        if (S[u].empty()) a[u] = 0;
        else {
            auto it = S[u].end(); it -- ;
            if (*it == S[u].size()-1) a[u] = S[u].size();
            else {
            	p = -1;
            	for (auto v : S[u]) if (p ++ , v != p) {
					a[u] = p; break;
				}
			}
        }
        for (p = s(u); p; p = n(p))
			if (S[t(p)].insert(a[u]), !(--ind[t(p)]))
				s[++top] = t(p);
    }
    cnt = 0;
    Rep (u,1,n) if (ind[u]) {
    	cnt ++ ;
    	if (S[u].empty()) continue;
    	getnxt(u);
    	auto it = S[u].end(); it -- ;
    	int val[3]; val[0] = 0;
    	p = -1;
    	for (auto v : S[u]) if (p ++ , v != p) {
    		while (p != v) {
    			val[++val[0]] = p;
    			p ++ ;
    			if (val[0] == 2) break;
			}
    		if (val[0] == 2) break;
		}
    	if (!val[0])
    		val[1] = S[u].size(), val[2] = val[1]+1;
		else if (val[0]==1)
			val[2] = S[u].size()+1;
		puts((check(nxt[u],u,val[1],val[1])||check(nxt[u],u,val[2],val[2])) ? "POSSIBLE": "IMPOSSIBLE");
		goto END;
    }
	puts(cnt&1 ? "IMPOSSIBLE": "POSSIBLE");
    END: getchar(), getchar();
    return 0;
}

Measured memory_bytes: 39168
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	for(int W, H; cin >> W >> H, W || H;) {
		vector<string> field(H);
		rep(i,H) cin >> field[i];
		// First = y, Second = x;
		P s;
		rep(y,H) rep(x,W) {
			if(field[y][x] == '@') {
				s.first = y;
				s.second = x;
			}
		}

		bool reach[20][20];
		memset(reach, 0, sizeof reach);

		int ans = 1;
		reach[s.first][s.second] = true;

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

		queue<P> que;
		que.push(s);
		while(!que.empty()) {
			P here = que.front();
			que.pop();

			rep(i,4) {
				int ny = here.first + dy[i];
				int nx = here.second + dx[i];
				if(0 <= ny && ny < H && 0 <= nx && nx < W && field[ny][nx] == '.' && reach[ny][nx] == false) {
					reach[ny][nx] = true;
					ans++;
					que.push(mp(ny, nx));
				}
			}
		}

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

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

bool read(int** ppArray, int &n)
{
    cin >> n;
    *ppArray = new int[n];
    if (NULL == ppArray) {
        return false;
    }
    for (int i = 0; i < n; i++) {
        cin >> *(*ppArray + i);
    }

    return true;
}

int bubbleSort(int* A, int N)
{
    int sw = 0;
    int flag = 1;
    while (flag) {
        flag = 0;
        for (int i = N - 1; i >= 1; i--) {
            if (*(A + i) < *(A + i - 1)) {
                swap(*(A + i), *(A + i - 1));
                flag = 1;
                sw++;
            }
        }
    }

    return sw;
}

int main()
{
    int n = 0;
    int* pArray = NULL;

    if (!read(&pArray, n)) {
        return 1;
    }

    int sw = bubbleSort(pArray, n);

    for (int i = 0; i < n; i++) {
        i > 0 ? cout << " " << *(pArray + i) : cout << *(pArray + i);
    }
    cout << endl;
    cout << sw << endl;

    delete[] pArray;

    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	ll res=1;
	int I=0,num=0,b=0;
	while(I<n){
		num++;
		if(b||num>a[I]/2+1){
			I--;
			num--;
			(res*=num)%=mod;
			num--;
			b=-1;
		}
		if(b==0&&a[I]%2==0&&a[I]/2+1==num) b=1;
		else b=0;
		I++;
	}
	for(int i=1;i<=num;i++) (res*=i)%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int result;
  int i,j;
  int n;
  while(scanf("%d",&n)!=EOF)
    {
      result=0;
      for(i=0;i<10;i++)
	{
	  if((n-i<0)||(n-i>27)) continue;
	  for(j=0;j<10;j++)
	    {
	      if((n-(i+j)<0)||(n-(i+j)>18)) continue;
	      if(n-(i+j)<10) result+=n-(i+j)+1;
	      else result+=19-n+(i+j);
	    }
	}
      printf("%d\n",result);
    }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin>>s){
		if(s.length()==1&&s[0]=='0')break;
		int k=0;
		for(int i=0;i<s.length();i++)k+=s[i]-'0';
		cout<<k<<endl;
	}
	return 0;
}


Measured memory_bytes: 3228