akhauriyash/Code-Regression huggingface dataset:
/*
    Author : Simanta Deb Turja
*/
#include <bits/stdc++.h>
using namespace std;

#define Professor

using ll = long long;
using i64 = unsigned long long;

template <typename T> inline T Min (T a, T b, T c) { return min(a, min(b, c)); }
template <typename T> inline T Min (T a, T b, T c, T d) { return min(a, min(b, min(c, d))); }
template <typename T> inline T Max (T a, T b, T c) { return max(a, max(b, c)); }
template <typename T> inline T Max (T a, T b, T c, T d) { return max(a, max(b, max(c, d))); }

template <typename T> inline T Ceil(T a, T b) { return ((a % b == 0) ? (a / b) : (a / b + 1)); } 
template <typename T> inline T Floor(T a, T b) { return a / b; }

template <typename T> inline T Power (T a, T p) { T res = 1, x = a; while ( p ) { if ( p & 1 ) res = ( res * x ); x = ( x * x ); p >>= 1;}return res; }
template <typename T> inline T BigMod (T a,T p,T M) { a %= M;T ret = 1; while (p) { if (p & 1) ret = (ret * a) % M; a = (a * a) % M; p = p >> 1; } return ret; }
template <typename T> inline T InverseMod (T a,T M) { return BigMod (a, M - 2, M); }

template <typename T> inline T gcd ( T a, T b ) { a = abs(a); b = abs(b); while ( b ) { a = a % b; swap ( a, b ); } return a; }
template <typename T> inline T lcm(T x,T y) { return (((x)/gcd((x),(y)))*(y)); }


#define endl '\n'
#define eb emplace_back

const int N = (int)4e5 + 10;
const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = numeric_limits<ll>::max();
const int INF = numeric_limits<int>::max();
const ll MOD = (ll)1e9 + 7;

template <typename T> bool cmp (const pair <T, T> &a, const pair <T, T> &b) { return a.first < b.first; }


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    auto Solve = [&]() {
        #ifdef __APPLE__
            cout << "Running\n";
        #endif
        int n;
        cin >> n;
        vector <int> h(n + 1), dp(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> h[i];
        }
        dp[1] = 0, dp[2] = abs(h[2] - h[1]);
        for (int i = 3; i <= n; ++i) {
            dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
        }
        cout << dp[n] << endl;

    };
    Solve();
    
    return 0;
}



