akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var brue = new Dictionary<string, int>();
        var red = new Dictionary<string, int>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            if (brue.ContainsKey(s)) brue[s]++;
            else brue[s] = 1;
        }
        var m = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < m; i++)
        {
            var s = Console.ReadLine().Trim();
            if (red.ContainsKey(s)) red[s]++;
            else red[s] = 1;
        }
        int res; var resmax = 0;
        foreach (var x in brue)
        {
            if (!red.ContainsKey(x.Key)) res = x.Value;
            else res = x.Value - red[x.Key];
            resmax = Math.Max(resmax, res);
        }
        Console.WriteLine(resmax);
    }
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    int P[N];
    rep(i, N) cin >> P[i];
    int pos[N];
    rep(i, N) pos[P[i]-1] = i;
    int max_row = 1;
    int current_row = 1;
    int appear;
    rep(i, N){
        if(i == 0) appear = pos[i];
        else{
            if(appear < pos[i]){
                current_row++;
                appear = pos[i];
            }
            else{
                if(current_row > max_row) max_row = current_row;
                current_row = 1;
                appear = pos[i];
            }
        }
    }
    if(current_row > max_row) max_row = current_row;
    cout << N - max_row << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1792
a,b = map(int, input().split())
ans = 0
if (a>b):
  ans += a
  a -= 1
else:
  ans += b
  b -= 1

if (a>b):
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
  
print(ans)
  
  

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) throws IOException {
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
       
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            if (!list.isEmpty()) {
                ans.append(list.getFirst());
                list.removeFirst();
            }
            while (!list.isEmpty()) {
                ans.append(" ").append(list.getFirst());
                list.removeFirst();
            }
            System.out.println(ans.toString());
       
    }
}



Measured memory_bytes: 228408
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<vector<int> > edge(n);
  vector<Pii> unorderedEdge(n);
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    edge[a-1].push_back(b-1);
    edge[b-1].push_back(a-1);
    unorderedEdge[i] = Pii(a-1, b-1);
  }
  int m;
  cin >> m;
  vector<Pii> uv(m);
  for (auto &x: uv) {
    cin >> x.first >> x.second;
    x.first--;
    x.second--;
  }

  // find path
  vector<unordered_set<int> > path(m);
  vector<unordered_set<int> > req(m);
  for (int i = 0; i < m; i++) {
    queue<pair<int, unordered_set<int> > > que;
    unordered_set<int> beginning;
    beginning.insert(uv[i].first);
    que.emplace(uv[i].first, beginning);
    while (!que.empty()) {
      auto now = que.front();
      que.pop();
      if (now.first == uv[i].second) {
        path[i] = now.second;
        break;
      }
      for (auto &x: edge[now.first]) {
        if (now.second.find(x) != now.second.end()) continue;
        auto nextset = now.second;
        nextset.insert(x);
        que.emplace(x, nextset);
      }
    }
    for (int j = 0; j < n-1; j++) {
      if (path[i].find(unorderedEdge[j].first) != path[i].end() && path[i].find(unorderedEdge[j].second) != path[i].end()) req[i].insert(j);
    }
  }

  vector<int> mask(n-1);
  for (int i = 0; i < m; i++) {
    for (auto &x: req[i]) mask[x] |= (1 << i);
  }

  vector<vector<ll> > dp(n, vector<ll>(1 << m));
  dp[0][0] = 1;
  for (int i = 0; i < n-1; i++) {
    for (int j = 0; j < (1 << m); j++) dp[i+1][j] = dp[i][j];
    for (int j = 0; j < (1 << m); j++) dp[i+1][j|mask[i]] += dp[i][j];
  }

  ll ans = dp[n-1][(1<<m)-1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 418304
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void) {
	
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
	return 0;

}


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

