akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace exw1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            if (a == b && b == c)
            {
                Console.WriteLine("Yes");
            }
            else {


                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
        #define ll long long int
        #define vi vector<int>v
        #define vll vector<long long int>v
        #define vc vector<char>v
        #define vpi vector< pair <int,int> >v
        #define vpll vector< pair <long long int,long long int> >v
        #define pb v.push_back
        #define si set<int>s
        #define sc set<char>s
        #define nl cout<<endl
        //#define fl0 for(int i=0; i<n; i++)
        //#define fl1 for(int i=1; i<=n; i++)
        using namespace std;
        bool prime(int n)
        {
         for(int i=2; i<=(n/i); i++)
         {
             if(n%i==0){return 0;}
         }
         return 1;

        }

        int binarySearchCount(int arr[], int n, int t)
        {
            int left = 0;
            int right = n - 1;

            int count = 0;

            while (left <= right) {
                int mid = (right + left) / 2;

                if (arr[mid] <= t) {

                    count = mid + 1;
                    left = mid + 1;
                }

                else
                    right = mid - 1;
            }

            return count;

        }

        long long countGreater(long long arr[], int n, long long k)
    {
        long long l = 0;
        long long r = n - 1;
        long long leftGreater = n;

        while (l <= r) {
            long long m = l + (r - l) / 2;
            if (arr[m] >= k) {
                leftGreater = m;
                r = m - 1;
            }

            else
                l = m + 1;
        }

        return (n - leftGreater);

    }
    bool tonmoy(char c)
    {
        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')
            return 0;
        return 1;
    }
    int main()
    {
      int n;
      cin>>n;
      if(n>=30){cout<<"Yes\n";}
      else {cout<<"No\n";}
    }


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    if(n%10==3){
        cout<<"bon";
    }elif(n%10==0||n%10==1||n%10==6||n%10==8){
        cout<<"pon";
    }else{
        cout<<"hon";
    }
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define Nodes 100100
#define S second
#define ll long long
using namespace std;
//union find{
#define MAX_N 100100
int par[MAX_N]; // 親
int Rank[MAX_N]; // 木の深さ

void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    Rank[i] = 0;
  }
}
// 木の根を求める
int find(int x){
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}
// xとyの属する集合を併合
void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  
  // 木の高さが高い方を代表ノードにする
  if(Rank[x] < Rank[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(Rank[x] == Rank[y]) Rank[x]++;
  }
}
// xとyが同じ集合ならtrue
bool same(int x,int y){
  return find(x) == find(y);
}
int main(){
  int n,m;cin>>n>>m;
  vector<int>num(n);
  init(100010);
  for(int i=0;i<n;i++)cin>>num[i];
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    unite(a,b);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    if(find(num[i])==find(i+1))ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
   int n; cin >> n;
   map<string, int> s;

   for (int i = 0; i < n; i ++) {
      string tmp; cin >> tmp;
      if (s.count(tmp) == 0) {
         s[tmp] = 1;
      } else {
         s[tmp] ++;
      }
   }

   int m; cin >> m;
   for (int i = 0; i < m; i ++) {
      string tmp; cin >> tmp;
      if (s.count(tmp) == 0) {
         s[tmp] = -1;
      } else {
         s[tmp] --;
      }
   }

   int max = -101;
   for (map<string, int>::iterator itr = s.begin(); itr != s.end(); ++itr) {
      if(itr->second > max) {
         max = itr->second;
      }
   }
   if (max < 1) {
      cout << 0 << endl;
   } else {
      cout << max << endl;
   }
   return 0;
}


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

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

    set<string> substr_set;
    for (int l = 1; l <= K; l++) {
        for (int i = 0; i + l <= s.length(); i++) {
            string substr = s.substr(i, l);
            substr_set.insert(substr);
        }
    }

    string ans;
    set<string>::iterator it = substr_set.begin();
    for (int i = 0; i < K; i++) ans = *(it++);

    cout << ans << endl;
}

Measured memory_bytes: 1664
N = int(input())
TXY = [list(map(int, input().split())) for i in range(N)]
TXY.insert(0, [0, 0, 0])

