akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n; cin >> n;
    int ans = 0;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int cnt = 0;
    // iに降り立つ
    rep(i,n-1) {
        if (h[i] >= h[i+1])
        {
            if (i+1 == n-1)
            {
                cnt++;
                ans = max(cnt, ans);
                break;
            } else {
                cnt++;
            }
        } else {
            //cout << i <<" is cnt = " << cnt << endl;
            ans = max(ans,cnt);
            //cout << "ans = " << ans << endl;
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
const int N=55;
int arr[N];
int main() {
	int n,mn=0,mx=0,cntp=0,cntn=0,idn=-1,idp=-1;cin>>n;
	loop(n,i,0){
		cin>>arr[i];
		cntp+=(arr[i]>0);
		cntn+=(arr[i]<0);
		if(mn>arr[i]){
			mn=arr[i];
			idn=i;

		}
		if(mx<arr[i]){
			mx=arr[i];
			idp=i;
		}
	}
	vector<pair<int,int>>v;
//	cout<<idp<<' '<<idn<<endl;
	if(abs(mn)>mx||cntp==0){
		if(idn==-1)idn=0;
		loop(n,i,0){
			if(idn==i)continue;
			if(arr[i]>=0)
				v.pb({idn+1,i+1});
		}
		for(int i=n;i>1;i--){
			v.pb({i,i-1});
		}
	}
	else{
		if(idp==-1)idp=0;
		loop(n,i,0){
			if(i==idp)continue;
			if(arr[i]<=0)
			v.pb({idp+1,i+1});
		}
		loop(n-1,i,0)
			v.pb({i+1,i+2});
	}
	cout<<sz(v)<<endl;
	for(auto z:v)cout<<z.first<<' '<<z.second<<endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::vector<int64_t> v(n);
  std::cin >> v;

  std::vector<int64_t> l_s(n + 1), r_s(n + 1);
  std::vector<std::set<int64_t>> l_set(n + 1), r_set(n + 1);

  l_s[0] = 0;

  for (int64_t i = 1; i < n + 1; i++) {
    l_s[i] = l_s[i - 1] + v[i - 1];
    l_set[i] = l_set[i - 1];
    if (v[i - 1] < 0) {
      l_set[i].insert(v[i - 1]);
    }
  }

  r_s[0] = 0;

  for (int64_t i = 1; i < n + 1; i++) {
    r_s[i] = r_s[i - 1] + v[n - i];
    r_set[i] = r_set[i - 1];
    if (v[n - i] < 0) {
      r_set[i].insert(v[n - i]);
    }
  }

  int64_t val = 0;

  for (int64_t i = 0; i <= k; i++) {
    for (int64_t j = 0; j <= k - i; j++) {
      if (n < i + j) {
        break;
      }
      const auto m = k - i - j;
      int64_t tmp = l_s[i] + r_s[j];
      auto p = l_set[i];
      p.insert(r_set[j].cbegin(), r_set[j].cend());

      auto itr = p.cbegin();
      auto h = 0;
      for (; itr != p.cend() && h < m; itr++, h++) {
        tmp -= *itr;
      }
      val = std::max(val, tmp);
    }
  }
  std::cout << val << std::endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	deque<int> d;
	rep(i,N){
		int x; cin >> x;
		if(i%2==0) d.push_back(x);
		else d.push_front(x);
	}
	if(N&1) reverse(all(d));
	rep(i,N) cout << d[i] << " ";
	cout << endl;
}


Measured memory_bytes: 3072
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> key;

void solve() {
  string s;
  cin >> s;
  deque<char> q;
  for(int i = 0; i < s.size(); i++) {
    q.push_back(s[i]);
  }
  int ret = 0;
  while(q.size() > 1) {
    if(q.front() == q.back()) {
      q.pop_front();
      q.pop_back();
      continue;
    }
    if(q.front() == 'x') {
      q.pop_front();
      ret++;
      continue;
    }
    if(q.back() == 'x') {
      q.pop_back();
      ret++;
      continue;
    }
    cout << "-1\n";
    return;
  }
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1,
    x=-x;
  }
  while(x){
    f[s++]=x%10,
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
const int SZ=500;
int c[SZ], f[SZ], s[SZ];
int main(){
  int cur, i, n;
  rd(n);
  {
    int lhxun_Zi;
    for(lhxun_Zi=0;lhxun_Zi<n-1;lhxun_Zi++){
      rd(c[lhxun_Zi]);
      rd(s[lhxun_Zi]);
      rd(f[lhxun_Zi]);
    }
  }
  for(i=0;i<n;i++){
    int j;
    cur = 0;
    for(j=i;j<n-1;j++){
      chmax(cur, s[j]);
      cur = (cur+f[j]-1)/f[j]*f[j];
      cur += c[j];
    }
    wt_L(cur);
    putchar_unlocked('\n');
  }
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// const int SZ = 500;
// int c[SZ], s[SZ], f[SZ];
// {
//   int n, cur;
//   rd(n, (c,s,f)(n-1));
//   rep(i,n) {
//     cur = 0;
//     rep(j,i,n-1) {
//       cur >?= s[j];
//       cur = (cur+f[j]-1)/f[j]*f[j];
//       cur += c[j];
//     }
//     wt(cur);
//   }
// }

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

int query(int);

int main()
{
	int N;
	scanf("%d", &N);
	int upper{N}, lower{}, gender{query(0)};
	if (gender == 2) return 0;
	while (true)
	{
		int mid{(upper + lower) >> 1};
		int input{query(mid)};
		if (input == 2) break;
		if ((gender + input) % 2 == (mid - lower) % 2)
		{
			lower = mid;
			gender = input;
		}
		else
			upper = mid;
	}

	return 0;
}

int query(int output)
{
	printf("%d\n", output);
	fflush(stdout);
	std::string s;
	std::cin >> s;
	if (s == "Male") return 0;
	else if (s == "Female") return 1;
	else return 2;
}

Measured memory_bytes: 852
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    char a;
    cin >> a;
    if(a<'a')cout << 'A' << endl;
    else cout << 'a' << endl;
}

Measured memory_bytes: 3028
import math
b = 0
N, D = map(int, input().split())
ls = [list(map(int, input().split()))for i in range(N)]
for i in range(N - 1):
    for j in range(i + 1, N):
        a = 0
        for k in range(D):
            a += (ls[i][k] - ls[j][k]) ** 2
        if math.sqrt(a).is_integer() is True:
            b += 1

print(b)


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

void inputVectorString(vector<string> * p, long long a){
    rep(i, a){
        string input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    string S;
    cin >> S;

    if(S.compare("ARC") == 0){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x)
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

struct edge{ll from,to,cost;};
struct graph{
    ll V; //1番でかい頂点番号+1
    vector<edge> es; //辺
    vector<ll> d; //最短距離
 
    graph(ll n){
        init(n);
    }
 
    void init(ll n){ //n:頂点数
        V=n+1; //1-origin
        d.resize(V);
        rep1(i,V-1) d[i]=INF; //1~n
    }
 
    void add_edge(ll from,ll to,ll cost){
        edge e;
        e.from=from;
        e.to=to;
        e.cost=cost;
 
        es.pb(e);
    }
 
    bool bellman_ford(ll s){//O(|V||E|)
        bool loop=false;
        rep1(i,V-1) d[i]=INF;
        d[s]=0;
        
        rep1(i,(V-1)*2){
            bool update=false;
            rep(j,es.sz){
                edge e=es[j];
                if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
                    d[e.to]=d[e.from]+e.cost;
                    if(i>=V-1){
                        d[e.to]=-INF;
                        loop=true;
                    }
 
                    update=true;
                }
            }
            if(!update) break;
        }
 
        if(loop) return true;
        else return false;
    }
};
/*
 bool(BellmanFord)がtrue:負閉路あり
                    false:負閉路なし
 graph.d[目的地]が-INF:目的地に関与する負の閉路あり
 */


int main(){
    ll N,M,P; cin>>N>>M>>P;//辺数
    graph G(N); //グラフの構成、初期化
    //Mコの辺の情報入力
    rep(i,M){
        ll from,to,cost; cin>>from>>to>>cost;
        G.add_edge(from,to,P-cost);
    }

    G.bellman_ford(1);
    if(-G.d[N]<0) cout<<0;
    else if(-G.d[N]==INF) cout<<-1;
    else cout<<-G.d[N];
}



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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int a, cnt[5];
	memset(cnt, 0, sizeof cnt);
	for (int i = 0; i < 2; i++) {
		scanf("%d", &a);
		cnt[a]++;
	}
	for (int i = 1; i < 4; i++)
		if (cnt[i] == 0)
			printf("%d\n", i);
	return 0;
}

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

int main()
{
	int n, m, distance[100][100]{}, edge[100][100]{};
	std::fill(distance[0], distance[0] + 10000, 1000000000);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--; b--;
		distance[a][b] = distance[b][a]
		= edge[a][b] = edge[b][a] = c;
	}
	for (int i = 0; i < n; i++)
		distance[i][i] = 0;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = j + 1; k < n; k++)
				distance[k][j] = distance[j][k] = std::min(distance[j][k], distance[j][i] + distance[i][k]);
	
	int count{};
	for(int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (distance[i][j] < edge[i][j])
				count++;
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  string s = "MARCH";
  ll c[5] = {0};
  REP(i, n)
  {
    string tmp;
    cin >> tmp;
    REP(j, 5)
    {
      if (tmp[0] == s[j])
      {
        c[j]++;
      }
    }
  }

  ll anser = 0;
  REP(i, 3)
  {
    FOR(j, i + 1, 5)
    {
      FOR(k, j + 1, 5)
      {
        anser += c[i] * c[j] * c[k];
      }
    }
  }

  cout << anser << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

const int INF = 1001001001;
int dist[100005][3];

typedef pair<int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> to(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
    }

    int sv, tv;
    cin >> sv >> tv;
    --sv;
    --tv;
    rep(i, N) rep(j, 3) dist[i][j] = INF;

    queue<P> q;
    q.push(P(sv, 0));
    dist[sv][0] = 0;
    while (!q.empty()) {
        int v = q.front().first;
        int l = q.front().second;
        q.pop();

        for (int u: to[v]) {
            int nl = (l + 1) % 3;
            if (dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            q.push(P(u, nl));
        }
    }

    int ans = dist[tv][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
}


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

int main() {
    ll N,A,B,C,D;
    cin >> N >> A >>B >>C >> D;
    --N;
    for(int i=0;i<N;i++){
        ll diff = abs(B-A);
        if((diff>= (C *(N-i) -i*D)) &&(diff<= (D*(N-i)-i*C))){
            // cerr <<"i=" <<i <<"lower = " <<C *(N-i) -i*D <<" upper=" << D*(N-i)-i*C << endl;
            cout <<"YES" << endl;
            return 0;
        } 
    }
    cout <<"NO" << endl;

    return 0;
}

Measured memory_bytes: 3516
from itertools import groupby

S = input()
K = int(input())

def count(nums):
    return sum(num//2 for num in nums)

l = [len(list(g)) for k, g in groupby(S)]

if len(l) == 1:
    print(l[0]*K//2)
elif S[0] == S[-1]:
    print(count(l)*K - (count([l[0]]) + count([l[-1]]) - count([l[0]+l[-1]]))*(K-1))
else:
    print(count(l)*K)

Measured memory_bytes: 3064
import numpy as np

def solve():
    H,W=map(int,input().split(' '))
    max_value = H+W
    values =[]
    for i in range(H):
      values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(W-1):
        values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
    for x in range(W-1,0,-1):
        values[:,x-1] = np.minimum(values[:,x-1],values[:,x]+1)
    for x in range(H-1):
        values[x+1,:] = np.minimum(values[x,:]+1,values[x+1,:])
    print('')
    for x in range(H-1,0,-1):
        values[x-1,:] = np.minimum(values[x,:]+1,values[x-1,:])
    print(np.max(values))
solve()

Measured memory_bytes: 28948
#include <iostream>
#include <cmath>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;
int main(){
    long double a;
    long double b;
    cin >> a;
    cin >> b;
    int n;

    long double c = a*b;
    std::string p = std::to_string(c);
    for(int i = 0; i < p.size(); i++){
        if(p[i] == '.'){
            n = i;
            break;
        }
    }

    string t;
    for(int i = 0; i < n; i++){
        t = t + p[i];
    }
    cout << t << endl;
    return 0;
}

/*
198 1.10
1 0.01
1000000000000000 9.99
*/

Measured memory_bytes: 3268
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int N = scanner.nextInt();
			int[] A = new int[N];
			for (int i = 0; i < N; i++) {
				A[i] = scanner.nextInt();
			}
			bubbleSort(A, N);
			System.out.println(Arrays.stream(A).mapToObj(a -> "" + a)
					.reduce((a, b) -> a + " " + b).get());
			System.out.println(count);
		}
	}

	static int count = 0;
	public static void bubbleSort(int[] A, int N) {
		count = 0;
		boolean flag = true;
		while (flag) {
			flag = false;
			for (int j = N - 1; j >= 1; j--) {
				if (A[j] < A[j - 1]) {
					int tmp = A[j];
					A[j] = A[j - 1];
					A[j - 1] = tmp;
					flag = true;
					count++;
				}
			}
		}
	}
}

Measured memory_bytes: 32444
#include <iostream>
#include <string>
using namespace std;
int main() {
  int num;
  cin >> num;
  string taro, hanako;
  int taro_count=0, hanako_count=0;

  for (int i = 0; i < num; i++) {
    cin >> taro >> hanako;
    if (taro == hanako) {
      taro_count++;
      hanako_count++;
    } else if (taro > hanako) {
      taro_count += 3;
    } else {
      hanako_count += 3;
    }
  }
  cout << taro_count << " " << hanako_count << endl;
  return 0;
}

Measured memory_bytes: 1208
#!/usr/bin/env python3
# GRL_5_C: Tree - Lowest Common Ancestor


class UnionFind:
    def __init__(self, n):
        self.nodes = [i for i in range(n)]
        self.sizes = [1 for _ in range(n)]

    def union(self, p, q):
        rp = self.root(p)
        rq = self.root(q)
        if self.sizes[rp] > self.sizes[rq]:
            self.nodes[rq] = rp
            self.sizes[rp] += self.sizes[rq]
        else:
            self.nodes[rp] = rq
            self.sizes[rq] += self.sizes[rp]

    def connected(self, p, q):
        return self.root(p) == self.root(q)

    def root(self, p):
        while p != self.nodes[p]:
            self.nodes[p] = self.nodes[self.nodes[p]]
            p = self.nodes[p]

        return p


class Edge:
    __slots__ = ('v', 'w')

    def __init__(self, v, w):
        self.v = v
        self.w = w

    def either(self):
        return self.v

    def other(self, v):
        if v == self.v:
            return self.w
        else:
            return self.v


class WeightedEdge(Edge):
    __slots__ = ('v', 'w', 'weight')

    def __init__(self, v, w, weight):
        super().__init__(v, w)
        self.weight = weight


class Graph:
    def __init__(self, v):
        self.v = v
        self._edges = [[] for _ in range(v)]

    def add(self, e):
        self._edges[e.v].append(e)
        self._edges[e.w].append(e)

    def adj(self, v):
        return self._edges[v]

    def edges(self):
        for es in self._edges:
            for e in es:
                yield e


def lca(graph, root, queries):
    index = [set() for _ in range(graph.v)]
    for v, w in queries:
        index[v].add((v, w))

    visited = [False] * graph.v
    stored = [False] * graph.v
    parents = [None] * graph.v
    uf = UnionFind(graph.v)
    res = {}
    stack = [root]
    while stack:
        v = stack.pop()
        if not visited[v]:
            visited[v] = True
            stack.append(v)
            for e in graph.adj(v):
                w = e.other(v)
                if not visited[w]:
                    stack.append(w)
                    parents[w] = v
        else:
            stored[v] = True
            p = parents[v]
            rest = set()
            for i, j in index[v]:
                if stored[i] and stored[j]:
                    if uf.connected(i, j) and (i, j) not in res:
                        res[(i, j)] = v
                    else:
                        rest.add((i, j))
                else:
                    index[j].add((i, j))
            index[v] = None
            if p is not None:
                uf.union(p, v)
                index[p].update(rest)

    return res


def run():
    n = int(input())
    g = Graph(n)

    for i in range(n):
        k, *cs = [int(i) for i in input().split()]
        if k > 0:
            for j in cs:
                g.add(Edge(i, j))

    q = int(input())
    qs = []
    for _ in range(q):
        v, w = [int(i) for i in input().split()]
        qs.append((v, w))

    res = lca(g, 0, qs)
    for v, w in qs:
        print(res[(v, w)])


if __name__ == '__main__':
    run()



Measured memory_bytes: 87956
import java.util.Scanner;

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

		int x = scan.nextInt();
		int y = scan.nextInt();

		if(y % 2 != 0 || (x * 4) < y || (x * 2) > y) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 35792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

uint64_t a[500];
vector<uint64_t> factors;
uint64_t r[500];

int main()
{
    int n;
    uint64_t k;

    cin >> n >> k;

    uint64_t asum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        asum += a[i];
    }

    for (uint64_t i = 1; i * i <= asum; i++)
    {
        if (asum % i == 0)
        {
            factors.push_back(i);
            if (i * i != asum)
            {
                factors.push_back(asum / i);
            }
        }
    }

    uint64_t maxFactor = 0;
    for (const uint64_t f : factors)
    {
        for (int i = 0; i < n; i++)
        {
            r[i] = a[i] % f;
        }
        sort(r, r + n);

        int i = 0;
        int j = n - 1;
        uint64_t cnt = 0;
        while (i < j)
        {
            uint64_t p = r[i];
            cnt += p;
            r[i] = 0;

            while (p > 0)
            {
                uint64_t q = min(p, f - r[j]);
                r[j] += q;
                p -= q;
                if (f == r[j])
                {
                    j--;
                }
            }
            i++;
        }
        if (r[j] == 0 && cnt <= k)
        {
            maxFactor = max(maxFactor, f);
        }
    }

    cout << maxFactor << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
cost = [list(input().split()) for i in range(N)]
count = 0

for i in range(N):
  if cost[i][1] == "JPY":
    count += float(cost[i][0])
  else:
    count += float(cost[i][0]) * 380000.0
    
print(count)


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

using namespace std;


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


int main(){
  int n,m,k;

  cin>>n>>m>>k;
  bool f=0;
  for(int i=0;i<=n;i++)
    for(int j=0;j<=m;j++){
      int c=i*m+j*n-2*i*j;

      if(c==k)f=1;
    }

  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
  }
    cout << str << endl;
  return 0;
}

Measured memory_bytes: 1176
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			Deque<Process> process=new ArrayDeque<>();
			int n=Integer.parseInt(sc.next());
			int q=Integer.parseInt(sc.next());
			for(int i=0;i<n;i++){
				String name=sc.next();
				int time=Integer.parseInt(sc.next());
				process.addLast(new Process(name,time));
			}
			int totalTime=0;
			while(process.size()!=0){
				Process p = process.pollFirst().clone();
				if(p.isEnds(q)){
					totalTime+=p.time;
					System.out.println(p.name+" "+totalTime);
				}else{
					totalTime+=q;
					p.work(q);
					process.addLast(p);
				}
			}
		}
	}
}

