akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100100;

int n;
int a[maxn + 5], b[maxn + 5];

int tmpa[maxn + 5], tmpb[maxn + 5];

int fa[maxn + 5];

int get(int x) { return fa[x] == x ? x : fa[x] = get(fa[x]); }

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	int suma = 0;
	REP(i, 0, n) scanf("%d", a + i), suma ^= a[i];
	a[n] = suma;
	int sumb = 0;
	REP(i, 0, n) scanf("%d", b + i), sumb ^= b[i];
	b[n] = sumb;
	memcpy(tmpa, a, sizeof tmpa);
	memcpy(tmpb, b, sizeof tmpb);
	sort(tmpa, tmpa + n + 1);
	sort(tmpb, tmpb + n + 1);
	REP(i, 0, n + 1) if (tmpa[i] != tmpb[i])
	{
		printf("-1\n");
		return 0;
	}
	REP(i, 0, n + 1) a[i] = lower_bound(tmpa, tmpa + n + 1, a[i]) - tmpa;
	REP(i, 0, n + 1) b[i] = lower_bound(tmpa, tmpa + n + 1, b[i]) - tmpa;
	REP(i, 0, n + 1) fa[i] = i;
	set<int> all;
	int ans = 0;
	REP(i, 0, n) if (a[i] != b[i]) 
	{
		++ans;
		all.insert(a[i]), all.insert(b[i]);
		fa[get(a[i])] = get(b[i]);
	}
	set<int> comp;
	for (auto u : all) comp.insert(get(u));
	ans += SZ(comp);
	if (all.count(a[n])) --ans;
	printf("%d\n", ans);
	return 0;
}


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

long long bb[4];
long long aa;
long long ans = 0;
int main(){
    scanf("%lld%lld%lld%lld",&bb[0],&bb[1],&bb[2],&bb[3]);
    scanf("%lld",&aa);
    for(int i=1;i<=3;i++) bb[i] = min(bb[i], bb[i-1] * 2);
    aa *= 4;
    for(int i=3;i>=0;i--){
        long long cal = aa / (1 << i);
        aa %= (1 << i);
        cal *= bb[i];
        ans += cal;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
S = input()


def f(s):
    if len(s)==1:
        return [s]
    def add(st,ls):
        return [st+s for s in ls]
    return add(s[0],f(s[1:])) +add(s[0]+'+',f(s[1:]))

#print(f(S))
print(sum(map(eval,f(S))))

Measured memory_bytes: 3064
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

bool is_kaibun(string s) {
	for (int i=0; i<s.size(); i++) {
		if (s[i] != s[s.size() - 1 - i]) return false;
	}

	return true;
}

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

	string sub1 = S.substr(0, S.size() / 2);
	string sub2 = S.substr(S.size() / 2 + 1);

	//cout << sub1 << " " << sub2 << endl;

	string ans;
	if (sub1 == sub2 && is_kaibun(sub1) && is_kaibun(sub2)) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <map>

using namespace std;

typedef pair<int, int> P;
vector<P> D;

int n, a, b;
int DP[101][101];

void solve()
{
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
			if(i!=j) DP[i][j] = INT_MAX;
			else DP[i][j] = 0;
		}
	}	

	for(int i=1; i<n; i++)
	{
		for(int j=0; j<n-i; j++)
		{
			for(int k=j; k<j+i; k++)
			{
				int cost = D[j].first * D[k].second * D[k+1].first * D[j+i].second;
				DP[j][j+i] = min(DP[j][j+i], cost + DP[j][k] + DP[k+1][j+i]);
			}
		}
	}

	cout << DP[0][n-1] << endl;
}

int main(int argc, char** argv)
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> a >> b;
		P p(a, b);
		D.push_back(p);
	}

	solve();
}

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