for i in range(N):
    # 秒数が足りないパターンと、奇数分余ってもとに戻れないパターン
    if (abs(TXY[i][1]-TXY[i+1][1])+abs(TXY[i][2]-TXY[i+1][2]) > (TXY[i+1][0]-TXY[i][0])) or \
            ((TXY[i+1][0] - TXY[i][0]) - (abs(TXY[i][1]-TXY[i+1][1])+abs(TXY[i][2]-TXY[i+1][2]))) % 2 == 1:
        print("No")
        break
else:
    print("Yes")

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

int main() {
    int N;
    int t[100100], x[100100], y[100100];
    cin >> N;
    t[0] = x[0] = y[0] = 0;
    for(int i = 0; i < N; i++) {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }

    bool can = true;
    for(int i = 0; i < N; i++) {
        int dt = t[i + 1] - t[i];
        int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if(dt < dist || (dist % 2 != dt % 2)) {
            can = false;
        }
    }

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

Measured memory_bytes: 1408
package main

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

func main() {
	numMap := make(map[string]bool)
	n := intStdin()
	for i := 0; i < n; i++ {
		s := strStdin()
		if _, ok := numMap[s]; ok {
			delete(numMap, s)
		} else {
			numMap[s] = true
		}
	}
	fmt.Println(len(numMap))
}

/* template */
var sc = bufio.NewScanner(os.Stdin)

// 文字列を1行取得
func strStdin() (stringInput string) {
	sc.Scan()
	stringInput = sc.Text()
	stringInput = strings.TrimSpace(stringInput)
	return
}

// 整数値1つ取得
func intStdin() (num int) {
	stringInput := strStdin()
	num, _ = strconv.Atoi(strings.TrimSpace(stringInput))
	return
}

// 空白や空文字だけの値を除去したSplit()
func splitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func splitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := strStdin()

	// 空白で分割
	stringReturned = splitWithoutEmpty(stringInput, delim)

	return
}
/* template */

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    int a,b;cin>>a>>b;
    string s,t;
    rep(i,b)s+=(char)('0'+a);
    rep(i,a)t+=(char)('0'+b);
    out(min(s,t));
}

Measured memory_bytes: 256
x,y,z = map(int, input().split())

hantei_flag = 0

if(x == (y+z)):
    hantei_flag=1
elif(y == (z+x)):
    hantei_flag=1
elif(z == (x+y)):
    hantei_flag=1

if(hantei_flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define SENTINEL 99999999
using namespace std;
typedef pair<int,int> pii;
map<int,int>h;
class union_find{
	vector<pii>parent;
	pii root(int a){
		if(parent[a].first==a)return parent[a];
		pii ret=root(parent[a].first);
		return parent[a]=make_pair(ret.first,ret.second+parent[a].second);
	}
public:
	union_find(int n): parent(n){for(int i=0;i<n;i++)parent[i]=make_pair(i,0);}
	int dist(int a,int b){
		pii x=root(a),y=root(b);
		if(x.first!=y.first)return SENTINEL;
		return x.second-y.second;
	}
	int unite(int a,int b,int w){
		pii x=root(a),y=root(b);
		if(x.first==y.first)return 0;
		parent[x.first]=make_pair(y.first,y.second-x.second -w-h[a]+h[b]); ///
		return 1;
	}
};
int main(){
	int N,Q,a,b,w;
	string s;
	cin>>N>>Q;
	union_find uf(N);
	for(;Q--;){
		cin>>s>>a>>b,a--,b--;
		if(s=="IN"){
			cin>>w;
			h[a]+=w,h[b]+=w;
			uf.unite(a,b,w);
		}else{
			w=uf.dist(a,b);
			if(w==SENTINEL)cout<<"WARNING"<<endl;
			else cout<< -w-h[a]+h[b]<<endl; ///
		}
	}
}

Measured memory_bytes: 4700
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string str;
    cin >> str;
    string a = "A";
    string b = "B";
    string c = "C";
    string bc = "BC";
    
    long ans = 0;
 
    if(str.length()<3){
        cout << ans  << endl;
        return 0;
    }
 
    long counta = 0, countbc = 0;
 
    for(int i=str.length()-1;i>0;i--){
        if((counta ==0)&&(countbc==0)){
            if(str.compare(i-1,2,bc)==0){
                countbc ++;
                i --;
            }
        }else if((counta==0)&&(countbc>0)){
            if(str.compare(i,1,a)==0){
                counta ++;
            }else if(str.compare(i-1,2,bc)==0){
                countbc ++;
                i--;
            }else{
                counta =0;
                countbc = 0;
            }
        }else if((counta>0)&&(countbc>0)){
            if(str.compare(i,1,a)==0){
                counta ++;
            }else if(str.compare(i-1,2,bc)==0){
                ans += counta * countbc;
                                counta = 0;
                countbc++;
                i--;
            }else{
                ans += counta * countbc;
                counta = 0;
                countbc = 0;
            }
        }
    }

    ans += counta * countbc;
    counta = 0;

    if(str.compare(0,1,a)==0){
        counta ++;
        ans += counta * countbc;
    }

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

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int a,b,c,max;
    scanf("%d %d %d",&a,&b,&c);
    //2連続で毒入り食べると死
    if(a+b>=c) max=b+c;
    else max=a+2*b+1;  
  printf("%d",max);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int e[12],count=0;
  for(int i=0;i<12;i++){
    cin>>e[i];
  }
  sort(e,e+12);
  for(int i=0;i<12;i+=4){
    if(e[i]==e[i+3]){
      count++;
    }
  }
  if(count==3){
    cout<<"yes"<<"\n";
  }else{
    cout<<"no"<<"\n";
  }
  return 0;
}



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


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

	int l = s.size();


