akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] A = cin.ArrayInt(2 * N);
        Array.Sort(A);
        Array.Reverse(A);
        int ans = 0;
        for (int i = 0; i < A.Length; i+=2)
        {
            ans += A[i + 1];
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from numba import njit

def main():
    N = int(input())
    @njit
    def solve(N):
        for h in range(1, 3501):
            for n in range(1, 3501):
                shisu = h * N * n
                bosu = n * (h * 4 - N) - h * N
                if bosu >= 1 and not (shisu / bosu) % 1:
                    return h, n , int((h * N * n) / (n * (h * 4 - N) - h * N))
    r = solve(N)
    print(*r , sep=' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 109688
#include <bits/stdc++.h>
  using namespace std;
  typedef long long ll;
  int main()
  {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

      int n,k;
      cin>>k>>n;
      vector<int>a(n),present(1001,0);
      for(int i=0;i<n;i++)
        {cin>>a[i];
        present[a[i]]++;
        }
      int i=0;
      while(1)
      {
          if(present[k-i]==0)
          {cout<<k-i<<endl;
          break;
          }
          else if(present[k+i]==0)
          {
              cout<<k+i<<endl;
              break;
          }
          i++;
      }


    return 0;
  }


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

ll gcd(ll x, ll y){
  if(!(x >= y)) swap(x, y);
  while(!(x == 0 || y == 0)){
    x = x % y;
    swap(x, y);
  }
  return max(x, y);
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[3], m[3];
  while(cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2], a[0] | m[0] | a[1] | m[1] | a[2] | m[2]){
    ll T[3];
    for(int t = 0; t < 3; t++){
      ll x = a[t];
      for(T[t] = 2;; T[t]++){
        x = (x * a[t]) % m[t];
        if(x == 1) break;
      }
    }

    ll ans = T[0] * T[1] / gcd(T[0], T[1]);
    ans = ans * T[2] / gcd(ans, T[2]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, N;
  cin >> H >> N;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    sum += A;
  }
  if (H > sum) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int k,a,b;
    cin>>k>>a>>b;
    f(i,a,b)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;

















    return 0;

}













Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

ll mod=1e9+7;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

//階乗
vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

//nCk
ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,k;
  cin >> n >> k;
  fact(n);
  k=min(k,n-1);
  ll ans=1;
  for(ll i=1;i<=k;i++) {
    ll temp=comb(n,i);
    ans=(ans+comb(i+n-i-1,i)*temp%mod)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 78336
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

#include <map>
using namespace std;
const int MAXN = 2e5;
map <int, int> cnt;
int a[MAXN];
int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
        cnt[a[i] - 1]++;
        cnt[a[i] + 1]++;
    }
    int mxx = 0;
    for (auto i: cnt) {
        mxx = max(i.second, mxx);
    }
    cout << mxx;
    return 0;
}


Measured memory_bytes: 5120
def main():
    def f(s):
        n = len(s)

        ret = 0
        i = 0
        while i < n - 1:
            if s[i] == s[i + 1]:
                ret += 1
                i += 2
                continue
            i += 1

        return ret

    s = input()
    k = int(input())

    if k == 1:
        print(f(s))
        return

    if k <= 4:
        print(f(s * k))
        return

    d2 = f(s * 4) - f(s * 3)
    d1 = f(s * 3) - f(s * 2)

    q, r = divmod(k - 1, 2)
    ret = f(s * 1) + (d1 + d2) * q + d1 * r

    print(ret)

    # for x in range(1, 14):
    #     print(f(s * x), x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
 
int main(){
  int a[10];
  int i,j,temp;
  for(i=0;i<10;i++)
    scanf("%d",&a[i]);
  for(i=0;i<10;i++){
    for(j=i+1;j<10;j++){
      if(a[j]>a[i]){
         temp = a[i];
         a[i] = a[j];
         a[j] = temp;
      }
    }
  }
  for(i=0;i<3;i++) printf("%d\n",a[i]);
 
  return 0;
}

Measured memory_bytes: 600
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    char alpha;
    cin >> alpha;

    if (alpha >= 97 && alpha <= 122)
    {
        cout << "a" << endl;
    }
    else
    {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
 
ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}
 
ll mul(ll A, ll B) {
    return (A*B)%MOD;
}
 
ll add(ll A, ll B) {
    return (A+B)%MOD;
}
 
ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}
 
ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);    
    int N; cin >> N; int P; cin >> P;
    string S; cin >> S;
    if (P == 5 || P == 2) {
        ll ans = 0;
        F0R(i, N) {
            if ((S[i] - '0') % P == 0) {
                ans += i+1;
            }
        }
        cout << ans << endl;
        return 0;
    }
 
    ll counts[P]; F0R(i, P) counts[i] = 0;
    counts[0] = 0;
    int cur = 0;
    MOD = P;
    F0R(i, N) {
        cur *= 10; cur += S[i] - '0'; cur %= MOD;
        int val = modExp(10, N-1-i) * cur; val %= MOD;
        counts[val]++;
    }
 
    ll ans = 0;
    F0R(i, P) ans += (counts[i] * (counts[i] - 1)) / 2;
    ans+=counts[0];
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 788
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <time.h>
#define last(x, y) (x)[(x).size() - y]
#define endl '\n'
#define flush fflush(stdout), cout.flush()
#define fast ios::sync_with_stdio(0), cin.tie(0)
#define debug cout << "ok" << endl
#define in(X) ((X) - '0')
const int md = 1e9 + 7;
typedef long long ll;
typedef long double ldb;
using namespace std;

