akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main()
{
   // string S,t;    
    int n,k,r,s,p,i,len,sum=0;
    cin>>n>>k;
  char S[n],t[n];
    cin>>r>>s>>p;
    cin>>S;
  //  len=S.length();
    for(i=0;i<k;i++)
    {
        if(S[i]== 'r')
        {
            sum+=p;
            t[i]= 'p';
        }
            
        else if(S[i]== 's')
        {
            sum+=r;
            t[i]= 'r';
        }
        
        else
        {
            sum+=s;
            t[i]= 's';
        }
    }
    for(i=k;i<n;i++)
    {
        if(S[i]==S[i-k] && S[i]!=t[i-k])
        {
            sum+=0;
            t[i]=S[i];
         }
        else
        {
            if(S[i]== 'r')
        {
            sum+=p;
            t[i]= 'p';
        }
            
        else if(S[i]== 's')
        {
            sum+=r;
            t[i]= 'r';
        }
        
        else
        {
            sum+=s;
            t[i]= 's';
        }
        }
            
    }
    cout<<sum;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main() {
  int n, m;
  cin >> n >> m;
  mint ans = 0;
  rep(i,n+1) {
    mint now = c(n,i);
    now *= c.p(m,n);
    now *= c.p(m-i,n-i);
    if (i&1) now = -now;
    ans += now;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

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

  int a = (S[0]-'0')*10 + (S[1]-'0');
  int b = (S[2]-'0')*10 + (S[3]-'0');


  int res = 0;
  if (1 <= b && b <= 12) res |= 1;
  if (1 <= a && a <= 12) res |= 2;

  if (res == 1)
    cout << "YYMM" << endl;
  if (res == 2)
    cout << "MMYY" << endl;
  if (res == 3)
    cout << "AMBIGUOUS" << endl;
  if (res == 0)
    cout << "NA" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k=inpm()
    ans = 0
    for b in range(k+1,n+1):
        x=n//b
        y=n%b
        a=x*(b-k)+max(0,y-k+1)
        ans+=a
    if k==0:
        ans-=n
    print(ans)


if __name__ == "__main__":
    main()

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    rep(i, n) if (i%2==0 && a[i]%2==1) ++ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
using System;

namespace A.Eating_Symbols_Easy
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var ans = 0;

            for (int i = 0; i < 4; i++)
                ans = S[i] == '+' ? ++ans : --ans;

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if(K<=A){
    cout << K << endl;
  }
  else if(K<=A+B){
    cout << A << endl;
  }
  else{
    cout << 2*A+B-K <<endl;
  }
}

        

        

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll MOD = 1e9+7;

int main(){
  ll n,m; cin >> n >> m;
  vector<ll> a(m+1);
  REP(i,m) cin >> a[i];
  a[m] = 1e18;
  vector<ll> dp(n+5,0);
  dp[0] = 1;
  ll p = 0;
  REP(i,n) if(i==a[p]){
    p++;
  }else{
    (dp[i+1] += dp[i]) %= MOD;
    (dp[i+2] += dp[i]) %= MOD;
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 1792
n=int(input())
a=[int(i) for i in input().split()]

cnt=[0]*8
count=0
for i in range(n):
    if a[i]>=1 and a[i]<=399:
        cnt[0]=1
    elif a[i]>=400 and a[i]<=799:
        cnt[1]=1
    elif a[i]>=800 and a[i]<=1199:
        cnt[2]=1
    elif a[i]>=1200 and a[i]<=1599:
        cnt[3]=1
    elif a[i]>=1600 and a[i]<=1999:
        cnt[4]=1
    elif a[i]>=2000 and a[i]<=2399:
        cnt[5]=1
    elif a[i]>=2400 and a[i]<=2799:
        cnt[6]=1
    elif a[i]>=2800 and a[i]<=3199:
        cnt[7]=1
    else:
        count+=1
min_ans=sum(cnt)
if min_ans==0 and count>=1:
    min_ans=1
    count-=1

print(str(min_ans)+' '+str(min_ans+count))


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
template <typename T>
struct TopologicalSort {
  struct Edge {
    int src, dst;
    T cost;
    Edge(int dst_, T cost_ = 0) : src(-1), dst(dst_), cost(cost_) {}
    Edge(int src_, int dst_, T cost_) : src(src_), dst(dst_), cost(cost_) {}
    inline bool operator < (const Edge &rhs) { return cost < rhs.cost; }
    inline bool operator <= (const Edge &rhs) { return cost <= rhs.cost; }
    inline bool operator > (const Edge &rhs) { return cost > rhs.cost; }
    inline bool operator >= (const Edge &rhs) { return cost >= rhs.cost; }
  };

  vector<vector<Edge> > graph;
  vector<int> order;

  TopologicalSort(int sz_) : sz(sz_), graph(sz_) {}

  void add(int src, int dst, T cost = 0) { graph[src].emplace_back(Edge(dst, cost)); }

  bool build() {
    order.clear();
    vector<int> state(sz, 0);
    REP(i, sz) if (state[i] == 0 && !dfs(i, state)) return false;
    reverse(ALL(order));
    return true;
  }

private:
  int sz;

  bool dfs(int ver, vector<int> &state) {
    state[ver] = 1;
    for (Edge e : graph[ver]) {
      if (state[e.dst] == 1) return false;
      if (state[e.dst] == 0 && !dfs(e.dst, state)) return false;
    }
    order.emplace_back(ver);
    state[ver] = -1;
    return true;
  }
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, m; cin >> n >> m;
  TopologicalSort<int> ts(n);
  REP(i, m) {
    int x, y; cin >> x >> y;
    --x;
    --y;
    ts.add(x, y);
  }
  ts.build();
  vector<int> toposo = ts.order;
  reverse(ALL(toposo));
  vector<int> dp(n, 0);
  for (int i : toposo) {
    for (auto e : ts.graph[i]) dp[i] = max(dp[i], dp[e.dst] + 1);
  }
  int ans = 0;
  REP(i, n) ans = max(ans, dp[i]);
  cout << ans << '\n';
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    }
    else
        cout << (a + b) / 2 + 1 << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e18
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=ans*a%c;
    }
    a=a*a%c;
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll z=fact[n];
    z=z*power(fact[r],mod-2,mod)%mod;
    z=z*power(fact[n-r],mod-2,mod)%mod;
    return z;
}
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll n,k; cin>>n>>k;
        for(int i=1;i<=200004;++i)fact[i]=i*fact[i-1]%mod;
        ll ans=0;
        ll sum[n+2];
        sum[0]=0;
        memset(sum,0,sizeof(sum));
        for(int i=2;i<=n+1;++i)sum[i]=i+sum[i-1];
        for(int i=k;i<=n+1;i++){
            if(i==n+1){
                ans++;
                continue;
            }
            ans=ans+sum[n+1]-sum[n+1-i]-sum[i];
            ans%=mod;
        }
        cout<<ans%mod;

        return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long

const int maxn = 1e5 + 7;
int a[maxn];

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

	int n; cin >> n;
	cin >> a[1];
	a[1]--;
	bool ok = true;
	for (int i = 2; i <= n; i++) {
		cin >> a[i];
		if (a[i] > a[i - 1]) a[i]--;

		if (a[i] < a[i - 1]){
			ok = false;
			break;
		}
		//cout << i << ": " << a[i] << endl;

	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = sc.nextInt();
        
        int ans = (a + b) * h / 2;

        System.out.println(ans);
    }
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
#define Matrix vector<vector<ll>>

class Matcalc{
public:
  Matrix matrix;
  ll row,col;
  Matcalc(ll r,ll c){
    row=r;col=c;
    matrix.resize(row);
    for(int i=0;i<row;i++)
      matrix[i].resize(col);
  }
  void input(){
    for(int i=0;i<row;i++)
      for(int j=0;j<col;j++)
	cin>>matrix[i][j];
  }
  Matrix mult(Matrix mat){
    Matrix result(row);
    if(col!=mat.size())return result;
    for(int i=0;i<row;i++){
      for(int j=0;j<mat[0].size();j++){
	ll sum=0;
	for(int k=0;k<col;k++){
	  sum+=matrix[i][k]*mat[k][j];
	}
	result[i].pb(sum);
      }
    }
    return result;
  }
  void mult_change(Matrix mat){
    if(col!=mat.size())return;
    Matrix result(row);
    for(int i=0;i<row;i++){
      for(int j=0;j<mat[0].size();j++){
	ll sum=0;
	for(int k=0;k<col;k++){
	  sum+=matrix[i][k]*mat[k][j];
	  sum%=MOD;
	}
	result[i].pb(sum);
      }
    }
    matrix=result;
    return;
  }
  void print(){
    for(int i=0;i<row;i++){
      for(int j=0;j<col;j++)
	cout<<matrix[i][j]<<" ";
      cout<<endl;
    }
  }
};
int main(){
  ll n,k;cin>>n>>k;
  Matcalc mat(n,n);
  mat.input();
  vector<Matrix> Mat;
  Mat.pb(mat.matrix);
  for(ll i=1;(ll)(1LL<<i)<=1e18;i++){
    mat.mult_change(mat.matrix);
    Mat.pb(mat.matrix);
  }
  vector<ll>hoge;
  for(ll i=Mat.size()-1;i>=0;i--){
    if(k>=(1LL<<i)){
      hoge.pb(i);
      k-=(1LL<<i);
    }
  }
  Matcalc ansMat(n,n);
  ansMat.matrix=Mat[hoge[0]];
  for(int i=1;i<hoge.size();i++)
    ansMat.mult_change(Mat[hoge[i]]);
  ll ans=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++){
      ans+=ansMat.matrix[i][j];
      ans%=MOD;
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//　宣言
  int a = 0,b = 0,c = 0;
  

//入力    
   cin >> a >> b;
    
//処理
   c = a * a - b;
  
//出力
  cout << c << endl;
}

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

int main() {
  double currentRating, targetRating;
  cin >> currentRating >> targetRating;
  
  // rating is calculated by
  // rating = (currentRating + performanceScore) / 2
  // so, performanceScore will be
  // performanceScore = rating * 2 - currentRating
  double performanceScore;
  performanceScore = (targetRating * 2 - currentRating);
  cout << performanceScore << endl;
}

Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("No"),0;
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,amin,amax,a[N];
signed main(){
	n=read();
	amin=n;
	F(i,1,n) a[i]=read(),amin=min(amin,a[i]),amax=max(amax,a[i]);
	if (amax-amin>1) ret;
	if (amin==amax){
		if (amin<=n/2||amin==n-1) puts("Yes");
		else ret;
	}
	else{
		int num=n;
		F(i,1,n) if (a[i]==amin) num--;
		if (num>=2*(amax-(n-num))&&(n-num)<amax) puts("Yes");
		else ret;
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
using namespace std;
// using namespace atcoder;
void Main()
{
    int n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll X = 0; // target xor
    for (int i = 2; i < n; i++) X ^= A[i];

	vector<int> cand;
	rep(i,1<<20) if(i<A[0]) {
		ll v=(A[0]-i)^(A[1]+i)^X;
		if((v&((1<<20)-1))==0) cand.push_back(i);
	}
	
	ll mi=1LL<<50;
	for(auto c : cand) {
		for(ll a=c;a<min(mi,A[0]);a+=1<<20) {
			ll v=(A[0]-a)^(A[1]+a)^X;
			if(v==0) mi=min(mi,a);
		}
	}

	if(mi==1LL<<50) mi=-1;
	cout<<mi<<endl;

    // ll S = A[0] + A[1]; // +

    // vector<int> cand();
    // int mask = (1LL << 20) - 1;
    // int Sm = S & mask;
    // rep(a, 1LL << 20) {
    //     if (a > A[0]) {
    //         break;
    //     }
    //     if (((a + (a^X)) & mask) == Sm) {
    //         cand.push_back(a);
    //     }
    // }

    // ll ma = -1;
    // for (int a1: cand) {
    // for (int i = 0; i < cnt; i++) {
    //     ll a1 = cand[i];
    //     for (ll a2 = 0; a2 < (1LL << 20); a2++) {
    //         ll a = (a2 << 20) + a1;
    //         if (a > A[0]) {
    //             break;
    //         }
    //         if (0 >= a) {
    //             continue;
    //         }
    //         if (a + (a^X) == S) {
    //             ma = max(ma, a);
    //         }
    //     }
    // }

    // if (ma < 0) {
    //     put(-1);
    //     return;        
    // }

    // int res = A[0] - ma;
    // put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int r, c, i, j, sum1;
		r = stdIn.nextInt();
		c = stdIn.nextInt();
		int[][] a = new int[r][c];
		int[] sum = new int[c];
		for (i = 0; i < r; i++) {
			for (j = 0; j < c; j++) {
				a[i][j] = stdIn.nextInt();
				sum[j] += a[i][j];
			}
		}
		for (i = 0; i < r; i++) {
			sum1 = 0;
			for (j = 0; j < c; j++) {
				System.out.print(a[i][j] + " ");
				sum1 += a[i][j];
			}
			System.out.println(sum1);
		}
		sum1=0;
		for (j = 0; j < c; j++) {
			System.out.print(sum[j] + " ");
			sum1 += sum[j];
			if(j==c-1){
				System.out.println(sum1);
			}
		}
		stdIn.close();
	}
}



Measured memory_bytes: 42040
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := intScanner(), intScanner(), intScanner()
	fmt.Println(max([]int{a, b, c}) - min([]int{a, b, c}))
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define mod 1000000007
#define DEBUG cout<<"Hello1\n";
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))
#define deb(...) debug(#__VA_ARGS__, __VA_ARGS__);
const int N = 1e6 + 5;
const double pi =  acosl(-1);
const ll inf = 1e18 + 5;
using namespace std;
template<typename T> void debug(string s, T x) {cout << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cout << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}
template<class T> void print_container(T &container) { for (auto &t : container) { cout << t << " ";} cout << endl;}
template<class T> void printArr(T &a , int n) { for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << endl;}

//Template Ends
int n, m, k;
int a[N], b[N];
int prea[N], preb[N];



void solve() {
	cin >> n >> m >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 01; i <= m; i++) {
		cin >> b[i];
	}
	prea[1] = a[1];
	preb[1] = b[1];
	for (int i = 1; i <= n; i++) {
		prea[i] = prea[i - 1] + a[i];
	}
	for (int i = 1; i <= m; i++) {
		preb[i] = preb[i - 1] + b[i];
	}

	int ans = 0;


	for (int i = 0; i <= n; i++) {
		int cnt = prea[i];
		if (cnt > k) {
			break;
		}
		int books = i ;
		int low = 0, high = m + 1;

		while (high - low > 1) {
			int mid = (high + low) / 2;
			if (cnt + preb[mid] <= k) {
				// deb(cnt + preb[mid]);
				low = mid;
			} else {
				high = mid;
			}
		}
		books += low;
		// deb(books);
		ans = max(ans, books);
	}

	cout << ans << endl;
}

