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


int main() {
	long long A, B;
	int r, temp;

	cin >> A >> B;

	int a = A, b = B;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	cout << A * B / b;

}

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

using namespace std;

typedef long long ll;

int main(void)
{
    int ans = 0;
    int n;
    
    cin >> n;
    
    vector<int> l(n);

    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    
    for (int a = 0; a < n-2 ; a++) {
        for (int b = a+1; b < n-1; b++) {
            for (int c = b+1; c < n; c++) {
                if (l[a] < l[b] + l[c] && l[b] < l[a] + l[c] && l[c] < l[a] + l[b]) {
                    ans++;
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
	long long n, k, x, y;
	scanf("%lld %lld %lld %lld", &n, &k, &x, &y);
	long long ans = 0;
	if (k >= n) ans = x * n;
	else {
		ans = x * k;
		ans += y * (n - k);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll dp[111][111111];
const int C=100000+300;

int main(){
  string s,t;cin>>s>>t;
  int m=s.length(),n=t.length();
  int L[m+1][n+1];
  for(int i=0;i<=m;i++)for(int j=0;j<=n;j++){
    if(i==0||j==0)L[i][j]=0;
    else if(s[i-1]==t[j-1])L[i][j]=L[i-1][j-1]+1;
    else L[i][j]=max(L[i][j-1],L[i-1][j]);
  }
  int l=L[m][n];
  string ans(l,'?');
  int i=m,j=n;
  while(i>=0&&j>0){
     if(s[i-1]==t[j-1]){ans[l-1]=s[i-1];l--;i--;j--;}
     else if(L[i-1][j]>L[i][j-1])i--;
     else j--;
  }
  cout<<ans;

}

Measured memory_bytes: 35456
import Control.Monad
import Data.List

main = do
    n <- readLn
    ls <- replicateM n (map read . words <$> getLine)
    print $ getsolve ls
    
getsolve :: [[Int]] -> Int
getsolve [] = 0
getsolve ls = (last ( head ls) - head (head ls) + 1) + getsolve ( tail ls)

Measured memory_bytes: 1660
/*Lucky_Glass*/
#include<cstdio>
#include<algorithm>
using namespace std;
int n,ans=1e8;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int A=i,B=n-i,sum=0;
		while(A)
			sum+=A%10,A/=10;
		while(B)
			sum+=B%10,B/=10;
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

int n,a[200100],f[20][200100][2],log_[200100],top;
struct data
{
    int l,r,x,y;
    bool operator<(const data &t) const
    {
        return a[x]>a[t.x] || a[x]==a[t.x] && a[y]>a[t.y];
    }
} heap[100100];

int minp(int x,int y)
{
    return a[x]<a[y]?x:y;
}

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int query(int l,int r,int t)
{
    int k=log_[r-l+1];
    return minp(f[k][l][t],f[k][r-(1<<k)+1][t]);
}

void insert(int l,int r)
{
    if (l>r)
        return;
    int x=query(l,r,l&1),y=query(x+1,r,r&1);
    heap[++top]=(data){l,r,x,y},push_heap(heap+1,heap+1+top);
}

int main()
{
    n=getint(),a[0]=1<<30;
    repu(i,1,n)
        a[i]=getint();
    repu(i,1,n)
        f[0][i][i&1]=i;
    repu(i,2,n)
        log_[i]=log_[i>>1]+1;
    repu(i,1,log_[n])
        repd(j,n-(1<<i)+1,1)
        {
            f[i][j][0]=minp(f[i-1][j][0],f[i-1][j+(1<<i-1)][0]);
            f[i][j][1]=minp(f[i-1][j][1],f[i-1][j+(1<<i-1)][1]);
        }
    insert(1,n);
    while (top)
    {
        data t=heap[1];
        pop_heap(heap+1,heap+1+top--);
        printf("%d %d ",a[t.x],a[t.y]);
        insert(t.l,t.x-1),insert(t.x+1,t.y-1),insert(t.y+1,t.r);
    }
    return 0;
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A!=B&&B!=C&&C!=A) cout<<3<<endl;
  else if(A==B&&B==C&&C==A) cout<<1<<endl;
  else cout<<2<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

constexpr int64_t MOD = 1'000'000'007;
constexpr int     MAX =       200'005;

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

// 二項係数計算
int64_t 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(void) {
    int64_t N, M;
    cin >> N >> M;
    COMinit();

    if(N > M) swap(N, M);
    if(N == M) {
        cout << (fac[N] * fac[M] * 2) % MOD << endl;
    } else if(N + 1 == M) {
        cout << (fac[N] * fac[M]) % MOD << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int a, b; cin >> a >> b;
	int cnt = 0, cur = 1;
	while (cur < b) {
		cur += a - 1;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#include<stdlib.h>

int asc(const void *a, const void *b)
{
        return *(int *)a - *(int *)b;
}

int main()
{
        int A[MAX];
        int N;
        int i;
        int cnt;

        scanf("%d", &N);
        for(i=0; i<N; i++)
        {
                scanf("%d", &A[i]);
        }

        //sort(A, N);
        qsort(A, N, sizeof(int), asc);

        cnt = 0;
        for(i=0; i+1<N; i++)
        {
                if(A[i]==A[i+1])
                {
                        A[i] = 0;
                        A[i+1] = 0;
                        i++;
                }
        }

        cnt = 0;
        for(i=0; i<N; i++)
        {
                if(A[i]!=0)cnt++;
        }

        printf("%d\n", cnt);

        return 0;
}



Measured memory_bytes: 892
#include<stdio.h>
#define N 10000

int prime(int num,int n){
  int i;
    
    if(num<2)
      return 0;
    else if(num==2)
      return 1;

    if(num%2 == 0)
      return 0;

    for(i=3;i<=num/i;i+=2){
      if(num%i == 0)
	return 0;
    }
    return 1;



}


int main(void){

  int i, n=0;
  int num[N],A=0;

  scanf("%d",&n );

  for(i=0;i<n;i++)
    scanf("%d",&num[i]);
  for(i=0;i<n;i++)
  A= A + prime(num[i],n);

  printf("%d\n",A);

  return 0;
}




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



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

    double n, dif = 10000000;
   int x = 0;
    double s = 0;

    cin >> n;
    vector<double> a(n);
    rep(i, n) {
        cin >> a[i];
        s += a[i];
    }

    s /= n;

    rep(i,n){
        if(abs(a[i]-s)<dif){
            dif = abs(a[i] - s);
            x = i;
        }
    }

    cout << x << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    long long n;
    string s;
    cin >> n >> s;
    long long cnt1[4005] = {0}, cnt2[4005] = {0}, cnt3[4005] = {0};
    for(long long i = n - 1; i >= 0; i--){
        if(s[i] == 'R'){
            cnt1[i] = cnt1[i + 1] + 1;
            cnt2[i] = cnt2[i + 1];
            cnt3[i] = cnt3[i + 1];
        }
        if(s[i] == 'G'){
            cnt2[i] = cnt2[i + 1] + 1;
            cnt1[i] = cnt1[i + 1];
            cnt3[i] = cnt3[i + 1];
        }
        if(s[i] == 'B'){
            cnt3[i] = cnt3[i + 1] + 1;
            cnt1[i] = cnt1[i + 1];
            cnt2[i] = cnt2[i + 1];
        }
    }
    long long sum = 0;
    for(long long i = 0;i < n; i++){
        for(long long j = i + 1; j < n; j++){
            if(s[i] == s[j])
                continue;
            else if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
                long long x = j - i;
                sum += cnt2[j+1];
                if(j + x < n)
                    if(s[j + x] == 'G')
                        sum--;
            }
            else if((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')){
                long long x = j - i;
                sum += cnt1[j+1];
                if(j + x < n)
                    if(s[j + x] == 'R')
                        sum--;
            }
            else if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
                long long x = j - i;
                sum += cnt3[j+1];
                if(j + x < n)
                    if(s[j + x] == 'B')
                        sum--;
            }
            
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3724
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    double a,b,c,d=0,e=0,x=0;
    string s;
    string t;
    cin>>t>>s;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){x++;}
    }
    cout<<x;
    return 0;
}


Measured memory_bytes: 3684
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC071C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var S = ss.Next(String, N);
            var cs = new int[26];

            for (var i = 0; i < 26; i++) cs[i] = int.MaxValue;

            foreach (var s in S)
            {
                foreach (var c in "abcdefghijklmnopqrstuvwxyz")
                {
                    cs[c - 'a'] = Math.Min(cs[c - 'a'], s.Count(_c => _c == c));
                }
            }

            for (var i = 0; i < 26; i++)
            {
                for (var j = 0; j < cs[i]; j++)
                {
                    sw.Write((char)(i + 'a'));
                }
            }
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 7;
int f[N];

void modify(int i, int val) {
    for (; i < N; i |= i + 1) f[i] += val;
}

int get(int r) {
    int res = 0;
    for (; r >= 0; r &= r + 1, --r) {
        res += f[r];
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];    
    vector <int> p = a;
    sort(p.begin(), p.end());
    for (int i = 0; i < n; ++i) a[i] = lower_bound(p.begin(), p.end(), a[i]) - p.begin();
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += (a[i] % 2) != (i % 2);
    }
    cout << ans / 2 << '\n';
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll m;
bool comp(pair<ll, ll> &a, pair<ll, ll> &b) {

  if (a.second > b.second)
    return true;
  else if (a.second < b.second)
    return false;
  else {
    return (m - a.first) > (m - b.first);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin >> n >> m;

  pair<ll, ll> arr[n + 5];

  for (ll i = 1; i <= n; i++) {
    cin >> arr[i].first >> arr[i].second;
  }

  sort(arr + 1, arr + n + 1, comp);

  ll res = 0;
  bool visited[m + 5];
  memset(visited, false, sizeof(visited));

  map<ll, ll> par;

  for (ll i = 0; i <= m; i++) {
    par[i];
  }

  for (ll i = 1; i <= n; i++) {

    // cout << arr[i].first << " " << arr[i].second << en;
    ll st = m - arr[i].first;

    auto it = par.upper_bound(st);

    if (it == par.begin())
      continue;
    it--;

    st = it->first;

    visited[st] = true;
    res += arr[i].second;
    par.erase(st);
  }

  cout << res << en;

  return 0;
}


Measured memory_bytes: 8192
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;
int a[MAX_N];
ll b[MAX_N];

int main(){
  int N,K; cin >> N >> K;
  rep(i,N) scanf("%d%lld",a+i,b+i);
  ll ans = 0LL ,temp = 0LL;
  rep(i,N) if((a[i]|K)==K) ans += b[i];
  rep(i,30){
    if((K&(1<<i))==0) continue;
    int t = (K ^ (1<<i))|((1<<i)-1);
    temp = 0LL;
    rep(i,N) if((a[i]|t)==t) temp += b[i];
    ans = max(ans,temp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define REP(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)

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

ll go(ll l, ll s) {
    if (l < s) {
        swap(l, s);
    }
    ll t = l / s;
    ll ret = 2 * s * t;
    if (l % s == 0) {
        return ret - s;
    }
    ll a = l - s * t;
    return ret + go(a, s);
}

int main() {
    ll N; cin >> N;
    ll X; cin >> X;

    ll ans = 0;
    if (X * 2 == N) {
        ans = X * 3;
    }
    else {
        ans = N + go(X, N - X);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>
#include <stack>
#include <string>

using namespace std;

int main()
{
	stack<int> S;
	int a, b;
	string s;

	while (cin >> s)
	{
		switch (s[0])
		{
		case '+':
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
			break;
		case '-':
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
			break;
		case '*':
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
			break;
		default:
			S.push(atoi(s.c_str()));
			break;
		}
	}

	cout << S.top() << endl;
}

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

// 素因数分解
// O(√N)くらい（エネストラストの篩を組み合わせたもっと早い素因数分解もある）
vector<pair<ll, int>> prime_factorization(ll n) {
	vector<pair<ll, int>> res;
	for(ll i = 2; i * i <= n; i++){
		if(n % i) continue;
		res.emplace_back(i, 0);
		while(n % i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1) res.emplace_back(n, 1);
	return res;
}

int main() {
	ll n;
	cin >> n;
	auto p = prime_factorization(n);
	ll ans = 0;
	for(auto t: p) {
		ll f = t.first;
		ll s = t.second;
		int now = 1;
		for(int i = 0; i < s; i+=now) {
			ans++;
			now++;
			// cout << f << " " << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;
 
double EPS = 1e-10;
 
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x,y;
  point() {}
  point(double x,double y):x(x),y(y){
  }
  point operator + (point p){
    return point(add(x,p.x),add(y,p.y));
  }
  point operator - (point p){
    return point(add(x,-p.x),add(y,-p.y));
  }
  point operator * (double d){
    return point(x*d,y*d);
  }
  point operator / (double d){
    return point(x/d,y/d);
  }
};
 
double dist(point a,point b){
	return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
 
int main(void){
	int n,x,y,v;
	vector<point>P;
	vector<double>V;
	
	while(cin >> n,n){
		P.clear();
		V.clear();
		
		for(int i=0;i<n;i++){
			cin >> x >> y >> v;
			P.push_back(point(x,y));
			V.push_back(v);
		}
		
		
		double r=0.999;
		point now(0,0);
		
		for(double d=10;d>EPS;d*=r){
			int mx=0;
			double mxd=0;
			
			for(int j=0;j<P.size();j++){
				if(dist(now,P[j])/V[j]>mxd)mx=j,mxd=dist(now,P[j])/V[j];
			}
			
			now=now+((P[mx]-now)/dist(P[mx],now)*d);
		}
		
		double ans=0;
		for(int i=0;i<P.size();i++){
			ans=max(ans,dist(now,P[i])/V[i]);
		}
		printf("%.8f\n",ans);
	}
	
	return 0;
}

Measured memory_bytes: 1248
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    long n;
    scan(n);

    long ans = infl;

    for (long i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            chmin(ans, (i - 1) + (n / i - 1));
        }
    }

    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int BIT[200001];

void add(ll A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}

int query(int A) {
	int kotae = 0;
	while (A <= 200000) {
		kotae += BIT[A];
		A += A & -A;
	}
	return kotae;
}


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


	string S;
	cin >> S;
	int N = S.size();
	int A[26] = {};
	rep(i, N) {
		A[S[i] - 'a']++;
	}
	int kisuu = 0;
	rep(i, 26) {
		if (A[i] % 2) kisuu++;
	}
	if (kisuu > 1) co(-1);
	else {
		vector<int> V1[26], V2[26];
		rep(i, N) {
			V1[S[i] - 'a'].pb(i);
			V2[S[i] - 'a'].pb(N - 1 - i);
		}
		int used[200001] = {};
		int kazu = 0;
		ll kotae = 0;
		int atta = 0;
		rep(i, N) {
			if (kazu * 2 >= N - 1) break;
			if (used[i] == 0) {
				int kari1 = V1[S[i] - 'a'].back();
				int kari2 = V2[S[i] - 'a'].back();
				if (i + kari2 == N - 1) {
					atta = 1;
					continue;
				}
				kotae += kari2 - query(kari1) + atta;
				used[kari1] = 1;
				add(kari1);
				V1[S[i] - 'a'].pop_back();
				V2[S[i] - 'a'].pop_back();
				kazu++;
			}
		}
		co(kotae);
	}

	Would you please return 0;
}


Measured memory_bytes: 4108
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

ull n, m, a[100000], nok = 1;

ull nod(ull a, ull b)
{
	while (b != 0)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

ull lcm(ull a, ull b)
{
	return a / nod(a, b) * b;
}

bool st_vh[60];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("memory.in", "r", stdin);
	//freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] >>= 1;
		ull b = a[i];
		int vh = 0;
		while (b % 2 == 0)
		{
			b >>= 1;
			vh++;
		}
		st_vh[vh] = true;
		nok = lcm(nok, a[i]);
		if (nok > m)
		{
			cout << 0;
			return 0;
		}
	}
	int cnt = 0;
	for (int i = 0; i < 60; i++)
		cnt += (st_vh[i]);
	if (cnt > 1)
	{
		cout << 0;
		return 0;
	}
	ull res = (m - nok) / (2 * nok);
	cout << res + 1;
	return 0;
}

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

int main(){
    double d,t,s;
    cin>>d>>t>>s;
    double temp=d/s;
    if(temp<=t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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


int main(){
 int n,k ;
  vector<int> h(n);
  cin >> n >> k ;
  int count = 0;
  for (int i = 0;i<n;i++){
   cin >> h.at(i); 
    
    if (h.at(i) >= k){
      count++;      
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 16640
#include<stdio.h>

int N;

int A[101][101];


main (){

  int i,j,k;

  scanf("%d",&N); //input needed vertex numbers

  for(i=1; i<=N; i++){
    
    j=1;
    scanf("%d %d",&A[i][1],&k); 
//first number input : the index for the number (first one is 1, second one is 2....)
//second number input : how many hands arethere in that vertex
    for(j=2; j<k+2; j++){
      
      scanf("%d",&A[i][j]);
//third, fourth, fifth... number : the index number that each hands are connectet to. (looking at the hands in second number)
      
    }
  }

  for(i=1; i<=N; i++){

    for(j=1; j<=N; j++){    

      if(j==N){

	printf("%d\n",hantei(i,j));

      }

      else {

	printf("%d ",hantei(i,j));

      }
    }
  }

  return 0;
}

int hantei(int x,int y){

  int i;
  int flag =0;

  for(i=2; i<=N; i++){
   
    if(A[x][i]==y){
      
      flag=1;
    }
  }

  if(flag==1){
    
    return 1;
    
  }
 
  else if(flag==0){

    return 0;
  }
}

Measured memory_bytes: 632
#include <stdio.h>

int
main(void)
{
        int a, b, c, d, e, k;

        scanf("%d\n", &a);
        scanf("%d\n", &b);
        scanf("%d\n", &c);
        scanf("%d\n", &d);
        scanf("%d\n", &e);
        scanf("%d", &k);

        if ((e - a) > k)
                printf(":(");
        else
                printf("Yay!");
}


Measured memory_bytes: 128
S = str(input())

S_len = len(S)
half_len = int(len(S)/2)

if S_len%2 != 0:
    print('No')
    exit()

for i in range(half_len):
    if S[2*i:2*i+2] != 'hi':
        print('No')
        exit()

print('Yes')


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

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); }
// clang-format on

void solver() {
  // ans * 108 / 100 == A
  // ans * 110 / 100 == B

  i32 A = input(), B = input();
  range(i, 1, 100000) {
    if (i * 8 / 100 == A && i * 10 / 100 == B) {
      cout << i << endl;
      return;
    }
  }

  cout << -1 << endl;
}

signed main(int argc, char *argv[]) { solver(); }

Measured memory_bytes: 256
/*  AtCoder Beginner Contest 133 C - Remainder Minimization 2019
    2019.07.25 by meyon */

#include <stdio.h>

int main()
{
  // input date
  int L, R;
  scanf("%d %d", &L, &R);
  if (0>L || L>=R || 2000000000<R) {
    printf("Error!\n");
    return 1;
  }

  // modulo
  int ans=2018;
  for (int i=L; i<R; i++) {
    for (int j=i+1; j<=R; j++) {
      int remain=(i%2019)*(j%2019)%2019;
      if(ans>remain) {
        ans=remain;
      }
//      printf("%d %d %d %d\n", i, j, remain, ans); // check
      if (0==ans) {
        i=R;
        j=R+1;    // end of modulo
      }
    }
  }

  // answer
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    const ll MOD = 1e9 + 7;
	int N;
    ll res = 0, sum = 0;
    cin >> N;
    for (int i = 0; i < N; ++i){
        ll a;
        cin >> a;
        res = ( res + (sum * a) % MOD ) % MOD;
        sum = (sum + a) % MOD;
    }

    cout << res << endl;
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
  
    int n;
    cin >> n;
    vi p(n);
    int sol=0;
    bool check = true;
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(p[i] != i+1)
            sol++;
        if(sol>2){
            check = false;
            break;
        }
    }
    if(check)
        cout << "YES";
    else
        cout << "NO";
}

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

// ------ disjoint set ------ //
struct UnionFind {
    vector<int> data;
    int __size;
    UnionFind(int size) : data(size, -1), __size(size) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) != (y = root(y))) {
            if (data[y] < data[x]) swap(x, y);  // par -> child とは限らない
            data[x] += data[y]; data[y] = x; __size--;
        }
        return x != y;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() { return __size; }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m), y(m), z(m);
    UnionFind uf(n * 2);
    // 0 .. n-1
    // n .. 2n-1
    for (int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> z[i];
        if (z[i] % 2) { // Axi + Ayi は奇数
            uf.unionSet(x[i], y[i] + n);
            uf.unionSet(x[i] + n, y[i]);
        } else {
            uf.unionSet(x[i], y[i]);
            uf.unionSet(x[i] + n, y[i] + n);
        }
    }
    cout << uf.size() / 2 << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const ll INF = 1001001001001001001;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n+1);
    for(int i = 1; i <= n; i++) cin >> p[i];
    vector<int> c(n+1);
    for(int i = 1; i <= n; i++) cin >> c[i];

    vector<bool> isvisit(n+1, false);
    ll ans = -INF;
    for(int i = 1; i <= n; i++){
        vector<int> path;
        if(!isvisit[i]){
            int cur = i;
            path.push_back(i);
            isvisit[i] = true;
            while(p[cur] != i){
                path.push_back(p[cur]);
                isvisit[p[cur]] = true;
                cur = p[cur];
            }

            ll cycletotal = 0;
            for(int j = 0; j < path.size(); j++) cycletotal += c[path[j]];
            ll coans = -INF;
            //if(cycletotal < 0){
                for(int start = 0; start < path.size(); start++){
                    ll subtotal = 0;
                    for(int j = 0; j < min((int)path.size(), k); j++){
                        subtotal += c[path[(start+j)%path.size()]];
                        ll cyclepoint = 0;
                        if(cycletotal > 0) cyclepoint = cycletotal * ((k-j-1)/path.size());
                        if(coans < subtotal+cyclepoint) coans = subtotal+cyclepoint;
                    }

                }
            //}else{

            //}
            if(ans < coans) ans = coans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
struct State{int H,W,sx,sy,x[500][500];};
struct P{int cost,cx,cy;};
bool operator<(P p1,P p2){
	if(p1.cost<p2.cost)return true;
	return false;
}
bool operator>(P p1,P p2){
	if(p1.cost>p2.cost)return true;
	return false;
}
int dist[500][500];vector<int>v1,v2;
vector<int>dijkstra(State I){
	for(int i=0;i<I.H;i++){for(int j=0;j<I.W;j++)dist[i][j]=999999999;}
	priority_queue<P,vector<P>,greater<P> >Q;
	Q.push(P{1,I.sx,I.sy});
	dist[I.sx][I.sy]=1;
	while(!Q.empty()){
		P a1=Q.top();Q.pop();
		int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
		for(int i=0;i<4;i++){
			int ex=a1.cx+dx[i],ey=a1.cy+dy[i];
			if(ex<0 || ey<0 || ex>=I.H || ey>=I.W)continue;
			int dst=max(dist[a1.cx][a1.cy],I.x[ex][ey]);
			if(dist[ex][ey]>dst){
				dist[ex][ey]=dst;Q.push(P{dist[ex][ey],ex,ey});
			}
		}
	}
	vector<int>ret;ret.push_back(0);
	for(int i=0;i<I.H;i++){for(int j=0;j<I.W;j++)ret.push_back(dist[i][j]);}
	sort(ret.begin(),ret.end());
	return ret;
}
int main(){
	while(true){
		State S[2];int R;cin>>R;if(R==0)break;
		for(int i=0;i<2;i++){
			cin>>S[i].W>>S[i].H>>S[i].sy>>S[i].sx;S[i].sx--;S[i].sy--;
			for(int j=0;j<S[i].H;j++){
				for(int k=0;k<S[i].W;k++){
					scanf("%d",&S[i].x[j][k]);
				}
			}
		}
		for(int i=0;i<2;i++){
			vector<int>v=dijkstra(S[i]);
			if(i==0)v1=v;else v2=v;
		}
		int minx=999999999;
		for(int i=0;i<(int)v1.size();i++){
			int U=R-i;if(U>(int)v2.size())break;
			if(U<0)minx=min(minx,v1[i]);
			else minx=min(minx,v1[i]+v2[U]);
		}
		cout<<minx<<endl;
	}
	return 0;
}

Measured memory_bytes: 10412
import sys
input = sys.stdin.readline

from collections import deque

N = int(input())

# empty
N += 1

bit = [i for i in range(60) if N&(1<<i)]

n = bit[-1]
left = deque(range(n,0,-1))
right = deque()
x = n+1

for i in range(n,0,-1):
    right.append(i)
    if i-1 in bit:
        right.append(x)
        left.appendleft(x)
        x += 1

S = list(left) + list(right)
print(len(S))
print(' '.join(map(str,S)))

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

  fastio; 
long double d,t,s;
cin>>d>>t>>s;
if((d/s)<=t)
cout<<"Yes";
else
cout<<"No";

 
return 0;   
}

Measured memory_bytes: 3736
#include<cstdio>
#include<vector>
using namespace std;

int n,a,b,dis[200001],p,l;
vector<int> v[200001];

void dfs(int x,int y){
    for(int i=0;i<v[x].size();i++){
        if(v[x][i]!=y){
            dis[v[x][i]]=dis[x]+1;
            dfs(v[x][i],x);
        }
    }
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n-1;i++){
        scanf("%d %d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dis[1]=0;
    dfs(1,-1);
    p=1;
    l=0;
    for(int i=1;i<=n;i++){
        if(l<dis[i]){
            l=dis[i];
            p=i;
        }
    }
    dis[p]=0;
    dfs(p,-1);
    for(int i=1;i<=n;i++){
        if(l<dis[i]){
            l=dis[i];
        }
    }
    if(l%3!=1){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }
}

Measured memory_bytes: 24448
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

// i枚目まで考慮してk枚選んだ時に合計がsumである場合の数.
ll dp[60][60][3000];
int n, ave;
vector<int> A(50);

ll dfs(int i = 0, int k = 0, ll sum = 0) {
  ll &cc = dp[i][k][sum];
  if (~cc) return cc;
  if (i == n) return cc = k*ave == sum;
  ll ret = 0;
  ret += dfs(i+1, k, sum);
  ret += dfs(i+1, k+1, sum+A[i]);
  return cc = ret;
}


int main() {
  in(n),in(ave);
  loop(i,0,n) in(A[i]);
  memset(dp, -1, sizeof(dp));
  
  print(dfs()-1);
  return 0;
}


Measured memory_bytes: 87944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    deque<int> dq;
    bool rev = false;
    rep(i, n) {
        int a;
        cin >> a;
        if (!rev) {
            dq.push_back(a);
        } else {
            dq.push_front(a);
        }
        rev = !rev;
    }
    if (!rev) {
        rep(i, n) cout << dq[i] << (i == n-1 ? '\n' : ' ');
    } else {
        rrep(i, n) cout << dq[i] << (i == 0 ? '\n' : ' ');
    }
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define F first
#define S second
const long long MOD ((long long)(1e9+7));
const long long LLX ((long long)(1e18));
long long SS[405],dp[405][405],re;
int x,n;
using namespace std;
int main()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++)
   {
      scanf("%d",&x);
      SS[i]=SS[i-1]+x;
   }
   for(int d=2;d<=n;d++)
   {
      for(int i=1;i+d-1<=n;i++)
      {
         int j=i+d-1;
         re=LLX;
         for(int k=i;k<j;k++)
         {
            re=min(re,dp[i][k]+dp[k+1][j]+SS[j]-SS[i-1]);
         }
         dp[i][j]=re;
      }
   }
   printf("%lld",dp[1][n]);
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;using ull=unsigned ll;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPARR(i,v) for(int i=0;i<v.size();++i)
#define all(v) (v).begin(),(v).end()
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define bit(n) (1ll<<(n))
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(a>b){a=b;return 1;}return 0;}
#define cut(n, Min, Max) max(min(n,Max),Min)
#define HS(n) cout<<((n)?"Heisei":"TBD")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"":"im")<<"possible"<<endl
#define Poss(n) cout<<((n)?"P":"Imp")<<"ossible"<<endl
template<typename T>ostream&operator<<(ostream&o,const vector<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<typename T>ostream&operator<<(ostream&o,const set<T>&v){for(T i:v)o<<i<<' ';return o;}
template<typename T,typename U>ostream&operator<<(ostream&o,const pair<T,U>&v){o<<v.first<<' '<<v.second;return o;}

int main(){
    string s;
    cin>>s;
    HS(stoi(s.substr(5,2))<=4);
    return 0;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (a, b, c, d) = (v[0], v[1], v[2], v[3]);
    let ans = vec![a * c, a * d, b * c, b * d].into_iter().max().unwrap();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2160
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>

using namespace std;


typedef int INT;
#define int long long


INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n;
	cin >> n;
	vector <int> a(n);
	int sum = 0, k = 0, ans = 0, p = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (sum + a[i] == (sum ^ a[i]))
		{
			k++;
			ans += k;
			sum += a[i];
		}
		else
		{
			while (sum + a[i] != (sum ^ a[i]))
			{
				sum -= a[p];
				p++;
				k--;
			}
			sum += a[i];
			k++;
			ans += k;
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

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

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 50;
const long long mod_const = 1e9 + 7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

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

using pll = pair<long long, long long>;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	ll N, M;
	cin >> N >> M;

	vector<pair<ll, pll> > vpath(M);
	rep(i, M) {
		ll l, r, c;
		cin >> l >> r >> c;
		l--;
		r--;
		vpath[i] = make_pair(l, make_pair(r, c));
	}

	sort(vpath.begin(), vpath.end());

	vector<ll> vLen(N, longinf);
	vLen[0] = 0;
	rep(i, M) {
		ll start = vpath[i].first;
		ll end = vpath[i].second.first;
		ll d = vpath[i].second.second;

		if (start == 0) {
			for (int j = start + 1; j <= end; ++j) {
				vLen[j] = min(vLen[j], vLen[start] + d);
			}
		}
		else {
			if (vLen[start] != longinf) {
				if (vLen[start] + d <= vLen[end]) {
					for (int j = start + 1; j <= end; ++j) {
						vLen[j] = min(vLen[j], vLen[start] + d);
					}
				}
			}
		}
	}

	if (vLen[N - 1] == longinf) {
		cout << "-1" << endl;
	}
	else {
		cout << vLen[N - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3328
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';

const ll M = 1e5+1;
vector < vector <ll> > g(M);
vector < bool> vis(M,false);

void dfs(ll u){
	vis[u] = true;
	for(auto x : g[u]){
		if(vis[x]) continue;
		dfs(x);
	}
}

void solve(){
	ll n,m;
	cin >> n >> m;
	for(ll i=0;i<m;i++){
		ll u,v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ll cc = 0;
	for(ll i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
			cc++;
		}
	}
	cout << cc-1 << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int z;
	z = 1;
	//cin >> z;
	for(int z1=1;z1<=z;z1++){
		solve();
	}
	return 0;
}



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

using namespace std;

int main()
{
    char e;
    string a,b,c;
    cin>>a>>b>>c;
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    char d=a[0];
    while(1){
        if(d=='a'){
            if(a.empty()==true){
                e='A';
                break;
            }
            else{
                d=a[a.size()-1];
            a.pop_back();
            }
        }
         if(d=='b'){
            if(b.empty()==true){
                e='B';
                break;
            }
            else{
            d=b[b.size()-1];    
            b.pop_back();
            }
        }
         if(d=='c'){
            if(c.empty()==true){
                e='C';
                break;
            }
            else{
            d=c[c.size()-1];    
            c.pop_back();
            }
        }
    }
    cout<<e<<endl;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  vi a(n), b(n);
  for (int &x : a)
    cin >> x;
  for (int &x : b)
    cin >> x;
  reverse(all(b));

  int v = -1;
  queue<int> eq;
  queue<int> dif;
  int l = INF, r = -1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i]) {
      v = a[i];
      l = min(l, i);
      r = max(r, i);
    }
  }

  if (v == -1)
    goto print;

  for (int i = 0; i < n; ++i) {
    if (a[i] != v && b[i] != v && l <= r) {
      swap(b[i], b[l]);
      ++l;
    }
  }

  for (int i = 0; i < n; ++i) {
    if (a[i] == b[i] || l <= r) {
      cout << "No" << endl;
      return;
    }
  }

print:
  cout << "Yes" << endl;
  for (int x : b)
    cout << x << ' ';
  cout << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 6368