int n;
vector<int> cnt(100003, 0);

int main() {
	fast;
	cin >> n;
	for (int i = 0, u; i < n; i++) {
		cin >> u;
		if (u > 0) cnt[u - 1]++;
		cnt[u]++, cnt[u + 1]++;
	}

	int mx = 0;
	for (auto i : cnt) mx = max(mx, i);
	cout << mx << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
char S[2][55];
ll ways[55];
const int MOD = 1000000007;
int main() {
	scanf("%d", &n);
	scanf("%s", S[0]);
	scanf("%s", S[1]);
	ll ans = 1;
	REP(i, n) {
		if(S[0][i] == S[1][i]) {
			//A
			//A
			if(i == 0) {
				ans = (ans*3)%MOD;
			} else {
				if(S[0][i-1] == S[1][i-1]) {
					ans = (ans*2)%MOD;
				}
			}
		} else {
			//xx
			//yy
			if(i == 0) {
				ans = (ans*3*2)%MOD;
			} else {
				if(S[0][i-1] == S[1][i-1]) {
					ans = (ans*2)%MOD;
				} else {
			//xxyy
			//yyxx
			
			//xxzz
			//yyxx
			
			//xxyy
			//yyzz
					ans = (ans*3)%MOD;
				}
			}
			i += 1;
		}
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        n: usize,
        ls: [i64; n],
    }
    let max = ls.iter().enumerate().fold((0, 0),

    |acm, (i, &v)| if acm.1 < v {(i, v)} else {acm});
    let res = (ls[..max.0].into_iter().sum::<i64>() + ls[max.0+1..].into_iter().sum::<i64>()) > max.1;
    println!("{}", if res { "Yes" } else { "No" });
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int a;
    string s;
    in2(a, s);
    if (a >= 3200)
    {
        out(s);
    }
    else
    {
        out("red");
    }
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int mn = 1e9;
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    int x;
    cin >> x;
    if (mn >= x)
      cnt++;
    mn = min(mn, x);
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int mass = (a+b)-(c+d);
    if(mass == 0){
        cout << "Balanced";
    }else if(mass > 0){
        cout << "Left";
    }else{
        cout << "Right";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int a[] = new int [n];
        for(int i = 0; i < n; i++){
          a[i] = stdIn.nextInt();
          if(a[i] % 2 == 0){if(a[i] % 3 != 0 && a[i] % 5 != 0){System.out.println("DENIED"); return;}} 
        }
        System.out.println("APPROVED");
    }
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

bool pal(std::string a){
	for(int i = 0; i < SZ(a)/2; ++i){
		if(a[i] != a[SZ(a)-1-i]) return false;
	}
	return true;
}

int main(){
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);
	std::string a;
	std::cin >> a;
	if(pal(a) && pal(a.substr(0, SZ(a)/2)) && pal(a.substr((SZ(a)+1)/2, SZ(a)/2)))
		std::cout << "Yes\n";
	else{
		std::cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
*S, = map(int, input().split())
c = 0

def marge(A, p, q, r):
    # n1 = q - p + 1 # qの要素に関しても加算する必要がある。
    # n2 = r - q
    L, R = A[p: q], A[q: r]
    global c
    L.append(int(10E10))
    R.append(int(10E10))

    i, j = 0, 0
    for k in range(p, r):
        c = c + 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1

def marge_sort(A, p, r):
    if p + 1 < r:
        q = math.ceil((p + r) / 2)
        marge_sort(A, p, q)
        marge_sort(A, q, r)
        marge(A, p, q, r)

marge_sort(S, 0, len(S))
print(' '.join(map(str, S)))
print(c)


Measured memory_bytes: 70748
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n;
	long long a;
	cin >> n;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		sum += a - 1;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

    int cnt[2]={};

    for(int i = 0; i < s.size(); i++){
        if(i%2==0){
            if(s[i]=='1')cnt[0]++;
            else cnt[1]++;
        }else{
            if(s[i]=='1') cnt[1]++;
            else cnt[0]++;
        }
    }
    cout<<min(cnt[0],cnt[1])<<endl;

    return 0;
}

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

const int INF = 2e9;

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int s = min(a,k);
    if(k>a)k-= a;
    else k = 0;
    int t = min(b,k);
    if(k>b)k-= b;
    else k = 0;
    int r = min(k,c);
    cout << s - r << endl;
}

Measured memory_bytes: 3664
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            int H = scan.nextInt();
            int W = scan.nextInt();
            if (H == 0 && W == 0) {
                break;
            }

            for (int i = 0; i < H; i += 1) {
                for (int j = 0; j < W; j += 1) {
                    if (i % 2 == 0) {
                        if (j % 2 == 0) {
                            out.print("#");
                        } else {
                            out.print(".");
                        }
                    } else {
                        if (j % 2 == 1) {
                            out.print("#");
                        } else {
                            out.print(".");                            
                        }
                    }
                }
                out.println();
            }
            out.println();
        }
    }   
}