Measured memory_bytes: 1024
/**
       **********    ************
	  Author : Avi J Patel
	  University : DA-IICT
       **********    ************
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001
#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    if(a.second < b.second) return true; 
    else if(a.ss==b.ss) return a.ff<b.ff;
	else return false;
}
bool sortbyboth(const pair<int,int> &a, const pair<int,int> &b)
{
	if(a.first<b.first) return true;
	else if(a.first==b.first) return a.second<b.second;
	else return false;
}
int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			ans+=(a[i]*a[j]);
		}
	}
	cout<<ans;
	return 0;
}















Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	int N;
	cin>>N;
	lli A[MAX],B[MAX];
	rep(i,N)cin>>A[i]>>B[i];
	lli ans=0;
	for(int i=N-1;i>=0;i--){
		A[i]+=ans;
      	if(A[i]%B[i]==0)continue;
		ans+=(A[i]/B[i]+1)*B[i]-A[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  if(n<=104){
    print(0);
  }
  else{
    for (ll i = 1; i <= n;i+=2){
      ll count = 0;
      for (ll j = 1; j <= i;j++){
        if(i%j==0){
          count++;
        }
      }
      if(count==8){
        ans++;
      }
    }
    print(ans);
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace dpsheet
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            int[] temp = new int[n];
            string[] st = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
                arr[i] = int.Parse(st[i]);
            for (int i = 0; i < n; i++)
                temp[i] = -1;
            Console.WriteLine(frog(arr, 0, n, temp));

        }
        static int frog(int[] arr, int i, int n, int[] temp)

        {
            int m = int.MaxValue;
            if (temp[i] != -1)
                return temp[i];
            if (i == n - 1 || i == n)
                return temp[i] = 0;
            for (int j = i + 1; j <= i + 2 && j < n; j++)
            {
                m = Math.Min(m, frog(arr, j, n, temp) + Math.Abs(arr[i] - arr[j]));
            }
            temp[i] = m;
            return temp[i];
        }
    }
}


Measured memory_bytes: 26592
#include<iostream>
#include<cmath>
#include <cstdlib> 
#include<iomanip>
using namespace std;
int main(){
	int n;
	int x[1000]={0};
	int y[1000]={0};
	long double d=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>x[i];
	for(int i=0;i<n;i++)
		cin>>y[i];
		
	for(int i=0;i<n;i++)
		d+=abs(x[i]-y[i]);
	cout<<fixed<<setprecision(6)<<d<<endl;
	
	d=0;
	for(int i=0;i<n;i++)
		d+=pow(abs(x[i]-y[i]),2);
	cout<<fixed<<setprecision(6)<<sqrt(d)<<endl;
	
	d=0;
	for(int i=0;i<n;i++)
		d+=pow(abs(x[i]-y[i]),3);
	cout<<fixed<<setprecision(6)<<pow(d,1.0/3.0)<<endl;
	
	d=0;
	
	for(int i=0;i<n;i++){
		if(d<=abs(x[i]-y[i]))
			d=abs(x[i]-y[i]);
	}
	cout<<fixed<<setprecision(6)<<d<<endl;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  if(S.size()+1!=T.size()){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<S.size(); i++){
    if(S[i]!=T[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
signed main() {
    cin >> N;
    int ans = 0;
    for (int i = 1; i * i < N; i++) {
        if (N % i != 0) { continue; }
        int m = (N - i) / i;
        if (N / m == N % m) { ans += m; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
        ulong a = ulong.Parse(input[0]);
        ulong b = ulong.Parse(input[1]);
				ulong c = ulong.Parse(input[2]);
				bool flag = true; 
				ulong x = 0;
				if(c<a+b){flag = false;}
				else{x = c-a-b;}
				ulong y = 4*a*b;
      			x = x*x;
			//	Console.WriteLine(x+" "+y+" "+flag);

					if(!flag){
						Console.WriteLine("No");
					}else if(x>y){
						Console.WriteLine("Yes");
					}else{
						Console.WriteLine("No");
					}
				
	}

}

Measured memory_bytes: 13140
module HinaArare
  def solve
    n = gets.to_i
    s = gets.split(" ")
    for i in 1..n do 
      if s[i] == 'Y'
        return 'Four'
      end
    end
    return 'Three'
  end
end

include HinaArare
puts HinaArare.solve

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include <string>
#include<set>
using namespace std;
int s[200005];
int main()
{
    int N,M;
   
   cin>>N>>M;
   double a;
   int X=0,Y=0;
   for(int i=0;i<N;i++)
   {
       scanf("%d",&s[i]);
   }
  for(int i=0;i<M;i++)
   {
        X=X+s[i]+1;
   }
   Y=X;
   for(int i=M;i<N;i++)
   {    Y=Y+s[i]-s[i-M];
       if(X<Y)
        X=Y;
       
   }
   printf("%.12lf",X*1.0/2);
    return 0;
}


Measured memory_bytes: 1024
/*** author: yuji9511 ***/
/***
      .....                                  .,          .,        .....      .......,       ..,         ...
    .M97?7Mm.                               ,M@         ,M@      .MMB"WMm.    ,M#""""3    .gMMMF       (MMMM~
   (M!     dN. ..     ..,   ...    .,    .....,      .....,      dM\   ?Mb    ,M]         .=`,MF       ?! dM~                     ..-...     ......    ....-, .-,   .......,      ., ....      ..-..
  .M\.jMMM@.M] ?Mb    dM\   dM~    M@    ,""TMF      .""TM@      MMx    MN_   ,ML...         ,MF          dM~                   (MM"""T$   .MM@""HMp   dMM"MNM"MN-  ,MM#""WMR    .MNM#""8    .MM""TMN,
  .#`j#`.M] M]  dM;  -MF    dM~    M@       .MF         .M@      .WMNggMMM{   .T9"TMN,       ,MF          dM~                  JMD         MM>    dM]  dM~ dM: JM)  ,M$    dM]   .M#!       .M@    .MN..
  .N.Mb .M}.M'  .MN..M@     dM~    M@       .MF         .M@         _!` M#~        .MN.      ,MF          dM~                  MM~        .M#     ,Mb  dN` JM: (M[  ,M]    ,Mb   .MF        JM]     dM}
  .M;?NgMMNM\    ,MbdM`     dM-   .M@       .MF         .M@    `       (MF         .M#`      ,MF     `    dM~                  dMp         MN,    jM%  dN` JM: (M[  ,Mp    (M%   .MF        ,Mb.   .M#`
   dN,            dMM\      /MNJ(gMM@       .MF    `    .M@      .gJ(JMM$     jgJ(JMM^    .++gMN++,    (++MMg+J                 TMNg-.Je   .MMa-(MMD   dN` JM: (M[  ,MMNJ(dMF    .MF         ?MNJ(JMM'
    ?MNgJgN$      .MF         7"=` ?!  `    .MF          ?!       ?7""!       _?"""!       ???????`    ???????!                   ?7""=`     .7""^     ~?  -?  .?`  ,M].7""`      ?!           ?7""!
               (.(MF      `              (-.jM%                                                                  .............                                      ,M]
               7""!                      ?"""!                `                                                 .HHHHHHHHHHHH$                                      ,"^
                                                     `                                  `
***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22){
        print("bust");
    }else{
        print("win");
    }
    

}

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int N;
    cin >> N;
    int R;
    cin >> R;
    int ans;
    if(N >= 10) {
        ans = R;
    }
    else {
        ans = R + 100 * (10 - N);
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
string S;
ll R=0,G=0,B=0;

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

    rep(i,N){
        if(S[i]=='R') R++;
        else if(S[i]=='G') G++;
        else B++;
    }

    ll ans=R*G*B;
    rep(i,N){
        repn(j,N){
            if(i+j*2>=N) break;
            if(S[i]!=S[i+j] && S[i+j]!=S[i+j*2] && S[i+j*2]!=S[i]){
                ans--;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  ll sum = 0;
  ll now = v[0];
  for (int i = 1; i < n; ++i) {
    ll diff = now - v[i];
    sum += max(0ll, now - v[i]);
    v[i] += max(0ll, diff);
    now = v[i];
  }
  cout << sum << endl;
}


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int n,a;
	cin>>n>>a;
	cout<<n*n-a<<endl;
	return 0;
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

vector<int> find_divisors(int x) {
  vector<int> res;
  for (int i = 1; i * i <= x; i++) {
    if (x % i == 0) {
      res.push_back(i);
    }
    if (i * i != x) {
      res.push_back(x / i);
    }
  }
  return res;
}

int main() {
  _upgrade;
  int x;
  cin >> x;
  auto divs = find_divisors(x);

  for (auto &d : divs) {
    for (LL j = -201, i = j + d; j < 200; i++, j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << " " << j << "\n";
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3776
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################


// int count;

void dfs(vector<int> adj[],vector<bool> &vis,int v,int &count){
    if(vis[v])
    return;

    count++;
    vis[v]=true;

    for(int i:adj[v]){
      if(vis[i])
        continue;
      dfs(adj,vis,i,count);
    }
}

int main(){
  boost;
  ll n,m;
  cin>>n>>m;
  vector<int> adj[n];
  vector<bool> vis(n,false);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int mx=0;
  for(int i=0;i<n;i++){
    int count=0;
    if(!vis[i]){
      dfs(adj,vis,i,count);
    }

  mx=max(count,mx);
  }
  cout<<mx;
}



Measured memory_bytes: 27028
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int N; ll K; cin >> N >> K;
    std::vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll dp [41][2];

    REP(i,41) REP(j, 2) dp[i][j] = -1;
    dp[40][0] = 0;

    for(int i = 39; i >= 0; --i){

        ll d = 1LL << i;

        int one_cnt = 0;
        REP(i,N) if(d & A[i]) one_cnt++;

        if(dp[i+1][1] >= 0){
            dp[i][1] = max(dp[i][1], dp[i+1][1]+max(one_cnt, N-one_cnt)*d);
        }

        if(dp[i+1][0] >= 0){
            if(d & K){
                dp[i][0] = max(dp[i][0], dp[i+1][0]+d*(N-one_cnt));
                dp[i][1] = max(dp[i][1], dp[i+1][0]+d*one_cnt);
            } else {
                dp[i][0] = max(dp[i][0], dp[i+1][0]+d*one_cnt);
            }
        }

    }

    // REP(i,40) cout << dp[i][0] << " ";
    // cout << '\n';
    // REP(i,40) cout << dp[i][1] << " ";
    // cout << '\n';


    cout << max(dp[0][0], dp[0][1]) << endl;



    return 0;
}


Measured memory_bytes: 1024
def solve(N, A):
    dp = [0] * N
    for i in xrange(1, N):
        if A[i] <= A[i-1]:
            dp[i] = 1 + dp[i-1]
    return max(dp)

N = int(raw_input())
A = map(int, raw_input().split())
print solve(N, A)

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  c += a + b;
  if (c >= 22){
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

string ToString(ll i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

int main() {
  ll N;
  cin >> N;
  ll count = 0;
  for (ll i = 1; i <= N; i++) {
    if (ToString(i).length() % 2 == 1) {
      count++;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

int main(){
  string S;
  cin>>S;
  int N=S.size();

  string pre="";
  int ans=0;
  string now="";
  for(int i=0;i<N;i++){
    now+=S[i];
    if(pre!=now){
      ans++;
      pre=now;
      now="";
    }
  }

  reverse(S.begin(),S.end());
  string p="";
  int res=0;
  string n="";
  for(int i=0;i<N;i++){
    n+=S[i];
    if(p!=n){
      res++;
      p=n;
      n="";
    }
  }
  cout<<max(ans,res)<<endl;

  return 0;
}


Measured memory_bytes: 644
// trace works only with c++ 14

#include<bits/stdc++.h>
using namespace std;

//#pragma comment (linker, "/STACK:256000000")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define all(a) a.begin(), a.end()
#define endl '\n'
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define boost  ios_base::sync_with_stdio(false);
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long llint;
typedef long long ll ;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return a==0?b:gcd(b%a,a);}
/*---------------------------------------------------------------------------------------------------------------------*/
const int maxn = 100010;
const int inf = INT_MAX;