int main(){
  string s;
  cin >> s;
  string t = "keyence";
  int l = t.length(), r = s.length();
  if(r < l){
    cout << "NO" << endl;
    return 0;
  }
  for(int i = 0; i <= l; ++i){
    if(s.substr(0,i)+s.substr(r-(l-i),l-i) == t){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}


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

int ans(string s, int n, int pp)
{
    int m = count(s.begin(), s.end(), 'G');

    int t = 0;
    for (int turn=0 ;; ++turn) {
      if (s.empty()) break;
      t = (t+n+(turn==pp)) % s.length();
      if (s[t]=='G') {
	--m;
	if (m==0) {
	  s.erase(s.begin()+t);
	  break;
	}
      }
      s.erase(s.begin()+t);
    }

    return s.length();
}

int main()
{
  int T;
  for (cin>>T; T>0; --T) {
    int n;
    string s;
    cin >> n >> s;
    --n;

    int x = 0;
    for (int i=0; i < s.length(); ++i) {
      x = max(x, ans(s, n, i));
    }
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 928
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+7;
char s[N], t[N];
ll gcd(ll a, ll b)
{
    return b == 0 ? a : gcd(b, a%b);
}
int main()
{
    int n, m;
    ll l, a, b, k, flag = 1;
    scanf("%d%d%s%s", &n, &m, s+1, t+1);
    l = n/gcd(n, m)*m;
    a = l/n;
    b = l/m;
    for(int i = 1; i <= n; i++)
    {
        if((i-1)*a%b==0)
        {
            if(s[i]!=t[(i-1)*a/b+1])
            {
                flag = 0;
            }
        }
    }
    if(flag)
    {
        printf("%lld\n", l);
    }
    else
    {
        puts("-1");
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;


ll N;
int ansh;
int answ;

int main() {
	cin.tie(0);
	cout.tie(0);

	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;
	FOR(i, 1, H+1) {
		FOR(j,1,W+1) {
			string S;
			cin >> S;
			if (S == "snuke") {
				ansh = i;
				answ = char('A'+j-1);
			}
		}
	}
	cout << char(answ) << ansh << endl;


	return 0;
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string a,b;
	cin>>a>>b;
	if(a!=b.substr(0,a.size()))
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < N-i; j++) {
            
            if(S[i+j] == S[j]){
                int a = 1;
                
                while (j+a<=i+j && i+j+1 <= N-a+1) {
                    if(S[i+j+a-1] == S[j+a-1]) a++;
                    else break;
                }
                
                j += a-1;
                
                ans = max(a-1, ans);
            }
            
            
            
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
import io.{StdIn => in}

object Main extends App {
  val Array(w, a, b) = in.readLine.split(" ").map(_.toInt)
  val (s, l) = if(a < b) (a, b) else (b, a)
  val res = l - (s + w)
  val ans = if(res < 1) 0 else res
  println(ans)
}

Measured memory_bytes: 27464
#include"bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
//#include <vector>
//#include <iostream>

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; std::swap(a, b);
		u -= t * v; std::swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



void Main()
{
	double a, b, x;
	std::cin >> a >> b >> x;
	double ans;

	if (2 * x < a * a * b) {
		ans = std::atan(a * b * b / (2 * x));
	} else {
		ans = std::atan(2 * (a*a*b - x)/(a*a*a));
	}
	std::cout << ans * 360 / (2 * M_PI) <<std::endl;

}

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


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
    ll g = gcd(x, y);
    return x/g*y;
}

ll LCM(vl &v) {  // vの全要素のlcm
    ll x = 1;
    rep(i, v.size()) {
        x = lcm(x, v[i]);
    }
    return x;
}

int main() {
    ll n, m;
    cin >> n >> m;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }

    ll u = LCM(a);
    rep(i, n) {
        if( (u/a[i])%2 == 0 ) {
            out(0);
            re0;
        }
    }

    ll ans = m/(2*u);
    ll c = m%(2*u);
    if(c >= u) {
        ans++;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
void readtxt()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}
int main()
{
	//readtxt();
    int s, w;
    cin >> s >>w;
    if(w>=s)cout << "unsafe" << endl;
    else cout <<  "safe" << endl;
}

Measured memory_bytes: 3636
#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> a(N);
	rep(i,N) cin >> a[i];
	int ans=0;
	rep(i,N){
		int A=a[i];
		while(A%2==0){
			ans++;
			A/=2;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,ch,ff,qn;
ll t;
ll a[N],q[N],ans[N];
void R(ll &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(ll x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
int find(ll x) {
	int l=0,r=qn,mid;
	while (l<r) {
		mid=(l+r+1)>>1;
		if (q[mid]<=x) l=mid;
		else r=mid-1;
	}
	return l;
}
int main() {
	scanf("%d%d",&n,&m);
	q[++qn]=n;
	for (i=1;i<=m;i++) {
		R(t);
		while (qn && t<q[qn]) qn--;
		q[++qn]=t;
	}
	a[qn]=1;
	for (i=qn;i;i--) {
		ll t=q[i];
		int tt=i-1;
		while (t>q[1]) {
			a[tt]+=a[i]*(t/q[tt]);
			t=t%q[tt];
			tt=find(t);
		}
		ans[t]+=a[i];
	}
	for (i=n;i;i--) ans[i]+=ans[i+1];
	for (i=1;i<=n;i++) W(ans[i]),puts("");
}

Measured memory_bytes: 3968
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
dic={"r":p,"s":r,"p":s}
ans=0

for i in range(k):
    ans+=dic[t[i]]
for i in range(k,n):
    if t[i] != t[i-k]:
        ans+=dic[t[i]]
    else:
        try:
            if t[i] == t[i+k]:
                t[i] = "0"
        except:
            pass
print(ans)


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

using namespace std;
long long int n , W;
long long int f[100003];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>W;
    for(int i =1 ;i< 100003; i++)
    {
        f[i] = INT_MAX;
    }
    for(int i = 1;i <= n;i ++)
    {
        int x, y;
        cin>>x>>y;
        for(int j = 100002; j>= y; j--)
        {
            f[j] = min(f[j], f[j-y] + x);
        }
    }
    for(int i = 100002; i>=1; i--)
    {
        if(f[i] <= W)
        {
            cout<<i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation

using namespace std;

int main() {
    long long n , m;
    cin >> n >> m;
    vector<long long> vec(n);
    vector<int> bad(n, 0);
    for(long long i = 0; i<n;i++){
        long long d;
        cin >> d;
        vec.at(i)=d;
    }

    for(long long i = 0; i < m; i++){
        long long x, y;
        cin >> x >> y;
        x--;
        y--;
        if(vec.at(x) < vec.at(y)) bad.at(x) = 1;  
        else if(vec.at(x) > vec.at(y))bad.at(y) = 1;
        else if(vec.at(x) == vec.at(y)){
            bad.at(x) = 1;
            bad. at(y) = 1;
        }  
    }

    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        if(bad.at(i) == 0) cnt++;
    }
    cout << cnt << endl;

}

Measured memory_bytes: 4576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#pragma warning (disable: 4996)

struct Point {
	long long a, b;
};

bool operator<(const Point& a1, const Point& a2) {
	if ((a1.b + 1LL) * a2.a < (a2.b + 1LL) * a1.a) return true;
	return false;
}

bool operator==(const Point& a1, const Point& a2) {
	if ((a1.b + 1LL) * a2.a == (a2.b + 1LL) * a1.a) return true;
	return false;
}

long long N, T;
long long A[1 << 18], B[1 << 18];
long long dp[1 << 18][44];
vector<Point> L;
vector<long long> L2;

int main() {
	cin >> N >> T;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
		if (A[i] != 0) L.push_back(Point{ A[i], B[i] });
		if (A[i] == 0) L2.push_back(B[i]);
	}
	sort(L.begin(), L.end());
	sort(L2.begin(), L2.end());

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 40; j++) dp[i][j] = (1LL << 60);
	}
	dp[0][0] = 0;
	for (int i = 1; i <= L.size(); i++) {
		for (int j = 0; j <= 40; j++) {
			if (dp[i - 1][j] > T) continue;
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			long long V = dp[i - 1][j] + 1LL;
			long long S = V * L[i - 1].a + L[i - 1].b;
			dp[i][j + 1] = min(dp[i][j + 1], V + S);
		}
	}

	long long Answer = 0;
	for (int i = 0; i <= 40; i++) {
		if (dp[L.size()][i] > T) continue;
		long long R = dp[L.size()][i], cnt = i;
		for (int j = 0; j < L2.size(); j++) {
			if (R + L2[j] + 1LL <= T) { cnt++; R += L2[j] + 1LL; }
		}
		Answer = max(Answer, cnt);
	}
	cout << Answer << endl;
	return 0;
}

Measured memory_bytes: 77164
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
typedef long long ll;

int main()
{
  int D, N; cin >> D >> N;
  int T[D]; FOR(i,0,D) cin >> T[i];
  int A[N], B[N], C[N]; FOR(i,0,N) cin >> A[i] >> B[i] >> C[i];
  int dp[D][N]; CLR(dp);// ???????????\??°?????????????????????
  FOR(i,0,N) if(T[0] >= A[i] && B[i] >= T[0]) dp[0][i] = 0;
  FOR(i,0,D-1) {
    FOR(j,0,N) {
      // k???????????´???
      if(dp[i][j] == -1) continue;
      FOR(k,0,N) {
        if(T[i+1] < A[k] || B[k] < T[i+1]) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abs(C[j] - C[k]));
      }
    }
  }
  int ans = 0;
  FOR(i,0,N) ans = max(ans, dp[D-1][i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3144
import numpy as np

N,k=map(int,input().split())
h = np.array(list(map(int,input().split())))

dp = np.zeros(N, dtype=int)

for i in range(1,N):
    start = max(i-k,0)
    dp[i] = np.min(dp[start:i] + np.abs(h[i] - h[start:i]))
    
print(dp[-1])

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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i,n){
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for(auto t : mp) mx = max(mx, t.second);
    for(auto t : mp){
        if(mx==t.second) cout << t.first << endl;
        else continue;
    }
    return 0;
}

Measured memory_bytes: 25216
//
// Created by yamunaku on 2020/03/21.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define MOD 2
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}


vector<ll> fact, invfact;

void buildFact(int n){
    fact = vector<ll>(n + 1, 1);
    invfact = vector<ll>(n + 1, 1);
    for(int i = 1; i <= n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    invfact[n] = inv(fact[n]);
    for(int i = n - 1; i >= 1; i--){
        invfact[i] = invfact[i + 1] * (i + 1) % MOD;
    }
}

ll bcomb(int n, int k){
    return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD;
}


int main(){
    //CFS;
    int n;
    string s;
    cin >> n >> s;
    bool one = false;
    rep(i, n){
        s[i]--;
        if(s[i] == '1'){
            one = true;
        }
    }
    buildFact(n);
    if(one){
        ll ans = 0;
        rep(i, n){
            if(s[i] == '1'){
                if(n - 1 == (i | (n - 1 - i))) ans++;
            }
        }
        cout << ans % 2 * 1 << endl;
    }else{
        ll ans = 0;
        rep(i, n){
            if(s[i] == '2'){
                if(n - 1 == (i | (n - 1 - i))) ans++;
            }
        }
        cout << ans % 2 * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 17028
import scala.io.StdIn

object Main extends App {
  val Array(a, b, c) = StdIn.readLine().split(' ').map(_.toInt)
  val (max, other) = if(a >= b && a >= c) {
    (a, b + c)
  } else if(b >= a && b >= c) {
    (b, a + c)
  } else {
    (c, a + b)
  }
  val k = StdIn.readLine().toInt
  val r = (0 until k).foldLeft(max) { (acc, _) =>
    acc*2
  } + other
  
  println(r)
  
}


Measured memory_bytes: 25404
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
using namespace std;

int main(void)
{
    #ifdef test
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test

    int N,M;
    scanf("%d%d",&N,&M);
    if(N==M)printf("Yes\n");
    else printf("No\n");
    
    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


Measured memory_bytes: 256
n = int(input())
array = list(map(int,input().split()))
if len(array) < 3:
  print(0)
  exit()
count = 0
array = sorted(array)
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
          if array[i] != array[j] != array[k] and array[i] + array[j] > array[k]:
            count += 1
print(count)
            


     

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define cout if (1) cout

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define pb push_back

const int N = 3e5+7;

ll n, a, b;
int v[N];

int main () {
	scanf("%lld %lld %lld", &n, &a, &b);

	if (n < a + b - 1 || n > a*b) { printf("-1\n"); return 0; }

	bool s = 0;
	if (a < b) { swap(a,b); s = 1; }
	
	int dec = n - a;

	ll p = 0;
	for (ll i = 1; i <= n;) {
		ll s = p;
		for (ll j = 0; j < b && p < n; j++, p++) {
			if (j && !dec) break;
			v[p] = j + i;
			if (j) dec--;
		}
		i = v[p-1] + 1;
		reverse(v+s,v+p);
	}

	for (int i = 0; i < n; i++) printf("%lld ", s?n-v[i]+1:v[i]);
	printf("\n");
}


Measured memory_bytes: 3328
S = [i for i in list(input())]
N = len(S)
k = [i for i in list('keyence')]

for d in range(N-6):
    for i in range(N-(d-1)):
        s = S[:i] + S[i+d:]
        if s==k:
            print('YES')
            quit()
print('NO')

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

#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define fill(a,v)  memset(a, v, sizeof a)
#define maX(a,b)  ( (a) > (b) ? (a) : (b))
#define miN(a,b)  ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)  ( (n >> b) & 1)
#define ll long long
#define endln '\n'
#define nperm next_permutation
#define forel(i, str) forall(i, 0, str.size())
#define contains(needle,haystack) (haystack.find(needle) != haystack.end())
#define strlower(data) transform(data.begin(), data.end(), data.begin(), ::tolower)
#define strupper(data) transform(data.begin(), data.end(), data.begin(), ::toupper)
#define umap unordered_map
#define pb(i) push_back(i)
#define pf(i) push_front(i)
#define is_pow2(a) ((a & (a - 1)) == 0)
#define between(a, b, c) (a >= b && a <= c)
#define pq priority_queue
#define v(type) vector<type>

using namespace std;

string str;

bool is_beautiful(string& str) {
	umap<char, int> mmap;
	forall(i, 0, str.size()) {
		mmap[str[i]] += 1;
	}

	for (char c = 'a'; c <= 'z'; ++c) {
		if(mmap[c] % 2 == 1) {
			return false;
		}
	}

	return true;
}

int main() {
	std::ios::sync_with_stdio(false);
	// freopen("_in","r",stdin);
    // freopen("_out","w",stdout);

    cin >> str;
    cout << (is_beautiful(str) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
import math
import fractions

a, b, c, d = map(int, input().split())

a_c = (a - 1) // c
b_c = b // c
a_d = (a - 1) // d
b_d = b // d

lcm = int(c * d / fractions.gcd(c, d))
a_cd = (a - 1) // lcm
b_cd = b // lcm

result = b - a + 1 - (b_c - a_c) - (b_d - a_d) + (b_cd - a_cd)
print(int(result))

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int h,w;
string s[33][33];

int main(){
	cin.sync_with_stdio(false);
	cin>>h>>w;
	rep(i,h)rep(j,w)cin>>s[i][j];
	rep(i,h)rep(j,w){
		if(s[i][j]=="snuke"){
			cout<<(char)('A'+j)<<i+1<<endl;
		}
	}
	return 0;
}


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

using namespace std;

char affine(int a,int b,char c)
{
	if(c==' ')	return c;
	return 'a'+(a*(c-'a')+b)%26;
}

int main()
{
	int a[]={1,3,5,7,9,11,15,17,19,21,23,25,0};
	int n;	cin>>n;cin.ignore();
	string ciph,ciph_copy,sp=" ";

	while(getline(cin,ciph)){
		ciph=ciph_copy=sp+ciph+sp;
		bool f=false;
		for(int i=0;!f&&a[i];i++){
			for(int b=0;!f&&b<26;b++){
				for(int j=0;j<ciph.length();j++)
					ciph[j]=affine(a[i],b,ciph[j]);

				if(ciph.find(" that ")!=string::npos
				|| ciph.find(" this ")!=string::npos){
					f=true;
					break;
				}

				ciph=ciph_copy;
			}
		}
		cout<<ciph.substr(1,ciph.length()-2)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){


  
long long x;
string ans="0";
cin>>x;
if(x<100){
    cout<<ans<<endl;
    return 0;
}
long long l=x/100;
x%=100;



    for(int a5=0;a5*5<=x && a5<=l;a5++){
        for(int a4=0;a5*5+a4*4<=x && a5+a4<=l;a4++){
            for(int a3=0;a5*5+a3*3+a4*4<=x && a5+a4+a3<=l;a3++){
                for(int a2=0;a2*2+a3*3+a4*4+a5*5<=x && a5+a4+a3+a2<=l;a2++){
                    for(int a1=0;a1*1+a2*2+a3*3+a4*4+a5*5<=x && a5+a4+a3+a2+a1<=l;a1++){
                        if(a1*1+a2*2+a3*3+a4*4+a5*5==x){
                            ans="1";
                            break;
                        }
                    }
                }
            }
        }
    }


cout<<ans<<endl;
 return 0;
}
/*
615

1

217

0

*/

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

int main(void) {
    std::vector<int> alpha_count(26, 0);
    std::string s;
    std::cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (alpha_count[(int)s[i] - 97] == 1) {
            std::cout << "no" << std::endl;    
            return 0;
        }
        alpha_count[(int)s[i] - 97]++;
    }
    std::cout << "yes" << std::endl;    
    return 0;
}



Measured memory_bytes: 256
#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;}

// (行き先,容量,逆辺)
struct edge{ int to,cap,rev; };

const int MAX_V = 222; // TODO:initialize
const int F_INF = 19191919; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,0,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをdfsで探す
int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

int main(){
    int n,m,s,t;
    cin >>n >>m >>s >>t;
    --s; --t;

    vector<int> u(m),v(m),d(m),c(m);
    rep(i,m){
        cin >>u[i] >>v[i] >>d[i] >>c[i];
        --u[i];
        --v[i];
    }

    using pi = pair<int,int>;
    vector<vector<pi>> g(n);
    rep(i,m) g[u[i]].pb({v[i],d[i]});

    vector<int> dist(n,19191919);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(const auto &e:g[now]){
            int to = e.fi, cost = e.se;
            if(dist[to] > dist[now]+cost){
                dist[to] = dist[now]+cost;
                que.push(to);
            }
        }
    }

    rep(i,m)if(dist[u[i]] + d[i] == dist[v[i]]) add_edge(u[i],v[i],c[i]);
    cout << max_flow(s,t) << endl;
    return 0;
}



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


int main() {

    int K = 0;
    string S;

    cin >> K >> S;

    if ((int)(S.length() <= K)) {
        cout << S;
    }
    else {
        for (int i = 0; i < K; i++) {
            cout << S[i];
        }
        cout << "...";
    }

    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.first << ", " << a.second << ')';
    return out;
}
}

int main(){
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    map<int, int> ma, mb;
    rep(i, n) {
        ma[a[i]]++;
        mb[b[i]]++;
    }
    for(auto&& p : mb) {
        if(ma.count(p.first) == 0) continue;
        if(p.second + ma[p.first] > n) {
            cout << "No" << '\n';
            return 0;
        }
    }
    using P = pair<int, int>;
    priority_queue<P> pa, pb;
    for(auto&& p: ma) pa.emplace(p.second, p.first);
    for(auto&& p: mb) pb.emplace(p.second, p.first);
    vector<vector<int>> ind(n+1);
    rep(i, n) ind[a[i]].emplace_back(i);

    vi ans(n,-1);
    

    while(pa.size()) {
        auto p = pa.top(); pa.pop();

        
        auto q = pb.top(); pb.pop();
        P x = q;

        if(p.second == q.second && pb.size() > 0) {
            x = pb.top(); pb.pop();
            pb.emplace(q);
        }
        
        int a = p.second;
        ans[ind[a].back()] = x.second;
        ind[a].pop_back();
        x.first--;
        p.first--;
        if(x.first > 0) pb.emplace(x);
        if(p.first > 0) pa.emplace(p);
    }

    // dumpVL(a);
    // dumpVL(ans);

    rep(i, n) if(a[i] == ans[i]) {
        rep(j, n) {
            if(a[i] != ans[j] && a[j] != ans[i]) {
                swap(ans[i], ans[j]);
                break;
            }
        }
    }
    



    cout << "Yes" << '\n';
    rep(i, n) {
        cout << ans[i] << (i+1 == n ? '\n' : ' ');
    }

    return 0;
}

Measured memory_bytes: 38220
num = int(input())
l = list(map(int, input().split()))
count = 1
var = var2 = 0
c = l[0]
for i in l[1:]:
    if c < i:
        var = 1
    elif c > i:
        var2 = 1
    if var == 1 and var2 == 1:
        count += 1
        var = var2 = 0
    c = i
print(count)

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

void gcd(int a, int b)
{
    if ( a % b == 0)
        return;

    return gcd(b, a % b);
}

int main() { 
    ll A, B;
    cin >> A >> B;

    cout << A * B / gcd(A, B) << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>
#define ll unsigned long long
using namespace std;
    vector <ll> vec;
ll qkpow(ll x, ll n)
{
    ll res=1;
    while(n>0)
    {
        if(n&1)
            res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}
int main(void)
{
    int a,b,c;
    scanf("%d/%d/%d",&a,&b,&c);
    printf("2018/%02d/%02d",b,c);
    //cout<<2018<<"/"<<b<<"/"<<c<<endl;
    return 0;
}




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

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

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

int main() {
	int data[100];
	rep (i, 100) data[i] = 0;
	int num, cnt = 0;
	while (cin >> num) {
		data[num]++;
	}
	rep(i, 100) {
		cnt = max(cnt, data[i]);
	}
	rep(i, 100) {
		if (data[i] == cnt) {
			cout << i << endl;
		}
	}
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H;
    int N;
    cin >> H >> N;
    ll sum = 0;
    rep(i, N){int a; cin >> a; sum += a;}

    if (sum >= H){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,k;
int main() {
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a>k) {
		cout<<":("<<endl;
	} else {
		cout<<"Yay!";
	}
	return 0;
}

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

int main()
{
    double a ,b ,c;
    cin >>a>>b>>c;
    double h;
    if (c==90){
        h=b; 
    }else {
        h=b*sin(c*3.14159265359/180); 
    }
    double s=(0.5)*a*b*sin(c*3.14159265359/180);
    
    double l=sqrt(pow(a,2)+pow(b,2)-(2*a*b*cos(c*3.14159265359/180)));
    double L=l+a+b;
    printf("%f",s);
    cout<<endl;
    printf("%f",L);
    cout<<endl;
    printf("%f",h);
    cout<<endl;
    return 0;
}


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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 200010;

int n;
int A[MAXN];
LL sum[MAXN], xr[MAXN];

int main()
{
	in(n);
	FOR(i, 1, n) in(A[i]);
	FOR(i, 1, n) sum[i] = sum[i - 1] + A[i];
	FOR(i, 1, n) xr[i] = xr[i - 1] ^ A[i];

	int l = 1; LL ans = 0;
	
	FOR(i, 1, n) {
		while (sum[i] - sum[l - 1] != (xr[i] ^ xr[l - 1])) l++;
		ans += i - l + 1;
	}

	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 4096
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        k: usize,
        s: usize,
        t: usize,
        a: [usize; n],
    }
    let a: Vec<usize> = a.into_iter().filter(|a| a & s == s && a | t == t).collect();
    if a.len() == 0 {
        println!("0");
        return;
    }
    let n = a.len();
    let k = std::cmp::min(k, n);
    let w = 50usize;
    let mut binom = vec![vec![0i64; w + 1]; w + 1];
    binom[0][0] = 1;
    for i in 1..=w {
        binom[i][0] = 1;
        for j in 1..=i {
            binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
        }
    }
    for i in 2..=w {
        for j in 2..=i {
            binom[i][j] += binom[i][j - 1];
        }
    }
    let mut bit = vec![];
    for i in 0usize..18 {
        if s >> i & 1 != t >> i & 1 {
            bit.push(i);
        }
    }
    let mut ans = 0i64;
    for (i, s) in a.iter().enumerate() {
        let mut cnt = vec![0; 1 << bit.len()];
        for &a in a.iter().skip(i + 1) {
            let mut v = 0;
            for (i, x) in bit.iter().enumerate() {
                if s >> x & 1 == a >> x & 1 {
                    v |= 1 << i;
                }
            }
            cnt[v] += 1;
        }
        for i in 0..bit.len() {
            for j in 0..(1 << bit.len()) {
                if j >> i & 1 == 1 {
                    cnt[j ^ (1 << i)] += cnt[j];
                }
            }
        }
        for (i, c) in cnt.into_iter().enumerate().filter(|p| p.1 > 0) {
            let sign = if i.count_ones() % 2 == 0 {1} else {-1};
            ans += sign * binom[c][std::cmp::min(k - 1, c)];
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4272
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
#define N 101010
LL n , m , fac[ N ];
void init(){
  fac[ 0 ] = 1;
  for( int i = 1 ; i < N ; i ++ )
    fac[ i ] = mul( fac[ i - 1 ] , i );
  n = getint();
  m = getint();
}
void solve(){
  if( abs( n - m ) > 1 ){
    puts( "0" );
    return;
  }
  if( n == m ){
    printf( "%lld\n" , mul( mul( fac[ n ] , fac[ m ] ) , 2 ) );
  }else{
    printf( "%lld\n" , mul( mul( fac[ n ] , fac[ m ] ) , 1 ) );
  }
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c; cin>>a>>b>>c;
  if(a==b+c||b==a+c||c==a+b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
var i,j,k,ans,n  :int64;
    p:array[1..22]of int64;
 
begin
  readln(n);
  ans:=0;
  for i:=1 to n do read(p[i]);
  for i:=2 to n-1 do begin
    if p[i]<p[i-1] then begin
      if p[i]>=p[i+1] then inc(ans)
    end
    else if p[i]<p[i+1] then inc(ans)
  end;
  writeln(ans);
end.

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>

using namespace std;

string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> grh;
vector<int> ary;
vector<int> bry;
void dfs (int crr, int cnt) {
  ary[crr] = cnt;
  for (int nxt : grh[crr]) {
    if (ary[nxt] == -1) {
      dfs(nxt, cnt);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, l;
  cin >> n >> k >> l;
  for (int t = 0; t < 2; t++) {
    grh.clear();
    grh.resize(n);
    for (int i = 0; i < k; i++) {
      int s, t;
      cin >> s >> t;
      grh[--s].push_back(--t);
      grh[t].push_back(s);
    }
    ary.resize(n, -1);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (ary[i] == -1) {
        dfs(i, cnt);
        cnt++;
      }
    }
    swap(k, l);
    swap(ary, bry);
  }
  vector<pair<int, int>> prs(n);
  for (int i = 0; i < n; i++) {
    prs[i] = {ary[i], bry[i]};
  }
  sort(prs.begin(), prs.end());
  for (int i = 0; i < n; i++) {
    pair<int, int> val = {ary[i], bry[i]};
    int ret = upper_bound(prs.begin(), prs.end(), val) - lower_bound(prs.begin(), prs.end(), val);
    cout << ret;
    if (i < n - 1) {
      cout << ' ';
    } else {
      cout << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 11520
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    cout<<((n-1)*n)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char st[300];
	int i=0;
	
	for(i=0; i<300; i++) {
		scanf("%c", &st[i]);
		if('a' <= st[i] && st[i] <='z') st[i] -= 32;
		if(st[i] == '\0') break;
		printf("%c", st[i]);
	}
	
	return 0;

}

Measured memory_bytes: 524
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n;
	vector<ll>	p(n+1);
	for(i=1;i<=n;i++) cin >> p[i];
	
	for(i=1;i<=n;i++) {
		if (p[i]!=i) continue;
		if (i+1<=n && p[i]!=i+1) {
			swap(p[i],p[i+1]);
		} else {
			swap(p[i],p[i-1]);
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024