Measured memory_bytes: 33196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    vec<string> S(2);
    cin >> S[0] >> S[1];
    if (S[0].size() > S[1].size()) {
        cout << "GREATER" << endl;
    } else if (S[0].size() < S[1].size()) {
        cout << "LESS" << endl;
    } else if (S[0] == S[1]) {
        cout << "EQUAL" << endl;
    } else {
        string A = S[0];
        sort(all(S));
        if (A == S[0]) {
            cout << "LESS" << endl;
        } else {
            cout << "GREATER" << endl;
        }
    }
}


Measured memory_bytes: 3596
#include <iostream>

int main()
{
	char mark;
	int number,tarou_have;
	bool cards[4][13] = {false};
	std::cin >> tarou_have;

		for(int i=0; i<tarou_have; i++)
		{
		std::cin >> mark >> number;
			switch(mark)
			{
				case 'S' : mark = 0; break;
				case 'H' : mark = 1; break;
				case 'C' : mark = 2; break;
				case 'D' : mark = 3; break;
			}
		cards[mark][number-1] = true;
		}
	
		//S
			for(int k=0; k<13; k++)
			{
				if(cards[0][k] == false){
					std::cout << "S " << k+1 << std::endl;
				}
			}
		//H
			for(int k=0; k<13; k++)
			{
				if(cards[1][k] == false){
					std::cout << "H " << k+1 << std::endl;
				}
			}
		//C
			for(int k=0; k<13; k++)
			{
				if(cards[2][k] == false){
					std::cout << "C " << k+1 << std::endl;
				}
			}
		//D
			for(int k=0; k<13; k++)
			{
				if(cards[3][k] == false){
					std::cout << "D " << k+1 << std::endl;
				}
			}
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;


int main() 
{
	int a, b;
	cin >> a >> b;
	vector<int>d(a);
	for (int c = 0; c < a; c++) {
		cin >> d[c];
	}
	vector<int>e(a);
	for (int f = 0; f<b; f++) {
		int g;
		cin >> g;
		for (int h = 0; h < d.size(); h++) {
			if (g >= d[h]) { e[h]++; break; }
		}
	}
	map<int, int>s;
	for (int n = 0; n < e.size(); n++) {
		s.insert(pair<int, int>(e[n], n));
	}
	auto u = s.end();
	u--;
	cout << u->second + 1 << endl;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[52];
int diff,n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]!=i)
			diff++;
	}
	if(diff>2)cout<<"NO";
	else if(diff==2){
		diff=-1;
		for(int i=1;i<=n;i++){
			if(a[i]!=i&&diff==-1)diff=a[i];
			else if(a[i]!=i&&diff!=-1)
				if(diff==i){
					cout<<"YES";
					return 0;
				}
				else{
					cout<<"NO";
					return 0;
				}
		}
	}
	else if(diff==0)cout<<"YES";
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map { it.toLong() }

    if (h == 1L || w == 1L) {
        println(1)
    } else {
        var ans: Long = 0L
        var odd: Long = h / 2
        val even: Long = odd
        if (h % 2L == 1L) {
            odd += 1
        }

        ans += odd * (w / 2)
        ans += even * (w / 2)
        if (w % 2L == 1L) {
            ans += odd
        }

        println(ans)
    }
}