int main() {
	ll a, b;
	cin >> a >> b;
	if(a == b) {
		cout << 0;
		return 0;
	}
	if(a < b) {
		if(b <= 0 || a >= 0) {
			cout << b - a;
		}
		else {
			if(-a <= b)
				cout << b + a + 1;
			else
				cout << -b - a + 1;
		}
	}
	else {
		if(b >= 0)
			cout << min(-b + a + 1, b + a) + 1;
		else if(a < 0)
			cout << 1 + 1 -b + a;
		else if(a == 0)
			cout << -b + 1;
		else
			cout << 1 + abs(b + a);
	}
	cin.get();
	cin.get();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
void exchange(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
int main() {
  int a,b;
  for(int i=0;i<3000;i++) {
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    if(a > b) exchange(&a,&b);
    cout << a << ' ' << b << endl;
  }
  return 0;
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
#include <set>
#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)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<llong> h(n,0);
    REP(i,n) cin>>h[i];
   string ans="Yes";
   REP(i,n-1){
       if(h[i]<h[i+1]) h[i+1]-=1;
   }
   REP(i,n-1)
   {
       if(h[i]>h[i+1]) {ans="No";
           break;}
   }
   cout<<ans<<endl;

    return  0;
}


Measured memory_bytes: 1024
input = readlines()

n, k = input.shift.chomp.split("\s").map{|x| x.to_i}
list = []
input.each do |l|
  list.push(l.chomp.to_i)
end

min = nil
list = list.sort()
list.each_with_index do |l, i|
  next if i < (k - 1)
  diff = (l - list[i - (k - 1)]).abs
  min = diff if min.nil? || min > diff
end

puts min


Measured memory_bytes: 24344
n_vec = list(map(int, input().split()))
n1 = n_vec[0]
n2 = n_vec[1]
n3 = n_vec[2]
def abc_057_1(a,b,c):
    if b-a == c-b:
        return(print('YES'))
    else:
        return(print('NO'))
abc_057_1(n1,n2,n3)   

Measured memory_bytes: 2940
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int X;
    cin>>X;
    //cout<<LLONG_MAX<<endl;
    //=9223372036854775807^(1/5)=6208.37506
    for(int A=-3000;A<=3000;A++){
        for(int B=-3000;B<=3000;B++){
            if(A*A*A*A*A-B*B*B*B*B==X){
                cout<<A<<" "<<B<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3180
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    ll a,b;
    cin>>a>>b;
    map<ll,ll> mp;
    rep(i,1000){
        mp[i*i]++;
    }
    ll c=stoi((string)(to_string(a)+to_string(b)));
    if(mp[c]>0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int prev = sc.nextInt();
        int p[] = new int[N];
        boolean flag = true;
        p[0] = prev;
        for(int i = 1; i < N; i++){
            p[i] = sc.nextInt();
            if(p[i] < prev){
                flag = false;
            }
            prev = p[i];
        }
        if(flag){
            System.out.println("YES");
        }else{
            boolean f = false;
            for(int i = 0; i < N - 1; i++){
                for(int j = i + 1; j < N; j++){
                    f = true;
                    for(int k = 0; k < N - 1; k++){
                        int a = p[k];
                        if(k == i){
                            a = p[j];
                        }
                        if(k == j){
                            a = p[i];
                        }
                        int b = p[k + 1];
                        if(k + 1 == i){
                            b = p[j];
                        }
                        if(k + 1 == j){
                            b = p[i];
                        }
                        if(a > b){
                            f = false;
                            break;
                        }
                    }
                    if(f){
                        break;
                    }
                }
                if(f){
                    break;
                }
            }
            if(f){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}


Measured memory_bytes: 23764
//created by Whiplash99
import java.io.*;
import java.util.*;
public class Main
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

        int i,N;

        N=Integer.parseInt(br.readLine().trim());
        ArrayList<Integer> edge[]=new ArrayList[N];
        for(i=0;i<N;i++) edge[i]=new ArrayList<>();

        for(i=0;i<N-1;i++)
        {
            String s[]=br.readLine().trim().split(" ");
            int u=Integer.parseInt(s[0])-1;
            int v=Integer.parseInt(s[1])-1;

            edge[Math.min(u,v)].add(Math.max(u,v));
        }

        long ans=0;
        for(i=0;i<N;i++) ans+=(long)(i+1)*(N-i);
        for(i=0;i<N;i++)
        {
            for(int v:edge[i])
                ans-=(long)(i+1)*(N-v);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 74256
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c =[2]
if x in a and y in a:
  print("Yes")
elif x in b and y in b:
  print("Yes")
elif x in c and y in c:
  print("Yes")
else:
  print("No")

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


using namespace std;

void solve() {
    long double l;
    cin >> l;

    const long double side = l / 3;
    cout << pow(side, 3) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);

    solve();
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int n,c[500], s[500], f[500];

void solve(int x) {
	int t = 0;
	for (int i = x; i < n-1; i++) {
		if (t < s[i])t = s[i];
		while (t%f[i] != 0)t++;
		t += c[i];
	}
	cout << t << endl;
}

int main() {
	
	cin >> n;
	for (int i = 0; i < n-1; i++)cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n-1; i++)solve(i);
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)

s = []
h.times {s << gets.chomp}

ans = 0
h.times do |i|
    w.times do |j|
        next if s[i][j] == "#"
        arr = Array.new(h){Array.new(w, 0)}
        arr[i][j] = 1
        que = [[i, j]]

        while x = que.shift
            ni, nj = x[0], x[1]

            if ni > 0 && s[ni-1][nj] == "." && arr[ni-1][nj] == 0
                arr[ni-1][nj] = arr[ni][nj] + 1
                que << [ni-1, nj]
            end

            if ni < h - 1 && s[ni+1][nj] == "." && arr[ni+1][nj] == 0
                arr[ni+1][nj] = arr[ni][nj] + 1
                que << [ni+1, nj]
            end

            if nj > 0 && s[ni][nj-1] == "." && arr[ni][nj-1] == 0
                arr[ni][nj-1] = arr[ni][nj] + 1
                que << [ni, nj-1]
            end

            if nj < w - 1 && s[ni][nj+1] == "." && arr[ni][nj+1] == 0
                arr[ni][nj+1] = arr[ni][nj] + 1
                que << [ni, nj+1]
            end
        end

        max = arr.map(&:max).max - 1
        ans = max if ans < max
    end
end

puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int r, g, b, n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> r >> g >> b >> n;
  ll ans = 0;
  FOR(i, 0, 3001)FOR(j, 0, 3001){
    int k = n - r*i - g*j;
    if(k >= 0 && k%b==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

int dp[200005];

int longestPath(int n, vector<int> *v)
{
	if (v[n].size() == 0)
		return dp[n] = 0;
	if (dp[n] != 0)
		return dp[n];
	int maxx = 0;
	for (auto j : v[n])
		maxx = max(longestPath(j, v), maxx);
	return dp[n] = 1 + maxx;
}

void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int> v[n + 1];
	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}
	int maxx = 0;
	int dp[n + 1];
	for (int i = 0; i <= n; ++i)
		dp[i] = 0;
	for (int i = 1; i <= n; ++i)
		maxx = max(maxx, longestPath(i, v));
	cout << maxx << endl;
}

int main()
{
	fast
	ll t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 8576
MOD = 10**9+7

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    A = list(mi())
    A.sort()
    if N%2:
        for i in range(N):
            if A[i] != i+(i%2):
                print(0)
                return
    else:
        for i in range(N):
            if A[i] != i+((i+1)%2):
                print(0)
                return
    print(pow(2, N//2, MOD))


if __name__ == '__main__':
    main()

Measured memory_bytes: 52204
using System;
    class Program
    {
        static void Main(string[] args)
        {
            for (int a = 1; a <=9; a++)
            {
                for (int b = 1; b <=9;b++ )
                {
                    Console.WriteLine("{0}x{1}={2}",a,b,a*b);
                }
            }
        }
    }

Measured memory_bytes: 5596
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x=0;
    cin>>a>>b;
    if(a>b)
        x=a+a-1;
    else
    if(a<b)
        x=b+b-1;
    else
        x=a+b;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String strS = sc.nextLine();
		String strP = sc.nextLine();

		String str2S = strS + strS;

	//	System.out.println("str2S.indexOf(strP);"+str2S.indexOf(strP));

		if(str2S.indexOf(strP) != -1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26320
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define PQ priority_queue<ll>
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define mem(a,b) memset(a,b,sizeof(a))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

ll gcd(ll a, ll b){
	return (!b)?a:gcd(b,a%b);
}

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

int main(){
	IOS
	ll n;
	double temp,x,y;
	cin>>n;
	priority_queue<double,vector<double>,greater<double>> heap;
	loop(0,n-1,1){
		cin>>temp;
		heap.push(temp);
	}
	while(heap.size()>1){
		x=heap.top();
		heap.pop();
		y=heap.top();
		heap.pop();
		heap.push((x+y)/2);
	}
	cout<<heap.top();
	return 0;
}


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

int main() {
  int64_t N,K;
  cin>>N>>K;
  if(K%2==1){
    cout<<(N/K)*(N/K)*(N/K)<<endl;
  }
  else{
    cout<<(N/K)*(N/K)*(N/K)+((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)<<endl;
  }
}

Measured memory_bytes: 256
N,M=[int(i) for i in input().split()]
s=[]
for i in range(M):
    switch=[]
    k,*switch = map(int,input().split())
    for j in range(len(switch)):
        switch[j]-=1
    s.append(switch)
p=[int(l) for l in input().split()]


count=0
for i in range(1<<N):
    is_ok =True
    for j in range(len(s)):
        c=0
        for k in s[j]:
            if (i>>k)%2==1:
                c+=1
        if c%2==p[j]:
            continue
        else:
            is_ok=False
            break
    if is_ok:
        count+=1

print(count)

Measured memory_bytes: 3064
package main

import "fmt"

/*
あなたは、 500 円玉を A 枚、 100 円玉を B 枚、 50 円玉を C
枚持っています。 
 これらの硬貨の中から何枚かを選び、
 合計金額をちょうど X円にする方法は何通りありますか。
同じ種類の硬貨どうしは区別できません。
2 通りの硬貨の選び方は、
ある種類の硬貨についてその硬貨を選ぶ枚数が異なるとき区別されます。
*/
func main() {
	var A, B, C, X int
	fmt.Scan(&A, &B, &C, &X)
	ans := 0
	
	for a := 0; a <= A; a++ {
	  for b := 0; b <= B; b++ {
	    for c := 0; c <= C; c++ {
				//fmt.Printf("a=%d,b=%d,c=%d\n",a,b,c)
				if ((500 * a + 100 * b + 50 * c) == X) {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 512
/*
く__,.ヘヽ.　　　　/　,ー､ 〉
　　　　　＼ ', !-─‐-i　/　/´
　　　 　 ／｀ｰ'　　　 L/／｀ヽ､
　　 　 /　 ／,　 /|　 ,　 ,　　　 ',
　　　ｲ 　/ /-‐/　ｉ　L_ ﾊ ヽ!　 i
　　　 ﾚ ﾍ 7ｲ｀ﾄ　 ﾚ'ｧ-ﾄ､!ハ|　 |
　　　　 !,/7 '0'　　 ´0iソ| 　 |　　　
　　　　 |.从"　　_　　 ,,,, / |./ 　 |
　　　　 ﾚ'| i＞.､,,__　_,.イ / 　.i 　|
　　　　　 ﾚ'| | / k_７_/ﾚ'ヽ,　ﾊ.　|
　　　　　　 | |/i 〈|/　 i　,.ﾍ |　i　|
　　　　　　.|/ /　ｉ： 　 ﾍ!　　＼　|
　　　 　 　 kヽ>､ﾊ 　 _,.ﾍ､ 　 /､!
　　　　　　 !'〈//｀Ｔ´', ＼ ｀'7'ｰr'
　　　　　　 ﾚ'ヽL__|___i,___,ンﾚ|ノ
　　　　　 　　　ﾄ-,/　|___./
　　　　　 　　　'ｰ'　　!_,.
*/
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<fstream>
#include<sstream>
#include<stack>
#include<queue>
#include<map>
#include<deque>
#include<string>
#include<cstring>
#include<cmath>
#include<cctype>
#include<climits>
#include<algorithm>
#include<utility>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()

typedef long long int ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> ppi;
typedef pair<int, pii> pip;

#define all(x) x.begin(),x.end()
#define CASE() for(int Case=1;Case<=Tc;Case++)
#define ITR(itr,it) for(__typeof((it).begin()) itr=(it).begin();itr!=(it).end();itr++)
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)

const int adj[8][2]={{-1,0},{0,-1},{1,0},{0,1},{-1,-1},{-1,1},{1,1},{1,-1}};
const ll LLINF=9e18;
const int INF=2e9;
const int MOD=1e9+7;
const double EPS=1e-10;
const double PI=acos(-1);
const int SIZE=100005;

int N;
int A[SIZE];

int main (){
	
	scanf("%d", &N);
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
	}
	bool flag=true;
	int ans=0;
	while(flag==true){
		int Mn=INF, l=-1, r=N;
		for(int i=0;i<N;i++){
			if(A[i]!=0){
				l=i;
				break;
			}
		}
		if(l==-1) break;
		for(int i=l;i<N;i++){
			if(A[i]==0){
				r=i;
				break;
			}
		}
		if(r==-1) break;
		for(int i=l;i<r;i++){
			Mn=min(Mn,A[i]);
		}
		if(Mn==0) break;
		ans+=Mn;
		for(int i=l;i<r;i++){
			A[i]-=Mn;
		}
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import bisect
from itertools import accumulate

n = int(input())
a_s = sorted([int(item) for item in input().split()])
b_s = sorted([int(item) for item in input().split()])
c_s = sorted([int(item) for item in input().split()])

count = [0] * n
for i, b in enumerate(b_s):
    count[i] = bisect.bisect_left(a_s, b)
cumsum = list(accumulate(count))

ans = 0
for i, c in enumerate(c_s):
    index = (bisect.bisect_left(b_s, c)-1)
    if index >= 0:
        ans += cumsum[index]

print(ans)

Measured memory_bytes: 25416
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce, lru_cache  # @lru_cache(None)
from fractions import gcd
import sys  # def input(): return sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**6)

a = int(input())
print(a+a**2+a**3)

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,m;
    cin >> n >> m;
    vector<string> A(n),B(m);

    FOR(i,0,n)
    	cin >> A[i];

   	FOR(i,0,m)
   		cin >> B[i];

    for(int i=0;i+m<=n;i++){
    	for(int j=0;j+m<=n;j++){
    		bool flag=true;
    		FOR(k,0,m){
    			FOR(l,0,m){
    				if(B[k][l]!=A[i+k][l+j])
    					flag=false;
    			}
    		}
    		if(flag){
    			cout << "Yes\n";
    			return 0;
    		}
    	}
    }

    cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n,d,tot;
int a[maxn];
ll ans;
class Edge{
public:
	int u,v;
	ll w;
	Edge(int _u=0,int _v=0,ll _w=0):u(_u),v(_v),w(_w){}
	bool operator < (const Edge &o)const{
		return w<o.w;
	}
}e[maxn*20];

namespace Dsu{
	int f[maxn];
	void init(){
		REP(i,n)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]);
	}
}

void solve(int l,int r){
	if(l==r)return;
	int mid=l+r>>1;
	pair<ll,int>mn=mp(Inf,0);
	for(int i=l;i<=mid;i++)mn=min(mn,mp(-1LL*i*d+a[i],i));
	for(int i=mid+1;i<=r;i++)e[++tot]=Edge(mn.snd,i,mn.fst+1LL*i*d+a[i]);
	mn=mp(Inf,0);
	for(int i=mid+1;i<=r;i++)mn=min(mn,mp(1LL*i*d+a[i],i));
	for(int i=l;i<=mid;i++)e[++tot]=Edge(i,mn.snd,-1LL*i*d+a[i]+mn.fst);
	solve(l,mid);solve(mid+1,r);
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&d);
	REP(i,n)scanf("%d",&a[i]);
	solve(1,n);
	sort(e+1,e+1+tot);
	Dsu::init();
	REP(i,tot){
		int u=Dsu::find(e[i].u),v=Dsu::find(e[i].v);
		if(u==v)continue;
		ans+=e[i].w;
		Dsu::f[u]=v;
	}
	printf("%lld\n",ans);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

long digit(long k){
    long cnt = 0;
    while(k != 0){
        k = k / 10;
        cnt++;
    }
    return cnt;
}

int main(){long N;
cin >> N;
long tmp = 12;
erep(i, 1e5){
    if(N % i == 0){
        tmp = min(tmp, max(digit(N / i), digit(i)));
    }
}

cout << tmp << endl;
return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  string s, t;
  ll ans=0;

  cin >> s >> t;

  for (int i=0; i<(int)s.size(); i++) {
    if (s[i] != t[i]) ans++;
  }

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


Measured memory_bytes: 3856