akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import numpy as np


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):

    sumA = np.hstack([0,np.cumsum(A)])
    sumB = np.hstack([0,np.cumsum(B)])
    
    #print(sumA)
    #print(sumB)

    books = 0
    j = M
    for i in range(N+1):
        if sumA[i] > K:
            break
        while sumB[j] > K - sumA[i]:
            j -= 1
        books = max(books, i+j)

    print(books)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, K, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 64024
#include<cstdio>
using namespace std;
int main()
{
	int w,a,b;
	scanf("%d%d%d",&w,&a,&b);
	if(b<=a+w&&a<=b+w) 
	{
		printf("0\n");
		return 0;
	}
	if(b>a+w) printf("%d\n",b-a-w);
	else printf("%d\n",a-b-w);
	return 0;
}

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

using namespace std;

using ll = long long;

priority_queue<ll> lq;
priority_queue<ll, vector<ll>, greater<>> rq;
vector<ll> m(1);
ll mi = 0;
ll B = 0;

void query2()
{
  cout << m[0] << " " << mi + B << endl;
}

void query1(ll a, ll b)
{
  B += b;
  if (m.size() == 1) {
    mi += abs(a - m[0]);
    if (m[0] < a) {
      rq.push(a);
      m.push_back(rq.top());
      rq.pop();
    } else {
      lq.push(a);
      m.push_back(lq.top());
      lq.pop();
      swap(m[0], m[1]);
    }
  } else {
    if (a <= m[0]) {
      lq.push(a);
      rq.push(m[1]);
      mi += m[0] - a;
      m.pop_back();
    } else if (m[1] <= a) {
      rq.push(a);
      lq.push(m[0]);
      mi += a - m[1];
      m[0] = m[1];
      m.pop_back();
    } else {
      lq.push(m[0]);
      rq.push(m[1]);
      m[0] = a;
      m.pop_back();
    }
  }
}

int main()
{
  int Q;
  cin >> Q;
  ll q, a, b;
  cin >> q >> a >> b;
  B = b;
  m[0] = a;
  Q--;
  while (Q--) {
    cin >> q;
    if (q == 1) {
      cin >> a >> b;
      query1(a, b);
    } else {
      query2();
    }
  }
}

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

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep2(i,a,b) for(ll i=a; i<=b; i++)
#define drep2(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back

ll getNum(int l, int r, string& s)
{
  ll result = 0;
  rep2(i,l,r) {
    result = (s[i] - '0') + result * 10;
  }
  return result;
}

int main ()
{
  string S;
  cin >> S;
  for(int i=0; i <= 7; i++) {
    // printf("i: %d\n", i);
    int sum = S[0] - '0';
    int bs = i;
    for(int j=1; j<4; j++) {
      if (bs & 1 == 1) {
        sum += S[j] - '0';
      } else {
        sum -= S[j] - '0';
      }
      bs >>= 1;
    }
    if (sum == 7) {
      cout << S[0];
      int bs = i;
      for(int j=1; j<4; j++) {
        if (bs & 1 == 1) {
          cout << "+";
        } else {
          cout << "-";
        }
        bs >>= 1;
        cout << S[j];
      }


      cout << "=7" << endl;
      return 0;
    } 

  }
}

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

using namespace std;

