akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

string S;
int N, l_m = 0, r_m = 0;
vector<vector<bool> > alphabet(26,vector<bool>(2));
int kind = 0;
int main(){
  cin >> N;
  cin >> S;
  rep(i,26){
    rep(j,1){
      alphabet[i][j] = false;
    }
  }
  rep(i,N){
    if(!alphabet[(S[i]-97)%26][0]){
      alphabet[((S[i]-97)%26)][0] = true;
    }
  }
  rep(i,N){
    int l_kind = 0, r_kind = 0;
    rep(j,N){
      if(j <= i){
        if(!alphabet[((S[j]-97)%26)][1]){
          l_kind++;
          alphabet[((S[j]-97)%26)][1] = true;
        }
      }
      else if(N > j){
        if(alphabet[((S[j]-97)%26)][1]){
          r_kind++;
          alphabet[((S[j]-97)%26)][1] = false;
        }
      }
    }
    rep(idx,26) alphabet[idx][1] = false;
    if(l_m < l_kind) l_m = l_kind;
    if(r_m < r_kind) r_m = r_kind;
  }
  if(l_m > r_m) cout << r_m << endl;
  else cout << l_m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
using namespace std;
int main()
{
	set<int> se;
	for(int i = 1; i <= 30; i++) se.insert(i);
	for(int i = 0, t; i < 28; i++)
		scanf("%d\n", &t), se.erase(t);
	for(set<int>::iterator it = se.begin(); it != se.end(); it++)
		printf("%d\n", *it);
	return 0;
}

Measured memory_bytes: 0
<?php

while ($stdin = fgets(STDIN)) {
    $line[] = trim($stdin);
}
foreach ($line as $key => $value) {
    $data[] = explode(' ', $value);
}

foreach ($data as &$line) {
    $line = array_map(function($val) { return (int)$val; }, $line);
}

$N = $data[0][0];
$L = $data[0][1];
$tastes = [];

for ($i = 0;$i < $N; $i++) {
    $tastes[] = $L + $i;
    $abs[] = abs($L + $i);
}

$minKey = array_keys($abs, min($abs))[0];
$ans  = array_sum($tastes) - $tastes[$minKey];

printf('%d', $ans);



Measured memory_bytes: 4728
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
  function compareFunc(a, b) {
  return a - b;
}
input.sort(compareFunc);
    console.log(input[0]*input[1]/2)
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import numpy as np
n=input()
n=int(n)
k=np.log10(n)
k=int(k)
a=0
if k % 2 == 0:
  a+=n-10**k+1
if n>=100000:
  a+=90909
elif n>=1000:
  a+=909
elif n>=10:
  a+=9
print(a)

Measured memory_bytes: 12392
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
using namespace std;
#define fastestiointhewest   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll          long long
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define mii         map<int,int>
#define vi          vector<int>
#define vll         vector<long long>
#define all(a)      (a).begin(),(a).end()
#define clz(a)      __builtin_clz(a) // count leading zeroes
#define ctz(a)      __builtin_ctz(a) // count trailing zeroes
#define popc(a)     __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define SIZE        1000005
#define F           first
#define S           second
#define debug(x)    cerr << #x << " = " << x << endl;
#define mod         998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl        '\n'
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
   int n; cin>>n;
   ll a[n];
   rep(i,0,n) cin>>a[i];
   ll ans=0,chck=0;
   rep(i,0,n)
   {
      chck+=(a[i]<0);
      ans+=abs(a[i]);
      a[i]=abs(a[i]);
   }
   if(chck%2) ans-=2*(*min_element(a,a+n));
   cout<<ans;
} 
int main()
{   
    fastestiointhewest;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	string abc = "ABC";
	int ans = 0;
	rep(i, n - 2)
	{
		bool find = true;
		rep(j, 3)
		{
			if(s[i+j] != abc[j])
				find = false;
		}
		if(find)
			ans++;
	}
	cout << ans << endl;
}


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