Measured memory_bytes: 36512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a;
  b = a/1000;
  c = a%1000/100;
  d = a%100/10;
  e = a%10;
  if(b == c && c == d)
    cout << "Yes" << endl;
  else if(c == d && d == e)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
xx=list(map(int,input().split()))
yy=list(map(int,input().split()))
a = True
for i in range(-100,100):
    if x < i <= y and max(xx) < i <= min(yy):
        a = False
        break
print('War' if a else 'No War')

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

int main() {
  string S;
  int X;
  cin >> S;
  X = S.size();
  for (int i = 0; i < X; i++){
    if (S.at(i) == '?'){
      S.at(i) = 'D';
    }
  }
  
  cout << S << endl;
}


Measured memory_bytes: 3708
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int changes = 0;

    for (int i = 0; i < N; i++) {
        if (A[i] == B[i] && B[i] == C[i])
            continue;

        if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i])
            changes++;
        else
            changes += 2;
    }

    cout << changes << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//
//using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/

int main()
{
    fast_in_out
    ll n,m ,x;
    cin>>n>>m;
    ll sum=0;
    vector<ll>v;
    for(int i=0; i<n; i++){
        cin>>x;
        v.pb(x);
        sum+=x;
    }
  sort(all(v));

   reverse(all(v));
   int cnt=0;
   double val=sum*1.0/(4*m);
   for(int i=0; i<n; i++){
      if((double)v[i]<val) break;
      cnt++;
   }
  if(cnt>=m) puts("Yes");
  else puts("No");
    return 0;
}



Measured memory_bytes: 256
//FA専用
#include <bits/stdc++.h>
using namespace std;
#define int long long
const long long LINF=1e18;
using ld=long double;
template<typename T>
void chmax(T &a,T b){
  if(a<b)a=b;
}
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

typedef pair<int,int> P;
int d[2345];