int main()
{
    int a;
    int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> a;
    cout << v[a-1] << endl;
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

#define N 100

void output(int A[], int n);
void insertionSort(int A[], int n);

void output(int A[], int n){
	int i;
	for(i=0; i<(n-1); i++){
		printf("%d ", A[i]);
	}
	printf("%d\n", A[i]);
}

void insertionSort(int *A, int n){
	int i, j, v;

	for(i=1; i<=(n-1); i++){
		v = A[i];
		j = i - 1;
		while( (j>=0) && (A[j] > v) ){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		output(A, n);
	}
}

int main(){
	int n, i;
	int A[N+1];
	scanf("%d", &n);

	for ( i = 1; i <= n; i++ ) scanf("%d", &A[i-1]);

	output(A, n);
	insertionSort(A, n);

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct tank{
  int w,c,l,r,s,f;
  tank(){w=c=l=r=s=f=0;}
  tank(int w,int c,int l,int r):w(w),c(c),l(l),r(r){}
};
signed main(){
  int D;
  cin>>D;
  while(D--){
    int n;
    cin>>n;
    int b[n],h[n];
    for(int i=0;i<n;i++) cin>>b[i]>>h[i];
    int m;
    cin>>m;
    int f[m],a[m];
    for(int i=0;i<m;i++) cin>>f[i]>>a[i];
    int l;
    cin>>l;
    int p[l],t[l];
    for(int i=0;i<l;i++) cin>>p[i]>>t[i];
    int INF=1LL<<30LL;
    vector<tank> v(n+3);
    v[0]=tank(INF,0,100,50);
    v[1]=tank(b[0],0,50,h[0]);
    for(int i=1;i<n;i++)
      v[i+1]=tank(b[i]-b[i-1],0,h[i-1],h[i]);
    v[n+1]=tank(100-b[n-1],0,h[n-1],50);
    v[n+2]=tank(INF,0,50,100);
    for(int i=0;i<m;i++){
      int tmp=0,k=0;
      while(k<n&&tmp<f[i]) tmp=b[k++];
      if(tmp<f[i]) k++;
      v[k].s+=a[i];
    }
    
    for(int i=0;i<l;i++){
      vector<tank> w(v);
      int tmp=0,k=0;
      while(k<n&&tmp<p[i]) tmp=b[k++];
      //cout<<k<<" "<<tmp<<" "<<p[i]<<endl;
      if(tmp<p[i]) k++;
      w[k].f=1;
      
      //for(int j=0;j<(int)w.size();j++)
      //cout<<w[j].w<<" "<<w[j].c<<" "<<w[j].l<<" "<<w[j].r<<" "<<w[j].s<<" "<<w[j].f<<endl;
      
      for(int j=0;j<(int)w.size();j++) w[j].c=w[j].s*t[i];
      
      while(1){
	bool flg=0;
	for(int j=0;j<(int)w.size();j++){
	  int hei=min(w[j].l,w[j].r);
	  if(w[j].c<=w[j].w*hei*30) continue;
	  //cout<<j<<" "<<w[j].c<<":"<<w[j].w*hei*30<<endl;
	  flg=1;
	  if(w[j].l<w[j].r){
	    if(w[j-1].l>w[j-1].r&&w[j-1].c>=w[j-1].w*w[j-1].r*30){
	      w[j-1].w+=w[j].w;
	      w[j-1].r=w[j].r;
	      w[j-1].c+=w[j].c;
	      w[j-1].f|=w[j].f;
	      w.erase(w.begin()+j);
	      break;
	    }
	    w[j-1].c+=(w[j].c-w[j].w*hei*30);
	    w[j].c=w[j].w*hei*30;
	  }else{
	    if(w[j+1].l<w[j+1].r&&w[j+1].c>=w[j+1].w*w[j+1].l*30){
	      w[j+1].w+=w[j].w;
	      w[j+1].l=w[j].l;
	      w[j+1].c+=w[j].c;
	      w[j+1].f|=w[j].f;
	      w.erase(w.begin()+j);
	      break;
	    }
	    w[j+1].c+=(w[j].c-w[j].w*hei*30);
	    w[j].c=w[j].w*hei*30;
	  }
	  break;
	}
	if(!flg) break;
      }
      //for(int j=0;j<(int)w.size();j++)
      //cout<<w[j].w<<" "<<w[j].c<<" "<<w[j].l<<" "<<w[j].r<<" "<<w[j].s<<" "<<w[j].f<<endl;
      for(int j=0;j<(int)w.size();j++){
	if(w[j].f){
	  //cout<<w[j].w<<" "<<w[j].c<<" "<<w[j].l<<" "<<w[j].r;
	  //cout<<w[j].c<<" "<<w[j].w<<endl;
	  assert((double)w[j].c/(w[j].w*30.0)<=50.0);
	  printf("%.12f\n",(double)w[j].c/(w[j].w*30.0));
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	ll n,m; cin>>n>>m;
	vl a(m);
	vector<char> b(m);
	ll ans=-1;
	rep(i,0,m){
		cin>>a[i]>>b[i];
	}
	rep(i,0,1000){
		string s=to_string(i);
		if(s.size()!=n)continue;
		bool ok=true;
		rep(i,0,m){
			if(s[a[i]-1]!=b[i])ok=0;
		}
		if(ok){
			ans=i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3704
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t N;
int64_t a[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> a[i];
	}
	if (a[N - 1] != 2) {
		out << -1 << endl; return 0;
	}

	int64_t min = 2;
	int64_t max = 3;
	for (int i = N - 2; i >= 0; i--)
	{
		if (max < a[i]) {
			out << -1 << endl; return 0;
		}
		else {
			max = (max / a[i])*a[i] + a[i] - 1;
		}

		if (min <= a[i]) {
			min = a[i];
		}
		else {
			min = ((min + a[i] - 1) / a[i])*a[i];
		}
		if (min > max) {
			out << -1 << endl; return 0;
		}
	}
	out << min << ' ';
	out << max << endl;

	return 0;
}
#endif


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

char a,b;

int main(){
    cin >> a >> b;
    vector<string> ans(2);
    for(int i=0;i<(int)(b-'0');i++){
        ans[0] += a;
    }
    for(int i=0;i<(int)(a-'0');i++){
        ans[1] += b;
    }
    //sort(ans.begin(),ans.end());
    if(ans[0]<ans[1]) cout << ans[0] << endl;
    else cout << ans[1]  << endl;
    //cout << ans[0] << endl;
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long int
#define ld long double
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back

using namespace std;
typedef pair<int, int> pii;

#define MOD 1000000007;

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

    ll dp[n + 1];
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;


    for (int j = 0; j <= n; j++) {
        for (int i = 3; i <= n; i++) {
            if (j + i <= n) {
                dp[j + i] += dp[j];
                dp[j + i] %= MOD;
            }
        }
    }

    cout << dp[n];

}


Measured memory_bytes: 3652
#include <bits/stdc++.h> 
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	string s;
	string t;
	cin>>s;
	cin>>t;
	long long int n,c=0,i;
	n=s.length();
	for(i=0;i<n;i++)
	{
		if(s[i]==t[i])
		{
			continue;
		}
		else
		{
			c++;
		}
	}
	cout<<c<<"\n";
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//青いカード入力
  int N,t,Alice,Bob;
  Alice = 0 ;
  Bob = 0 ;
  cin >> N;
  vector<int> data(N);
  for (int i =0 ; i < N ; i++){
    cin >> data.at(i);
  }
  //ここまで入力

  for (int i = 0; i <N-1; i++){
      for (int j =i+1; j<N; j++){
          if(data.at(i)>data.at(j)){
          }else{
              t = data.at(j);
              data.at(j) = data.at(i);
              data.at(i) = t;   
          }
      }
  }
  for(int i = 0; i<N; i++){
      if(i%2==0){
          Alice+=data.at(i);
      }else{
          Bob += data.at(i);
      }
  }
  cout << Alice -Bob << endl;
}

Measured memory_bytes: 3588
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, w, h;
struct Node {
	ll x, ya, yb;
	ll val;
}l[SIZE];
namespace SegTree {
	typedef long long LL;
	const int maxn = 100005;
	const LL inf = -1; //为lazy不用修改的值
	LL tree[maxn << 2], lazy[maxn << 2], a[maxn];
	void build(int root, int left, int right) {
		lazy[root] = inf;
		if (left == right) {
			tree[root] = a[left];
			return;
		}
		int mid = (left + right) >> 1;
		build(root << 1, left, mid);
		build(root << 1 | 1, mid + 1, right);
		tree[root] = max(tree[root << 1], tree[root << 1 | 1]);
		//operation，可更改
	}
	void pushdown(int root, int left, int right) {
		//operation，均要修改！！！！！！！！！！
		if (lazy[root] == inf)
			return;
		int mid = (left + right) >> 1;
		tree[root << 1] = max(tree[root << 1], lazy[root]);
		tree[root << 1 | 1] = max(tree[root < 1 | 1], lazy[root]);
		lazy[root << 1] = max(lazy[root << 1], lazy[root]);
		lazy[root << 1 | 1] = max(lazy[root << 1 | 1], lazy[root]);
		lazy[root] = inf;
	}
	void add(int root, int left, int right, int stdl, int stdr, LL val) {
		if (left >= stdl && right <= stdr) {
			tree[root] = max(tree[root], val);
			lazy[root] = max(lazy[root], val); //operation，可更改
			return;
		}
		pushdown(root, left, right);
		int mid = (left + right) >> 1;
		if (stdl <= mid)
			add(root << 1, left, mid, stdl, stdr, val);
		if (stdr > mid)
			add(root << 1 | 1, mid + 1, right, stdl, stdr, val);
		tree[root] = max(tree[root << 1], tree[root << 1 | 1]);
		//operation，可更改
	}
	LL query(int root, int left, int right, int stdl, int stdr) {
		if (left >= stdl && right <= stdr)
			return tree[root];
		pushdown(root, left, right);
		int mid = (left + right) >> 1;
		LL res = inf;
		if (stdl <= mid)
			res = max(res, query(root << 1, left, mid, stdl, stdr));
		if (stdr > mid)
			res = max(res, query(root << 1 | 1, mid + 1, right, stdl, stdr));
		//operation，可更改
		return res;
	}
}
using namespace SegTree;

int main() {
	while (~scanf("%lld %lld %lld", &h, &w, &n)) {
		ll ans = ceil(1.0 * n / max(h, w));
		printf("%lld\n", ans);
	}
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 100010
#define MOD 1000000007

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); ++i)
	{
		cout << 'x';
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  double tmp = N / 1.08;
  int cand1 = floor(tmp);
  int cand2 = ceil(tmp);
  if(floor(cand1 * 1.08) == N) cout << cand1 << endl;
  else if(floor(cand2 * 1.08) == N) cout << cand2 << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);

    if (B === 1) {
        return console.log(0);
    } else if (B <= A) {
        console.log(1);
    } else {
        console.log(1 + Math.ceil((B - A) / (A - 1)));
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

int main()
{
  while(true)
  {
    int h, w;
    cin >> h >> w;
    if ( h == 0 && w == 0) return 0;
    for (int i=0; i<h; i++)
    {
      for (int j=0; j<w; j++)
      {
        cout << ((i+j)%2 == 0 ? '#' : '.') << flush;
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>
#define MAX_NODES 2000000
#define INF 1010001000

int queue[MAX_NODES];

int pop(void);
void init(void);
void push(int x);
int sz;

int main(void)
{
    int tmp;
    char input[11];
    //init();
    while (scanf("%s", input)) {
        if (input[0] == 'i') {
            scanf("%d", &tmp);
            push(tmp);
        } else if (input[1] == 'x') {
            printf("%d\n", pop());
        } else {
            break;
        }
    }
    return 0;
}


void init(void)
{
    int i;
    for (i = 0; i < MAX_NODES; i++) {
        queue[i] = INF;
    }
}

void push(int x)
{
    int i = sz++, p;
    while (i > 0) {
        p = (i - 1) / 2;
        if (queue[p] >= x) {
            break;
        }
        queue[i] = queue[p];
        i = p;
    }
    queue[i] = x;
}

int pop(void)
{
    int i = 0, a, b;
    int ans = queue[0], x = queue[--sz];
    while (i * 2 + 1 < sz) {
        a = i * 2 + 1;
        b = i * 2 + 2;
        if (b < sz && queue[b] > queue[a]) { 
            a = b;
        }
        if (queue[a] <= x) {
            break;
        }
        queue[i] = queue[a];
        i = a;
    }
    queue[i] = x;
    //queue[sz] = INF;
    return ans;
}

Measured memory_bytes: 4696
#include <iostream>
#include <string>


using namespace std;
int main() {
	int age;
	cin >> age;
	if (age == 3 || age == 5 || age == 7) {
		cout << "YES" << endl;
	} else{
		cout << "NO" << endl;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 1008
import heapq

n, m = map(int,input().split())
s = list(map(int, input().split()))
s = list(map(lambda x: x * (-1), s))
heapq.heapify(s)

for i in range(m):
    mx = heapq.heappop(s) * (-1)
    mx = mx//2
    heapq.heappush(s, mx*(-1))
    
print(sum(s)*(-1))

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

const ll mod = pow(10, 9) + 7;

int main() {
  ll n, result = 1;
  cin >> n;
  
  rep(i, n) {
    result *= (i + 1);
    result %= mod;
  }
  
  cout << result << endl;
  
  return 0;
}


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

int main(int argc, char *argv[])
{
  char s[4];
  std::string r;

  std::cin >> s;
  std::sort(s, s+4);
  if ((s[0] == s[1]) && (s[2] == s[3]) && (s[1] != s[2])) {
    r = "Yes";
  } else {
    r = "No";
  }
  std::cout << r << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int lim=2e5+2;
using namespace std;
void dfs(int node,vector<int>adj[],int dp[],bool vis[]){
	vis[node]=true;
	for(int i=0;i<adj[node].size();i++){
		if(!vis[adj[node][i]])
			dfs(adj[node][i],adj,dp,vis);
		dp[node]=max(dp[node],1+dp[adj[node][i]]);
	}
}
void addEdge(vector<int>adj[],int x,int y){
	adj[x].push_back(y);
}
int main(){
	int i,j,k,n,m,x,y;
	cin>>n>>m;
	vector <int> adj[lim];
	int dp[lim];
	memset(dp,0,sizeof(dp));
	bool vis[lim];
	memset(vis,false,sizeof(vis));
	for(i=0;i<m;i++){
		cin>>x>>y;
		addEdge(adj,x,y);
	}
	for(i=1;i<=n;i++)
		if(!vis[i])
			dfs(i,adj,dp,vis);
	int ans=0;
	for(i=1;i<=n;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}


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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define M 1000000007ll
#define md 998244353

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

void init()
{
    int n;
    cin >> n ;
    vi v1;
    v1.resize(n);
    rep(i,0,n)
    cin >> v1[i];
    int ans = 0;
    int i=1;
    while(i<n)
    {
        if(v1[i] == v1[i-1])
        {
            ans++;
            i+=2;
        }
        else
        {
            i++;
        }
    }
    cout << ans ;
}

int main()
{
    clock_t time1 = clock();
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC085C_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var Y = ReadInt / 1000;

            for (int i = 0; i < 2001; i++)
            {
                for (int j = 0; j < 2001; j++)
                {
                    int rem = Y - 10 * i - 5 * j;
                    if (N - i - j != rem || rem < 0) continue;
                    else
                    {
                        Console.WriteLine(i.ToString() + " " + j.ToString() + " " + (N - i - j).ToString());
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
def main():
    H, W = map(int, input().split())
    s = [input() for _ in range(H)]

    dp = [[H * W] * W for _ in range(H)]

    dp[0][0] = int(s[0][0] == '#')

    for r in range(H):
        for c in range(W):
            if r > 0:
                dp[r][c] = min(dp[r][c], dp[r - 1][c] + int(s[r][c] == '#' and s[r - 1][c] == '.'))
            if c > 0:
                dp[r][c] = min(dp[r][c], dp[r][c - 1] + int(s[r][c] == '#' and s[r][c - 1] == '.'))

    res = dp[H - 1][W - 1]
    print(res)
    return


if __name__ == '__main__':
    main()


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

#define MAX 45

int fibonacci(int n)
{
    if (n == 0 || n == 1)
    {
        return 1;
    }
    else
    {
        return fibonacci(n-1) + fibonacci(n-2);
    }
}

int main()
{
    int C;

    cin >> C;

    //cout << fibonacci(C) << endl;

    int F[MAX];

    F[0] = 1;
    F[1] = 1;

    for (int i = 2; i < MAX; i++)
    {
        F[i] = F[i - 1] + F[i - 2];
    }

    cout << F[C] << endl;

    return 0;
}


Measured memory_bytes: 3100
X = list(map(int, input().split()))
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

#K = int(input())
#S = input()

##一次元配列の初期化
#a=[0]*5
#[i for i in range(100) if i%2==1] #奇数のみ
##二次元配列の初期化
#[[float("inf") for i in range(N)] for i in range(N)]

for i in range(len(X)):
    if X[i] == 0:
        break
    

print(i+1)

Measured memory_bytes: 9028
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int>X(N + 1);
    X[0] = 0;
    rep(i, N)X[i + 1] = X[i] + (S.at(i) == 'I' ? 1 : -1);
    sort(X.begin(), X.end());
    cout << X[N] << endl;
}

Measured memory_bytes: 3544
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;
 
void solve(){
	int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<"\n";
}
 
 
signed main(){
	ios::sync_with_stdio(false);
        cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int i,n,x,b,a,m,r;
  
  scanf("%d%d%d",&n,&b,&a);
  
  if(b>a) m=a;
  
  else m=b;
  
  for(i=2;i<n;i++)
    
    {
      
      scanf("%d",&x);
      if(x>a) a=x;
      if(x-m>a-b)
	
    {
      
      a=x;
      b=m;
    }
      
      if(x<m) m=x;
      
    }
  r=a-b;
  
  
  printf("%d\n",r);
  return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
#include<string.h>
int main(){
  char s[15];
  scanf("%s",s);
  int len,i,ans=0;
  len=strlen(s);
  if(s[0]=='A'){
    for(i=1;i<len;i++){
      if('A'<=s[i] && s[i] <='Z'){
        if(1<i&&i<len-1 && s[i]=='C')ans++;
        else ans+=2;
      }
    }
  }
  puts(ans==1?"AC":"WA");
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

using Input = pair<int, int>;

int main()
{
	long X, t;
	cin >> X >> t;
	auto result = X - t;
	if (result < 0)
		result = 0;

	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
x=[[0 for i in range(2)] for i in range(M)]
for i in range(M):
  a,b=map(int,input().split())
  x[i][0]=b
  x[i][1]=a
x.sort()
count=0
bmax=-1
for i in range(M):
  if(bmax<=x[i][1]):
    count+=1
    bmax=x[i][0]
#print(x)
print(count)

Measured memory_bytes: 21680
#include <iostream>
int main(){
int a,b,c=1,d=0;
while(c=1){
    std::cin>>a;
     
    int z=-100000;
 
    if(a==0){
        return 0;
    }
    int aa[a];
    for(int t=1;t<=a;t++){
        std::cin>>b;
     
        aa[t]=b;
    }
     
    for(int s=1;s<=a;s++){
         
            for(int l=s;l<=a;l++){
                d=d+aa[l];
                if(z<d){
                    z=d;
                }
            }d=0;
         
         
    }
    std::cout<<z<<std::endl;
     
}
}

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

int main(int argc, char const *argv[])
{
	int n,r;
	while(cin>>n>>r,n+r)
	{
		int a[n],b[n];
		for (int i = 0; i < n; ++i) a[i]=n-i;
		int p,c;
		for (int i = 0; i < r; ++i)
		{
			cin>>p>>c;
			--p;
			for (int i = 0; i < n; ++i) b[i]=a[i];
			for (int i = 0; i < c; ++i) a[i]=b[i+p];
			for (int i = 0; i < p; ++i) a[i+c]=b[i];
		}
		cout<<a[0]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3012
#include <algorithm> //STLÍ¨ÓÃËã·¨
#include <cmath> //¶¨ÒåÊýÑ§º¯Êý
#include <cstdio> //¶¨ÒåÊäÈë/Êä³öº¯Êý
#include <iostream> //Êý¾ÝÁ÷ÊäÈë/Êä³ö
#include <cstring> //×Ö·û´®´¦Àí
#include <string> //×Ö·û´®Àà
#include <ctime> //¶¨Òå¹ØÓÚÊ±¼äµÄº¯Êý
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLÎ»¼¯ÈÝÆ÷
#include <cstype> //×Ö·û´¦Àí
#include <cerrno> //¶¨Òå´íÎóÂë
#include <complex> //¸´ÊýÀà
#include <clocale> //¶¨Òå±¾µØ»¯º¯Êý
#include <cstdlib> //¶¨ÒåÔÓÏîº¯Êý¼°ÄÚ´æ·ÖÅäº¯Êý
#include <deque> //STLË«¶Ë¶ÓÁÐÈÝÆ÷
#include <exception> //Òì³£´¦ÀíÀà
#include <fstream> //ÎÄ¼þÊäÈë/Êä³ö
#include <functional> //STL¶¨ÒåÔËËãº¯Êý(´úÌæÔËËã·û)
#include <limits> //¶¨Òå¸÷ÖÖÊý¾ÝÀàÐÍ×îÖµ³£Á¿
#include <list> //STLÏßÐÔÁÐ±íÈÝÆ÷
#include <map> //STLÓ³ÉäÈÝÆ÷
#include <iomanip> //²ÎÊý»¯ÊäÈë/Êä³ö
#include <ios> //»ù±¾ÊäÈë/Êä³öÖ§³Ö
#include <iosfwd> //ÊäÈë/Êä³öÏµÍ³Ê¹ÓÃµÄÇ°ÖÃÉùÃ÷
#include <istream> //»ù±¾ÊäÈëÁ÷
#include <ostream> //»ù±¾Êä³öÁ÷
#include <queue> //STL¶ÓÁÐÈÝÆ÷
#include <set> //STL¼¯ºÏÈÝÆ÷
#include <sstream> //»ùÓÚ×Ö·û´®µÄÁ÷
#include <stack> //STL¶ÑÕ»ÈÝÆ÷
#include <stdexcept> //±ê×¼Òì³£Àà
#include <streambuf> //µ×²ãÊäÈë/Êä³öÖ§³Ö
#include <utility> //STLÍ¨ÓÃÄ£°åÀà
#include <vector> //STL¶¯Ì¬Êý×éÈÝÆ÷
#include <cwchar.h>//¿í×Ö·û´¦Àí¼°ÊäÈë/Êä³ö
#include <cwctype.h> //¿í×Ö·û·ÖÀà*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
char s[200200];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int flag=1;
	ans=n;
	for (int i=2;i<=n;i++)
	{
		if (s[i]==s[i-1]&&flag) flag=0,ans--,i++;else flag=1;
	}
	cout<<ans;
	return 0;
}








Measured memory_bytes: 384
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int d;
int main(){std::ios::sync_with_stdio(false);
cin>>d;
if(d==25)
{
	cout<<"Christmas"<<endl;
	return 0;
}
if(d==24)
{
	cout<<"Christmas Eve"<<endl;
	return 0;
}
if(d==23)
{
	cout<<"Christmas Eve Eve"<<endl;
	return 0;
}
cout<<"Christmas Eve Eve Eve"<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

long long int memo[51][51];

long long int hoge(int n, int k){
	if (memo[n][k] != 0)
		return memo[n][k];


	if (k == 0)
		return memo[n][k] = 1;

	if (n == 0)
		return memo[n][k] = 0;

	return memo[n][k] = hoge(n-1, k) + hoge(n-1, k-1);
}

int main(void){
	int n, a, b;
	cin >> n >> a >> b;

	vector<long long int> v(n);

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

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

	long long int sum = 0;
	for (int i = n-a; i < n; i++){
		sum += v[i];
	}
	double ave = (double)sum/a;

	int num_n = 0, num_k = 0;

	for (int i = 0; i < n; i++){
		if (v[i] == v[n-a]){
			num_n++;
			if (i >= n-a)
				num_k++;
		}
	}

	long long int fuga = 0;

	if (v[n-1] != v[n-a]){
		fuga = hoge(num_n, num_k);
	}
	else {
		for (int i = a; i <= min(num_n, b); i++){
			fuga += hoge(num_n, min(num_n - i, i));
		}
	}


	printf("%.20lf\n%lld\n", ave, fuga);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    priority_queue<long long> large;
    priority_queue<long long, vector<long long>, greater<long long>> small;
    REP(i, N) {
        long long a;
        cin >> a;
        large.push(a);
        small.push(a);
    }
    vector<long long> x(N);
    vector<long long> y(N);
    REP(i, N - 1) {
        long long s = small.top();
        long long l = large.top();
        small.pop();
        large.pop();
        if(l - s - large.top() > -(s - l - small.top()) or i == N - 2) {
            large.push(l - s);
            small.push(l - s);
            x[i] = l;
            y[i] = s;
        } else {
            x[i] = s;
            y[i] = l;
            large.push(s - l);
            small.push(s - l);
        }
    }
    cout << large.top() << endl;
    REP(i, N - 1) { cout << x[i] << " " << y[i] << endl; }
    return 0;
}

Measured memory_bytes: 5228
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
LL X[100000],Y[100000];
char C[100000];

LL ans = 0;

void solve(){
    vector<vector<LL>> accum(2*K,vector<LL>(2*K,0));
    for(int i=0;i<N;i++){
        X[i] %= (2*K);
        Y[i] %= (2*K);
        if(C[i]=='B') X[i] = (X[i]+K)%(2*K);
        accum[X[i]][Y[i]]++;
    }

    for(int y=1;y<2*K;y++) accum[0][y] += accum[0][y-1];
    for(int x=1;x<2*K;x++) accum[x][0] += accum[x-1][0];
    for(int y=1;y<2*K;y++){
        for(int x=1;x<2*K;x++){
            accum[x][y] += (accum[x-1][y]+accum[x][y-1]-accum[x-1][y-1]);
        }
    }

    auto get_accum = [&](int start_x,int start_y,int end_x,int end_y){
        LL ret = accum[end_x][end_y];
        if(start_x>=1 && start_y>=1){
            ret -= accum[start_x-1][end_y];
            ret -= accum[end_x][start_y-1];
            ret += accum[start_x-1][start_y-1];
        }else if(start_x>=1){
            ret -= accum[start_x-1][end_y];
        }else if(start_y>=1){
            ret -= accum[end_x][start_y-1];
        }
        return ret;
    };

    auto get_accum_rec = [&](int start_x,int start_y,int end_x,int end_y){
        if(start_x<=end_x && start_y<=end_y) return get_accum(start_x,start_y,end_x,end_y);
        if(start_x>end_x && start_y<=end_y) return get_accum(start_x,start_y,2*K-1,end_y)+get_accum(0,start_y,end_x,end_y);
        if(start_x<=end_x && start_y>end_y) return get_accum(start_x,start_y,end_x,2*K-1)+get_accum(start_x,0,end_x,end_y);
        LL ret = 0;
        ret += get_accum(start_x,start_y,2*K-1,2*K-1);
        ret += get_accum(0,0,end_x,end_y);
        ret += get_accum(0,start_y,end_x,2*K-1);
        ret += get_accum(start_x,0,2*K-1,end_y);
        return ret;
    };

    for(int start_y=0;start_y<2*K;start_y++){
        for(int start_x=0;start_x<2*K;start_x++){
            LL middle_x = (start_x+K-1)%(2*K);
            LL middle_y = (start_y+K-1)%(2*K);
            LL next_x = (middle_x+1)%(2*K);
            LL next_y = (middle_y+1)%(2*K);
            LL end_x = (next_x+K-1)%(2*K);
            LL end_y = (next_y+K-1)%(2*K);
            LL num = 0;
            num += get_accum_rec(start_x,start_y,middle_x,middle_y);
            num += get_accum_rec(next_x,next_y,end_x,end_y);
            ans = max(ans,num);
            ans = max(ans,N-num);
        }
    }
}

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> X[i] >> Y[i] >> C[i];

    solve();

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

Measured memory_bytes: 35900
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	cout << (ll)n * (n + 1) / 2 - n << endl;
	return 0;
}

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

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(r: int, g: int, b: int):
    if (r * 100 + g * 10 + b) % 4 == 0:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    g = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(r, g, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n,m = map(int,input().split())
par = [i for i in range(n)]
rank = [0 for i in range(n)]

def find(x, par):
    if x == par[x]:
        return par[x]
    else:
        return find(par[x], par)
def unite(x, y, par, rank):
    x = find(x, par)
    y = find(y, par)
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for i in range(m):
    x,y,z = map(int,input().split())
    unite(x-1, y-1, par, rank)
for i in range(n):
    par[i] = find(par[i], par)

T = list(set(par))
print(len(T))


Measured memory_bytes: 13984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<class T>
struct CumulativeSum2D{
    vector<vector<T>> data;

    CumulativeSum2D(int W, int H) : data(W + 1, vector<int>(H + 1, 0)) {}

    void add(int x, int y, T z){
        ++x, ++y;
        if(x >= data.size() || y >= data[0].size()) return;
        data[x][y] += z;
    }

    void build(){
        for(int i = 1; i < data.size(); ++i){
            for(int j = 1; j < data[i].size(); ++j){
                data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
            }
        }
    }

    T query(int sx, int sy, int gx, int gy){
        return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
    }
};

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

    int n, k;
    cin >> n >> k;
    CumulativeSum2D<int> S(k * 2, k * 2);
    for(int i = 0; i < n; ++i){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if(c == 'B')    x += k;
        x %= k * 2, y %= k * 2;
        S.add(x, y, 1);
    }
    S.build();
    int ans = 0;
    for(int i = 0; i <= k; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, i + k, j + k);
            X += S.query(0, 0, i, j);
            X += S.query(i + k, 0, k * 2, j);
            X += S.query(0, j + k, i, k * 2);
            X += S.query(i + k, j + k, k * 2, k * 2);
            chmax(ans, X);
        }
    }
    for(int i = k; i <= k * 2; ++i){
        for(int j = 0; j <= k; ++j){
            int X = S.query(i, j, k * 2, j + k);
            X += S.query(i - k, 0, i, j);
            X += S.query(i - k, j + k, i, k * 2);
            X += S.query(0, j, i - k, j + k);
            chmax(ans, X);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 19016
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+5000;
const ll inf=1e17+800;
const ll mod=1e9+7;

ll dp[maxn][5];

ll a[maxn];
char c[maxn];
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    

    ll n;
    cin>>n;
    c[1]='+';
    cin>>a[1];
    for(ll i=2;i<=n;i++){
        cin>>c[i]>>a[i];
    }
    dp[0][0]=0;
    for(ll i=1;i<5;i++){
        dp[0][i]=-inf;
    }
    ll v;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<5;j++){
            dp[i][j]=-inf;
            for(ll k=0;k<5;k++){
                // dp[i][j]
                if(c[i]=='-'){ 
                    ll x=j+k-1;
                    if(x%2==0){
                        v=-a[i];
                    }else{
                        v=a[i];
                    }
                    if(0<=x && x<5){
                        dp[i][j]=max(dp[i][j],dp[i-1][x]+v);
                    }
                }else{
                    ll x=j+k;
                    if(x%2==0){
                        v=a[i];
                    }else{
                        v=-a[i];
                    }
                    if(0<=x && x<5){
                        dp[i][j]=max(dp[i][j],dp[i-1][x]+v);
                    }
                }
            }
        }
    }
    cout<<dp[n][0];
}
































Measured memory_bytes: 5120
import Data.List

main ::  IO ()
main = getLine >>= print . solve . map (== 'B')

solve :: [Bool] -> Int
solve = count 0 0

count :: Int -> Int -> [Bool] -> Int
count acc bc xxs@(_ : _)
    | null rs = acc
    | otherwise = count (acc + bc + n) (bc + n) $ tail rs
    where
        (bs, rs) = span id xxs
        n = length bs 
count acc _ _ = acc

Measured memory_bytes: 13820
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> a1(n), a2(n);
    rep(i, n)
    {
        cin >> a1[i];
    }

    rep(i, n)
    {
        cin >> a2[i];
    }

    vector<int> b1(n), b2(n);
    rep(i, n)
    {
        if (i == 0) {
            b1[i] = a1[i];
        } else {
            b1[i] = b1[i - 1] + a1[i];
        }
    }

    rrep(i, n)
    {
        if (i == n - 1) {
            b2[i] = a2[i];
        } else {
            b2[i] = b2[i + 1] + a2[i];
        }
    }

    int result = 0;
    rep(i, n)
    {
        int score = b1[i] + b2[i];
        result = max(result, score);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	ll ans=t.length();
	for(ll p=0;p<s.length()-t.length()+1;p++)
	{
		ll cnt=0;
		for(ll j=0;j<t.length();j++)
		{
			if(s[p+j]==t[j]) cnt++;
		}
		ll kj=t.length();
		ans=min(ans,kj-cnt);
	}
	cout<<ans;
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
const int MOD = 2019;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>>s;
	int n = s.size();
	vector<int> num(n);
	FOR(0, i, <n){
		num[i] = s[i]-'0';
	}
	vector<int> suffix(n+1, 0);
	vector<int> occ(MOD, 0);
	occ[0]++;
	int tenPow = 1;
	int ans = 0;
	for (int i = n-1; i >= 0; i--){
		suffix[i] = (num[i]*tenPow+suffix[i+1]) % MOD;
		tenPow *= 10;
		tenPow %= MOD;
		ans += occ[suffix[i]]++;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 5088