akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < b) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		String sub;

		int sum = 0;
		for (int i = 0; i < num.length(); i++) {
			sub = num.substring(i, i + 1);
			sum += Integer.parseInt(sub);
		}
		String s;
		int n = Integer.parseInt(num);
		if (n % sum == 0) {
			s = "Yes";
		} else {
			s = "No";
		}
		// 出力
		System.out.println(s);
	}
}


Measured memory_bytes: 23124
#N = int(input())
#A = [int(x) for x in input().split()]
#a, b, c = map(int, input().split())
#name1 = str(input())
#alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
a, b ,c= map(int, input().split())
num = a*100+b*10+c
if num%4==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,m,n) for(int i = m;i<(int)n;i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
static const int MAX = 300;
static const long long INFTY = (1LL << 32);

ll n;
ll d[MAX][MAX];

void floyd() {
	//Floyd
	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < n; i++)
		{
			if (d[i][k] == INFTY) continue;
			for (int j = 0; j < n; j++)
			{
				if (d[k][j] == INFTY) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main()
{
	ll M, R;
	cin >> n >> M >> R;
	vector<ll> v;
	rep(i, 0, R) { ll s; cin >> s; v.push_back(s); }
	rep(i, 0, n)rep(j, 0, n) { d[i][j] = INFTY; };
	rep(i, 0, M) { 
		ll a, b, c;
		cin >> a >> b >>c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
	}
	sort(v.begin(), v.begin() + v.size());
	floyd();
	ll minsum = INFTY;
	do {
		ll sum = 0;
		for (vector<ll>::iterator it = v.begin(); it + 1 != v.end(); it++) {
			sum += d[*it - 1][*(it + 1) - 1];
		}
		minsum = min(minsum, sum);
	} while (next_permutation(v.begin(), v.end()));

	cout << minsum << endl;
	return 0;
}





Measured memory_bytes: 768
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append((i, cnt))

    if temp!=1:
        arr.append((temp, 1))

    if arr==[]:
        arr.append((n, 1))

    return arr

N = int(input())

if N == 1:
    print(0)
else:

    X = factorization(N)

    ans = 0
    for x,y in X:
        ans += int((-1+(1+8*y)**(1/2))/2)

    print(ans)

Measured memory_bytes: 63212
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
struct bot{int a,b;}a[100005];
bool cmp(bot a,bot b)
{  if(a.b!=b.b) return a.b<b.b;
   return a.a<b.a;
}
using namespace std;
int main()
{   int n,i,x,y;
   scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d %d",&x,&y),a[i].a=x-y,a[i].b=x+y;
   sort(a,a+n,cmp);
    int current=a[0].b,ans=1;
    for(i=1;i<n;i++)
    {  if(a[i].a>=current)
       {  current=a[i].b;
           ans++;
       }
    }
   printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <vector>

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<set<int> > member(n);
    for(int i=0,m;i<n;++i){
      cin>>m;
      for(int j=0,p;j<m;++j){
        cin>>p;
        member[i].insert(p);
      }
    }
    int k;
    cin>>k;
    vector<int> skimmed(k);
    for(int i=0;i<k;++i)cin>>skimmed[i];
    set<int> ans;
    for(int i=0;i<n;++i){
      bool f=true;
      for(int j=0;j<k;++j){
        if(!member[i].count(skimmed[j])){f=false;break;}
      }
      if(f)ans.insert(i+1);
    }
    if(ans.size()==1)cout<<*(ans.begin())<<endl;
    else cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1632
#include<stdio.h>
int main()
{
   int N,K;
   int sum=0;
   int temp=0;
   scanf("%d%d",&N,&K);
   int a[N];
   for(int i=0;i<N;i++)
   {
       scanf("%d",&a[i]);
   }

   for(int m=0;m<K;m++)
   {
       for(int n=m+1;n<N;n++){
           if(a[m]>a[n])
           {
               temp=a[m];
               a[m]=a[n];
               a[n]=temp;
           }
       }

       sum=sum+a[m];
   }
   
   printf("%d",sum);
    
}

Measured memory_bytes: 1712
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>

using namespace std;

typedef long long ll;

#ifdef ONPC
    mt19937 rnd(228);
#else
    mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    multiset <int> q;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        bool good = false;
        for (int pw = (1 << 30); pw > a[i]; pw /= 2)
        {
            if (q.find(pw - a[i]) != q.end())
            {
                good = true;
                ans++;
                q.erase(q.find(pw - a[i]));
                break;
            }
        }
        if (!good) q.insert(a[i]);
    }
    cout << ans << '\n';
}


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

int main()
{
	char T;
	while (cin >> T, T != '#') {
		int ns = 0, ew = 0, dea = 3;
		string card[4][13];
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				cin >> card[i][j];
			}
		}
		for (int i = 0; i < 13; i++) {
			int win, val = 0;
			for (int j = 0; j < 4; j++) {
				int num;
				switch (card[j][i][0]) {
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
					num = card[j][i][0] - '0';
					break;
				case 'T':
					num = 10;
					break;
				case 'J':
					num = 11;
					break;
				case 'Q':
					num = 12;
					break;
				case 'K':
					num = 13;
					break;
				case 'A':
					num = 14;
					break;
				}
				if (card[j][i][1] == card[dea][i][1]) num += 20;
				if (card[j][i][1] == T) num += 40;

				if (num > val) {
					val = num;
					win = j;
				}
			}
			if (win & 1) {
				ew++;
			}
			else {
				ns++;
			}
			dea = win;
		}
		if (ew > ns) {
			cout << "EW " << ew - 6 << endl;
		}
		else {
			cout << "NS " << ns - 6 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,K,C;
LL t[300010],b,c,d;
string s;

int main(){
    cin>>N>>C>>K;
    for(int i=0;i<N;i++){
        cin>>t[i];
    }
    sort(t,t+N);
    int cnt=0;
    int s=t[0];
    int ans=0;
    for(int i=0;i<N;i++){
        cnt++;
        if(t[i]-s>K || cnt>C){
            cnt=1;
            s=t[i];
            ans++;
        }
    }
    cout<<ans+1<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <utility>

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

using namespace std;

int dist[100010][5];

int main() {
	int n, m, u, v, s, t;
	vector<int> adj[100010];
	queue<ii> q;
	ii p;
	scanf("%d %d", &n, &m);
	while (m--) {
		scanf("%d %d", &u, &v);
		adj[u].pb(v);
	}
	scanf("%d %d", &s, &t);
	memset(dist, -1, sizeof dist);
	dist[s][0] = 0;
	q.push(mp(s, 0));
	while (q.size()) {
		p = q.front();
		q.pop();
		u = p.fi;
		v = p.se;
		for (int i = 0; i < (int) adj[u].size(); i++) {
			s = adj[u][i];
			if (dist[s][(v + 1) % 3] == -1) {
				dist[s][(v + 1) % 3] = dist[u][v] + 1;
				q.push(mp(s, (v + 1) % 3));
			}
		}
	}
	if (dist[t][0] < 0)
		puts("-1");
	else
		printf("%d\n", dist[t][0] / 3);
	return 0;
}

Measured memory_bytes: 7680
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;

int main() {

	int w;
	int h;
	int n;
	long long x[10000];
	long long y[10000];
	int d=0;

	cin>>w>>h>>n;

	for(int i=1; i<n+1; i++){
		cin>>x[i]>>y[i];

	}

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

		if(x[i]<x[i+1]&&y[i]<y[i+1]){
			if(x[i+1]-x[i]<y[i+1]-y[i]){
				d+=y[i+1]-y[i];
			}else{
				d+=x[i+1]-x[i];
			}
		}else if(x[i]<x[i+1]&&y[i]>y[i+1]){
			d+=(x[i+1]-x[i])+(y[i]-y[i+1]);
		}else if(x[i]<x[i+1]&&y[i]==y[i+1]){
			d+=x[i+1]-x[i];
		}else if(x[i]>x[i+1]&&y[i]>y[i+1]){
			if(x[i]-x[i+1]<y[i]-y[i+1]){
				d+=y[i]-y[i+1];
			}else{
				d+=x[i]-x[i+1];
			}



		}else if(x[i]>x[i+1]&&y[i]<y[i+1]){
			d+=(x[i]-x[i+1])+(y[i+1]-y[i]);
		}else if(x[i]>x[i+1]&&y[i]==y[i+1]){
			d+=x[i]-x[i+1];
		}else if(x[i]==x[i+1]&&y[i]<y[i+1]){
			d+=y[i+1]-y[i];
		}else if(x[i]==x[i+1]&&y[i]>y[i+1]){
			d+=y[i]-y[i+1];
		}
	}


	cout<<d<<endl;


}

Measured memory_bytes: 3124
//
//  main.cpp
//  ABC151C2

#include <iostream>
#include<vector>
#include<string>
#include<numeric>
using namespace std;
int main(int argc, const char * argv[])
{
    int N, M;
    cin >> N >> M; // N問題数　M提出回数
    vector<int>WA(N + 1);
    vector<int>AC(N + 1);
    string S;
    int p = 0;
    for (int i = 1; i <= M; i++)
    {
        cin >> p; // 問題番号
        cin >> S;
        if (S=="WA"&&AC.at(p)==0)
        {
            WA.at(p)++;
        }
        if (S=="AC")
        {
            AC.at(p) = 1;
        }
    }
    int ans_WA=0;
    for (int i=1; i<=N; i++) { // 最終的にクリアできた問題のWAのみ加算する
        if (AC.at(i)==1) {
            ans_WA+=WA.at(i);
        }
    }
    int ans_AC = accumulate(AC.begin(), AC.end(), 0);
    //int ans_WA = accumulate(WA.begin(), WA.end(), 0);
    cout << ans_AC << " " << ans_WA << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define X first
#define Y second
#define N 100010
#define M 11

typedef long long ll;
const int INF=1<<30;

int n,m;
vector<int> E[N];
int f[N][M];

struct Query
{
	int v,d,c;
}Q[N];

void Solve(int v,int d,int c)
{
	if (f[v][d]) return;
	f[v][d]=c;
	if (d==0) return;
	for (int i=0;i<E[v].size();i++) Solve(E[v][i],d-1,c);
	Solve(v,d-1,c);
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	int q; scanf("%d",&q);
	for (int i=1;i<=q;i++) scanf("%d%d%d",&Q[i].v,&Q[i].d,&Q[i].c);
	for (int i=q;i>=1;i--) Solve(Q[i].v,Q[i].d,Q[i].c);
	for (int i=1;i<=n;i++) printf("%d\n",f[i][0]);
	return 0;
}

Measured memory_bytes: 11896
import java.math.*;
import java.util.*;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String S = sc.next();
			int L = S.length();
			
			for(int i = 0;i<L;i++) {
				System.out.print("x");;
			}
			
		}

	}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int ans=0;
	string s,t;
	cin>>s>>t;
	rep(i,3)if(s.at(i)==t.at(i))ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

using namespace std;

main()
{
  fast;
  int n,a,i;
  cin>>n;
  int fl=0;
  for (i=0;i<n;i++)
  {
    cin>>a;
    if (!(a&1))
    {
      if (!(a%3) || !(a%5))
        continue;
      else
      {
        fl=1;
        break;
      }
    }
  }
  if (!fl)
    cout<<"APPROVED\n";
  else
    cout<<"DENIED\n";
}

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

int main() {
	int K, A, B;
	cin >> K >> A >> B;
	bool ans = false;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			ans = true;
			break;
		}
	}
	if (ans) cout << "OK";
	else cout << "NG";
}

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