int32_t main() {
	IOS;

	solve();

	return 0;
}




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


int main()
{
   
    long long int n,i,pi,j;
    
    cin>>n;
    vector<long long int>p;
    
    for(i=0;i<n;i++){
        cin>>pi;
        p.push_back(pi);
    }
    
    sort(p.begin(),p.end());
    //long int mid = (p[n-1]-p[0])/2;
    
    long long int total=0;
    long long int mn = INT_MAX;
    
    for(i=p[0];i<=p[n-1];i++){
        total=0;
        for(j=0;j<n;j++)
           total = total+(p[j]-i)*(p[j]-i);
        mn = min(mn,total);
    }
        
    cout<<mn;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x1: isize = iterator.next().unwrap().parse().unwrap();
    let y1: isize = iterator.next().unwrap().parse().unwrap();
    let x2: isize = iterator.next().unwrap().parse().unwrap();
    let y2: isize = iterator.next().unwrap().parse().unwrap();

    let dx = x2 - x1;
    let dy = y2 - y1;

    let x3 = x2 - dy;
    let y3 = y2 + dx;
    let x4 = x3 - dx;
    let y4 = y3 - dy;

    return format!("{} {} {} {}", x3, y3, x4, y4);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int main(){
  ll a, b, c, d, n;
  while (cin >> a >> b >> c >> d >> n) {
    n *= 4;
    ll result = 0;
    if (d < 2 * c && d < 4 * b && d < 8 * a) {
      ll t = n / 8;
      result += t * d;
      n -= t * 8;
    }

    if (c < 2 * b && c < 4 * a) {
      ll t = n / 4;
      result += t * c;
      n -= t * 4;
    }

    if (b < 2 * a) {
      ll t = n / 2;
      result += t * b;
      n -= t * 2;
    }

    result += n * a;
    cout << result << endl;
  }
}


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

int main() {
	int x, y, z;
	while (1) {

		cin >> x >> y;

		if (x == 0 && y == 0) break;


		if (x > y) {
			z = x;
			x = y;
			y = z;
		}
		cout << x << " " << y << endl;

	}

	return 0;
}


Measured memory_bytes: 3088
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N, M = get_inputs(int)
    if N == M:
        print('Yes')
    else:
        print("No")

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 111;
const int INF = 10101010;

int dp[N][N][N];
int nx[N][N];

int main(){
    int n,p;
    cin >>n >>p;
    vector<int> x(n),y(n);
    rep(i,n) cin >>x[i] >>y[i];

    rep(i,n){
        rep(j,i+1){
            int t = 0;
            int now_x;
            for(int k=j; k<=i; ++k){
                now_x = max(0, x[k]-t);
                t = max(0, y[k]-now_x);
            }
            nx[i][j] = now_x;
            // printf(" nx %d %d   = %d\n",i,j,nx[i][j]);
        }
    }

    rep(i,N)rep(j,N)rep(k,N) dp[i][j][k] = -INF;
    dp[0][0][0] = p;
    rep(i,n)rep(j,i+1)rep(k,n+1)if(dp[i][j][k] >= 0){
        dp[i+1][i+1][k] = max(dp[i+1][i+1][k], dp[i][j][k]);

        int rem = dp[i][j][k] - max(0, y[i]-nx[i][j]);
        dp[i+1][j][k+1] = max(dp[i+1][j][k+1], rem);
    }

    int ans = 0;
    rep(j,N)rep(k,N) if(dp[n][j][k]>=0) ans = max(ans, k);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8488
# coding=utf-8
line = input().split(" ")
h = int(line[0])
w = int(line[1])
d = int(line[2])

table = [0 for _ in range(h*w+1)]
for hi in range(h):
    line = list(map(int, input().split(" ")))

    for wi in range(w):
        table[line[wi]] = (hi+1, wi+1)

def calc(l,r):
    ret = 0
    if l!=r:
        c1 = table[l]
        c2 = table[r]
        ret += abs(c1[0]-c2[0])+abs(c1[1]-c2[1])
    return ret

acc = [0 for _ in range(h*w+1)]
for dd in range(1,d+1):
    s = dd+d
    while s<=h*w:
        acc[s] = calc(s-d,s)+acc[s-d]
        s += d

q = int(input())
for _ in range(q):
    line = input().split(" ")
    l = int(line[0])
    r = int(line[1])

    ret = acc[r] - acc[l]
    print(ret)


Measured memory_bytes: 14872
/////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
const int maxx=1e10+2;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL a) {
    return a*a;
}
int main() {
    while(cin>>n) {
        ma.clear();
        for(LL i=1;i<=n;i++) {
            LL t;
            cin>>t;
            for(LL j=2;j*j*j<=t;j++) {
                while(t%(j*j*j)==0) {
                    t/=(j*j*j);
                }
            }
            ma[t]++;a[i]=t;
            LL ans=1;
            for(LL j=2;j*j*j<=t;j++) {
                if(t%j==0) {
                    if(t%(j*j)==0) {
                        ans*=j;
                    }
                    else {
                        ans*=(j*j);
                    }
                }
                 while(t%j==0) {
                        t/=j;
                }
            }
            if (sqr((LL)sqrt(t))==t) ans*=(LL)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        LL ans1=0;
        if(ma[1]){
            ans1++;
            ma[1]=0;}
        for(int i=1;i<=n;i++) {
            ans1+=max(ma[a[i]],ma[b[i]]);
            ma[a[i]]=ma[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}


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

using namespace std;
int k[15],s[15][15],p[15];
int l[15]={};
int n,m;
int dfs(int a){
	if(a==n){
		int ans=0;
		for(int i=0;i<m;i++){
			int cnt=0;
			for(int j=0;j<k[i];j++){
				if(l[s[i][j]]==1)cnt++;
			}
			if(cnt%2!=p[i])break;
			if(i==m-1)ans++;
		}
		return ans;
	}
	else{
		int ans=0;
		l[a]=1;ans+=dfs(a+1);
		l[a]=0;ans+=dfs(a+1);
		return ans;
	}
	
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++)cin>>p[i];
	cout<<dfs(0);
	return 0;
}

Measured memory_bytes: 256
from heapq import heappop, heappush


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # search
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # unite
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # check
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


def solve(n, xy_list):

    # sort y by x
    xy_list_s = sorted(xy_list, key=lambda x: x[0])
    y_list_s = [xy[1] for xy in xy_list_s]

    # union_find
    uf = UnionFind(n)

    # heap
    h = []
    for y in y_list_s:
        yp_list = [y]
        while len(h):
            p = heappop(h)
            if p < y:
                yp_list.append(p)
                uf.union(p, y)
            else:
                heappush(h, p)
                break
        heappush(h, min(yp_list))

    # unite
    parent_n = [0] * n
    parent_cnt = [0] * (n + 1)
    for i in range(n):
        p = uf.find(xy_list[i][1])
        parent_n[i] = p
        parent_cnt[p] += 1

    return [parent_cnt[parent_n[i]] for i in range(n)]


def main():
    n = int(input())
    xy_list = [[0] * 2 for _ in range(n)]
    for i in range(n):
        x, y = map(int, input().split())
        xy_list[i][0] = x
        xy_list[i][1] = y
    res = solve(n, xy_list)
    for r in res:
        print(r)


def test():
    assert solve(4, [[1, 4], [2, 3], [3, 1], [4, 2]]) == [1, 1, 2, 2]
    assert solve(7, [[6, 4], [4, 3], [3, 5], [7, 1], [2, 7], [5, 2], [1, 6]]) == [3, 3, 1, 1, 2, 3, 2]


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 56872
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=86400;
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        int ans=1;
        for(int i=0;i<n;i++)
        {
            int t1=ans*2;
            int t2=ans+k;
            ans=min(t1,t2);
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int main(void){
  double a, v, b, w, t;
  
  std::cin >> a >> v >> b >> w >> t;
  
  if(abs(b-a)<=(v-w)*t||abs(a-b)<=(v-w)*t){
    std::cout << "YES" << std::endl;
  }else{
    std::cout << "NO" << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int a = 0;
  cin >> a;
  int kazu = 0;
  cin >> kazu;
  int c = 0;
  int d = 0;
  for(int i = 0;i <= kazu - 1;i++){
    cin >> c;
    d += c;
  }
  if(a > d){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
  return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	int a[n];
	long long ans, cnt;
	ans = pow(3, n);
	cnt = 1;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] % 2 == 0)
			cnt *= 2;	
	}
	ans -= cnt;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
//#include<functional>
#include<vector>
//#include<cmath>
using namespace std;

//スキャン
void myscan(vector<int> &x, int n){
  for (int i=0; i<n; i++){
    cin >> x[i];
  }
//  sort(x, x+n, greater<int>());
  sort(x.begin(), x.end());
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);

  myscan(a,n);
  myscan(b,n);
  myscan(c,n);

  long ans = 0;

  for(int i=0; i<n; i++){
    int p = b[i];
    ans += distance(a.begin(), lower_bound(a.begin(), a.end(), p))
      * distance(upper_bound(c.begin(), c.end(), p), c.end());
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;
	return x;
}

int main(){
	int n=readin(),k=readin();
	long long ans1=n/k;
	long long ans2=0;
	if (!(k%2)) ans2=n/(k/2)-n/k;
	printf("%lld",ans1*ans1*ans1+ans2*ans2*ans2);
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  int odd_count = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 1) {
      odd_count++;
    }
  }

  if (odd_count % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 3940
#include<iostream>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;

int N, K;

void solve() {
    double ans = 0.0;
    for (int i = 1; i < N+1; i++) {
        if(i >= K) {
            ans += (double)1.0/(double)N;
        } else {
            ans += (double)1.0/(double)N * pow((double)1.0/2.0, ceil((double)log2((double)K/(double)i)));
        }
    }
    cout << setprecision(12) << ans << endl;
}


int main() {
    cin >> N >> K;
    solve();
}

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

/* 
 * g++ -std=c++17 A.cpp -o A
 */
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> H(n+1);
  for (int i = 1; i<=n; i++) {
    int h;
    cin>>h;
    H[i]=h;
  }
  vector<int> dp(n+1);
  dp[1]=0;
  dp[2]=abs(H[2]-H[1]);
  for(int i = 3; i <= n; ++i) {
    int two = abs(H[i] - H[i-2]) + dp[i-2];
    int one = abs(H[i] - H[i-1]) + dp[i-1];
    dp[i] = min(two, one);
  }
  cout<<dp[n];
  cout<<endl;
}


Measured memory_bytes: 1024
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
counter = Counter()

for ai in a:
    if ai % 4 == 0:
        counter[4] += 1
    elif ai % 2 == 0:
        counter[2] += 1
    else:
        counter[1] += 1

ans = 'No'
if counter[1] == 0 and counter[2] == 0:
    ans = 'Yes'
elif counter[1] == counter[4]:
    ans = 'Yes'
elif counter[2] == 0:
    if counter[1] == counter[4] + 1:
        ans = 'Yes'

print(ans)




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

int main(){
  int N;
  cin >> N;
  int a;
  for (int i = 1; i <= 10; i++) {
    a = 1000 * i;
    if (a >= N) {
      break;
    }
  }
  cout << a - N << endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;
int main()
{
  string S;
  cin >> S;
  int win = 0;
  int num = S.length();
  for (int i=0;i<num; i++) {
    if (S[i] == 'o') win++;
  }
  if (15-num+win>7) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=55;
int a[N],w[N],n,m,K,S,T,aim;
ull C[N][N],ans;

int main(){
	read(n),read(K);
	read(S),read(T);
	rep(i,1,n){
		read(a[++m]);
		if((a[m]&S)!=S) m--;
		else if((a[m]|T)!=T) m--;
	}
	n=m,aim=(~S)&T;
	C[0][0]=1;
	rep(i,1,n){
		C[i][0]=1;
		rep(j,1,n){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
	rep(l,1,n){
		rep(r,l+1,n){
			w[r]=(a[l]^a[r])&aim;
		}
		for(int s=aim;;s=(s-1)&aim){
			int tot=0;
			rep(r,l+1,n){
				tot+=((w[r]|s)==s);
			}
			ull sum=0;
			rep(i,0,K-1){
				sum+=C[tot][i];
			}
			if(__builtin_popcount(aim^s)%2==0){
				ans+=sum;
			}
			else{
				ans-=sum;
			}
			if(!s) break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        String s = scanner.next();

        String regex = "(\\d){" + a + "}-(\\d){" + b + "}";

        System.out.println(s.matches(regex) ? "Yes" : "No");

    }
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToList().Count(x => x == 'o');
            Console.WriteLine( 700 + (100 * S));

        }
    }
}

Measured memory_bytes: 13268
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (h, w) = readIntegerList()
    val grid = Array(h) { br.readLine()!! }

    /** point of coordinate */
    data class Point(val x: Int, val y: Int)

    // 黒のマスすべてをキューに入れる
    val countGrid = Array(h) { LongArray(w) }
    val checkedGrid = Array(h) { BooleanArray(w) }
    val queue = ArrayDeque<Point>()
    for ((i, row) in grid.withIndex()) {
        for ((j, v) in row.withIndex()) {
            if (v == '#') {
                queue.addLast(Point(j, i))
                checkedGrid[i][j] = true
            }
        }
    }

    while (queue.isNotEmpty()) {
        val node = queue.removeFirst()
        for (d in GridDirection.values()) {
            val x = node.x + d.dx
            val y= node.y + d.dy
            if (!(y in 0 until h && x in 0 until w)) continue
            if (checkedGrid[y][x]) continue

            countGrid[y][x] = countGrid[node.y][node.x] + 1
            checkedGrid[y][x] = true
            queue.addLast(Point(x, y))
        }
    }

    val ans = countGrid.fold(0L) { acc, longs -> max(acc, longs.max()!!)}
    out.println(ans)
}

/** direction */
enum class GridDirection(val dx: Int, val dy: Int) {
    UP(0, -1),
    DOWN(0, 1),
    LEFT(-1, 0),
    RIGHT(1, 0),
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 98324
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

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

Measured memory_bytes: 256
import java.util.*
import javax.print.attribute.IntegerSyntax
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val n = readInt()
    val c0 = readLn().toCharArray()
    val c = c0.map {
        if (it == 'W') 0 else 1
    }.toIntArray()

//    val rCount: Int = c.sum()
//    val wCount: Int = c.size - rCount

    var r = 0

    var leftWhite = c.indexOfFirst { it == 0 }
    var rightRed = c.indexOfLast { it == 1 }

    while (true) {
        if (leftWhite == -1 || rightRed == -1 || leftWhite == n || leftWhite > rightRed) {
            println(r)
            break
        }
        c[leftWhite] = 1
        c[rightRed] = 0
        r++

        while (leftWhite < n && c[leftWhite] != 0) {
            leftWhite++
        }
        while (rightRed >= 0 && c[rightRed] != 1) {
            rightRed--
        }
    }
}


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

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


int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N)
    {
        cin >> H[i];
    }

    vector<int> dp(N); // dp[i]:i-1番目を含む0~i-1番目までの減少連続部分列の長さ
    dp[0] = 1;
    int max_length = dp[0]; // 最大長
    for (int i = 1; i < N; i++)
    {
        if (H[i - 1] >= H[i])
        {
            dp[i] = dp[i - 1] + 1;
            max_length = max(max_length, dp[i]);
        } else
        {
            dp[i] = 1;
        }
    }
    cout << max_length - 1 << endl;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
ab=[]
cd=[]

min = 10**9

for i in range(n):
    a,b=map(int,input().split())
    ab.append((a,b))

for i in range(m):
    c,d=map(int,input().split())
    cd.append((c,d))

for i in range(n):
    for j in range(m):
        dis= abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if dis < min:
            min = dis
            buf = j+1
        elif dis == min:
            continue
    print(buf)
    min=10**9


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
    long long n, k;
    long long p[200005]; 
    long long avg;
    long long max_avg;
    float ans;

    for (int i = 0; i < 200005; i++){ 
        p[i] = 0;
    }
    cin >> n >> k;
    for (int i = 0; i < n; i++){ 
        cin >> p[i];
    }

    avg = 0;
    for (int i = 0; i < k; i++){
        avg += p[i];
    }

    max_avg = avg;
    for (int i = k; i < n; i++){
        avg -= p[i-k];
        avg += p[i];
        //cout <<avg<< " | "<< p[i] << " | "<< p[i-k] << "\n";
        //cout << avg << "\n";

        if (avg > max_avg){ 
            //cout << "dbg:" << avg<< "\n";
            max_avg = avg;
        }
    }
   
    //cout << "max:" << max_avg << "\n";
    ans = (max_avg+k) / 2.0;
    printf("%.6lf\n", ans);
    //cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1792