bool ans = true;
int count[3000];
	for(int i = 0;i < l;i++){
		for(int j = 0;j < l;j++){
			if(s[i] == s[j]){
				count[i]++;
			}
			
		}
		if(count[i]%2 ==1){
				ans = false;
			}
	}

	if(ans ==true){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" <<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);

    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    int max = vec[0],max_n = 0;
    for(int i=0;i<n;i++){
        if(max < vec[i]){
            max = vec[i];
            max_n = i;
        }
    }

    sort(vec.rbegin(),vec.rend());

    for(int i=0;i<n;i++){
        if(i != max_n){
            cout << max << endl;
        }
        else{
            cout << vec[1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2432
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());

        int ans;
        
        if(N+W>24)          ans = Math.abs(24-(N+W));
        else if(N+W==24)    ans = 0; 
        else                ans = N+W;
        
        
        System.out.println(ans);
    }

}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  int sum = 0;
  int last = 0;
  int last_num = 0;

  FOR(i,0,4){
    if(10-a[i]%10>last && a[i]%10!=0){
      last = 10-a[i]%10;
      last_num = i;
      // cout << last << endl;
    }
  }

  FOR(i,0,4){
    sum += a[i];
    sum += (10-a[i]%10)%10;
    // cout << sum << endl;
  }

  if(last==99) cout << sum << endl;
  else cout << sum - last << endl;
  
  
}



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

int main()
{
        int n;
        cin >> n;

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

                int x = i+1;

                if (x % 3 == 0) {
                        cout << " " << i+1;
                        continue;
                }

                while (1) {
                        if (x % 10 == 3) {
                                cout << " " << i+1;
                                break;
                        }
                        x /= 10;
                        if (x == 0) {
                                break;
                        }
                }
        }
        cout << endl;
}



Measured memory_bytes: 3100
N, *A = map(int, open(0).read().split())
mod = 10**9 + 7

ans = 0
for i in range(60):
    mask = 1 << i
    cnt = 0
    for a in A:
        if a & mask:
            cnt += 1
    x = cnt * (N-cnt)
    x *= mask % mod
    ans += x
    ans %= mod

print(ans)

Measured memory_bytes: 49232
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
from collections import *;M=lambda:map(int,input().split());r=range;n,k,l=M()
def f(m):
  *a,=r(n)
  def g(i):
    if a[i]==i:return i
    a[i]=g(a[i]);return a[i]
  for _ in r(m):p,q=M();a[g(q-1)]=g(p-1)
  return g