class Process implements Cloneable{
	String name;
	int time;
	Process(String name, int time){
		this.name=name;
		this.time=time;
	}
	public Process clone(){
		Process p = new Process(this.name,this.time);
		return p;
	}
	public boolean isEnds(int q){
		return (this.time<=q);
	}
	public void work(int q){
		this.time-=q;
	}
}

Measured memory_bytes: 72276
//
//  main.cpp
//  DPpractice
//
//  Created by abhishek kumar on 20/04/20.
//  Copyright © 2020 abhishek kumar. All rights reserved.
//

#include <iostream>
#include<utility>
#include<math.h>
#include<vector>
#include<math.h>
using namespace std;
typedef long double ll;
const long long int N=1000;
ll n,w,k,m,temp,arr[N+1][N+1],dp[N+1][N+1],visited[N+1][N+1];


void maxi(ll& a,ll b)
{
    a=max(a,b);
}





int main(int argc, const char * argv[]) {
    
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll total=1.00;
    cin>>n;
    vector<ll> coins_prob(n+1,0);
    for(auto i=1;i<n+1;i++){
        cin>>temp;
        coins_prob[i]=temp;
        total*=temp;
    }
    vector<vector<ll>> prob(n+1,vector<ll>(n+1,0));
    prob[1][0]=1-coins_prob[1];
    prob[1][1]=coins_prob[1];
    for(auto i=2;i<n+1;i++)
        prob[i][0]=prob[i-1][0]*(1-coins_prob[i]);
    for(auto i=2;i<n+1;i++)
    {
        for(auto j=1;j<=i;j++)
        {
            prob[i][j]=prob[i-1][j-1]*coins_prob[i] + prob[i-1][j]*(1-coins_prob[i]);
        }
    }
    
    ll sum=0.00;
    for(auto i=n/2+1;i<n+1;i++)
    {
        sum+=prob[n][i];
    }
    
    printf("%.10Lf\n",sum);
    
    return 0;
        
}