int main()
{
  int x, y, z, k;
  cin >> x >> y >> z >> k;

  vector<int64_t> A(x), B(y), C(z);
  for (auto&& e : A) cin >> e;
  for (auto&& e : B) cin >> e;
  for (auto&& e : C) cin >> e;
  sort(begin(A), end(A), greater<>());
  sort(begin(B), end(B), greater<>());
  sort(begin(C), end(C), greater<>());

  vector<int64_t> ABC;
  for (int a = 0; a < x; a++) {
    for (int b = 0; b < y; b++) {
      if ((a + 1) * (b + 1) > k) break;
      for (int c = 0; c < z; c++) {
        if ((a + 1) * (b + 1) * (c + 1) > k) break;
        ABC.push_back(A[a] + B[b] + C[c]);
      }
    }
  }
  sort(begin(ABC), end(ABC), greater<>());

  for (int i = 0; i < k; i++) {
    cout << ABC[i] << endl;
  }
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 5 * 10000 + 1
#define INF 10000000000


int n;
vector<ll> stones;
vector<ll> dp(int(1e5 + 10), LLONG_MAX); // dp[i] is the minimum cost to reach stone i. Answer is at dp[n-1].
int main()
{
    cin >> n;
    stones.assign(n, 0LL);
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
        cin >> stones[i];

    for (int i = 1; i < n; ++i)
        for (int j : {1,2})
            if (i - j >= 0)
                dp[i] = min(abs(stones[i-j] - stones[i]) + dp[i - j], dp[i]);
    
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
S = input()
ans = S.count("E")
temp = ans
for i in range(N):
  if i == 0:
    if S[i] == "E":
      temp -= 1
  else:
    if S[i] == "E":
      temp -= 1
    if S[i - 1] == "W":
      temp += 1
  if temp < ans:
    ans = temp
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
bool IsPossible(int H, int W, const vector<string>& A)
{
    if (A[0][0] != '#') return false;
    if (A[H - 1][W - 1] != '#') return false;

    rep(r, 0, H)
    {
        rep(c, 0, W)
        {
            if (A[r][c] != '#') continue;

            int inNum = 0, outNum = 0;
            if (r > 0 && A[r - 1][c] == '#') ++inNum;
            if (c > 0 && A[r][c - 1] == '#') ++inNum;
            if (r < H - 1 && A[r + 1][c] == '#') ++outNum;
            if (c < W - 1 && A[r][c + 1] == '#') ++outNum;

            if (r == 0 && c == 0)
            {
                if (outNum != 1) return false;
            }
            else if (r == H - 1 && c == W - 1)
            {
                if (inNum != 1) return false;
            }
            else
            {
                if (inNum != 1 || outNum != 1) return false;
            }
        }
    }

    return true;
}

void _main()
{
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(r, 0, H) cin >> A[r];
    cout << (IsPossible(H, W, A) ? "Possible" : "Impossible") << endl;
}


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


int main()
{
	int m[100], f[100], r[100];
	int i = 0;

	while (1)
	{
		cin >> m[i] >> f[i] >> r[i];

		if (m[i] == -1 && f[i] == -1 && r[i] == -1)
		{
			break;
		}
		
		if (m[i] == -1 || f[i] == -1)
		{
			cout << "F" << endl;
		}
		else if (m[i] + f[i] >= 80)
		{
			cout << "A" << endl;
		}
		else if (m[i] + f[i] >= 65 && m[i] + f[i] < 80)
		{
			cout << "B" << endl;
		}
		else if (m[i] + f[i] >= 50 && m[i] + f[i] < 65)
		{
			cout << "C" << endl;
		}
		else if (m[i] + f[i] >= 30 && m[i] + f[i] < 50)
		{
			if (r[i] >= 50)
			{
				cout << "C" << endl;
			}
			else
			{
				cout << "D" << endl;
			}
		}
		else
		{
			cout << "F" << endl;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m, a[N];
inline int Calc(int l, int r, int llim, int rlim) {
    while (l < r) {
        int tmp = a[l] + a[r];
        if (tmp < llim) return -1;
        if (tmp > rlim) return 1;
        ++l; --r;
    }
    return 0;
}
inline bool Check(int lim) {
    for (int l = 0, r = n >> 1; l <= r; ) {
        int mid = (l + r) >> 1, ps = mid << 1;
        int lp = Calc(1, ps, 0, lim);
        int rp = Calc(ps + 1, n, m, m + lim);
        if (lp == 0 && rp == 0) return 1;
        if (lp == 1) { r = mid - 1; continue; }
        if (rp == 1) { r = mid - 1; continue; }
        if (rp == -1) { l = mid + 1; continue; }
    }
    return 0;
}
int main() {
    scanf("%d%d", &n, &m); n *= 2;
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    int ans = m;
    for (int l = 0, r = m; l <= r; ) {
        int mid = (l + r) >> 1;
        if (Check(mid)) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;

/*
問題文
ある街に、N 人のすぬけ君(すぬけ君 1 、すぬけ君 2 、 ...、 すぬけ君 N )が住んでいます。
この街には、 K 種類のお菓子(お菓子 1 、 お菓子 2 、....、お菓子 K )が売られています。
お菓子 i を持っているのは、すぬけ君 Ai,1, Ai,2, ⋯, Ai,di の計 di 人です。

高橋君は今からこの街を回り、お菓子を 1 つも持っていないすぬけ君にいたずらをします。
このとき、何人のすぬけ君がいたずらを受けるでしょうか。

制約
入力は全て整数
1≤N≤100
1≤K≤100
1≤di≤N
1≤Ai,1<⋯<Ai,di≤N
*/

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        // 全員のすぬけ君
        HashSet<Integer> sunuke = new HashSet<>();

        for (int i = 0; i < n; i++) {
            sunuke.add(i+1);
        }

        for (int i = 0; i < k; i++) {
            int ki = sc.nextInt();

            for (int j = 0; j < ki; j++) {
                int temp = sc.nextInt();
                if (sunuke.contains(temp)) {
                    sunuke.remove(temp);
                }
            }
        }
        System.out.println(sunuke.size());
    }
}

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

typedef long long ll;

#define N 100000001

int table[N];

void prim(){
    table[0]=table[1]=1;
    for(int i=2;i*i<N;i++){
        for(int j=2*i;j<N;j+=i){
            table[j]=1;
        }
    }
}

bool chepri(int n){
    if(n<2)return false;
    if(n==2)return true;
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cou=0,a;
//    prim();
//    for(int i=0;i<n;i++){
//        cin >> a;
//        if(!table[a])cou++;
//    }
//    cout << cou << endl;

    for(int i=0;i<n;i++){
        cin >> a;
        if(chepri(a))cou++;
    }
    cout << cou << endl;
}



Measured memory_bytes: 3144
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll h[111];

ll rec(ll l, ll r) {
    if(l>=r) return 0;
    
    ll res=0;
    ll i;
    ll min=INF;
    for(i=l; i<r; i++) chmin(min, h[i]);
    res+=min;
    
    vector<ll> ze;
    ze.pb(l-1);
    for(i=l; i<r; i++) {
        h[i]-=min;
        if(h[i]==0) ze.pb(i);
    }
    ze.pb(r);
    
    for(i=0; i<ze.size()-1; i++)
        res+=rec(ze[i]+1, ze[i+1]);
    
    return res;
}

int main(void) {
    cin >> N;
    ll i;
    
    for(i=0; i<N; i++) cin >> h[i];
    
    pt(rec(0, N));
}




Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
flg = True
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            flg = False
if flg == True:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 61912
/*input
sadasdaadsasdasdsadasd
*/
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#include <climits>
typedef unsigned long long ll;
using namespace std;

int main() {
	string alph = "abcdefghijklmnopqrstuvwxyz";
	string str;
	cin >> str;
	ll pairsEq = 0;
	for(ll i = 0; i < alph.length(); i++){
		ll count = 0;
		for(ll j = 0; j < str.length(); j++){
			if(alph[i] == str[j]){
				count++;
			}
		}
		pairsEq += (count*(count-1))/2;
	}
	ll n = str.length();
	ll totPairs = (n*(n-1))/2;
	ll res = totPairs - pairsEq + 1;
	cout << res << endl;
	return 0;
}

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

#define LL      long long
#define pb      push_back
#define inf     111111111111111
#define READ    freopen("in.txt", "r", stdin)
#define WRITE   freopen("out.txt", "w", stdout);

map <string, int> mp;

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

    int arr[n+5], sumA = 0, sumB = 0;
    for(int i=1; i<=n; i++){
        arr[i] = l + i -1;
        sumA += arr[i];
    }
    sumB = sumA;
    int mn = INT_MAX;
    int ans;
    for(int i=1; i<=n; i++){
        if(mn > abs(sumA - (sumB - arr[i]) ) ){
            mn = abs(sumA - (sumB - arr[i]) );
            ans = sumB - arr[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


//ユークリッドの互除法
ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;

  ll lcm = (C*D)/gcd(C,D);

  

  ll numB = B - B/C - B/D + B/lcm;
  ll numA = A-1 - (A-1)/C - (A-1)/D + (A-1)/lcm;

  cout<<numB-numA<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define N (4)
#define N2 (N * N)

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
    int f[N2], space, MD;
    int cost;
    
    bool operator < ( const Puzzle &p ) const {
	for ( int i = 0; i < N2; i++ ) {
	    if ( f[i] == p.f[i] ) continue;
	    return f[i] < p.f[i];
	}
	return false;
    }
};

struct State {
    Puzzle puzzle;
    int estimated;

    // priority_queue????????????????????§?????§??????????????????
    // ????°????????????????????????????????????????????????±????????????????????????????????¨????????????
    bool operator < ( const State &s ) const {
	return estimated > s.estimated;
    }
};

int getAllMD( Puzzle pz ) {
    int sum = 0;
    for ( int i = 0; i < N2; i++ ) {
	if ( pz.f[i] == N2 ) continue;
	sum += MDT[i][pz.f[i] - 1];
    }

    return sum;
}

int astar( Puzzle s ) {
    priority_queue<State> PQ;
    s.MD = getAllMD( s );
    s.cost = 0;
    map<Puzzle, bool> V;
    State initial;
    initial.puzzle = s;
    initial.estimated = getAllMD( s );

    PQ.push( initial );

    while ( !PQ.empty() ) {
	State st = PQ.top(); PQ.pop();
	Puzzle u = st.puzzle;

	if ( u.MD == 0 ) return u.cost;
	V[u] = true;
	
	int sx = u.space / N;
	int sy = u.space % N;
	
	for ( int r = 0; r < 4; r++ ) {
	    int tx = sx + dx[r];
	    int ty = sy + dy[r];
	    
	    if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
	    Puzzle v = u;
	    
	    v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
	    v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];
	    
	    swap( v.f[sx * N + sy], v.f[tx * N + ty] );
	    v.space = tx * N +ty;

	    if ( !V[v] ) {
		v.cost++;
		State news;
		news.puzzle = v;
		news.estimated = v.cost + v.MD;
		PQ.push( news );
	    }
	}
    }

    return -1;
}


int main()
{
    for ( int i = 0; i < N2; i++ ) {
	for ( int j = 0; j < N2; j++ ) {
	    MDT[i][j] = abs( i / N - j / N ) + abs( ( i % N ) - ( j % N ) );
	}
    }

    Puzzle in;
    
    for ( int i = 0; i < N2; i++ ) {
	scanf("%d", &in.f[i]);
	if ( in.f[i] == 0 ) {
	    in.f[i] = N2;
	    in.space = i;
	}
    }

    int ans = astar( in );
    
    if ( ans != -1 ) {
	printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 257132
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long h, w;
    cin >> h >> w;
    if(h > w) {
        int temp = w;
        w = h;
        h = temp;
    }
    if(h == 2 || w == 2) {
        cout << 0;
    } else if(h == 1) {
        if(w == 1) {
            cout << 1;
        } else {
            cout << w - 2;
        }
    } else {
        cout << (h - 2) * (w - 2);
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int A[200000];
ll S[200010];
ll X[200020];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
    X[i + 1] = X[i] ^ A[i];
  }

  int l = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    while (S[i + 1] - S[l] != (X[i + 1] ^ X[l])) {
      l++;
    }
    ans += i - l + 1;
  }

  cout << ans << endl;
}

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

int main()
{
	int n, amax, bmax, bloop, cloop, l_min, bafa;
	int min = INT16_MAX;
	cin >> n;

	amax = n / 9;

	for (int aloop = 0; aloop <= amax; aloop++)
	{
		bloop = (n - aloop * 9) / 6;
		cloop = n - aloop * 9 - bloop * 6;

		l_min = cloop;

		bafa = aloop;

		while (aloop>0)
		{
			l_min += aloop % 9;
			aloop /= 9;
		}
		while (bloop>0)
		{
			l_min += bloop % 6;
			bloop /= 6;
		}
		if (min>l_min)
		{
			min = l_min;
		}

		aloop = bafa;
	}

	cout << min << endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A == 1){
    A = A + 13;
  }
  if(B == 1){
    B = B + 13;
  }
  if(A == B){
    cout << "Draw" << endl;
  }
  else if(A > B){
    cout << "Alice" << endl;
  }
  else{
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

vector<LL> a; LL x;

int main() {
    GI(n);

    FORN(i, 3 * n) {
        GLL(x);
        a.PB(x);
    }

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

    LL res = 0;

    FORN(i, n) {
        res += a[3 * n - 2 * (i + 1)];
    }

    cout << res << "\n";

    
    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true,graph[100][100];

int dfs(int now,int nn,bool* visited){
    bool all_visited=true;
    rep(i,nn){
        if(!visited[i]){
            all_visited=false;
        }
    }
    ll tmp=0;
    if(all_visited){
        return 1;
    }
    rep(i,nn){
       if(!graph[now][i]){
           continue;
       }
       if(visited[i]){
           continue;
       }
       visited[i]=true;
       tmp+=dfs(i,nn,visited);
       visited[i]=false;
    }
    return tmp;
}

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

       cin >> n >> m;
       rep(i,m){
           cin>>a>>b;
           graph[a-1][b-1]=graph[b-1][a-1]=true;
       }
       bool visited[100];
       rep(i,101){
           visited[i]=false;
       }
       visited[0]=true;
      Cout(dfs(0,n,visited));
       
return 0;
}


Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val (A, B, C, X, Y) = readInputLine().split(" ").map{it.toLong()}
    
    var ABpizza = Math.max(X, Y) * 2L
    
    var ans = Long.MAX_VALUE

    while (ABpizza >= 0) {
        val tmp = Math.max(X - ABpizza / 2L, 0L) * A + Math.max(Y - ABpizza / 2L, 0L) * B + ABpizza * C
        ans = Math.min(tmp, ans)
        
        ABpizza -= 2L
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37968
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============



int main() 
{ 
	int n ; 
    cin >> n ; 
    vt<ll> a(n-1) ; 
    ll sum = 0 ;  
    rep(i,0,n-1) {
        cin >> a[i] ; 
    }
    sum += a[0] ;
    int tmp = 1e9+1 ; 
    rep(i,1,n-1) {
        sum += min(a[i],a[i-1]) ; 
    }
    cout << sum + a[n-2] ; 
    return 0; 
} 

Measured memory_bytes: 3604
my $c;
my $i = 1;
while (my $l = <STDIN>) {
        chomp $l;
        if ($l =~ m/^(\d*?) (\d*?) (\d*?)$/) {
                $c->{$i}->{1} = $1;
                $c->{$i}->{2} = $2;
                $c->{$i}->{3} = $3;
        }
        $i++;
}

my ($A, $B);
my $flag = 1;
     $A->{1}->{2} =  $c->{1}->{1}-$c->{2}->{1};
if (($A->{1}->{2} == $c->{1}->{2}-$c->{2}->{2})
 && ($A->{1}->{2} == $c->{1}->{3}-$c->{2}->{3})){
} else {
        $flag = 0;
}
     $A->{1}->{3} =  $c->{1}->{1}-$c->{3}->{1};
if (($A->{1}->{3} == $c->{1}->{2}-$c->{3}->{2})
 && ($A->{1}->{3} == $c->{1}->{3}-$c->{3}->{3})){
} else {
        $flag = 0;
}
     $A->{2}->{3} =  $c->{2}->{1}-$c->{3}->{1};
if (($A->{2}->{3} == $c->{2}->{2}-$c->{3}->{2})
 && ($A->{2}->{3} == $c->{2}->{3}-$c->{3}->{3})){
} else {
        $flag = 0;
}
     $B->{1}->{2} =  $c->{1}->{1}-$c->{1}->{2};
if (($B->{1}->{2} == $c->{2}->{1}-$c->{2}->{2})
 && ($B->{1}->{2} == $c->{3}->{1}-$c->{3}->{2})){
} else {
        $flag = 0;
}
     $B->{1}->{3} =  $c->{1}->{1}-$c->{1}->{3};
if (($B->{1}->{3} == $c->{2}->{1}-$c->{2}->{3})
 && ($B->{1}->{3} == $c->{3}->{1}-$c->{3}->{3})){
} else {
        $flag = 0;
}
     $B->{2}->{3} =  $c->{1}->{2}-$c->{1}->{3};
if (($B->{2}->{3} == $c->{2}->{2}-$c->{2}->{3})
 && ($B->{2}->{3} == $c->{3}->{2}-$c->{3}->{3})){
} else {
        $flag = 0;
}
if ($flag) {
        print "Yes\n";
} else {
        print "No\n";
}

Measured memory_bytes: 512
s=list(input())
l = len(s)
zero = [i % 2 for i in range(0, l)]
one = [(i+1) % 2 for i in range(0, l)]
strs_zero = [str(num) for num in zero]
strs_one = [str(num) for num in one]
import numpy as np
s_np = np.array(s)
zero_np = np.array(strs_zero)
one_np = np.array(strs_one)
count_zero = l - np.sum(s_np == zero_np)
count_one = l - np.sum(s_np == one_np)
if count_zero < count_one:
    print(count_zero)
else:
    print(count_one)

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

string toLower(string t) {
    string s = t;
    rep(i, s.size()) {
        s[i] = tolower(t[i]);
    }
    return s;
}

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

    int ans = 0;
    while (1) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        t = toLower(t);
        if (w == t) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3224
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int r,c;
bool d[11][10002];
int ans = 0;


void dfs(int n,bool ch[]){
  if(n == r){
    int tmp=0;
    for(int i = 0;i < c;i++){
      int k = 0;
      for(int j = 0;j < r;j++){
	if(ch[j] == true && d[j][i] == false){
	  k++;
	}else if(ch[j] == false && d[j][i] == true){
	  k++;
	}
      }
      tmp += max(k,r-k);
    }
    
    ans = max(ans,tmp);
    return;
  }else{
    dfs(n+1,ch);
    ch[n] = true;
    dfs(n+1,ch);
    ch[n] = false;
  }
}


int main(){
  
  while(1){
  bool ch[11];
  
  ans = 0;

  scanf("%d%d",&r,&c);
  if(r == 0)break;
  
  for(int i = 0;i < r;i++){
    for(int j = 0;j < c;j++){
      int t;
      scanf("%d",&t);
      d[i][j] = t;
    }
  }
  
  for(int i = 0;i < r;i++){
    ch[i] = false;
  }
  
  dfs(1,ch);
  ch[0] = 1;
  dfs(1,ch);
  
  printf("%d\n",ans);
  
  }
  
  return 0;
  
}


Measured memory_bytes: 1292
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f

using namespace std;
using namespace __gnu_pbds;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree<pair<int,int>,null_type, less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
const int N=1e6+10, mod=1e9+7;


int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	int n,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[n-1-i];
	bool poss=true;
	for(i=1;i<n;i++){
		if(a[i]<=a[i-1]) continue;
		if(a[i]==a[i-1]+1){
			a[i]--;
		}else {
			poss=false;
			break;
		}
	}
	if(poss)cout<<"Yes";
	else cout<<"No";	
}
// check for any potential overflow before submitting



Measured memory_bytes: 640
// https://atcoder.jp/contests/abc171/tasks/abc171_e

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 200000;
const int A_I_MAX = 1e9;

int N;
vector<int> a;

int main() {
  cin >> N;
  a = vector<int>(N);
  REP(i, N) cin >> a[i];

  int b = 0;
  REP(i, N) b ^= a[i];

  REP(i, N) {
    cout << (b ^ a[i]);
    if (i == N - 1) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 4028
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result}

const main = ()=>{
  let [a,b,c] = [...nrin(3)];
  out(min(floor(b/a), c));
}
main();

Measured memory_bytes: 7500
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n,m,q;
    cin >> n >> m >> q;
    vi a(q),b(q),c(q),d(q);
    rep(i,q)cin >> a[i] >> b[i] >> c[i] >> d[i],a[i]--,b[i]--;
    int wa = n+m-1;
    int ans = 0;
    rep(bit,1<<wa){
        vi v;
        int cnt = 0;
        rep(i,wa){
            if(bit & (1<<i))cnt++;
            else v.push_back(cnt+1);
        }
        if(cnt != m-1)continue;
        int tmp = 0;
        rep(i,q){
            if(v[b[i]]-v[a[i]] == c[i])tmp += d[i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


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

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

        string a = sc.Next();
        string b = sc.Next();
        string c = sc.Next();

        bool ok = a.Last() == b.First() && b.Last() == c.First();

        string answer = ok ? "YES" : "NO";

        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: 13268
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  long long C;
  scanf("%lld", &C);
  std::vector<long long> B(M);
  for (int i = 0; i < M; i++)
  {
    scanf("%lld", &B[i]);
  }
  std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      scanf("%lld", &A[i][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i)
  {
    int sum = C;
    for (int j = 0; j < M; ++j)
    {
      sum += A[i][j] * B[j];
    }
    if (sum > 0)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#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++)

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  vector<int> q(n);
  rep(i,n)cin >> p[i];
  rep(i,n)cin >> q[i];
  
  vector<int> a(n);
  rep(i,n)a[i]=i+1;
  
  int cp,cq;
  cp=0;
  cq=0;
  int count=0;
  do{
    bool eqp=true;
    bool eqq=true;
    count++;
    rep(i,n){
      if(a[i]!=p[i])eqp=false;
      if(a[i]!=q[i])eqq=false;
      if(!eqp&&!eqq)continue;
    }
      if(eqp)cp=count;
      if(eqq)cq=count;
  }while(next_permutation(a.begin(),a.end()));
  
  cout << max(cp,cq)-min(cp,cq) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), true);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.flush();
		out.close();
	}
}

class Pair {
	int first;
	int second;
	int pos;

	Pair(int first, int second, int pos) {
		this.first = first;
		this.second = second;
		this.pos = pos;
	}
}

class TaskB {

	public void solve(int testNumber, InputReader in, PrintWriter pw) {
		String S = in.next();
		long K = in.nextLong();
		char arr[] = S.toCharArray();
		long len = 0;
		int ans = -1;
		for (int i = 0; i < arr.length; i++) {
			int num = arr[i] - '0';
			len += Math.pow(num, 5e15);
			if (len >= K) {
				ans = num;
				break;
			}
		}
		pw.println(ans);

	}

	int __gcd(int a, int b) {
		if (b == 0)
			return a;
		return __gcd(b, a % b);

	}

	public int getInt(int num) {
		int ret = -1;
		switch (num) {
		case 0:
			ret = 6;
			break;
		case 1:
			ret = 2;
			break;
		case 2:
			ret = 5;
			break;
		case 3:
			ret = 5;
			break;
		case 4:
			ret = 4;
			break;
		case 5:
			ret = 5;
			break;
		case 6:
			ret = 6;
			break;
		case 7:
			ret = 3;
			break;
		case 8:
			ret = 7;
			break;
		case 9:
			ret = 6;
			break;
		}
		return ret;
	}

	public int isPow(long num) {
		int count = 0;
		while (num > 0) {
			num /= 2;
			count++;
		}
		return count;
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21460
#include <stdio.h>
#include <stdint.h>

int main(void) {
  int K, A, B;
  scanf("%d %d %d", &K, &A, &B);

  // 1st step
  uint64_t BIS = 1;
  uint64_t STEP = (A - BIS) + 2;
  if ((K < STEP) || (A >= B) || ((B-1) <= STEP)) {
    BIS += K;
    printf("%ld\n", BIS);
    return 0;
  } else {
    BIS = B;
    K -= STEP;
    //printf("BIS=%ld K=%d\n", BIS, K);
  }

  // 2nd step 
  STEP = 2;
  uint64_t LOOP = (K / STEP);
  uint64_t MOD  = (K % STEP);
  //printf("LOOP=%ld MOD=%ld\n", LOOP, MOD);
  BIS += LOOP * (uint64_t)(B - A);
  BIS += MOD;
  printf("%ld\n", BIS);
  return 0;
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;
 
// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  int a[N], b[N];
  for (int i = 0; i < N; i++) scanf("%d %d", a + i, b + i);

  int ans = 0;
  for (int i = 0; i < N; i++) if (a[i] >= H && b[i] >= W) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<ctime>
#include<set>
#include<queue>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);++(i))
#define fd1(i,n) for ((i)=(n);(i)>=1;--(i))
#define fz0g(i,n) for ((i)=0;(i)<=(n);++(i))
#define fd0g(i,n) for ((i)=(n);(i)>=0;--(i))
#define fz0k(i,n) for ((i)=0;(i)<(n);++(i))
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;--(i))
#define fz(i,x,y) for ((i)=(x);(i)<=(y);++(i))
#define fd(i,y,x) for ((i)=(y);(i)>=(x);--(i))
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
using namespace std;
long long n,m,i,j,l,r,mid,ans;
bool solve(long long x)
{
	long long l=0,r=x,mid;
	while(l<=r)
	{
		long long mid=(l+r)/2;
		long long tmp=x*x*2-x-(x-1)*mid-(x-mid)*x;
		if(tmp<n){
			l=mid+1;
		}
		else if(tmp>n){
			r=mid-1;
		}
		else{
			printf("%lld %lld %lld %lld %lld %lld\n",0,0,x,1,x-mid,x);
			return 1;
		}
	}
	return 0;
}
void solve2(long long x)
{
	long long l=0,r=x,mid;
	while(l<=r)
	{
		long long mid=(l+r)/2;
		long long tmp=x*(x+1)*2-x-mid*x-(x-mid)*(x+1);
		if(tmp<n){
			l=mid+1;
		}
		else if(tmp>n){
			r=mid-1;
		}
		else{
			printf("%lld %lld %lld %lld %lld %lld\n",0,0,x,1,x-mid,x+1);
			return;
		}
	}
}
int main()
{
	scanf("%lld",&n);
	if(n==1000000000000000000)
	{
		puts("0 0 0 1000000000 1000000000 1000000000");
		return 0;
	}
	l=0;r=sqrt(n)+2;
	while(l<r)
	{
		mid=(l+r)/2;
		long long mx=mid*mid-1;
		if(mx<n){
			l=mid+1;
			ans=mid+1;
		}
		else{
			r=mid;
		}
	}
	if(!solve(ans))solve2(ans-1);
	return 0;
}

Measured memory_bytes: 256
<?php
  function fc($arg1,$arg2) {
  	$res = "";
  	for($n=0;$n<=$arg2;$n++) {
      $res = $res.$arg1;
    }
  	return $res;
}
  
  $S = trim(fgets(STDIN));
  list($a,$b) = explode(" ",$S);

	$str1 = "a" . fc($a,$b);
	$str2 = "a" .  fc($b,$a);

  if($str1 > $str2) {
    $res = $str2;
  } elseif($str2 > $str1) {
    $res = $str1;
  } else {
    $res = $str1;
  }

	print substr($res,2,strlen($res));

?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MOD=1e9+7;
#define endl '\n'
#define F first
#define S second
#define pb push_back
const double PI = 3.141592653589793238460;
  void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
    #endif
}
ll dp[100005][101];ll wt[100005], val[100005];ll  n,W;
ll  knapsack(ll *wt, ll *val, ll W, ll n)
{
  if(n==0||W==0)
    return 0;
  if(dp[W][n]!=-1)
    return dp[W][n];
  if(wt[n-1]<=W)
    return dp[W][n]=max(val[n-1]+knapsack(wt,val,W-wt[n-1],n-1),knapsack(wt,val,W,n-1));
  else if(wt[n-1]>W)
    return dp[W][n]=knapsack(wt,val,W,n-1);


 


  


}
  
 

int  main()
{
  c_p_c();
 cin>>n>>W;
 memset(dp,-1,sizeof(dp));

 for(int i=0;i<n;i++)
 {
  cin>>wt[i]>>val[i];
 }

  cout<<knapsack(wt,val,W,n);
 

  return 0;

}

Measured memory_bytes: 82576
#include<stdio.h>
int main()
{
    int n,i,len,vowel=0,consonant=0;
    char str[100];
    char rev1[]="Sunny";
    char rev2[]="Rainy";
    char rev3[]="Cloudy";
    gets(str);
    if(strcmp(str,rev1)==0)
    {
        printf("Cloudy\n");
    }
    else if(strcmp(str,rev2)==0)
    {
        printf("Sunny\n");
    }
    else if(strcmp(str,rev3)==0)
    {
        printf("Rainy\n");
    }
    return 0;


}


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

int N, K, X, Y;
int ans;

signed main()
{
	cin >> N >> K >> X >> Y;
	ans = X * min(N, K);
	N -= K;
	if (N > 0) ans += Y * N;
	cout << ans << endl;
}


Measured memory_bytes: 256
class Tree:
    __slots__ = ['id', 'p', 'left', 'right', "type"]
    def __init__(self, id):
        self.id = id
        self.p = -1
        self.left = -1
        self.right = -1
        self.type = "leaf"
    def __str__(self):
        return f"node {self.id}: parent = {self.p}, left = {self.left}, right = {self.right}, type = {self.type}"
n = int(input())
tree = tuple(Tree(i) for i in range(n))
for _ in range(n):
    id, l, r = map(int, input().split())
    if l != -1:
        tree[id].left = l
        tree[l].p = id
    if r != -1:
        tree[id].right = r
        tree[r].p = id
root = 0
while tree[root].p != -1:
    root = tree[root].p
def preorder_tree_walk(id):
    print(f" {tree[id].id}", end="")
    if tree[id].left != -1:
        preorder_tree_walk(tree[id].left)
    if tree[id].right != -1:
        preorder_tree_walk(tree[id].right)
def inorder_tree_walk(id):
    if tree[id].left != -1:
        inorder_tree_walk(tree[id].left)
    print(f" {tree[id].id}", end="")
    if tree[id].right != -1:
        inorder_tree_walk(tree[id].right)
def postorder_tree_walk(id):
    if tree[id].left != -1:
        postorder_tree_walk(tree[id].left)
    if tree[id].right != -1:
        postorder_tree_walk(tree[id].right)
    print(f" {tree[id].id}", end="")
print("Preorder")
preorder_tree_walk(root)
print("\nInorder")
inorder_tree_walk(root)
print("\nPostorder")
postorder_tree_walk(root)
print()



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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    map<ll, ll> cnt;
    cnt[0] = 1;
    ll sum = 0;
    ll ans = 0;
    rep(i, N) {
        int a;
        cin >> a;
        sum += a;
        ans += cnt[sum];
        cnt[sum]++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 12800
n=int(input())
a=0
b=0
c=0
d=0
while n:
    n-=1
    s=input()
    if(s=='AC'):a+=1
    if(s=='WA'):b+=1
    if(s=='TLE'):c+=1
    if(s=='RE'):d+=1
print('AC x %d'%a)
print('WA x %d'%b)
print('TLE x %d'%c)
print('RE x %d'%d)


Measured memory_bytes: 9196
#include <stdio.h>

int main(void)
{
    int d[102] = { 0 };
    int a, b, c, t = 0;
    scanf("%d %d %d", &a, &b, &c);
    ++d[a];
    ++d[b];
    ++d[c];
    for (int i = 1; i < 101; ++i) {
        if (d[i] > 0) {
            ++t;
        }
    }
    printf("%d\n", t);

    return 0;
}


Measured memory_bytes: 128