x,y=f(k),f(l);c=Counter((x(i),y(i))for i in r(n));print(*((c[x(i),y(i)])for i in r(n)))

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string ss;cin>>ss;
  int tot=0;
  rep(i,ss.size()){
      if(ss[i]=='p')tot++;
  }
  cout<<((int)ss.size())/2-tot<<endl;
  return 0;
  }


Measured memory_bytes: 512
#python3
MOD = 2019
def main():
    l, r = map(int, input().split())
    if r - l >= MOD:
        print(0)
        return
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            v = (i*j)%MOD
            ans = min(ans, v) 
    print(ans)
main()

Measured memory_bytes: 2940
n, a, b = [int(x) for x in input().split(' ')]

diff = abs(a - b)
if diff % 2 == 0:
    print(diff // 2)
else:
    x1 = min(a, b) + ((max(a, b) - min(a, b)) - 1) // 2
    x2 = min(n + 1 - a, n + 1 - b) + ((max(n + 1 - a, n + 1 - b) - min(n + 1 - a, n + 1 - b)) - 1) // 2
    print(min(x1, x2))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  string S;
  cin >> S;
  int res=0,ans=0;

  if(S.size()==1){
    if(S[0]=='A' || S[0]=='G' || S[0]=='C' || S[0]=='T') cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
  }
  rep(i,0,S.size()){
    rep(j,i+1,S.size()){
      res=0;
      rep(k,i,j+1){
        if(S[k]=='A' || S[k]=='G' || S[k]=='C' || S[k]=='T') res++;
        else{
          res=0;
          break;
        }
        chmax(ans,res);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


class PrimeFactorization{
 private:
  vector<int> primes;

 public:
  PrimeFactorization(int N){
    bool ckecked[N+1];
    fill(ckecked, ckecked+N+1, false);

    for (int i = 2, len=sqrt(N)+1; i < len; ++i) {
      if(ckecked[i]) continue;

      for (int j = i*2; j <= N; j += i) {
        ckecked[j] = true;
      }
    }

    for (int i = 2; i <= N; ++i) {
      if(!ckecked[i]) {
        primes.push_back(i);
      }
    }
  }

  map<int, int> get_pairs(int n){
    map<int, int> prime_frq_map;

    int index_primes = 0;
    while(n > 1){
      int prime = primes[index_primes];

      if(n % prime != 0) {
        index_primes++;
        continue;
      }

      //
      n /= prime;

      //
      if(prime_frq_map.find(prime) == prime_frq_map.end()) {
        prime_frq_map[prime] = 1;
      }else{
        prime_frq_map[prime] += 1;
      }
    }

    return prime_frq_map;
  }


};



//
int main(){
  int n;
  cin >> n;
//  int n = 1000;
  long threshold = pow(10, 9) + 7;


  PrimeFactorization pe(n);
  map<int, int> all_prime_frq_map;

  for (int i = 2; i <= n; ++i) {
    map<int, int> prime_frq_map = pe.get_pairs(i);
    for (auto pair: prime_frq_map) {
      int prime = pair.first;
      int frq = pair.second;

      if(all_prime_frq_map.find(prime) == all_prime_frq_map.end()) {
        all_prime_frq_map[prime] = frq;
      }else{
        all_prime_frq_map[prime] += frq;
      }
    }
  }


  long long num_divisor = 1;
  for (auto pair: all_prime_frq_map) {
//    cout << pair.first << "  " << pair.second << endl;
    num_divisor *= (pair.second+1);
    if(threshold < num_divisor) num_divisor %= threshold;
  }

  cout << num_divisor << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h[100005];
bool huai[100005];
int main()
{
	int m,n;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(h[a]==h[b])huai[a]=huai[b]=true;
		if(h[a]>h[b])huai[b]=true;
		else huai[a]=true;
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(huai[i]==false)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))

using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

ll n, m, s, t, a, b;
vi adj[100001];
int dist[3][100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n >> m;
    for(int i=0; i<3; i++)
    {
        for(int j=1; j<=100000; j++)
        {
            dist[i][j] = INF;
        }
    }
    for(int i=0; i<m; i++)
    {
        cin >> a >> b;
        adj[a].pb(b);
    }
    cin >> s >> t;
    dist[0][s]=0;
    priority_queue< pi, vector< pi >, greater< pi > > pq;
    pq.push({0, s});
    while(!pq.empty())
    {
        auto cur = pq.top();
        pq.pop();
        for(auto nxt : adj[cur.S])
        {
            for(int j=0; j<3; j++)
            {
                if(dist[(j+1)%3][nxt]>dist[j][cur.S]+1)
                {
                    dist[(j+1)%3][nxt]=dist[j][cur.S]+1;
                    pq.push({dist[j][cur.S], nxt});
                }
            }
        }
    }
    if(dist[0][t]==INF) cout << -1;
    else cout << dist[0][t]/3;
}


Measured memory_bytes: 6912
# coding: utf-8
# Your code here!
count = 0
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(n):
    if a[i] > b[i]:#倒しきれない
        count = count + b[i]
    else:
        if a[i+1] - (b[i] - a[i]) < 0:
            count = count + a[i] + a[i+1]
            a[i+1] = 0
        else:
            count = count + a[i] + (b[i] - a[i])
            a[i+1] = a[i+1] - (b[i] - a[i])
             
    
print(count)

Measured memory_bytes: 18476
#!/usr/bin/perl
my $s = <STDIN>;
$s =~ s/[\x00-\x20]+$//ios;

my $r = 'Yes';

for(my $i=0;$i<length($s);$i++){
  my $c1 = substr($s,$i,1);
  if( $i % 2 == 0 ){
    $r = 'No' unless $c1 =~ /[RUD]/o;
  } else {
    $r = 'No' unless $c1 =~ /[LUD]/o;
  }
}
print "$r\n";



Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N = 0;
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		ArrayList<String> ary = new ArrayList<String>();
		int max = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {
			int n = Integer.parseInt(sc.next());
			if (n >= max) {
				max = n;
				count++;
			}
		}
		System.out.println(count);
	}

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,s2;
	int j=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='B' && j>0)
		  j--;
		else
		{
			if(s[i]=='B')
			  continue;
			else
			  s2[++j]=s[i];
		}
	}
	for(int i=1;i<=j;i++)
	  cout<<s2[i];
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

ll A,B,C,K;
  cin>>A>>B>>C>>K;
  
  ll sum=0;
  sum+=min(K,A);
  K-=A;
  K-=B;
  if(K>0&&C>0){
  sum-=min(K,C);
  }
  cout<<sum<<endl;
    
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dp[105][4][2];

int main(){
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    dp[0][0][0] = 1;
    rep(i,n) rep(j,4) rep(k,2){
        int nd = s[i] - '0';
        rep(d, 10){
            int ni = i+1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > K) continue;
            if (k == 0){
                if (d > nd) continue;
                else if (d < nd) nk++;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

  
  // map <int, int> score;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  vector<vector<int>> a(k, vector<int> (n));
  map <int, int> score;
  rep (i, k) {
    cin >> d.at(i);
    rep (j, d.at(i)) {
      cin >> a.at(i).at(j);
      score[a.at(i).at(j)] = d.at(i);
    }
  }

  cout << n - score.size() << endl;

}


Measured memory_bytes: 3648
#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 ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vector<int> C(n), S(n), F(n);
    rep(i, n) cin >> C[i] >> S[i] >> F[i];

    rep(i, n-1) {
        int cur = 0;
        REP(j, i, n-1) {
            chmax(cur, S[j]);
            cur += (F[j] - cur % F[j]) % F[j];
            cur += C[j];
            // cout << " " << cur ;
        }
        cout << cur << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

int h, w, n, r, c;
string s, t;

int main()
{
    cin >> h >> w >> n >> r >> c >> s >> t;
    int lh = 1, rh = h, lw = 1, rw = w;
    for (int i = n - 1; i >= 0; i--)
    {
        switch (t[i])
        {
        case 'L':
            rw = min(w, rw + 1);
            break;
        case 'R':
            lw = max(1, lw - 1);
            break;
        case 'U':
            rh = min(h, rh + 1);
            break;
        case 'D':
            lh = max(1, lh - 1);
            break;
        }
        switch (s[i])
        {
        case 'L':
            lw++;
            break;
        case 'R':
            rw--;
            break;
        case 'U':
            lh++;
            break;
        case 'D':
            rh--;
            break;
        }
        if (lh > rh || lw > rw)
            return printf("NO\n"), 0;
    }
    if (lh > r || rh < r || lw > c || rw < c)
        printf("NO\n");
    else
        printf("YES\n");
}


Measured memory_bytes: 776
/*
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=200020;
int n,a[MAX];
ll s;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]),a[i]-=i;
    sort(a,a+n);
    for(int i=0;i<n;i++) s+=(ll)abs(a[n/2]-a[i]);
    printf("%lld\n",s);
}
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=200020;
const ll INF=(1ll<<63)-1ll;
ll n,a[MAX],s[MAX],ans=INF;
ll f(ll x,ll y){
    return s[y]-s[x];
}
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    for(int i=0;i<n;i++) s[i+1]=s[i]+a[i];
    int pt1=1,pt2=2,pt3=3;
    for(int pt2=2;pt2<=n-1;pt2++){
        while(f(0,pt1)<f(pt1,pt2)) pt1++;
        if(abs(f(0,pt1-1)-f(pt1-1,pt2))<abs(f(0,pt1)-f(pt1,pt2))) pt1--;
        while(f(pt2,pt3)<f(pt3,n)) pt3++;
        if(abs(f(pt2,pt3-1)-f(pt3-1,n))<abs(f(pt2,pt3)-f(pt3,n))) pt3--;
        ans=min(max(max(f(0,pt1),f(pt1,pt2)),max(f(pt2,pt3),f(pt3,n)))-min(min(f(0,pt1),f(pt1,pt2)),min(f(pt2,pt3),f(pt3,n))),ans);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
n = int(input())
l = list(map(int, input().split()))

ans = [0, abs(l[0]-l[1])]
for i in range(2, n):
  ans.append(min(abs(l[i]-l[i-1])+ans[i-1], abs(l[i]-l[i-2])+ans[i-2]))

print(ans[n-1])

Measured memory_bytes: 13980
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[]A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		scan.close();
		disp(A, N);
		insertionSort(A, N);
	}
	static void insertionSort(int[]A, int n) {
		for(int i = 1; i < n; i++) {
			int v = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > v) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = v;
			disp(A, n);
		}
	}
	static void disp(int[]A, int n) {
		for(int i = 0; i < n; i++) {
			if(i == n - 1) {
				System.out.println(A[i]);
			}else {
				System.out.print(A[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 31228
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
typedef long long ll;
const int N=309;
int n,m,mod,C[N][N],f[N][N],g[N][N];
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int main()
{
	n=read(),m=read(),mod=read();
	C[0][0]=1;
	for (int i=1;i<N;i++)
		for (int j=0;j<=i;j++) C[i][j]=(C[i-1][j]+(j?C[i-1][j-1]:0))%mod;
	for (int i=0;i<=m;i++) f[1][i]=1,g[1][i]=m-i+1;
	for (int i=2;i<=n+1;i++)
		for (int j=0;j<=m;j++)
		{
			for (int k=1;k<i;k++)
				f[i][j]=(f[i][j]+(ll)C[i-2][k-1]*f[i-k][j]%mod*g[k][j+1])%mod;
			for (int k=1;k<=j;k++) g[i][k]=(g[i][k]+f[i][j])%mod;
		}
	printf("%d\n",f[n+1][0]);
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;

    vector<vector<int>> g(n+1);
    vector<int> deg(n+1);
    for(int i=1;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
        deg[x]++;
        deg[y]++;
    }
    queue<int> q;
    for(int i=1;i<=n;++i)
    {
        if(deg[i]==1)
            q.push(i);
    }
    vector<int> ans(n+1),c(n);
    for(int i=0;i<n;++i)cin>>c[i];
    sort(c.begin(),c.end());
    int sum = 0;
    auto it = c.begin();
    while(!q.empty())
    {
        int t = q.front();
        q.pop();
        ans[t] = *it;
        sum += *it;
        it++;
        for(int o:g[t])
        {
            deg[o]--;
            if(deg[o]==1)
                q.push(o);
        }
    }
    cout<<sum-c.back()<<endl;
    for(int i=1;i<=n;++i)
    {
        cout<<ans[i]<<" ";
    }
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

ll a[200000];
ll sum[200001];

int main() {
	int N;
	scanf("%d", &N);
	rep(i, N) scanf("%lld", &a[i]);
	sum[0] = a[0];
	FOR(i, 1, N) sum[i] = sum[i - 1] + a[i];
	ll res = LLONG_MAX;
	rep(i, N - 1) {
		ll a = sum[i];
		ll b = sum[N - 1] - sum[i];
		ll tmp = a - b;
		if(tmp < 0) tmp = -tmp;
		if(res > tmp) res = tmp;
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 3328
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: White Cells
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int h, w, bh, bw;
  scanf("%d%d%d%d", &h, &w, &bh, &bw);

  printf("%d\n", (h - bh) * (w - bw));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll a, b, c, d, e;
	cin >> a >> b >> c >> d;
	e = lcm(c, d);
	vector<ll> x(3);
	vector<ll> y(3);
	vector<ll> z(3);
	if (a % c == 0) {
		x[0] = (a / c) - 1;
	}
	else {
		x[0] = a / c;
	}
	y[0] = b / c;
	z[0] = y[0] - x[0];

	if (a % d == 0) {
		x[1] = (a / d) - 1;
	}
	else {
		x[1] = a / d;
	}
	y[1] = b / d;
	z[1] = y[1] - x[1];

	if (a % e == 0) {
		x[2] = (a / e) - 1;
	}
	else {
		x[2] = a / e;
	}
	y[2] = b / e;
	z[2] = y[2] - x[2];

	ll cnt = z[0] + z[1] - z[2];
	ll res = b - a + 1 - cnt;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
    ll n;
    cin >> n;
    cout << (n - 1) * n  / 2 << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

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

using ll = long long;

int main()
{
    int N, M;
    cin >> N >> M;
    map<int, int> m;
    int b1, b2;
    bool check = true;
    for(int i = 0; i< M; i++){
        cin >> b1 >> b2;
        if(m.find(b1) == m.end()){
            m[b1] = b2;
        }else{
            if(m[b1] != b2){
                check = false;
            }
        }
    }

    if(!check){
        cout << -1 << endl;
        return 0;
    }

    if(m.find(1) != m.end()){
        if(m[1] == 0){
            if(N != 1){
                cout << -1 << endl;
                return 0;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }
    }

    if(m.find(1) == m.end()){
        if(N == 1){
            cout << 0 << endl;
            return 0;
        }
    }

    

    string num;

    for(int i = 1; i<=N; i++){
        if(m.find(i) != m.end()){
            num += '0'+ m[i];
        }else{
            if(i == 1){
                num += '1';
            }else{
                num += '0';
            }
        }
    }

    cout << num << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cout << v << " ";                                                          \
  }                                                                            \
  cout << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N);
  REP(i, N) cin >> a[i];

  //尺取り法
  int ans = 0;
  vec< vec< int > > sum(N + 2, vec< int >(20, 0));
  REP(i, N) {
    REP(j, 20) {
      if (a[i] & BIT(j)) {
        sum[i + 1][j] = sum[i][j] + 1;
      } else {
        sum[i + 1][j] = sum[i][j];
      }
    }
  }
  REP(j, 20) { sum[N + 1][j] = INF; }
  // REP(i, N) { PRINTALL(sum[i]); }
  int l, r, prevl = 0;
  REP(i, N) {
    l = prevl;
    r = N;
    while (r - l > 1) {
      int lr = (l + r) / 2;
      bool check = true;
      REP(j, 20) {
        if (sum[lr + 1][j] - sum[i][j] >= 2) {
          check = false;
          break;
        }
      }
      if (check) {
        l = lr;
      } else {
        r = lr;
      }
      //  DEBUG(l);
      //  DEBUG(r);
    }
    //  DEBUG(i);
    //  DEBUG(l);
    prevl = l;
    ans += l + 1 - i;
  }
  print(ans);
}

Measured memory_bytes: 40832
#include<stdio.h>
int main(void)
{
   int W,H,x,y,r;
   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
   if(W<x+r||x-r<0||H<y+r||y-r<0){
      printf("No\n");
   }else{
      printf("Yes\n");
   }
   return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int n,m;
	cin >> n >> m;

	int tb[300],ta[300];
	for(int i=1; i<=2*n; i++){
		tb[i] = i;
	}

	for(int i=0; i<m; i++){
		int ope;
		cin >> ope;

		if(ope == 0){
			for(int j=1; j<=2*n; j++){
				if(j<n+1){
					ta[2*j-1] = tb[j];
				}
				else{
					ta[(j-n)*2] = tb[j];
				}
			}
		}

		else{
			for(int j=1; j<=2*n; j++){
				if(j<ope+1){
					ta[n*2-ope+j] = tb[j];
				}
				else{
					ta[j-ope] = tb[j];
				}
			}
		}


		for(int j=1; j<=2*n; j++){
			tb[j] = ta[j];
		}


	}

	for(int i=1; i<=2*n; i++){
		cout << tb[i] << endl;
	}

	return 0;

}



Measured memory_bytes: 3088
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	char s[101];
	bool isC = false;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (s[i] == 'C') {
			isC = true;
		} else if (s[i] == 'F' && isC) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;


int main() {
    ll k, n;
    cin >> k >> n;

    vector<ll> lake(n);
    rep(i, n) cin >> lake[i];

    rep(i, n) lake.push_back(lake[i] + k);

    ll ans = INF;
    rep(i, n) {
        ll now = lake[i + n - 1] - lake[i];
        cmin(ans, now);

    }
    cout << ans << endl;

}


Measured memory_bytes: 4736
#セグメント木のverify

class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*2**(self.K+1)

        for i in range(self.n):
            self.seg[i+2**self.K-1] = lists[i]

        for i in range(2**(self.K)-2, -1, -1):
            self.seg[i] = self.func(self.seg[2*i+1], self.seg[2*i+2])

    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        k += 2**self.K-1
        self.seg[k] = value
        while k:
            k = (k-1)//2
            self.seg[k] = self.func(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q):
        # 0-indexで[p,q)の値を取得する
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res

import sys
input=sys.stdin.readline
N=int(input())
S=list(input())
Q=int(input())
que=[tuple(input().split()) for i in range(Q)]
alpha="abcdefghijklmnopqrstuvwxyz"
Data={alpha[i]:[0]*N for i in range(26)}
for i in range(N):
    Data[S[i]][i]+=1
SEG={alpha[i]:SegTree(Data[alpha[i]],max,0) for i in range(26)}
for X,u,v in que:
    if X=="1":
        u=int(u)-1
        NOW=S[u]
        S[u]=v
        SEG[NOW].update(u,0)
        SEG[v].update(u,1)
    else:
        u,v=int(u)-1,int(v)-1
        res=0
        for j in range(26):
            res+=SEG[alpha[j]].query(u,v+1)
        print(res)
            
        
    
    

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

int main()
{
        ll N; cin >> N;
        vector<ll> a(N, 0);
        for (int i = 0; i < N; ++i) {
                cin >> a[i];
        }
        vector<ll> o;
        vector<ll> e;
        for (int i = 0; i < N; ++i) {
                if (i % 2) {
                        o.push_back(a[i]);
                }
                else {
                        e.push_back(a[i]);
                }
        }
        vector<ll> b;
        for (int i = o.size(); i > 0; --i) {
                b.push_back(o[i-1]);
        }
        for (int i = 0; i < e.size(); ++i) {
                b.push_back(e[i]);
        }
        if (N % 2 == 0) {
                for (int i = 0; i < N; ++i) {
                        cout << b[i] << " ";
                }
        }
        else {
                for (int i = N; i > 0; --i) {
                        cout << b[i-1] << " ";
                }
        }
        cout << endl;

}


Measured memory_bytes: 7016