akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF ((int)(1e9))
#define LINF ((ll)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%I64d ",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
struct InputReader{
    static const int bs = 1000000;
    char buf[bs];
    int p;
    InputReader():p(bs) {}
    void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
    int operator() (){
        int ans = 0;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans;
    }
    void nextlet( int &x ){
    	char ch = c();
    	while( ch < 'a'  ||  ch > 'z' ) ch = c();
    	if( ch == 'c' ) x = 1;
    	if( ch == 'd' ) x = 2;
    	if( ch == 'q' ) x = 3;
	}
	ll readll(){
		ll ans = 0LL;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read2( int &x, int &y ){
	x = in(); y = in();
}
il void read3( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
/*********************************************************************/
/*********************************************************************/
#define MAXN 12

int n;
int a[MAXN];
ll ans = 0LL;

void dfs( int pos , bool hasou ){
	if( pos == n + 1 ){
		if( hasou ) ans++;
		return;
	}
	dfs( pos+1 , hasou | (a[pos] & 1));
	dfs( pos+1 , hasou | (a[pos] & 1));
	dfs( pos+1 , hasou | (!(a[pos]&1)));
}

int main(){

	read(n);
	for( int i = 1 ; i <= n ; i++ ){
		read(a[i]);
	}

	dfs( 1 , 0 );

	printf("%lld\n",ans);

	return 0;
}


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

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main(void)
{
    long long n, m;
    std::cin >> n >> m;

    std::vector<long long> dp(1 << n, 1e10);
    dp[0] = 0;

    for (int i = 0; i < m; i++) {
        long long a, b;
        std::cin >> a >> b;

        long long goods = 0;
        for (int j = 0; j < b; j++) {
            long long temp;
            std::cin >> temp;

            goods |= 1 << (temp - 1);
        }

        for (int j = 0; j < 1 << n; j++) {
            dp[j | goods] = std::min(dp[j | goods], dp[j] + a);
        }
    }

    if (dp[(1 << n) - 1] == 1e10) {
        dp[(1 << n) - 1] = -1;
    }

    std::cout << dp[(1 << n) - 1] << std::endl;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll A, ll B) {
  cout << min(A*N,B) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
#define mod 1000000007
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int dp[101][4][4][4];
int main(){
    int N;
    cin>>N;
    dp[0][3][3][3]=1;
    rep(len,N)rep(c1,4)rep(c2,4)rep(c3,4){
        //....c3 c2 c1 a
        if(dp[len][c1][c2][c3]==0)continue;
        rep(a,4){
            if(c2==0&&c1==1&&a==2)continue;
            if(c2==1&&c1==0&&a==2)continue;
            if(c2==0&&c1==2&&a==1)continue;
            if(c3==0&&c1==1&&a==2)continue;
            if(c3==0&&c2==1&&a==2)continue;
            dp[len+1][a][c1][c2]+=dp[len][c1][c2][c3];
            dp[len+1][a][c1][c2]%=mod;
        }
    }
    int ans=0;
    rep(c1,4)rep(c2,4)rep(c3,4){
        ans+=dp[N][c1][c2][c3];
        ans%=mod;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

N = int(input())

target = 'MARCH'
first = [0 for _ in range(5)]
for _ in range(N):
    s = input()
    if s[0] in target:
        first[target.find(s[0])] += 1

res = 0
for c in combinations(first, 3):
    res += c[0]*c[1]*c[2]
    
print(res)


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

int main(void){
    int N, X, Y;
    cin >> N >> X >> Y;

    vector<int> cost(N, 0);

    for(int i=1; i < N; i++){
        for(int j = i+1; j <= N; j++){
            if(i <= X && Y <= j){
                cost[j-Y + X-i + 1]++;
            }else{
                cost[min(j-i,  abs(Y-j)+1+abs(i-X))]++;
            }
        }
    }
    for(int i=1; i<N; i++){
        cout << cost[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B,$C,$D) =  explode(" ",trim(fgets(STDIN)));
//$a =  explode(" ",trim(fgets(STDIN)));

$len = strlen($N);
for($i=0;$i<$len;$i++) {
  if (isset($res[$N[$i]])) {
    $res[$N[$i]]+=1;
  }
  else {
    $res[$N[$i]]=1;
  }
}
foreach($res as $v) {
  if ($v!=2) {
    printf("No\n");
    exit;
  }
}
printf("Yes\n");


Measured memory_bytes: 4728
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
#define ll long long 
#define il inline
const int maxn=500010;
const ll mod=1e9+7;
int n,m;
ll inv[maxn],jc[maxn];
ll ans;
ll ksm(ll x,ll k){
    ll res=1;
    while (k){
        if (k&1) res=res*x%mod;
        x=x*x%mod; k>>=1;
    }
    return res;
}
int main(){
    scanf("%d%d",&n,&m);
    jc[0]=1;
    for (int i=1;i<=m;++i){
        jc[i]=jc[i-1]*i%mod;
    }
    inv[m]=ksm(jc[m],mod-2);
    for (int i=m-1;i>=0;--i){
        inv[i]=inv[i+1]*(i+1)%mod;
    }
    ll tmp;
    for (int i=0;i<=n;++i){
        tmp=jc[n]%mod*jc[m-i]%mod;
        tmp=tmp*inv[i]%mod*inv[n-i]%mod*inv[m-n]%mod;
        if (i&1) ans=(ans-tmp+mod)%mod;
        else ans=(ans+tmp)%mod;
    }
    ans=ans*jc[m]%mod*inv[m-n]%mod;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 11576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

double dist(double gx,double gy, P p) {
  return sqrt((gx-p.first)*(gx-p.first)+(gy-p.second)*(gy-p.second));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x,y;cin>>n;
  double gx=0.0,gy=0.0,r=0.0,r_=0.0,c=0.1;
  vector<P> points(n);
  rep(i,n) {cin>>x>>y;gx+=x;gy+=y;points[i]=P(x,y);}
  gx/=n,gy/=n;
  P far;
  rep(i,3e4) {
    r=0.0;
    for(P p:points) {
      r_=dist(gx,gy,p);
      if(r<r_) {r=r_;far=p;} 
    }
    gx+=c*(far.first-gx);
    gy+=c*(far.second-gy);
    c*=0.999;
  }
  for(P p:points) r=max(r,dist(gx,gy,p));
  printf("%.10f\n",r);
  return 0;
}

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

int main(){
 int n;
 cin >> n;
 string s;
 cin >> s;
 int ans = 0;
 rep(i,n){
    if( s[i-1]=='A' && s[i]=='B' && s[i+1]=='C' ) ++ans; 
 }
 cout << ans << endl;
 }




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            var n = cin.ReadInt;
            var k = cin.ReadInt;
            Console.WriteLine(n <= k ? 1 : 0);
        }
    }

    static class ExtendClass {
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



Measured memory_bytes: 18436
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <regex>



using ull = unsigned long long;
using ll = long long;

using namespace std;


vector<string> split(string str, string separator) {
	if (separator == "") return { str };
	vector<string> result;
	string tstr = str + separator;
	long l = tstr.length(), sl = separator.length();
	string::size_type pos = 0, prev = 0;

	for (; pos < l && (pos = tstr.find(separator, pos)) != string::npos; prev = (pos += sl)) {
		result.emplace_back(tstr, prev, pos - prev);
	}
	return result;
}



int main() {
   
	
	string s(10, ' ');
	cin >> s;
	int num = s.length() - 1;
	
	
	ll sum = 0;
	for (int bit = 0; bit < (1<<num); bit++)
	{
		
		string tmp = s;
		for (int i = 0; i < num; i++)
		{
			if (bit & (1 << i))
			{
				tmp.insert(s.length() -1 - i, "+");
			}
			
		}
		//cout << tmp << endl;
		
		auto r = split(tmp, "+");
		for (auto i = 0; i < r.size(); i++)
		{
			ll t;
			sscanf(r[i].c_str(), "%lld", &t);
			sum += t;
		}
		
	}

	cout << sum << endl;
	
	return 0;
	
}

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

int cmp(int *x, int *y)
{
	return (*y - *x);
}

int main(void)
{
	long long n;
	
	while (scanf("%lld", &n), n){
		long long ans, len;
		int joints[65001];
		int i, pn;

		len = 0;
		for (i = 0; i < n; i++){
			int pipe;
			scanf("%d", &pipe);

			len += pipe;
		}
		
		ans = len * n;
		pn = n;

		for (i = 0; i < n - 1; i++){
			scanf("%d", joints + i);
		}

		qsort(joints, n, 4, cmp);

		for (i = 0; i < n - 1; i++){
			if (ans < (joints[i] + len) * (pn - 1)){
				ans = (joints[i] + len) * --pn;
				len += joints[i];
			}
		}

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

	return (0);
}

Measured memory_bytes: 1028
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
const int N=20;
typedef long long ll;
int h[N];
int n;
ll ans;
void dfs(int x,ll sum,ll f){
    if(x==n+1){
        sum+=f;
        ans+=sum;
        return ;
    }
    dfs(x+1,sum,f*10+h[x]);
    dfs(x+1,sum+f,h[x]);
}
int main()
{
    while(1){
        char c=getchar();
        if(c<'0'||c>'9')
            break ;
        h[++n]=c-'0';
    }
    dfs(1,0,0);
    printf("%lld\n",ans/2);
}


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

int main()
{
  int n, ans = 0;
  string s;
  map<string, int> x;

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    if (x.count(s))
      x[s]++;
    else
      x[s] = 1;
  }
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    if (x.count(s))
      x[s]--;
    else
      x[s] = -1;
  }
  for (auto p: x)
  {
    ans = max(ans, p.second);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let r: String = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = match &*r {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => unreachable!()
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
s =input()
l =len(s)
ans =0
for i in range(l):
    x =s[i]
    count =0
    if x =='A' or x =='C' or x =='G' or x =='T':
        count +=1
        for j in range(i+1, l):
            x =s[j]
            if x =='A' or x =='C' or x =='G' or x =='T':
                count +=1
            else:
                break
    ans = max(count ,ans)
print(ans)

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

int calc(string &s,int &i){
  int res=0;
  while(1){
    if(isdigit(s[i]))res=s[i++]-'0';
    else if(s[i]=='('){res=calc(s,++i),i++;}
    else if(s[i]=='+')res+=calc(s,++i);
    else if(s[i]=='-')res-=calc(s,++i);
    else break;
  }
  return res;
}

map<string,int> mem[2];
int dfs(string &s,int f){
  if(mem[f].count(s))return mem[f][s];

  int j=0,res=calc(s,j),n=s.size(),d=-1;
  for(int i=0;i<n;i++) d+=(s[i]=='+'||s[i]=='-');
  
  for(int i=0,c=0,cnt=0;i<n;i++,cnt++,d--){
    while(1){
      while(s[i]=='('||s[i]==')')c+=(s[i]=='(')-(s[i]==')'),i++;
      if(i>=n||s[i]=='+'||s[i]=='-') break;
      i++;
    }
    if(i>=n||(cnt&&s[i-2]=='(')||(d&&s[i+2]==')'))continue;
    string a=s.substr(0,i),b=s.substr(i+1,n-i-1);
    int t=c,ch=s[i];
    while(t--)a+=')',b='('+b;
    int mxa=dfs(a,0),mna=dfs(a,1);
    int mxb=dfs(b,0),mnb=dfs(b,1);
    if(f==0&&ch=='+') res=max(res, mxa+mxb);
    if(f==0&&ch=='-') res=max(res, mxa-mnb);
    if(f==1&&ch=='+') res=min(res, mna+mnb);
    if(f==1&&ch=='-') res=min(res, mna-mxb);
  }
  return mem[f][s]=res;
}

int main(){
  string S;
  cin>>S;
  cout <<dfs(S,0)<<endl;
  return 0;
}

Measured memory_bytes: 4660
import heapq as h;I=lambda:list(map(int,input().split()));n,k=I();z=[i*2+1for i in range(n)];s=sorted([I()for _ in[0]*n],key=lambda x:-x[1]);q=[];v=A=0;l=[0]*-~n
for a in s[:k]:
 if l[a[0]]:h.heappush(q,a[1])
 else:A+=z[v];v+=1
 l[a[0]]=1;A+=a[1]
T=A
for a in s[k:]:
 if q and l[a[0]]^1:l[a[0]]=1;t=h.heappop(q);T=T-t+a[1]+z[v];v+=1;A=max(A,T)
print(A)

Measured memory_bytes: 73760
mod=10**9+7
S=input()
dp=[0]*13
dp[0]=1

for s in S:
    prev=[x for x in dp]
    dp=[0]*13
    if s=='?':
        nx=range(10)
    else:
        nx=[int(s)]
    for i in range(13):
        for j in nx:
            dp[(10*i+j)%13]+=prev[i]
    dp=[x%mod for x in dp]
print(dp[5])

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N;
    cin >> N;
    int best = -1, ans = 0;
    for (int i=N; i>=1; --i) {
        int tmp = i, tmp2 = 0;
        while (tmp%2 == 0) {
            tmp/=2;
            tmp2++;
        }
        if (best < tmp2) {
            best = tmp2;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: n, res, i
  integer, allocatable :: a(:)

  read (*, *) n
  allocate (a(n))
  read (*, *) a(:)

  res = a(1)
  do i = 2, n
    res = gcd(res, a(i))
  end do

  write (*, "(i0)") res

  contains

  function gcd(x, y)
    integer, intent(in) :: x, y
    integer :: gcd, a, b, r
    a = min(x, y)
    b = max(x, y)
    do while (b > 0)
      r = mod(a, b)
      a = b
      b = r
    end do
    gcd = a
  end function gcd
end program main


Measured memory_bytes: 1152
#include<stdio.h>
#include<map>
using namespace std;
map<char,int> mp;
int x1[10];
int x2[10];
int y1[10];
int y2[10];
bool used[10];
int t[50][50];
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void update(int n,int x,int y){
	x1[n]=min(x1[n],x);
	x2[n]=max(x2[n],x);
	y1[n]=min(y1[n],y);
	y2[n]=max(y2[n],y);
}
int main(){
	int d;
	int h,w;
	int i,j,k;
	scanf("%d",&d);
	for(int di=0;di<d;di++){
		scanf("%d %d",&h,&w);
		int p=1;
		mp.clear();
		for(i=0;i<10;i++){
			x1[i]=100;
			x2[i]=0;
			y1[i]=100;
			y2[i]=0;
			used[i]=false;
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				char c;
				scanf(" %c",&c);
				if(c=='.'){
					t[i][j]=-1;
					continue;
				}
				if(mp[c]==0)mp[c]=p++;
				update(mp[c],i,j);
				t[i][j]=mp[c];
			}
		}
		while(1){
			for(i=1;i<=p;i++){
				if(used[i])continue;
				int res=0;
				for(j=x1[i];j<=x2[i];j++){
					for(k=y1[i];k<=y2[i];k++){
						if(t[j][k]==i||t[j][k]==0)res++;
					}
				}
				if(res==(x2[i]-x1[i]+1)*(y2[i]-y1[i]+1)){
					for(j=x1[i];j<=x2[i];j++){
						for(k=y1[i];k<=y2[i];k++){
							t[j][k]=0;
						}
					}
					used[i]=true;
					break;
				}
			}
			if(i==p+1)break;
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(!(t[i][j]==0||t[i][j]==-1))break;
			}
			if(j!=w)break;
		}
		if(i==h)printf("SAFE\n");
		else printf("SUSPICIOUS\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    cin >> X;

    ll ans = 0;
    REP(i, N - 1) {
        ans += min(B, (X[i + 1] - X[i]) * A);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
    char ch[10][10]={ {'a','b','c','d','e'}, {'f','g','h','i','j'}, {'k','l','m','n','o'}, {'p','q','r','s','t'}, {'u','v','w','x','y'}, {'z','.','?','!',' '} };
    string s;
    while(cin>>s){
        int len=s.size();
        string ans="";
        
        try{
            if(len%2==1)throw 1;
            for(int i=0;i<len;i+=2){
                int a,b;
                if(s[i]<'1' || '6'<s[i] || s[i+1]<'1' || '5'<s[i+1] )throw 1;
                a=s[i]-'0'-1;
                b=s[i+1]-'0'-1;
            
                ans+=ch[a][b];
            }
        }catch(int a){
            cout<<"NA"<<endl;
            goto next;
        }
        cout<<ans<<endl;
        next:;
    }
}

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

int main()
{
  double s = 0.0;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;
    s += 1.0 / a;
  }
  cout << 1.0 / s << endl;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    double ans = 0;
    for(ll i=1; i<=N; i++){
        ll now = i;

        ll div = 1;
        while(now < K){
            now *= 2;
            div *= 2;
        }
        ans += 1.0/div;
    }
    cout << ans/N << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# コード綺麗に
# リファクタリング


S = input()
LS = len(S)

LEFT = [None] * LS
RIGHT = [None] * LS

# 最寄りのR
near_R = 0
for i in range(LS):
    s = S[i]
    if s == 'R':
        near_R = i
    else:
        LEFT[i] = near_R

# 最寄りのL
near_L = LS - 1
for i in range(LS - 1, -1, -1):
    s = S[i]
    if s == 'L':
        near_L = i
    else:
        RIGHT[i] = near_L

ans = [0] * LS

for i in range(LS):
    # 見てるのがLEFT
    if LEFT[i] != None:
        near_R = LEFT[i]
        d = i - near_R
        if d % 2 == 0:
            ans[near_R] += 1
        else:
            ans[near_R+1] += 1

    # 見てるのがRIGHT
    if RIGHT[i] != None:
        near_L = RIGHT[i]
        d = near_L - i
        if d % 2 == 0:
            ans[near_L] += 1
        else:
            ans[near_L - 1] += 1

print(" ".join((map(str, ans))))


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

int imos[100000 + 10];

int main() {

    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        imos[a] += 1;
        imos[b+1] += -1;
    }

    for(int i=1; i<100000 + 10; i++){
        imos[i] += imos[i-1];
    }

    int ans = 0;

    for(int i=1; i<100000 + 10; i++){
        if(i <= imos[i] + 1){
            ans = i-1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> cost(n, vector<int>(m+1));
    for(int i=0; i<n; i++){
        for(int j=0; j<m+1; j++){
            cin >> cost[i][j];
        }
    }
    int min_cost = 1e18;
    for(int i=1; i<((int)1<<n); i++){
        vector<int> require(m, 0);
        int temp = 0;
        // cerr << "curr value of i: " << i << endl;
        for(int j=0; j<n; j++){
            if((1<<j)&i){
                // cerr << "set bit #: " << j << endl;
                temp += cost[j][0];
                for(int k=1; k<=m; k++) require[k-1] += cost[j][k];
            }
        }
        bool flag = false;
        for(auto f: require){
            if(f < x){
                flag = true;
                break;
            }
        }
        if(!flag)    min_cost = min(min_cost, temp);
    }
    if(min_cost == 1e18){
        cout << -1 << endl;
    }
    else cout << min_cost << endl;
}

Measured memory_bytes: 3556
# AOJ 2304 Reverse Roads
# Python3 2018.7.21 bal4u

# *******************************************
# Dinic's Max Flow Algorithm
# *******************************************
class MaxFlow:
    def __init__(self, V):
        self.V = V
        self.level = [0] * V
        self.iter = [0] * V
        self.edge = [[] for i in range(V)]

    def add_edge(self, fr, to, cap):
        f, t = len(self.edge[fr]), len(self.edge[to])
        self.edge[fr].append([to, cap, t])
        self.edge[to].append([fr, cap, f])

    def bfs(self, s):
        self.level = [-1] * self.V
        self.level[s] = 0
        Q = []
        Q.append(s)
        while Q:
            v = Q.pop()
            for to, cap, rev in self.edge[v]:
                if cap > 0 and self.level[to] < 0:
                    self.level[to] = self.level[v] + 1
                    Q.append(to)

    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.edge[v])):
            to, cap, rev = self.edge[v][i]
            if cap > 0 and self.level[v] < self.level[to]:
                d = self.dfs(to, t, min(f, cap))
                if d > 0:
                    self.edge[v][i][1] -= d
                    self.edge[to][rev][1] += d
                    return d
            self.iter[v] = i
        return 0

    def maxFlow(self, s, t, INF=10**8):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0: break
            self.iter = [0] * self.V
            while True:
                f = self.dfs(s, t, INF)
                if f <= 0: break
                flow += f
        return flow

N, M = map(int, input().split())
dir = [[0 for j in range(N)] for i in range(N)]
id =  [[0 for j in range(N)] for i in range(N)]
d = MaxFlow(N)
for i in range(M):
	x, y = map(int, input().split())
	x, y = x-1, y-1
	dir[y][x] = 1
	id[y][x] = i+1
	d.add_edge(x, y, 1)
S, T = map(int, input().split())
print(d.maxFlow(S-1, T-1))

ans = []
for i in range(N):
	for to, cap, rev in d.edge[i]:
		if cap < 1 and dir[i][to]: ans.append(id[i][to])
ans.sort()
print(len(ans))
if len(ans) > 0: print(*ans, sep='\n')



Measured memory_bytes: 7432
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int a, b, k, K;
int v[101];

int main(int argc, char ** argv) {
	scanf("%d%d%d", &a, &b, &K);
	PER(i, 100, 1) {
		if(a%i == 0) v[i]++;
		if(b%i == 0) v[i]++;
		if(v[i] == 2) k++;
		if(k == K) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	int cnt = 0;
	char s[100000];
	scanf("%s", s);
	for (int i = 0; i < strlen(s) - 1; i++) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int k, x;
  cin >> k >> x;
  cout << (k * 500 >= x ? "Yes" : "No") << endl;


  
  return 0;
}

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

int main() {
	long N, M;
	cin >> N >> M;
	if (1 == N && 1 == M) cout << 1;
	else if (2 == N || 2 == M) cout << 0;
	else if (1 == N) cout << M - 2;
	else if (1 == M) cout << N - 2;
	else cout << (N - 2) * (M - 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++){
    for (int j = 0; j <= K; j++){
      if (i + j <= S && i + j + K >= S) count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};

fn abssub(x: usize, y: usize) -> usize {
  if x < y { y - x } else { x - y }
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (h, w) = (xs[0], xs[1]);
  let mut xss: Vec<Vec<usize>> = Vec::new();
  for _ in 0..h {
    let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    xss.push(xs);
  }
  let mut yss: Vec<Vec<usize>> = Vec::new();
  for _ in 0..h {
    let ys: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    yss.push(ys);
  }
  let mut zss: Vec<Vec<usize>> = vec![vec![0; w]; h];
  for i in 0..h {
    for j in 0..w {
      zss[i][j] = abssub(xss[i][j], yss[i][j]);
    }
  }
  let max = zss.iter().map(|zs| zs.iter().max().unwrap()).max().unwrap();
  let m = (h + w + 1) * max + 1;
  let mut memo: Vec<Vec<Vec<bool>>> = vec![vec![vec![false; m]; w]; h];
  memo[0][0][zss[0][0]] = true;
  for i in 0..h {
    for j in 0..w {
      for k in 0..m {
        if j > 0 && memo[i][j-1][k] {
          memo[i][j][k+zss[i][j]] = true;
          memo[i][j][abssub(k, zss[i][j])] = true;
        }
        if i > 0 && memo[i-1][j][k] {
          memo[i][j][k+zss[i][j]] = true;
          memo[i][j][abssub(k, zss[i][j])] = true;
        }
      }
    }
  }
  let ans = memo[h-1][w-1].iter().position(|x| *x).unwrap();
  println!("{}", ans);
}

Measured memory_bytes: 83080
s = input()
num = []
for c in s:
    num.append(int(c))

ans = ["","","","="]
for i in range(8):
    temp = format(i,"b").zfill(3)
    su = num[0]
    # print(temp)
    for j in range(3):
        if temp[j] == "1":
            su += num[j+1]
            ans[j] = "+"
        else:
            su-=num[j+1]
            ans[j] = "-"
    if su == 7:
        break

buf=str(num[0])
for i in range(3):
    buf+=ans[i]
    buf+=str(num[i+1])
buf+=ans[-1]
buf+="7"
print(buf)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main{
    static int maxVal=Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        
        int ans[][]=new int[n+1][n+1]; 

       for(int i=1;i<=n;i++){
            int u=sc.nextInt();
            int k = sc.nextInt();
            for(int j=0;j<k;j++){
                int v=sc.nextInt();
                ans[i][v]=1;
            }
       }

       for(int l=1;l<=n;l++){
           for(int m=1;m<n;m++){
               System.out.print(ans[l][m]+" ");
           }
           System.out.println(ans[l][n]);
       }

        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //    try{
        //         //int n= Integer.parseInt(br.readLine());
        //         //int[] array = Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();

                
                
        //     }catch(IOException e){e.printStackTrace();}
    }
}
    


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

void insertionSort(vector<int> &A, int N) {
    for (int i = 1; i < N; ++i) {
        rep(i, N) {
            if (i != N - 1) cout << A[i] << " ";
            else cout << A[i] << endl;
        }
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    insertionSort(A, N);
    rep(i, N) {
        if (i != N - 1) cout << A[i] << " ";
        else cout << A[i] << endl;
    }
}


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Da;
		s[2]/=s[0];
		if(s[0]*s[1]==s[2]){
			Console.WriteLine("{0}",0);
		}
		else if(s[2]<=s[0]*s[1]/2){
			Console.WriteLine("{0}",Gp4((s[2]*2)/s[1],s[1],0,0,(s[2]*2)/s[1],0));
		}
		else{
			s[2]=s[0]*s[1]-s[2];
			Console.WriteLine("{0}",90-Gp4((s[2]*2)/s[0],s[0],0,0,(s[2]*2)/s[0],0));
		}
	}
	static double Gp4(double ax,double ay,double bx,double by,double cx,double cy){
		double a1=ax-bx,a2=ay-by,c1=cx-bx,c2=cy-by;
		return Math.Acos((a1*c1+a2*c2)/Math.Sqrt((a1*a1+a2*a2)*(c1*c1+c2*c2)))*180/Math.PI;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long N,M;
    std::cin >> N >> M;
    if(N>=3 && M>=3){
        std::cout << (N-2)*(M-2) << std::endl;
    }
    else if(N==2 || M==2){
        std::cout << 0 << std::endl;
    }else{
        if(N>M){
            long temp=N;
            N=M;
            M=temp;
        }
        long count=M-2;
        if(N==1 && M==1){
            count=1;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
start, end = 0, 1
now = a[0]
ans = 0
while end < n:
  NEXT = a[end]
  if now + NEXT == now ^ NEXT:
    now += NEXT
    end += 1
  else:
    LEN = end - start
    ans += LEN
    now -= a[start]
    start = start + 1
LEN = end - start
ans += LEN * (LEN+1) // 2
print(ans)

Measured memory_bytes: 24840
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	void solve() {
		IOS;
		string s;
		cin >> s;
		int n = s.size();
		ll res = 0;
		REP(i, n) {
			if (s[i] == '?') {
				s[i] = 'D';
			}
		}
		REP(i, n) {
			if (i < n - 1) {
				if (s[i] == 'P' && s[i + 1] == 'D') {
					res++;
				}
			}
			if (s[i] == 'D') {
				res++;
			}
		}
		put(s);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b,m;
  cin>>a>>b>>m;
  vll d(a),e(b);
  REP(i,a)cin>>d[i];
  REP(i,b)cin>>e[i];

  ll ans=LLINF;
  REP(i,m){
    ll x,y,c;
    cin>>x>>y>>c;
    x--;
    y--;
    ans = min(ans,d[x]+e[y]-c);
  }

  sort(ALL(d));
  sort(ALL(e));
  ans = min(ans,d[0]+e[0]);
  cout<<ans<<endl;

}



Measured memory_bytes: 1792
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N=II()
S=SR()

cnt=1
for i in range(N-1):
    if S[i] != S[i+1]:
        cnt+=1
print(cnt)



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

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

// Sieve of Eratosthenes
// (*this)[i] = (divisor of i, greater than 1)
// Example: [0, 1, 2, 3, 2, 5, 3, 7, 2, 3, 2, 11, ...]
// Complexity: Space O(MAXN), Time (construction) O(MAXNloglogMAXN)
struct SieveOfEratosthenes : std::vector<int> {
  std::vector<int> primes;
  SieveOfEratosthenes(int MAXN) : std::vector<int>(MAXN + 1) {
    std::iota(begin(), end(), 0);
    for (int i = 2; i <= MAXN; i++) {
      if ((*this)[i] == i) {
        primes.push_back(i);
        for (int j = i; j <= MAXN; j += i) (*this)[j] = i;
      }
    }
  }
  using T = long long int;
  // Prime factorization for x <= MAXN^2
  // Complexity: O(log x)          (x <= MAXN)
  //             O(MAXN / logMAXN) (MAXN < x <= MAXN^2)
  std::map<T, int> Factorize(T x) {
    assert(x <= 1LL * (int(size()) - 1) * (int(size()) - 1));
    std::map<T, int> ret;
    if (x < int(size())) {
      while (x > 1) {
        ret[(*this)[x]]++;
        x /= (*this)[x];
      }
    }
    else {
      for (auto p : primes) {
        while (!(x % p)) x /= p, ret[p]++;
        if (x == 1) break;
      }
      if (x > 1) ret[x]++;
    }
    return ret;
  }
  std::vector<T> Divisors(T x) {
    std::vector<T> ret{1};
    for (auto p : Factorize(x)) {
      int n = ret.size();
      for (int i = 0; i < n; i++) {
        for (T a = 1, d = 1; d <= p.second; d++) {
          a *= p.first;
          ret.push_back(ret[i] * a);
        }
      }
    }
    return ret; // Not sorted
  }
  // Moebius function Table
  // return: [0=>0, 1=>1, 2=>-1, 3=>-1, 4=>0, 5=>-1, 6=>1, 7=>-1, 8=>0, ...]
  std::vector<int> GenerateMoebiusFunctionTable() {
    std::vector<int> ret(size());
    for (int i = 1; i < int(size()); i++) {
      if (i == 1) ret[i] = 1;
      else if ((i / (*this)[i]) % (*this)[i] == 0) ret[i] = 0;
      else ret[i] = -ret[i / (*this)[i]];
    }
    return ret;
  }
};
SieveOfEratosthenes sieve(1000000);

int main() {
  ll N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  vector<ll> cnt(1000011);
  ll res = A[0];
  for(int i = 0; i < N; ++i) res = gcd(res, A[i]);
  if(res != 1) {
    cout << "not coprime" << endl;
  } else {
    // エラトステネスの篩をかける
    // 高速素因数分解を用いる
    REP(i, N) {
      for(auto p : sieve.Factorize(A[i])) {
        cnt[p.first]++;
      }
    }

    if(*max_element(all(cnt)) <= 1) cout << "pairwise coprime" << endl;
    else cout << "setwise coprime" << endl;
  }
}

Measured memory_bytes: 23248