string a, b;
int lena, lenb;

bool check() {
	if(lena != lenb - 1) return true;
	for(int i = 0; i < lena; i++)
		if(a[i] != b[i]) return true;
	return false;
}

int main() {
	cin>>a>>b;
	lena = a.size(), lenb = b.size();
	if(!check()) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>

int main(int argc, char const *argv[])
{
  int N, M, count = 0;
  scanf("%d %d", &N, &M);

  int foods[M];
  for (int i = 0; i < M; ++i) foods[i] = 0;
  for (int i = 0; i < N; ++i) {
    int K, num;

    scanf("%d", &K);
    for (int j = 0; j < K; ++j) {
      scanf("%d", &num);
      foods[num-1]++;
    }
  }

  for (int i = 0; i < M; ++i) {
    if (foods[i] == N) ++count;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n;
string s;
signed main()
{
	
 	FLASH

 	cin>>n>>s;

 	int cnt[26] = {0};

 	fr(i, 0, n)
 	{
 		cnt[s[i] - 'a']++;
 	}

 	int ans = 1;

 	fr(i, 0, 26)
 	{
 		ans *= (cnt[i] + 1);
 		ans %= mod;
 	}
 	ans += mod - 1;
 	ans %= mod;
 	cout<<ans<<'\n';
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        System.out.println(s.replace("," , " "));

        }        
    }



Measured memory_bytes: 21844
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(struct Card A[], int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(struct Card A[], int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n - 1);

  for ( i = 0; i < n; i++ )
    if ( A[i].suit != B[i].suit ) stable = 0;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}



Measured memory_bytes: 5012
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1,y1,x2,y2;
    int x3,y3,x4,y4;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x2-x1 > 0 && y2-y1 <= 0) {
        x3 = x2 + abs(y2-y1);
        y3 = y2 + abs(x2-x1);
        x4 = x1 + abs(y2-y1);
        y4 = y1 + abs(x2-x1);
    }
    if(x2-x1 >= 0 && y2-y1 > 0){
        x3 = x2 - abs(y2-y1);
        y3 = y2 + abs(x2-x1);
        x4 = x1 - abs(y2-y1);
        y4 = y1 + abs(x2-x1);
    }
    if(x2-x1 <= 0 && y2-y1 < 0){
        x3 = x2 + abs(y2-y1);
        y3 = y2 - abs(x2-x1);
        x4 = x1 + abs(y2-y1);
        y4 = y1 - abs(x2-x1);
    }
    if(x2-x1 < 0 && y2-y1 >= 0){
        x3 = x2 - abs(y2-y1);
        y3 = y2 - abs(x2-x1);
        x4 = x1 - abs(y2-y1);
        y4 = y1 - abs(x2-x1);
    }
    

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(int argc, char const *argv[]) {
  char b;
  char ans;
  cin >> b;
 
  switch (b) {
    case 'A':
      ans = 'T';
      break;
    case 'T':
      ans = 'A';
      break;
    case 'C':
      ans = 'G';
      break;
    case 'G':
      ans = 'C';
      break;
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {

  int N,X,T;

  cin >> N >> X >> T;

  int ans;

  if(N%X == 0){
    ans = T * (N/X);
  }

  else{
    ans = T * (N/X + 1);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstdlib>
#define pb push_back
#define mk make_pair
#define ll long long
#define lson ch[x][0]
#define rson ch[x][1]
#include<bitset>
//贼巧妙的一个题，考虑每一个除了全集之外的每个子集，都对应了一个补集。
//我们令sum表示所有ai的和，如果一个子集的和小于sum/2,那么补集的和一定大于sum/2，这样就不会影响中位数的位置 
//那么我们会发现，由于多了一个全集，所以中位数会右偏（相对于中间），那我们就找到第一个大于(sum+1)/2的 出现过的值就可以了
//所以 我们用bitset优化这个过程
 
using namespace std;

inline int read()
{
   int x=0,f=1;char ch=getchar();
   while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
   while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
   return x*f;
}

const int maxn = 2010;

bitset<maxn*maxn> b;
int n,m;
int a[maxn];
int sum;

int main()
{
   n=read();
   for (int i=1;i<=n;i++) a[i]=read();
   for (int i=1;i<=n;i++) sum+=a[i];
   b[0]=1;
   b[a[1]]=1;
   for (int i=2;i<=n;i++)
   {
      b = b | (b << a[i]);
   }
   for (int i=(sum+1)/2;i;i++) 
     if (b[i]) 
     {
        cout<<i<<endl;
        break;
     }
   return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200025,inf=0x3f3f3f3f;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,ans,cnt,f[N];
char ch[N];
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read();
	scanf(" %s",ch+1);
	for (int i=1;i<=n;i++)
	f[i]=f[i-1]+(ch[i]=='#');
	ans=f[n];
	for (int i=n;i;i--){
		if (ch[i]=='.') cnt++;
		ans=min(ans,f[i-1]+cnt);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
 int count=0,n;
  cin >>n;
 vector<int>a(n);
 for(int i=0;i<n;i++){
 	cin>>a[i];
 } 
   for(int i=0;i<n;i++){
 	int p=sqrt(a[i]);
     if(a[i]==2){count++;}
     else{
    	for(int j=2;j<=p+1;j++){
 			if(a[i]%j==0){break;}
     		if(j==p+1){count++;}
          }
     }
 	}
  cout <<count<<endl;  
}


Measured memory_bytes: 3124
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;

const int MAXN = 200010;
int n, T, t[MAXN];
int ans;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = x*10 + ch-'0';
	return x * f;
}

int main() {
	int i;
	n = read(), T = read();
	for(i = 1; i <= n; i++) t[i] = read();
	int s = 0;
	for(i = 1; i < n; i++) {
		if(t[i] + T >= t[i+1]) continue;
		ans += t[i]+T-s;
		s = t[i+1];
	}
	ans += t[n]+T-s;
	printf("%d\n",  ans);
	return 0;
}


Measured memory_bytes: 1024
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Arrays;
 
public class Main {
  public static void main(String args[] ) throws IOException {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     int[] list = new int [10];
     for (int i = 0; i < 10; i++) {
       String s = br.readLine();
       int n = Integer.parseInt(s);
       list[i] = n;
     }
     Arrays.sort(list);

     System.out.println(list[list.length-1]);
     System.out.println(list[list.length-2]);
     System.out.println(list[list.length-3]);
     br.close();
  }
}

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

int main(){
    //input
    ll n, m;
    cin >> n >> m;
    vector <ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    //find x
    ll r, l, mid, j;
    r = 200001, l = 0;
    while(r-l > 1){
        mid = (r+l)/2;
        j = 0;
        rep(i,n){
            // finding how many times you can shake hands(including mid)
            j += a.end()- lower_bound(a.begin(), a.end(), mid-a[i]);
        }
        if(j>=m) l = mid;
        else r = mid;
    }
    ll x = l;

    //calculating 幸福度
    vector <ll> sum(n+1);
    sum[0] = 0;
    rep(i,n){
        sum[i+1] = sum[i] + a[i];
    }
    ll count = 0, ans = 0;
    rep(i,n){
        ll v = upper_bound(a.begin(), a.end(), x - a[i]) - a.begin();
        count += n - v;
        ans +=  a[i] * (n-v) + sum[n]- sum[v];
    }
    ans+=x*(m-count);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"math/rand"
	"time"
	"os"
	"bufio"
	"fmt"
	"strconv"
	"strings"
)

var(
	inf = 10000000071000000
	sc = bufio.NewScanner(os.Stdin)
	stdin = bufio.NewReader(os.Stdin)
	mod = 1000000007
	mod9 = 1000000009
)

func init()  {
	rand.Seed(time.Now().UnixNano())
	buf := make([]byte, 0) //ここのサイズは何でもよさそう
	sc.Buffer(buf, 1000000009)
}


func main() {
	_ = goint();a := goint();b := goint();c := goint();d := goint()
	s := gostring()
	check := true
	for i:=a-1;i<c-1;i++{
		if s[i] == '#' && s[i+1] == '#'{
			check = false
			break
		}
	}
	for i:=b-1;i<d-1;i++{
		if s[i] == '#' && s[i+1] == '#'{
			check = false
			break
		}
	}
	if d < c{
		c := false
		for i:=b-1;i<d;i++{
			if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'{
				c = true
				break
			}
		}
		check = check && c
	}
	if check {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

//||||||||||||||||||||||||||入力|||||||||||||||||||||||||||||||||||||||\
//数字一文字入力
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

//文字列を一行入力
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

//空白区切りの文字列の入力
func spaceLine() []string {
	sc.Scan()
	return strings.Split(sc.Text()," ")
}

//数字を一行入力
func intLine() []int {
	str := spaceLine()
	buf := make([]int,len(str))
	for i,s:=range str{
		buf[i],_ = strconv.Atoi(s)
	}
	return buf
}

//次のスペースか改行まで読み込む
func gostring() string {
	byte_ls := make([]byte,0)
	for  {
		b, _ := stdin.ReadByte()
		if b == 32 || b == 10 || b == 0{
			return string(byte_ls)
		} else if b == 13 {
			continue
		} else {
			byte_ls = append(byte_ls,b)
		}
	}
}

//上の関数のintバージョン
func goint() int {
	n,_ := strconv.Atoi(gostring())
	return n
}

//|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

func sum(a ...int) int {
	ans := 0
	for i:=0;i<len(a);i++{
		ans += a[i]
	}
	return ans
}

func min(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans > a[i]{
			ans = a[i]
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0{
		return n
	} else {
		return -n
	}
}

func max(a ...int) int {
	ans := a[0]
	for i:=1;i<len(a);i++{
		if ans < a[i]{
			ans = a[i]
		}
	}
	return ans
}

Measured memory_bytes: 1792
import collections
import bisect
N = int(input())
S = list(input())

dp = [[0]*10 for i in range(N)]


table = collections.defaultdict(list)


for i in range(N):
    table[int(S[i])].append(i)

ans = 0
for x in range(10):
    if x not in table:
        continue
    i = table[x][0]
    for y in range(10):
        if y not in table:
            continue
        idy = bisect.bisect_left(table[y], i + 1)
        if idy < len(table[y]):
            idy = table[y][idy]
            for z in range(10):
                if z not in table:
                    continue
                idz = bisect.bisect_left(table[z], idy+1)
                if idz < len(table[z]):
                    ans += 1
print(ans)


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

int main()
{ 
  string s ;
  cin >> s ;
  string judge = "CODEFESTIVAL2016" ;

  int count = 0 ;
  for(int i = 0 ; i < s.size() ; i++)
  {
    if(s.at(i) != judge.at(i))
    {
      count++ ;
    }
  }
  cout << count << endl ;
}


Measured memory_bytes: 384
#include <stdio.h>

int main (void){
  int n, i;
  long int a[10000], min = 1000000 , max = -1000000, sum = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%ld ", &a[i]);
    if(a[i] < min) min = a[i];
    if(a[i] > max) max = a[i];
    sum += a[i];
  }

  printf("%ld %ld %ld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 1856
#include <cstdio>

typedef long long ll;
const int maxn=2000+10,mod=1000000007;
ll fac[maxn*maxn],ifac[maxn*maxn],f[maxn][maxn];

ll power(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}

ll C(ll n,ll m){
	if(n<m)return 0;
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int main(){
	// freopen("in.txt","r",stdin);
	int n,m;scanf("%d%d",&n,&m);
	if(m==1){printf("%d\n",1);return 0;}
	fac[0]=ifac[0]=1;
	for(int i=1;i<=n*m;++i)fac[i]=fac[i-1]*i%mod;
	ifac[n*m]=power(fac[n*m],mod-2);
	for(int i=n*m-1;i>=1;--i)ifac[i]=ifac[i+1]*(i+1)%mod;
	f[0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=0;j<=i;++j){
			if(i>j)f[i][j]+=f[i-1][j];
			if(j)f[i][j]+=f[i][j-1]*C(n*m-i-(j-1)*(m-1)-1,m-2)%mod;
			f[i][j]%=mod;
			// printf("%d %d %lld\n",i,j,f[i][j]);
		}
	printf("%lld\n",f[n][n]*fac[n]%mod);
	return 0;
}

Measured memory_bytes: 93056
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int ma,mi;
	while(n){
		ma = 0;
		mi = 10000;
		while(n--){
			int s = 0;
			for(int i = 0;i < 5; i++){
				int a;
				cin >> a;
				s += a;
			}
			ma = max(ma,s);
			mi = min(mi,s);
		}
		cout << ma << " " << mi << endl;
		cin >> n;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, k; cin >> n >> k;
        map<int, bool> m;
        for (int x = 1; x <= k; ++x){
            int d; cin >> d;
            while (d--){
                int q; cin >> q;
                m[q] = true;
            }
        }
        int cnt = 0;
        for (int x = 1; x <= n; ++x){
            if (m[x] == false) cnt++;
        }
        cout << cnt << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int pos = -1;
  int i = s.size() - t.size();
  while (0 <= i) {
    bool flag = true;
    int i_now = i;
    REP (j, t.size()) {
      if (s[i_now] != t[j] && s[i_now] != '?') flag = false;
      i_now++;
    }
    if (flag) {
      pos = i;
      break;
    }
    i--;
  }

  if (pos == -1) printf("UNRESTORABLE\n");
  else {
    REP (i, s.size()) {
      if (pos <= i && i < pos + int(t.size())) {
        cout << t[i - pos];
      } else if (s[i] == '?') {
        cout << "a";
      } else {
        cout << s[i];
      }
    }
    cout << endl;
  }
}


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

int main(){
    int a,b;
    int d,r;
    double f;
    cin >> a >> b;
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %.12lf",d,r,f);
    return 0;
}


Measured memory_bytes: 3232
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int):
    ans=N-1
    for i in reversed(range(2,int(N**0.5+1))):
        if N%i==0:
            ans=i + N//i - 2
            break
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i <= y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    set<string> set;
    string prev;
    NREP() {
        cin >> s;
        if (set.count(s) == 0) {
            set.insert(s);
        } else {
            END("No")
        }

        if (i == 0) {
            prev = s;
            continue;
        }
        if (prev.at(prev.size() - 1) != s.at(0)) {
            END("No")
        }
        prev = s;
    }
    MSG("Yes")
}


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

int main()
{
	int N, K;
	string S;
	cin >> N >> K >>S;

	int i;
	for (i = 0; i < N && K > 0; i++, K--)
	{
		if (S[i] == 'A'+ (i & 1))
			S[i] = 'B' - ((i--) & 1);
	}

	if (K == 0)
	{
		if (i < N)
		{
			char s[2] = { 'A', 'B' };
			if (i & 1)
			{
				s[0] = 'B';
				s[1] = 'A';
			}

			for (int j = i; j < N; j++)
				cout << s[S[j] - 65];
		}

		string part(i, ' ');
		char s[2] = { 'A', 'B' };
		for (int j = 0; j < i; j++)
			part[i - j - 1] = s[j & 1];
		cout << part;
	}
	else
	{
		if (N & 1)
		{
			if (K & 1)
				cout << 'B';
			else
				cout << 'A';
			for (int j = 2; j < N; j += 2)
				cout << "BA";
		}
		else
		{
			for (int j = 0; j < N; j+=2)
				cout << "BA";
		}
	}
}

Measured memory_bytes: 900
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int roc = 0;
string s;
bool formula();
bool equation();

vector<bool> tf(11);
bool rec(int n) {
	if(n == 11) {
		roc = 0;
		return equation();
	}
	else {
		bool res = true;
		tf[n] = true;
		res = res && rec(n + 1);
		tf[n] = false;
		res = res && rec(n + 1);
		return res;
	}
}

bool formula() {
	if(s[roc] == 'T') {
		++roc;
		return true;
	}
	if(s[roc] == 'F') {
		++roc;
		return false;
	}
	if(s[roc] >= 'a' && s[roc] <= 'k') {
		++roc;
		return tf[s[roc - 1] - 'a'];
	}
	if(s[roc] == '-') {
		++roc;
		return !formula();
	}
	else {
		++roc;
		bool tf1, tf2;
		char ope;
		tf1 = formula();
		if(s[roc] == '-') {
			++roc;
			ope = '-';
		}
		else ope = s[roc];
		++roc;
		tf2 = formula();
		++roc;
		if(ope == '*') return tf1 && tf2;
		if(ope == '+') return tf1 || tf2;
		else return (!tf1) || tf2;
	}
}

bool equation() {
	bool tf1, tf2;
	tf1 = formula();
	++roc;
	tf2 = formula();
	if(tf1 == tf2) return true;
	else return false;
}

int main(void) {
	while(true) {
		cin>>s;
		if(s == "#") break;
		if(rec(0)) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 3196
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s; cin >> s;
    rep(i, 0, s.size()) {
      if (s[i] == ',') s[i] = ' ';
    }
    cout << s << endl;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<int> hist(n + 1, 0);
  for(int x = 1; x*x < n; ++x)
  {
    int x2 = x * x;
    for(int y = 1; y*y < n; ++y)
    {
      int y2 = y * y;
      int xy = x * y;
      if (x2 + y2 + xy > n) break;
      for(int z = 1; z*z < n; ++z)
      {
        int sum = x2 + y2 + z*z + xy + (x + y)*z;
        if (sum > n) break;
        hist[sum]++;
      }
    }
  }
  for(int i = 1; i <= n; ++i)
  {
    cout << hist[i] << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i], --p[i];
    rep(i,n) cin >> q[i], --q[i];
    map<vector<int>, int> ord;
    int count = 0;
    vector<int> v(n);
    rep(i,n) v[i] = i;
    do{
        ord[v] = count++;
    }
    while(next_permutation(v.begin(),v.end()));
    cout << abs(ord[p]-ord[q]) << endl;
}

Measured memory_bytes: 8616
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
long long int n,m,k,i,j=1;
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1,};
ll a,b,c;

std::vector<P> tree[100010];
long long int d[100005];
bool flag=false;

int main(){
	cin>>n;
	
	cout<<n/3<<endl;
	return 0;
}


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

int main() {
    int N,D;
    scanf("%d %d",&N, &D);

    int width;
    width = D*2 + 1;
    if(N%width == 0){
        printf("%d",N/width);
    }else{
        printf("%d", N/width + 1);
    }
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;int main(){string u[256],t;int n,m,i,j,f=0,k;cin>>n;for(i=0;i<n;i++)cin>>u[i];cin>>m;for(i=0;i<m;i++){cin>>t;k=f;for(j=0;j<n;j++)if(t==u[j]){if(f==0)f=1,cout<<"Opened by "<<t<<endl;else f=0,cout<<"Closed by "<<t<<endl;}if(k==f)cout<<"Unknown "<<t<<endl;}return 0;}

Measured memory_bytes: 1216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,l,r,tmp=0,sum=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  
  r=0;
  rep(l,n){
    while(r<n && (tmp^(ll)a[r])==(sum+(ll)a[r])){
      tmp^=(ll)a[r];
      sum+=(ll)a[r];
      r++;
    }
    //printf("%lld %lld\n",l,r);
    result += (r-l);
    if(l==r) r++;
    else{
      tmp ^= (ll)a[l];
      sum -= (ll)a[l];
    }
  }
  printf("%lld",result);
  
  return 0;
}




Measured memory_bytes: 2176
#include"bits/stdc++.h"
    using namespace std;
    typedef long long ll;
    #define int ll
    const int N=1e5+4;
    vector<bool> prime(N,1);
    vector<int> spec(N,0);
    int32_t main()
    {
    	#ifndef ONLINE_JUDGE
    	freopen("in","r",stdin);
    	freopen("out","w",stdout);
    	#endif
    	
    	int n;
    	cin>>n;
    	vector<int>a(n),b(n),c(n);
    	for(auto &i:a)cin>>i;
    	for(auto &i:b)cin>>i;
    	for (int &i:c)cin>>i;
     
    	sort(a.begin(),a.end());
    	sort(b.begin(),b.end());
    	sort(c.begin(),c.end());
     
     
    	int ans=0;
     
    	for(int i=0;i<n;i++)
    	{
     
    		int l=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    		int r=n-(upper_bound(c.begin(),c.end(),b[i])-c.begin());
    		ans+=l*r;
    	}
     
    	cout<<ans;
     
    	
     
     
     
     
    	
    }

Measured memory_bytes: 6368
/*
                   _ooOoo_
                  o8888888o
                  88" . "88　AC!AC!
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
int main(){
    ll n;cin>>n;
    VP vec(n);
    rep(i,n){
        ll x,y;cin>>x>>y;
        vec[i]=Mp(x,y);
    }
    map<P,ll> res;
    ll Max=0;
    sort(all(vec));
    rep(i,n){
        rep3(j,i+1,n){
            if(vec[i].first-vec[j].first==0&&vec[i].second-vec[j].second==0)continue;
            //cout<<vec[i].first-vec[j].first<<" "<<vec[i].second-vec[j].second<<endl;
            res[Mp(vec[i].first-vec[j].first,vec[i].second-vec[j].second)]++;
            chmax(Max,res[Mp(vec[i].first-vec[j].first,vec[i].second-vec[j].second)]);
        }
    }
   // cout<<Max<<endl;
    cout<<n-Max<<endl;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()
#define Pb(i) push_back(i)

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

    ll n,k,ans; Cin2(n,k);
    ans = k;
    rep(i,n-1){
        ans *= (k-1);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
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> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let size: Vec<usize> = read_vec::<usize>();
    let start: Vec<usize> = read_vec::<usize>();
    let start: (usize, usize) = (start[0] - 1, start[1] - 1);
    let s = read::<String>().chars().collect::<Vec<char>>();
    let t = read::<String>().chars().collect::<Vec<char>>();

    let result = process(size, start, s, t);
    if result {
        println!("YES");
    } else {
        println!("NO");
    }
}

type XRange = (i32, i32);

fn process(size: Vec<usize>, start: (usize, usize), s: Vec<char>, t: Vec<char>) -> bool {
    
    let result = backtrack(size[2], size[1], &s, &t, 'L', 'R', start.1);
    if !result {
        return result;
    }
    let result = backtrack(size[2], size[0], &s, &t, 'U', 'D', start.0);
    return result;
}

fn backtrack(n:usize, size:usize, s: &Vec<char>, t: &Vec<char>, b:char, f:char, start:usize) -> bool {
    let size_i = size as i32;
    let mut r : XRange = (0, size_i-1);
    for i in (0..n).rev() {
        if t[i] == b {
            if r.1 < size_i - 1 {
                r.1 += 1;
            }
        } else if t[i] == f {
            if r.0 > 0 {
                r.0 -= 1;
            }
        }
        
        if s[i] == b {
            r.0 += 1;
        } else if s[i] == f {
            r.1 -= 1;
        }

        if r.0 > r.1 {
            return false;
        }
    }
    let start_i = start as i32;
    if start_i < r.0 || r.1 < start_i {
        return false;
    }
    return true;
}

Measured memory_bytes: 6396
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


n = int(input())
A = [0]*n

for i in range(n):
	A[i] = int(input())
A2 = A[:]

#
ans = 0
for i in range(n-1):
	now = A[i]
	ans += now // 2
	if now % 2 == 1:
		if A[i+1] > 0:
			A[i+1] -= 1
			ans += 1

ans += A[n-1] // 2

#
ans2 = 0
for i in reversed(range(1, n-1)):
	now = A[i]
	ans2 += now // 2
	if now % 2 == 1:
		if A[i-1] > 0:
			A[i-1] -= 1
			ans2 += 1

ans2 += A[0] // 2


print(max(ans, ans2))


Measured memory_bytes: 10228
#include<stdio.h>

typedef struct{

  char alf;
  int num;
 
}Roll;

int isStable(Roll  A[],Roll B[],int N){
  
  int i,j,a,b;

  // printf("%d\n", N);
  for(i=0;i<N;i++){

    // printf("%d %d\n",A[i].num,B[i].num);
    
    for(j=i+1;j<N;j++){
      for(a=0;a<N;a++){
	for(b=a+1;b<N;b++){
	  if(A[i].num==A[j].num&&A[i].alf==B[b].alf&&A[j].alf==B[a].alf&&A[i].num==B[b].num&&A[j].num==B[a].num) {
	    //printf("%d %d %d %d\n", i, j, a, b);
	    return 0;
	  }
	}
      }
    }
  }


  return 1;

}


int main( ){

  int N,i,j,minj,w;
  Roll C[36],D[36],c;

  scanf("%d%*c",&N);

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

    scanf("%c%d%*c",&C[i].alf,&C[i].num);

    D[i]= C[i];

  }

  //Bubble
  
  for(i=0;i<N;i++){
    for(j=N-1;i<j;j--){

      if(C[j].num<C[j-1].num){

        c.num=C[j].num;
	c.alf=C[j].alf;
	C[j].num=C[j-1].num;
	C[j].alf=C[j-1].alf;
       	C[j-1].num=c.num;
	C[j-1].alf=c.alf;

      }
    }
  }


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

    if(i==N-1)printf("%c%d\n",C[i].alf,C[i].num);
    else printf("%c%d ",C[i].alf,C[i].num);

  }

  
  w=isStable(D,C,N);

  if(w==0) printf("Not stable\n");
  else printf("Stable\n");
  

  for(i=0;i<N;i++){
  
    C[i]=D[i];
  }

 

  
  //SelectionSort

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

    minj=i;

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

      if(C[j].num<C[minj].num) minj=j;
    }


    //if(minj != i){
    //printf("minj=%d\n",minj);
    c=C[i];
    C[i]=C[minj];
    C[minj]=c;
    //}

    
    //for(k=0;k<N;k++){
    // printf("%c%d ",C[k].alf,C[k].num);
    // }
    // printf("\n");
    
    
    
  }

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

    if(i==N-1)printf("%c%d\n",C[i].alf,C[i].num);
    else printf("%c%d ",C[i].alf,C[i].num);

  }

  
  w=isStable(D,C,N);

  if(w==0) printf("Not stable\n");
  else printf("Stable\n");
  
  

  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

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

    std::vector<lint> a_l(n);

    lint minus_num = 0;
    lint min = 1e9 + 1;
    lint sum = 0;

    for (int i = 0; i < n; ++i)
    {
        lint a;
        scanf("%lld", &a);
        if (a < 0)
        {
            minus_num++;
            a *= -1;
        }
        sum += a;
        min = std::min(min, a);
    }

    if (minus_num % 2 == 0)
    {
        printf("%lld", sum);
    }
    else
    {
        printf("%lld", sum - min * 2);
    }

    return 0;
}


Measured memory_bytes: 1024