Measured memory_bytes: 141056
n = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
for i in range(1,n+1):
  if i%2==1:
    alice += max(a)
    a.remove(max(a))
  else:
    bob += max(a)
    a.remove(max(a))
    
print(alice-bob)

Measured memory_bytes: 3060
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)

    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val k = sc.nextInt()

    var v = 0
    var cnt = 0
    while (cnt < k && cnt < a) {
        v += 1
        cnt++
    }
    while (cnt < k && (cnt - a) < b) {
        cnt++
    }
    while (cnt < k && (cnt - a - b) < c) {
        v += -1
        cnt++
    }
    println(v)
}


Measured memory_bytes: 36180
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n, a[200001], b[200001];
    vector<int> ans;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        b[i] = a[i];
        if(i > n/2 && b[i] == 1){
            ans.push_back(i);
        }
    }
    for(int i=n/2;i>0;i--){
        for(int j=2;j*i<=n;j++){
            b[i] += b[j*i];
        }
        b[i] %= 2;
        if(b[i]%2 == 1){
            ans.push_back(i);
        }
    }
    int s = ans.size();
    cout << s << endl;
    if(s > 0){
        cout << ans[0] << endl;
        for(int i=1;i<s;i++){
            cout << " " <<ans[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3064
N, M = map(int, input().split())
A = list(map(int, input().split()))
votes = sum(A)
res = "Yes"

A.sort(reverse=True)

for i in range(1, M+1):
    if A[i-1] < (votes / (4 * M)):
        res = "No"
        break

print(res)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string w;
  cin >> w;
  int a[26]={};
  for (int i;i<w.size();i++){
  	a[(w[i]-'a')] = 1 - a[(w[i]-'a')]; 
  }
  sort(a,a+26);
  if (a[25]==0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
n,z,w = map(int, input().split( ))
*a, = map(int, input().split( ))
#添え字間違えたのでa逆
a.reverse()
ans1 = 0
if len(a)>1:
    ans1 = abs(a[1]-a[0])
ans2 = abs(a[0]-w)
print(max(ans1,ans2))

Measured memory_bytes: 38768
N, K = map(int, input().split())
coins = []
for i in range(1, N+1):
	m = i
	cnt = 0
	while m < K:
		cnt += 1
		m *= 2
	coins.append(cnt)
p6 = 0
for i in range(0, N):
	p6 += 1 / (2**coins[i])
print(round(p6/N, 10))

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

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


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int k;
	cin >> k;
	if(k%2==0 || k%5==0){
		cout << "-1";
		return 0;
	}

	int a=0, b=7, c=1;
	a = b%k;
	while(a!=0){
		b = (b*10)%k;
		a = (a+b)%k;
		c++;
	}

	cout << c;


	
	

	return 0;
}

Measured memory_bytes: 3632
def main():
    N = int(input())
    H = list(map(int, input().split()))
    for i in range(N-1):
        if H[i] < H[i+1]:
            H[i+1] -= 1
        if H[i] > H[i+1]:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()


Measured memory_bytes: 20516
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 33000
#define INF 0x3f3f3f3f
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define Mod 1000000007
#define i64 __int64
#define LIMIT_ULL 100000000000000000
using namespace std;
char a[60],b[60];
int n;
long long sum=0;
void dfs(int x,int y,long long z)
{
     if(x==n)
     {
          sum=(sum+z)%Mod;
          return;
     }
     if(x+1<n)
     if(a[x]==a[x+1])
          if(b[x]==b[x+1])
     {
          if(y==0)
               dfs(x+2,2,z*6%Mod);
          if(y==1)
               dfs(x+2,2,z*2%Mod);
          if(y==2)
               dfs(x+2,2,z*3%Mod);
     }
     if(a[x]==b[x])
     {
          if(y==0)
               dfs(x+1,1,z*3%Mod);
          if(y==1)
               dfs(x+1,1,z*2%Mod);
          if(y==2)
               dfs(x+1,1,z%Mod);
     }
}
int main()
{
     scanf("%d",&n);
     scanf("%s",a);
     scanf("%s",b);
     dfs(0,0,1);
     cout<<sum<<endl;
}


Measured memory_bytes: 256
def main():
    k = int(input())
    a, b = map(int, input().split())
    f = False
    for i in range(a, b+1):
        if i%k == 0:
            f = True
    if f:
        print("OK")
    else:
        print("NG")

if __name__ == "__main__":
    main()

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

int main() {
  vector<char>A(26);
  char B;
  cin >> B;
  A={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  for(int i=0;i<25;i++){
    if(B==A.at(i)){
    B=A.at(i+1);
    break;  
    }
  }
  cout << B << endl; 
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  for(int i = 0; i < N; ++i)
    cin >> H[i];
  vector<vector<int>> G(N);
  for(int i = 0; i < M; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    bool f = true;
    for(auto j : G[i]){
      f &= (H[i] > H[j]);
    }
    if(f) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8772
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]

    if N==1:
        print "Yes"
        print 2
        print 1, 1
        print 1, 1
        exit()
    x = 3
    idx = 1
    accept_set = set([x])
    is_accept = False
    while x <= N:
        if N == x:
            is_accept = True
            break
        x += (idx + 2)
        accept_set.add(x)
        idx += 1

    
    if is_accept == False:
        print "No"
        exit()


    base = idx + 1
    row_num = base + 1
    col_num = base

    res = [[0 for i in range(col_num)] for j in range(row_num)]
    count = 1
    for i in range(row_num):
        for j in range(i, col_num):
            res[i][j] = count
            count += 1
        for k in range(col_num - i):
            res[i + k + 1][i] = res[i][k + i]

    print "Yes"
    print base + 1
    for i in range(row_num):
        print base,
        for j in range(col_num):
            print res[i][j],
        print
        




if __name__ == '__main__':
    main()

Measured memory_bytes: 8048
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	s,w = l
	f = 1
	if(w < s):
		f = 0
	if(f):
		return 'unsafe'
	else:
		return 'safe'

l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print(ans)



Measured memory_bytes: 81280
#include <stdio.h>
#include <stdlib.h>

typedef struct{
  long long int cost;
  long long int hon;
} ST;

long long int compare_int(const void *a, const void *b)
{
  ST *A = (ST *)a;
  ST *B = (ST *)b;
  return A->cost - B->cost;
}

int main(){
  int i,j,k,h;
  long long int N,M,ans=0,tmp=0;
  //long long int A[10000000],B[10000000];
  ST data[10000000];
  
  scanf("%lld %lld",&N,&M);
  
  for(i=0;i<N;i++){
    scanf("%lld %lld",&data[i].cost,&data[i].hon);
  }
  h=0;ans=0;
  
  qsort(data, N, sizeof(ST), compare_int);

  i=0;j=0;h=0;
  while(1){
    ans+=data[i].cost;  
    h++;j++;
    if(j>=data[i].hon){
      i++;j=0;
    }
    if(h>=M)break;
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 5116
#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>;
const int INF = 1 << 29;
 
int main() {
	int a, b;
	cin >> a >> b;
	if (a * b == 0) cout << "Zero" << endl;
	else if (a > 0 && b > 0) cout << "Positive" << endl;
	else if (a < 0 && b > 0) cout << "Zero" << endl;
	else {
		int now = b - a + 1;
		if (now % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define roop(i,n) for(int i=0;i<n;i++)
int n,a[300001],sum;
main(){
	cin>>n;
	roop(i,n*3)cin>>a[i];
	sort(a,a+3*n);
	for(int i=n;i<3*n;i+=2)sum+=a[i];
	cout<<sum<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  long n,i,j,k,a[100010],b[100010],c[100010],ans=0;
  cin >> n;
  for (i=0;i<n;i++) cin >> a[i];
  for (i=0;i<n;i++) cin >> b[i];
  for (i=0;i<n;i++) cin >> c[i];
  sort(a,a+n,greater<int>());
  sort(b,b+n,greater<int>());
  sort(c,c+n,greater<int>());
  j=k=0;
  for (i=0;i<n;i++){
    while (j<n && b[i]<=a[j]) j++;
    while (k<n && b[i]<c[k]) k++;
    ans+=(long)(n-j)*k;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,vector<vector<int> >&GRAPH,vector<int>&dist,int depth)
{
  dist[V] = depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    if(dist[GRAPH[V][i]] == -1)
    {
      DFS(GRAPH[V][i],GRAPH,dist,depth+1);
    }
  }
  return;
}
void solve(void)
{
  int N;
  cin>>N;
  int ANS = 0;
  for (int i = 1; i <= 1000; i++)
  {
    for (int j = 2; j < 1000; j++)
    {
      int X = pow(i,j);
      if(X <= N )chmax(ANS,X);
    }
  }
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

bool check(int f, int v){
  for(int i = 0; i < 32; i++){
    if((f & (1 << i)) != 0 &&
      (v & (1 << i)) != 0){
      return false;
    }
  }
  return true;
}

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

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

  ll sum = 0;
  int s = 0, t = 0, f = 0;
  while(s < n){
    while(t < n && check(f, a[t])){
      f ^= a[t];
      ++t;
    }
    sum += (ll)(t - s);
    f ^= a[s++];
  }

  cout << sum << endl;

  return 0;
}


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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<int> v(3); int cnt5=0, cnt7=0;
	for(auto &x: v){
		cin >> x;
		if(x == 5) cnt5++;
		if(x == 7) cnt7++;
	}
	if(cnt5 == 2 && cnt7 == 1) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
    scanf("%d%d",&a,&b);
    if(a<=0&&b>=0){puts("Zero");return 0;}
    int t=b-a+1;
    if(a>0)puts("Positive");
    else if(t&1)puts("Negative");
    else puts("Positive");
    return 0;
}

Measured memory_bytes: 256
#include <boost/functional/hash.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define DOFAST 
#define rep(i,a,n) for(int i=a,_n=(n);i<_n;i++)
#define repr(i,n,a) for(int i=n-1;i>=a;i--)
#define foreach(it,ar) for(auto it:ar)
#define All(x) x.begin(),x.end()
#define Sort(v) sort(v.begin(),v.end())
#define Endl '\n'
#define space <<" "<<
#define Print(x) cout<<x
#define Pair make_pair
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef long long ll;
typedef unordered_map<int,int> UMP;
struct TreeNode {
    int data;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int NodeData,int l, int r) {
        left = NULL;
        right = NULL;
        data = NodeData;
    }
};
ll gcd(ll a, ll b) {
    if(!a || !b) {
        return a|b;
    }
    unsigned int  zeros = __builtin_ctzll(a|b);
    a>>=__builtin_ctzll(a);
    do{
        b>=__builtin_ctzll(b);
        if(a>b) {
            swap(a,b);
        }
        b-=a;
    }while(b);
    return a<<zeros;
}
void Main(){
   int t = 0;
   int n;
   cin>>n;
   string s;
   cin>>s;
   int i=0,j=n-1;
   while(i<j) {
       if(s[j] == 'R') {
           if(s[i] =='W'){
               swap(s[i],s[j]);
               i++;
               t++;
           }else {
               i++;
           }
           continue;
       }
       else if(s[j] == 'W'){
           j--;
           if(s[i] == 'R') i++;
       }
   }
   cout<<t;
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t; cin>>t;
    // while(t--)
    Main();
    return 0; 

} 



Measured memory_bytes: 3740
#include <stdio.h>
int main(void){
	long long a,b,x,ans;
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a==0){
		ans=b/x+1;
	}
	else{
		ans=b/x-(a-1)/x;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,k;
    cin>>a>>b>>c>>k;
    long long int total=0;
    if(a<=k && k!=0)
    {
        total+=a;
        k=k-a;
    }
    else
    {
        total+=k;
        cout<<total;
        return 0;

    }
    if(b<=k && k!=0)
    {
        k=k-b;
    }
    else
    {
        cout<<total<<endl;
        return 0;

    }
    if(c<=k && k!=0)
    {
        total=total-c;
        cout<<total;
        return 0;
    }
    else
    {
        total=total-k;
        cout<<total;
        return 0;
    }
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

typedef long long ll;

ll N,K;
ll A[100000];
ll b[100];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> A[i];
    int c = 0;
    ll k = K;
    while(k > 0){
        k /= 2;
        c++;
    }
    for(int i=0;i<c;i++){
        b[i] = 0;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<c;j++){
            b[j] += (A[i]>>j) % 2;
        }
    }

    ll x = 0;
    for(int i=c-1;i>=0;i--){
        if(2*b[i] < N && x + ((ll)1 << i) <= K) x += ((ll)1 << i);
    }

    ll sum = 0;
    for(int i=0;i<N;i++){
        sum += (A[i] ^ x);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back

int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> ans;
    int flag = 0;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        ans.pb(t);
        if (x == t)
        {
            flag = 1;
        }
    }
    if (flag == 0)
    {
        cout << x;
    }
    else
    {
        sort(ans.begin(), ans.end());
        int i = 0;
        while (ans[i] != x)
        {
            i++;
        }
        int pos = i;
        int c = 0, d = 0;
        while (pos < ans.size() - 1 && ans[pos + 1] - ans[pos] == 1)
        {
            c++;
            pos++;
        }
        pos = i;
        while (pos > 0 && ans[pos] - ans[pos - 1] == 1)
        {
            d++;
            pos--;
        }
        // cout << d << endl;
        if (c < d)
        {
            cout << x + c + 1;
        }
        else
        {
            cout << x - d - 1;
        }
    }
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
    int h,w,i,y;
    while(1){
        scanf("%d %d",&h,&w);
        if(w+h==0) break;
        for(i=0;i<h;i++){
            for(y=0;y<w;y++){
                if(i%2==0){
                    if(y%2==0)printf("#");
                    if(y%2==1)printf(".");
                }

                else if(i%2==1){
                    if(y%2==0)printf(".");
                    if(y%2==1)printf("#");

                }


            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2040