signed main(){
  int n,x,y;cin>>n>>x>>y;
  vector<int> edge[n];
  for(int i=0;i<n-1;i++){
    edge[i].push_back(i+1);
    edge[i+1].push_back(i);
  }
  edge[x-1].push_back(y-1);
  edge[y-1].push_back(x-1);
  map<int,int> m;
  for(int i=0;i<n;i++){
    priority_queue<P,vector<P>,greater<P>> que;
    que.push(P(0,i));
    for(int j=0;j<n;j++)d[j]=LINF;
    d[i]=0;
    while(que.size()){
      P p=que.top();que.pop();
      if(d[p.second]<p.first)continue;
      for(int q:edge[p.second]){
        if(d[q]>p.first+1){
          d[q]=p.first+1;
          que.push(P(d[q],q));
        }
      }
    }
    for(int j=0;j<n;j++)m[d[j]]++;
  }
  for(int i=1;i<n;i++)cout<<m[i]/2<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#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)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n,t,a;
cin >> n >> t >> a;
vi h(n);
rep(i,n) cin >> h[i];

double m = 1000000;
int ans;

rep(i,n){
    double ave = t - 0.006*h[i];
    double dist = abs(a-ave);
    if(dist < m){
        m = dist;
        ans = i + 1;
    }
}

cout << ans << endl;

return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int main() {
   int N; cin >> N;
   Vi A = Vi(N); rep(i, N) cin >> A[i];

   rep(i, N) {
      int j = i;
      int temp = A[i];
      while (j != 0 && A[j-1] > temp) {
         A[j] = A[j-1];
         j--;
      }
      A[j] = temp;
      cout << A[0]; REP(j, 1, N) cout << " " << A[j]; cout << endl;
   }

   return 0;
}



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

int main(void){
  int n;
  cin >> n;
  vector<float> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  double value = (v[0]+v[1])/2;
  for(int i = 2; i < n; i++){
    value = (value+v[i])/2;
  }
  cout << value << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

using pii = pair<int64_t, int64_t>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    intmax_t N, K;
    cin >> N >> K;

    intmax_t mul = 1;
    for (intmax_t i = 0; i < N - 1; ++i) {
        mul *= K - 1;
    }

    cout << K * mul << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll evalNow(vector<vector<int>> s, vector<int> c, vector<int> t, int d, vector<int>& last) {
    ll ans = 0;
    ans += s[d][t[d]-1];
    last[t[d]-1] = d+1;
    rep(j, 26) {
        ans -= c[j]*(d+1 - last[j]);
    }
    return ans;
}

ll evalAll(vector<vector<int>> s, vector<int> c, vector<int> t, int d) {
    ll ans = 0;
    vector<int> last(26,0);
    rep(i, d) {
        ans += s[i][t[i]-1];
        last[t[i]-1] = i+1;
        rep(j, 26) {
            ans -= c[j]*(i+1 - last[j]);
        }
    }
    return ans;
}

int main(){
    int d; cin >> d;
    vector<int> c(26);
    rep(i, 26) {
        cin >> c[i];
    }
    vector<vector<int>> s(d, vector<int>(26,0));
    rep(i, d) {
        rep(j, 26) {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    ll ans = 0;
    vector<int> last(26,0);

    rep(i, d) {
        // cin >> t[i];
        long tmpmax = -100000;
        long candidate = -1;
        rep(j, 26) {
            t[i] = j+1;
            if(tmpmax < evalNow(s,c,t,i,last)) {
                candidate = j;
            }
        }
        t[i] = candidate;
        // ans += evalNow(s,c,t,i, last);
        // cout << ans << endl;
        // cout << evalAll(s, c, t, i+1) << endl;
    }
    rep(i, d) {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 3732
package main

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

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	x := stdin.ReadInt()
	y := stdin.ReadInt()
	z := stdin.ReadInt()
	x, y = y, x
	x, z = z, x
	stdout.Println(x, y, z)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}

func CreateMatrix(x, y int) [][]int {
	matrix := make([][]int, x)
	for i := 0; i < x; i++ {
		matrix[i] = make([]int, y)
	}
	return matrix
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int n;cin>>n;
    vector<ll> a(n),f(n+1,0),b(n+1,0);
    rep(i,n){
        cin>>a[i];
    }    
    rep(i,n){
        f[i+1]=f[i]+a[i];
    }
    for(int i=n;i>0;i--){
        b[i-1]=b[i]+a[i-1];
    }
    ll ans=LINF;
    rep(i,n+1){
        chmin(ans,abs(b[i]-f[i]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
import fileinput

def find_path_count(n, m, wall_set):
    modulo = 10**9 + 7
    path_table = []
    def get_path_count(x, y):
        if x < 0 or y < 0 or (x, y) in wall_set:
            return 0
        return path_table[x][y]

    for x in range(n):
        path_table.append([0] * m)
        for y in range(m):
            if x == 0 and y == 0:
                path_table[x][y] = 1
            else:
                path_table[x][y] = (get_path_count(x - 1, y) + get_path_count(x, y - 1)) % modulo

    return path_table[n - 1][m - 1]

def parse_vall_set(map_strings):
    wall_set = set()
    for x, s in enumerate(map_strings):
        for y, ch in enumerate(s):
            if ch == "#":
                wall_set.add((x, y))
    return wall_set


inp = fileinput.FileInput()
n, m = inp.readline().split(" ")
n, m = int(n), int(m)
map_strings = []
for _ in range(n):
    map_strings.append(inp.readline())

print(find_path_count(n, m, parse_vall_set(map_strings)))

Measured memory_bytes: 116600
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut line = read_as_vec::<u64>();
    let k = read_as_vec::<u64>()[0];
    line.sort();
    line.reverse();

    for i in 0..k{
        line[0] *= 2;
    }

    println!("{}", line.into_iter().sum::<u64>());
}


Measured memory_bytes: 4352
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int n,s=0;
	cin>>n;
	vector<int> a(n);
	vector<bool> b(n,false),c;
	for(auto &i:a)
	{
		cin>>i;
	}
	sort(a.begin(),a.end());
	c.resize(*a.rbegin(),false);
	for(int i=0;i<a.size();i++)
	{
		if(i<a.size()-1&&a[i]==a[i+1]) b[i]=true;
		if(i&&a[i]==a[i-1])
		{
			b[i]=true;
			continue;
		}
		if(!b[i]) s++;
		for(int j=2;j<=*a.rbegin()/a[i];j++)
		{
			if(c[a[i]*j-1]) continue;
			c[a[i]*j-1]=true;
			int t=lower_bound(a.begin(),a.end(),a[i]*j)-a.begin();
			if(t<a.size()&&a[t]==a[i]*j)
			{
				b[t]=true;
			}
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 4268
l = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if a % c == 0:
    kokugo = a // c
else:
    kokugo = a // c + 1

if b % d == 0:
    sansu = b // d
else:
    sansu = b // d + 1

print(l - max(kokugo, sansu))


Measured memory_bytes: 5592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

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

    bitset<24> B(0);
    long long sum = 0;
    long long ans = 0;

    int right = 0;
    for (int left = 0; left < N; left++) {
        if (right <= left) right = left;
        while (right < N && (sum + A[right]) == (B ^ (bitset<24>(A[right]))).to_ullong()) {
            sum += A[right];
            B ^= bitset<24>(A[right]);
            right++;
        }
        ans += (right - left);
        sum -= A[left];
        B ^= A[left];
    }

    cout << ans << endl;

    return 0;
}














































Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

mod=998244353

n,k=map(int,input().split())
arr=[list(map(int,input().split())) for i in range(k)]
dp=[0]*(n+1)
dp[1]=1
acum=[0]*(n+1)
for i in range(k):
  l,r=arr[i]
  if 1+l<=n:
    acum[1+l]+=1
  if 1+r+1<=n:
    acum[1+r+1]-=1
for i in range(2,n+1):
  acum[i]+=acum[i-1]
  acum[i]%=mod
  dp[i]=acum[i]
  for j in range(k):
    l,r=arr[j]
    if i+l<=n:
      acum[i+l]+=dp[i]
    if i+r+1<=n:
      acum[i+r+1]-=dp[i]
print(dp[n]%mod)

Measured memory_bytes: 18328
n=int(input())
s =[]
l =[]
ans = []
for i in range(n):
    s1,p = map(str,input().split())
    p1 = int(p)
    l.append(s1)
    s.append(list([s1,p1]))
l = sorted(list(set(l)))
for i in l:
    t =[]
    index_num = [n for n, v  in enumerate(s) if v[0] == i]
    for k in index_num:
        t.append(list([s[k][1],k]))
    t=sorted(t,reverse=True)
    for z in t:
        ans.append(z[1]+1)
[print(i) for i in ans]

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);
		int c = Integer.parseInt(array[2]);

		if (a < b && b < c) {
			System.out.println("Yes");

		} else {
			System.out.println("No");

		}

	}

}

Measured memory_bytes: 26220
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double PI = 3.1415926535;

char s[100001];
int ans[100000];

int main(void){
    scanf("%s", &s);
    int now = 0;
    bool r = true;
    int c = 0;
    int lastr = -1;
    for(int i = 0;i < 100000;i++)ans[i] = 0;
    while(s[now] != '\0'){
        if(s[now] == 'R'){
            if(r){
                c++; now++;
            }else{
                ans[lastr] += c/2;
                ans[lastr+1] += c-c/2;
                c = 1; now++; r = true;
            }
        }else{
            if(r){
                lastr = now-1;
                ans[now] += c/2;
                ans[now - 1] += c-c/2;
                c = 1; now++; r = false;
            }else{
                c++; now++;
            }
        }
    }
    ans[lastr] += c/2;
    ans[lastr+1] += c-c/2;
    for(int i = 0;i < now;i++){
        printf("%d ", ans[i]);
    }
    printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 5100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n; cin >> n;
  string ls;
  int l = 0 ,r = n;
  cout << l << endl;
  cin >> ls;
  if(ls == "Vacant") return 0;
  while(true){
    int mid = (l+r)/2;
    string mids;
    cout << mid << endl;
    cin >> mids;
  if(mids == "Vacant") return 0;
    if((ls == mids && l%2 == mid%2) || (ls != mids && l%2 != mid%2)){
      l = mid;
      ls = mids;
    }
    else{
      r = mid;
    } 
  }
  return 0;
}


Measured memory_bytes: 852
//
// Created by Huang,Zhiqiang on 2018/6/24.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;

ll k;

ll getdigitsum(ll n) {
    ll ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

int main() {
    cin >> k;
    ll cur = 1;
    while(k--) {
        cout << cur << endl;
        ll t = -1;
        for (ll i = 1; i <= 1000000000000000; i *= 10) {
            if (t == -1 || t * getdigitsum(cur + i) > (cur + i) * getdigitsum(t))
                t = cur + i;
        }
        cur = t;
    }
}

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
A = [int(i) for i in input().split()]

s = sum(A)
for i in range(1, N) :
    A[i] += A[i-1]

ret = float('inf')
for b in range(1, N - 1) :
    a = bisect_left(A, A[b] / 2)
    c = bisect_left(A, A[b] + (s - A[b]) / 2)
    for i in [a - 1, a] :
        for j in [c - 1, c] :
            if not 0 <= i < b < j < N - 1 :
                continue
            cut = [A[i], A[b] - A[i], A[j] - A[b], s - A[j]]
            ret = min(ret, max(cut) - min(cut))
            
print(ret)

Measured memory_bytes: 82416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  char ch;
  cin>>ch;
  if(ch != 'z')
  {
    cout<<(char)(ch+1)<<endl;
  }
  else
  {
    cout<<ch<<endl;
  }
  
  
  return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
ll N,C,K; cin >> N >> C >> K;
  vector<ll> T(N);
  for(ll i = 0; i < N; i++){ cin >> T[i];}
  sort(T.begin(),T.end());
  ll cnt = 0;
  
  for(int i = 0; i < N; ){
    cnt++;
    int start = i;
    while( i < N && T[i] - T[start] <= K && i - start < C){ i++;}
  }
  
  cout <<cnt << endl; return 0;}
    
  
  

Measured memory_bytes: 1024