int main(void)
{
    double x1,y1,x2,y2,bottom,height,n;
    
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    
    bottom=pow((x2-x1),2);
    height=pow((y2-y1),2);
    
    n=sqrt(bottom+height);
    
    printf("%f\n",n);
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
//#define endl '\n'
 
int main() {
    int n;
    cin >> n;
    int result = 0;
    rep1(i,n){
        int j = i;
        int keta = 0;
        while(j){
            keta++;
            j /= 10;
        }
        if(keta%2 == 1){
            result++;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,y,h,w;
	cin>>h>>w;
	int count[h+3][w+3]={};
	char c[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				for(y=0;y<3;++y){
					for(x=0;x<3;++x){
						count[i+y][j+x]++;
					}
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(c[i][j]=='#'){
				cout<<c[i][j];
			}else{
				cout<<count[i+1][j+1];
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int d;
  cin>>d;
  vector<int>c(26);
  for(int i=0;i<26;i++){
    cin>>c[i];
  }
  vector<vector<int>>s(d,vector<int>(26));
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++){
      cin>>s[i][j];  
    }
  }
  for(int i=0;i<d;i++){
    int a=0,b=0;
    for(int j=0;j<26;j++){ 
      if(s[i][j]>a){a=s[i][j];b=j;}
    }cout<<b+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<int> v(n);
    int sum=0;
    for(int i=0;i<n;i++)cin>>v[i],sum+=v[i];
    for(int i=0;i<n;i++){
        if(sum-v[i]<=v[i]){cout<<"No";return 0;}
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    ll N, L, T;
    cin>>N>>L>>T;
    ll X[N], W[N];
    ll a;
    rep(i, N){
        cin>>X[i]>>W[i];
        if(i==0){
            a=X[i];
            X[i]=0;
        }
        else{
            X[i]-=a;
        }
    }
    ll cnt=0;
    if(W[0]==1){
        rep(i,N){
            if(W[i]==2){
                cnt+=dv1(2*T-X[i], L);
                X[i]=mod(X[i]-2*T, L);
            }
        }
        sort(X, X+N);
        cnt%=N;
        rep(i, N){
            cout<<(X[(N-cnt+i)%N]+T+a)%L<<endl;
        }
    }
    else{
        rep(i, N){
            if(W[i]==1){
                cnt+=(X[i]+2*T)/L;
                X[i]=(X[i]+2*T)%L;
            }
        }
        sort(X, X+N);
        cnt%=N;
        rep(i, N){
            cout<<mod(X[(cnt+i)%N]-T+a, L)<<endl;
        }
    }
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

string s;

signed main()
{

    cin >> s;

    string a = "Sunny";
    string b = "Cloudy";
    string c = "Rainy";

    if(s==a){
        print(b);
    }
    else if(s==b){
        print(c);
    }
    else if(s==c){
        print(a);
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N, L, Q;
int x[101010];
int bk[17][101010];
 
signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> N;
  REP(i,N) cin >> x[i];
  cin >> L >> Q;

  int pre = 0;
  for (int i=0; i<N; i++) {
    while (x[i] - x[pre] > L) pre++;
    bk[0][i] = pre; //i番目の頂点から次に行ける最も左の頂点番号
  }

  for (int i=1; i<17; i++) {
    for (int j=0; j<=N; j++) {
      bk[i][j] = bk[i-1][bk[i-1][j]];
    }
  }

  for (; Q--;) {
    int a, b;
    cin >> a >> b;
    a--; b--;

    if (a == b) {
      puts("0");
      continue;
    }
    if (a > b) swap(a, b);

    int ret = 0;
    for (int i=16; i>=0; i--) {
      if (bk[i][b] > a) {
        ret += 1 << i;
        b = bk[i][b];
      }
    }

    cout << ret + 1 << endl;
  }
}

Measured memory_bytes: 14976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 3010

int water[SIZE] = {0}, sug[SIZE] = {0};

int gcd (int a, int b) {
   if (a < b) swap(a, b);
   return ((b == 0) ? a : gcd(b, a % b));
}

int main() {
   int A, B, C, D, E, F;
   cin >> A >> B >> C >> D >> E >> F;
   int g = gcd(A, B);
   water[0] = 1;
   for (int i = A ; i <= F / 100 ; ++i) {
      if (water[(i - A) * 100] || (i >= B && water[(i - B) * 100])) water[i * 100] = 1;
   } 
   g = gcd(C, D);
   for (int i = C ; i <= F ; ++i) {
      if (sug[i - C] == i - C || (i >= D && sug[i - D] == i - D)) {
         sug[i] = i;
      }
   } 

   int prv = 0;
   for (int i = 0 ; i <= F ; ++i) {
      if (sug[i] == i) prv = i;
      sug[i] = prv;
   }

   int tot = 0, ss = 0, curr = 0;
   double dens = -1.0, cur = 0.0;
   for (int i = 0 ; i <= F ; i += 100) {
      if (!water[i]) continue;
      int exp = (E * i) / 100;
      while (exp > 0 && sug[exp] + i > F) {
         exp = sug[exp] - 1;
      }
      curr = sug[exp] + i;
      if (curr > F) continue;
      cur = ((db)sug[exp] / (db)curr);
      if (cur > dens) {
         dens = cur;
         ss = sug[exp];
         tot = curr;
      }
   }

   cout << tot << " " << ss << endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cctype>
using namespace std;
int a[300010];
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
    	int i;
    	for(i = 0; i < n * 3; i++)
    		scanf("%d", &a[i]);
    	sort(a, a + 3 * n);
    	long long sum = 0;
    	for(i = n * 3 - 2; n > 0; i -= 2)
    	{
    		//printf("%d ", a[i]);
    		sum += a[i], n--;
    	}
    	cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int t[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",t+i);
	std::sort(t,t+a);
bool ok=true;
	if(a%2==0){
		for(int i=0;i<a;i++){
			if(t[i]!=i/2*2+1)ok=false;
		}
		if(!ok)printf("0\n");
		else{
			int f=a/2;
			long long ret=1;
			for(int i=0;i<f;i++)ret=ret*2%mod;
			printf("%lld\n",ret);
		}
	}else{
		for(int i=0;i<a;i++){
			if(t[i]!=(i+1)/2*2)ok=false;
		}
		if(!ok)printf("0\n");
		else{
			int f=a/2;
			long long ret=1;
			for(int i=0;i<f;i++)ret=ret*2%mod;
			printf("%lld\n",ret);
		}
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main(){
	int n; cin>>n;
	vector<pair<int, int> >p;
	vector<int> v;
	rep(i,n){
		int a; cin >> a;
		p.push_back(make_pair(a,i));
		v.push_back(a);
	}
	sort(all(v));
	sort(all(p));
	rep(i,n){
		if(i <= n/2-1) p[i].first = v[n/2];
		else p[i].first = v[n/2-1];
		swap(p[i].first, p[i].second);
	}
	sort(all(p));
	rep(i,n){
		cout << p[i].second << endl;
	}
}


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

int main() {
    int a, k = 0;
    cin >> a;
    if (a / 100 == 7) {
        k++;
    }
    if ((a / 10) % 10 == 7) {
        k++;
    }
    if (a % 10 == 7) {
        k++;
    }

    if (k == 0) {
        cout << "No";
    }
    if(k>0) {
        cout << "Yes";
    }

}

Measured memory_bytes: 3624
def main():
    import sys
    input = sys.stdin.readline

    n,a,b = map(int,input().split())
    c_1 = (n // (a + b)) * a
    p = n % (a + b)
    c_2 = min(p,a)
    print(c_1+c_2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    string S;
    cin >> S;

    auto aitr = S.find("a");
    auto bitr = S.find("b");
    auto citr = S.find("c");

    if (aitr != string::npos && bitr != string::npos && citr != string::npos) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        List<string> ss = new List<string>();
        List<long> tt = new List<long>();

        for (int i = 0; i < n; i++)
        {
            ss.Add(sc.Next());
            tt.Add(sc.NextLong());
        }

        string x = sc.Next();

        long index = ss.IndexOf(x);

        long answer = tt.Where((item, i) => i > index).Sum();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28344
#include <stdio.h>
#include <string.h>
#include<algorithm>
#define mod 1000000007;
using namespace std;

int main()
{
    long long yu[100005];
    yu[0]=1;
    yu[1]=1;
    yu[2]=2;
    for(int x=3; x<=100000; x++)
    {
        yu[x]=yu[x-1]+yu[x-2];
        yu[x]%=mod;
    }
    long long n,m;
    scanf("%lld%lld",&n,&m);
    long long a[100005];
    a[0]=-1;
    for(long long x=1; x<=m; x++)
    {
        scanf("%lld",&a[x]);
    }
    a[m+1]=n+1;
    long long ans=1;
    for(long long x=1; x<=m+1; x++)
    {
        if((a[x]-1)-(a[x-1]+1)>=0)
        {
            ans*=yu[(a[x]-1)-(a[x-1]+1)];

            ans%=mod;
        }
        else
        {
            ans=0;
        }

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


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

/// Lib
///

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    const string yes = "Yes";
    const string no = "No";

    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i< n; ++i) {
        cin >> h[i];
    }
    int prev = h[0];
    string ans = yes;
    for(int i = 1; i < n; ++i) {
        if(prev <= h[i]){
            prev = h[i];
            continue;
        }
        else if(prev - 1 == h[i]){
            prev == h[i];
        }
        else{
            ans = no;
            break;
        }
    }

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> nums(n);
    long long ans=0;
    for(int i=0;i<n;i++) {
        int a; scanf("%d",&a);
        nums[i]=a-(i+1);
    }
    sort(nums.begin(),nums.end());
    int b;
    if(n%2==0) b=((nums[(n-1)/2]+nums[n/2])/2);
    else b=nums[n/2];
    for(int i=0;i<n;i++){
        ans+= abs(nums[i]-b);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {
	string st;
	int ans = 0;
	while (getline(cin,st)) {
		int num=0;
		for (auto c : st) {
			if (isdigit(c)) {
				num*=10;
				num+=c-'0';
			}
			else {
				ans+=num;
				num=0;
			}
		}
		ans+=num;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2996
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int main() {
    cout<<"square1001"<<endl;
    return 0;}


Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 10010
#define ll long long
#define mod 998244353
using namespace std;
ll ksm(ll a,ll b=mod-2)
{
	if(b==0) return 1;
	if(b==1) return a;
	ll q=ksm(a,b>>1);
	if(b&1)return q*q%mod*a%mod;
	return q*q%mod;
}
ll fac[N],inv[N];
int f[N][N];
ll C(int a,int b)
{
	if(b<0 || b>a) return 0;
	if(a==b || b==0) return 1;
	return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
char s1[N],s2[N];
int main()
{
	int n,m;
	scanf("%s%s",s1,s2);
	n=strlen(s1);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	int sum1=0,sum2=0;
	for(int i=0;i<n;i++)
	sum1+=s1[i]=='1' && s2[i]=='1';
	for(int i=0;i<n;i++)
	sum2+=s1[i]=='1' && s2[i]=='0';
	for(int i=0;i<=sum2;i++) f[0][i]=fac[i]*fac[i]%mod;
	for(int i=1;i<=sum1;i++)
        for(int j=1;j<=sum2;j++)
            f[i][j]=(1ll*f[i-1][j]*i%mod*j%mod+1ll*f[i][j-1]*j%mod*j%mod)%mod;
    ll ans=0;
    for(int i=0;i<=sum1;i++)
    ans=(ans+1ll*f[sum1-i][sum2]*fac[i]%mod*fac[i]%mod*C(sum1,i)%mod*C(sum1+sum2,i))%mod;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 389888
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

namespace MF {
	#define MAXN 50000
	#define MAXM 500000
	#define wint int
	const wint wEPS = 0;
	const wint wINF = 1001001001;
	int n, m, ptr[MAXN], next[MAXM], zu[MAXM];
	wint capa[MAXM], tof;
	int lev[MAXN], see[MAXN], que[MAXN], *qb, *qe;
	void init(int _n) {
		n = _n; m = 0; memset(ptr, ~0, n * 4);
	}
	void ae(int u, int v, wint w0, wint w1 = 0) {
		next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w0; ++m;
		next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = w1; ++m;
	}
	wint augment(int src, int ink, wint flo) {
		if (src == ink) return flo;
		wint f;
		for (int &i = see[src]; ~i; i = next[i]) if (capa[i] > wEPS && lev[src] < lev[zu[i]]) {
			if ((f = augment(zu[i], ink, min(flo, capa[i]))) > wEPS) {
				capa[i] -= f; capa[i ^ 1] += f; return f;
			}
		}
		return 0;
	}
	bool solve(int src, int ink, wint flo = wINF) {
		wint f;
		int i, u, v;
		for (tof = 0; tof + wEPS < flo; ) {
			qb = qe = que;
			memset(lev, ~0, n * 4);
			for (lev[*qe++ = src] = 0, see[src] = ptr[src]; qb != qe; ) {
				for (i = ptr[u = *qb++]; ~i; i = next[i]) if (capa[i] > wEPS && !~lev[v = zu[i]]) {
					lev[*qe++ = v] = lev[u] + 1; see[v] = ptr[v];
					if (v == ink) goto au;
				}
			}
			return 0;
		au:	for (; (f = augment(src, ink, flo - tof)) > wEPS; tof += f);
		}
		return 1;
	}
}

int H, W;
char A[110][110];

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		scanf("%s", A[i]);
	}

	int s, t;
	MF::init(H * W * 2 + H + W);

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int id = i * W + j;

			if (A[i][j] == 'S') s = id;
			if (A[i][j] == 'T') t = id;

			if (A[i][j] != '.') {
				MF::ae(id * 2, id * 2 + 1, 1, 0);
				MF::ae(id * 2 + 1, H * W * 2 + j, 1000);
				MF::ae(id * 2 + 1, H * W * 2 + W + i, 1000);
				MF::ae(H * W * 2 + j, id * 2, 1000);
				MF::ae(H * W * 2 + W + i, id * 2, 1000);
			}
		}
	}
	
	MF::solve(s * 2 + 1, t * 2);
	int ret = MF::tof;
	if (ret > 200) ret = -1;
	printf("%d\n", ret);

}


Measured memory_bytes: 4992
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

S = input().rstrip('\n')
left = ''
now = ''
ans = 0
for i in range(len(S)):
    now += S[i]
    if left != now:
        ans += 1
        left = now
        now = ''
    # print(S[i], ans)
print(ans)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
	int dat1[100005],dat2[100005];
using namespace std;
int main(){

	int n,m;
	cin>>n>>m;
	if(!(n&1)) n--;
	int mm = (n-1)/2;
	if(mm&1){
		for(int i=1;i<=mm/2;i++){
			dat1[i] = i;
			dat2[i] = (n+1)/2 - i;
		}
		for(int j=(n+1)/2,i = mm/2+1,k=0;i<=mm;i++,j++,k++){
			dat1[i] = j;
			dat2[i] = n - k;
		}
	}
	else{
		for(int i=1;i<=mm/2;i++){
			dat1[i] = i;
			dat2[i] = (n+3)/2 - i;
		}
		for(int i=(n+3)/2,j=n,k=mm/2+1;k<=mm;i++,j--,k++){
			dat1[k] = i;
			dat2[k] = j;
		}
	}
	//for(int i=1;i<=6;i++) cout<<dat1[i]<<" "<<dat2[i]<<endl;
	for(int i=1;i<=m;i++) cout<<dat1[i]<<" "<<dat2[i]<<endl;
	return 0;
}


Measured memory_bytes: 4300
N,M = map(int, input().split())
 
s = [list(map(int, input().split()))[1:] for _ in range(M)]
p = list(map(int, input().split()))
 
cnt = 0
 
for i in range(2 ** N):  # スイッチの全部の組み合わせについて
    flag = True
    for j in range(M): # 全ての電球がonとなる条件となっているか確認, i>>k-1で数値iをbitに変換、1(ON)の立っている数を数える
        if not([(i >> k-1) & 1  for k in s[j]].count(1) % 2 == p[j]):
            flag = False
    if flag:
        cnt += 1
 
print(cnt)

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

int main() {
    int k, a, b;
    bool flag = false;
    cin >> k;
    cin >> a >> b;

    int i = a;
    while(i <= b){
        if(i % k == 0){
            flag = true;
            break;
        }
        i++;
    }
    if(flag == 1){
        cout << "OK";
    }else{
        cout << "NG";
    }
}

Measured memory_bytes: 3580
class MinSegTree:
    """
    0-indexed
    query : [L, R)
    """
    def __init__(self, size):
        self.size = 1 << (size.bit_length())  # 完全二分木にする
        self.data = [INF] * (2 * self.size - 1)

    def build(self, rawData):
        self.data[self.size - 1: self.size - 1 + len(rawData)] = rawData
        for i in range(self.size - 1)[:: -1]:
            self.data[i] = min(self.data[2 * i + 1], self.data[2 * i + 2])

    def update(self, index, value):
        index += self.size - 1
        if self.data[index] <= value:
            return
        self.data[index] = value
        while index >= 0:
            index = (index - 1) // 2
            self.data[index] = min(self.data[2 * index + 1], self.data[2 * index + 2])

    def query(self, left, right):
        L = left + self.size
        R = right + self.size
        ret = INF
        while L < R:
            if R & 1:
                R -= 1
                ret = min(ret, self.data[R - 1])
            if L & 1:
                ret = min(ret, self.data[L - 1])
                L += 1
            L >>= 1
            R >>= 1
        return ret

N, Q = map(int, input().split())
INF = N - 2
treeRow = MinSegTree(N + 2)
treeCol = MinSegTree(N + 2)

miRow = N - 1
miCol = N - 1
ans = (N - 2)**2

for q in range(Q):
    q, x = map(int, input().split())

    if q == 1:
        col = x
        ans -= treeRow.query(col, N)
        miCol = min(col, miCol)
        treeCol.update(miRow, col - 2)
    if q == 2:
        row = x
        ans -= treeCol.query(row, N)
        miRow = min(row, miRow)
        treeRow.update(miCol, row - 2)

print(ans)


Measured memory_bytes: 102808
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<int> to[200009];
vector<int> ans;
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return(0);
}


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

using namespace std;

typedef long long int ll;

const int N = (int) 100 + 10;
const int W = (int) 1e5 + 10;
const ll oo = 1e18;

int n, w;
pair<int, int> items[N];
ll memo[N][W];

ll dp(int at, int left) {
    if(left < 0) return -oo;
    if(at == n) return 0;
    ll &ans = memo[at][left];
    if(ans != -1) return ans;
    ll choose = items[at].second + dp(at + 1, left - items[at].first);
    ll skip = dp(at + 1, left);
    return ans = max(choose, skip);
}

void solve() {
    cin >> n >> w;
    for(int i = 0; i < n; ++i) {
        cin >> items[i].first >> items[i].second;
    }
    memset(memo, -1, sizeof(memo));
    cout << dp(0, w) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxN = 1e5 + 10;

vector <int> adj[maxN];
int h[maxN], par[maxN];

void DFS(int v, int p = -1)
{
	par[v] = p;
	for (auto u : adj[v])
		if(u != p){
			h[u] = h[v] + 1;
			DFS(u, v);
		}
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i=0; i<n-1; i++)
	{
		int u, v; cin >> u >> v;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}

	DFS(0);

	int mx = -1, v = 0, u = 0;
	for (int i=0; i<n; i++)
		if(h[i] > mx) mx = h[i], v = i;
	
	h[v] = 0;
	DFS(v);


	mx = -1;
	for (int i=0; i<n; i++)
		if(h[i] > mx) mx = h[i], u = i;
	
	//cout << v << ',' << u << " ---> " << h[u] << endl;

	int sum = 0;

	int curr = u;
	while(curr != -1)
	{
		sum += (int)adj[curr].size();
		curr = par[curr];
	}

	sum -= 2 * h[u];

	if(sum != n - h[u] - 1) return cout << -1 << endl, 0;

	vector <int> v1, v2;

	curr = u;
	int now = 0;

	while(curr != -1)
	{
		now ++;
		if(adj[curr].size() == 1) v1.pb(now);
		else
		{
			int d = (int)adj[curr].size() - 2;
			for (int j=0; j<d; j++) v1.pb(now + j + 1);
			v1.pb(now);
			now += d;
		}
		curr = par[curr];
		

	}

	h[u] = 0; DFS(u);

	curr = v;
	now = 0;
	while(curr != -1)
	{
		now ++;
		if(adj[curr].size() == 1) v2.pb(now);
		else
		{
			int d = (int)adj[curr].size() - 2;
			for (int j=0; j<d; j++) v2.pb(now + j + 1);
			v2.pb(now);
			now += d;
		}
		curr = par[curr];
	}

	for (int i=0; i<n; i++)
		if(v1[i] < v2[i])
		{
			for (int j=0; j<n; j++) cout << v1[j] << ' ';
			cout << endl;
			return 0;
		}else if(v1[i] > v2[i])
		{
			for (int j=0; j<n; j++) cout << v2[j] << ' ';
			cout << endl;
			return 0;
		}

	for (int j=0; j<n; j++) cout << v1[j] << ' ';
	cout << endl;

}

Measured memory_bytes: 12664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
  int N;
  cin >> N;
  int a;
  int tmp = 0;
  REP(i, N){
    cin >> a;
    if (a != i + 1) tmp++;
  }
  auto ans = "NO";
  if (tmp == 0 || tmp == 2) ans = "YES";

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int a,b,c;
	cin >> a >> b >> c;

	if (a <= c && c<=b||a>=c&&c>=b)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

/*---------------------------------------------------------------------------------------------------*/
int r[300005],c[300005];
void solve()
{
  int n,m,x;
  cin >> n >> m >> x;
  map<pair<int,int>,int> mat;
  f(i,x)
  {
      int xx,yy;
      cin >> xx>> yy;
      c[yy]++;
      r[xx]++;
      mat[{xx,yy}]=1;
  }
  int mxc=0,mxr=0;
  f(i,m+1)
  {
      mxc=max(mxc,c[i]);
  }
  vi v;
  f(i,n+1)
  {
      mxr=max(mxr,r[i]);
  }
  f(i,n+1)
  {
      if(r[i]==mxr)
        v.pb(i);
  }
  vi z;
  f(i,m+1)
  {
      if(mxc==c[i])
        z.pb(i);
  }
  int sum=0;
  f(j,sz(v))
  {
      int i=v[j];
      f(k,sz(z))
      {
          if(mat[{i,z[k]}]==0)
          {
              cout << mxr+mxc << '\n';return;
          }
      }
  }
  cout << mxc+mxr-1 << '\n';
  return;
} 

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 35016
N, K, Q = list(map(int, input().split()))
Alist = [int(input()) for i in range(Q)] 


Slist=[0]*N


for i in Alist:

  Slist[i-1]=Slist[i-1]+1

for i in range(N):
  if Slist[i]>Q-K:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 8640
#include<iostream>
using namespace std;
#define MAX 250

int parent(int i){
    return i/2;
}

int left(int i){
    return i*2;
}

int right(int i){
    return i*2+1;
}

int main(){
    int H,h[MAX+1];
    cin>>H;
    for(int i=1;i<=H;i++) cin>>h[i];

    for(int i=1;i<=H;i++){
        cout<<"node "<<i<<": ";
        cout<<"key = "<<h[i]<<", ";
        if(parent(i)>=1) cout<<"parent key = "<<h[parent(i)]<<", ";
        if(left(i)<=H) cout<<"left key = "<<h[left(i)]<<", ";
        if(right(i)<=H) cout<<"right key = "<<h[right(i)]<<", ";
        cout<<endl;
    }
}


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	ll ans = 0LL;
	int r = 0;
	int sum = 0;
	for(int l = 0; l < n; ++l){
		while(r < n and ((sum^a[r]) == (sum+a[r]))){
			sum += a[r];
			++r;
		}
		ans += r-l;

		if(l == r) ++r;
		else sum -= a[l];
	}
	ppp(ans);

    return 0;
}


Measured memory_bytes: 1024
N = gets.to_i
A = gets.split.map(&:to_i)

ans = Float::INFINITY

cost = 0
val = 0

A.each_with_index do |a, i|
  val += a

  if i.even?
    if val <= 0
      c = 1 - val
      cost += c
      val = 1
    end
  else
    if val >= 0
      c = val + 1
      cost += c
      val = -1
    end
  end
end

ans = cost if ans > cost

cost = 0
val = 0

A.each_with_index do |a, i|
  val += a

  if i.odd?
    if val <= 0
      c = val.abs + 1
      cost += c
      val = 1
    end
  else
    if val >= 0
      c = val + 1
      cost += c
      val = -1
    end
  end
end

ans = cost if ans > cost

puts ans


Measured memory_bytes: 8588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n, pts=0; cin>>n;
	int A[n], B[n], C[n-1];
	for(int i=0; i<n; i++)cin>>A[i];
	for(int i=0; i<n; i++)cin>>B[i];
	for(int i=0; i<n-1; i++)cin>>C[i];
	
	for(int i=0; i<n-1; i++){
		pts+=B[A[i] - 1];
		if(A[i+1]-A[i]==1){
			pts+=C[A[i]-1];
		}
	}
	cout<<pts+B[A[n-1]-1]<<endl;
}


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

using ll=long long; 

void solve(){
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	int ans=0;
	for(auto& e:a)cin>>e;
	for(auto e:a){
		ans+=min(e*2, abs(e-k)*2);
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,d;
	scanf("%d%d",&n,&d);
	int num=0,t=0;
	while(num<=n)
	{
		if(num==0)
		{
			num+=d+1;
			t++;
		}
		else
		{
			if(num+d>=n) break;
			num+=2*d+1;
			t++;
		}
	}
	printf("%d\n",t);
	return 0; 
}

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

int main(void){
    int n,d,x,i,cnt,j;
    cnt = 0;

    cin >> n >> d >> x;

    vector<int> A(n);
    for(i=0; i<n; i++){
        cin >> A.at(i);
    }

    for(i=0; i<n; i++){
        for(j=0; j * A.at(i) + 1 <= d; j++){
            cnt++;
        }
    }

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


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
D,N = list(map(int,raw_input().split()))

count = 0
number = 0
a = 100**D
b = 100**(D+1)

while count < N:
    number += a
    if number%b != 0:
        count += 1
    else:
        pass
print number

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const db ex=1e-9;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
db s1,s2,s,ans;
int main() {
	int a,b,h,m;
	scanf("%d%d%d%d",&a,&b,&h,&m); 
	s1=h*30+m*0.5;
	s2=m*6;
	s=fabs(s1-s2); 
	if(s>180)s=360-s;
	s=s*acos(-1.0)/180;
	ans=sqrt( a*a+b*b-2*a*b*cos(s) );
	printf("%.20lf",ans);
} 

Measured memory_bytes: 4240
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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 <typename T>
class UnionFind {
public:
  T n;
  vector <T> d;
  UnionFind(T n) :d(n, -1) {} 
  int find(T x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(T x, T y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(d[y] < d[x]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  int size(T x){ return -d[find(x)];}
  bool same(T x, T y){
    return find(x) == find(y);
  }
};

int n, k, l;
bool visited[1000010];
ll ans[1000010];
int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  cin >> n >> k >> l;
  UnionFind<int> doro = UnionFind<int>(n+1); //nだとREでるの謎い..
  UnionFind<int> tetu = UnionFind<int>(n+1); //nだとREでるの謎い..

  REP(i, k){
    int p, q;
    cin >> p >> q;
    p--; q--;
    doro.unite(p, q);
  }
  REP(i, l){
    int r, s;
    cin >> r >> s;
    r--; s--;
    tetu.unite(r, s);
  }

  P roots[n];
  map<P, int> ans;
  REP(i, n){
    roots[i] = {doro.find(i), tetu.find(i)};
    ans[roots[i]]++;
  }
  REP(i, n) cout << ans[roots[i]] << endl;
  /*
  REP(i, n){
    if(doro.find(i) && tetu.find(i)){
      ans[i]++;
    }
    cout << ans[i] << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
vector<int> niten(int a,int d){
    vector<int> ans;
    rep(i,d){
        ans.push_back(0);
    }
    int cnt = 0;
    while(a>=1){
        ans[cnt] = a%2;
        a/=2;
        cnt++;
    }
    return ans;
}
int main(){
    int d;
    long long g;
    cin >> d >> g;
    int p[d];
    long long c[d],t[d];
    rep(i,d){
        cin >> p[i] >> c[i];
        t[i] = 100*(i+1)*p[i] + c[i];
    } 
    vector<int> temv;
    int k;
    long long temg;
    int ans = 100000000;
    int tem;
    rep(i,pow(2,d)){
        temg = g;
        tem = 0;
        temv = niten(i,d);
        rep(j,d){
            if(temv[j] == 0){
                k = j;
            }
            else{
                temg-=t[j];
                tem+=p[j];
            }
        }
        if(temg>0 && temg<=(p[k]-1)*((k+1)*100)){
            tem+=(temg-1)/((k+1)*100);
            tem++;
            if(tem<ans){
                ans = tem;
            }
        }
        if(temg <= 0){
            if(tem < ans){
                ans = tem;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512