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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  string s, t;
  cin >> s >> t;
  vector<int> sa(s.size() + 1, 0), sb(sa);
  rep(i, 0, s.size()) {
    sa[i + 1] = sa[i] + (s[i] == 'A');
    sb[i + 1] = sb[i] + (s[i] == 'B');
  }
  vector<int> ta(t.size() + 1, 0), tb(ta);
  rep(i, 0, t.size()) {
    ta[i + 1] = ta[i] + (t[i] == 'A');
    tb[i + 1] = tb[i] + (t[i] == 'B');
  }

  dump(sa);
  dump(sb);
  dump(ta);
  dump(tb);
  int q;
  cin >> q;
  loop(q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--, c--;
    dump(s.substr(a, b - a), t.substr(c, d - c));
    dump(sa[b]-sa[a],sb[b]-sb[a]);
    dump(ta[d]-ta[d],tb[d]-tb[c]);
    int x = abs(sa[b] - sa[a] + 2 * (sb[b] - sb[a])) % 3;
    int y = abs(ta[d] - ta[c] + 2 * (tb[d] - tb[c])) % 3;
    dump(x,y);
    YES(x == y);
  }

  return 0;
}


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

int main() {
	
	int N;
	cin >>N;
	
	int count=0;
	
	for(int i=0; i<N; i++){
		
		string str;
		str=to_string(i+1);
		
		if(str.size()%2==1){
			
			count++;
			
		}
		
	}
	
	cout <<count <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<climits>
#include<cmath>
#include<stdio.h>
#include<fstream>
#include<numeric>

int main(){
	int X, A;

	std::cin >> X >> A;

	if(X < A) std::cout << 0 << std::endl;
	else std::cout << 10 << std::endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let s = {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (a, b) = {
        let mut ws = s.split_whitespace();
        let a: i32 = ws.next().unwrap().parse().unwrap();
        let b: i32 = ws.next().unwrap().parse().unwrap();
        (a, b)
    };
    if (a * b) % 2 == 0 {
        print!("No");
    } else {
        print!("Yes");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int n, m;
    cin >> n >> m;
    
    ll tmp = 1900 * m + (n - m) * 100;

    int k = 2;
    for (int i = 0; i < m - 1; i++){
        k *= 2;
    }
  
    cout << tmp * k << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
ll mod = 1000000007,a[200010],s = 0;
int main(){
    int i,n; cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i]; (s += a[i]) %= mod;
    }
    (s *= s) %= mod;
    for(i=0;i<n;i++){
        s -= a[i]*a[i]%mod;
        if(s<0) s += mod;
    }
    (s *= (mod + 1)/2) %= mod;
    cout << s << endl;
}

Measured memory_bytes: 5176
module ABC142

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_B

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B (num_people, height_min, data_height)

    ! arguments for this <subroutine>
    integer(INT32), intent(in) :: num_people
    integer(INT16), intent(in) :: height_min
    integer(INT16), intent(in) :: data_height(1:num_people)

    ! variables for this <subroutine>
    integer(INT32) :: itr
    integer(INT32) :: sum

    ! STEP.01
    ! initialize the variables
    sum = 0_INT32

    ! STEP.02
    ! count up the number of people who can ride the roller coaster
    do itr = 1_INT32, num_people, 1_INT32
      if ( data_height(itr) .ge. height_min ) sum = sum + 1_INT32
    end do

    ! STEP.03
    ! output the answer of this task
    print '(I0)', sum

    ! STEP.END
    return

  end subroutine task_B

end module ABC142


program main

  ! <module>s to import
  use, non_intrinsic :: ABC142

  ! require all variables to be explicitly declared
  implicit none

  ! constants for this <program>
  integer(INT32), parameter :: num_people_max = 10_INT32 ** 5_INT32

  ! variables for this <program>
  integer(INT32) :: N
  integer(INT16) :: K
  integer(INT16) :: h(1:num_people_max)

  ! STEP.01
  ! read out the given data
  read(unit=INPUT_UNIT, fmt=*) N, K
  read(unit=INPUT_UNIT, fmt=*) h(1:N)

  ! STEP.02
  ! calculate & output the answer of this task
  call task_B (N, K, h(:))

end program main

Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
  int N,s[100010];
  double M[100010];
  double sum=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++)
  {
    scanf("%d",&s[i]);
    M[i]=(double)1/s[i];
    sum+=M[i];
  }
  printf("%lf",(double)1/sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	ll w, h;
	vector<pair<ll, ll> > e;
	cin >> w >> h;
	rep(i,0,w) {
		ll a;
		cin >> a;
		e.pb(mp(a,0));
	}
	rep(i,0,h) {
		ll a;
		cin >> a;
		e.pb(mp(a,1));
	}
	sort(all(e));
	h++;
	w++;
	ll cost = 0;
	rep(i,0,sz(e)) {
		ll d;
		if(e[i].S == 0) {
			d = h;
		} else {
			d = w;
		}
		cost += e[i].F * d;
		if(e[i].S == 0) {
			w--;
		} else {
			h--;
		}
	}
	cout << cost << '\n';
	return 0;
}


Measured memory_bytes: 6560
#include <stdio.h>
int main(void){
	int cir_x,cir_y,hankei,box_x,box_y;//?????¨????????¢????????°??????
	scanf("%d%d%d%d%d",&box_x,&box_y,&cir_x,&cir_y,&hankei);//??°????????\???
	if(0+hankei<=cir_x&&0+hankei<=cir_y){
		if(cir_x+hankei<=box_x&&cir_y+hankei<=box_y){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long ll;
#define print(x) cout<<(x)<<endl


#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


// DONT USE "int", USE "ll" !!!!!!!!!!!!
int main() {
	int out[50][50];

	int S[50][50];

	int H, W;
	cin >> H >> W;

	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < W; j++) {
			if (s[j] == '.') {
				S[i][j] = 0;
			}
			else{
				S[i][j] = 1;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			out[i][j] = 0;
			if (i > 0) {
				out[i][j] += S[i - 1][j];
				if (j > 0)out[i][j] += S[i - 1][j - 1];
				if (j < W-1)out[i][j] += S[i - 1][j + 1];
			}
			if (i < H-1) {
				out[i][j] += S[i + 1][j];
				if (j > 0)out[i][j] += S[i + 1][j - 1];
				if (j < W-1)out[i][j] += S[i + 1][j + 1];
			}
			if (j > 0) {
				out[i][j] += S[i][j-1];
			}
			if (j < W-1) {
				out[i][j] += S[i][j+1];
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if(S[i][j]==0)cout << out[i][j];
			else cout << '#';
		}
		cout << endl;
	}
	



	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string Si;
    cin >> Si;
    if (Si == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N-1) {
      cout << "Three" << endl;
    }
  }  
}

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

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

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);
double distance(int xi, int yi, int xj, int yj);

//main function
int main() {
    long long a = llin(), b = llin(), k = llin();
    if (a > k) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        if (k > 0) {
            if (b > k) {
                b -= k;
            } else {
                b = 0;
            }
        }
    }
    printf("%lld %lld\n", a, b);
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}

double distance(int xi, int yi, int xj, int yj) {
    return hypot(xj - xi, yj - yi);
}


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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};

/********************************************************************/
int main() {
	FAST();
	ll ar[5];
	ll ans ;
	for (int i = 0; i < 5; i++) {
		cin >> ar[i];
		if (!ar[i])
			ans = i + 1;
	}
	cout << ans;
	return 0;
}

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

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

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

    int a[n], b[n], c[n];
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];

    int dp[n][3];
    for (int i = 0; i < n; ++i) {
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (j == 0) {
                chmax(dp[i][0], dp[i - 1][1] + a[i]);
                chmax(dp[i][0], dp[i - 1][2] + a[i]);
            }

            if (j == 1) {
                chmax(dp[i][1], dp[i - 1][0] + b[i]);
                chmax(dp[i][1], dp[i - 1][2] + b[i]);
            }

            if (j == 2) {
                chmax(dp[i][2], dp[i - 1][0] + c[i]);
                chmax(dp[i][2], dp[i - 1][1] + c[i]);
            }
        }
    }

    int ans = max(dp[n - 1][0], dp[n - 1][1]);
    ans = max(ans, dp[n - 1][2]);

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

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

int A[9];
int B[9];

bool check(int* arr){
	return arr[0] + arr[2] + arr[5] + (arr[1] + arr[4])*10 + arr[3]*100 == arr[6]*100 + arr[7]*10 + arr[8];
}

int perm(vector<int> v,vector<int> idx,int* arr,int ans=0){
	if(v.empty()){
		if(check(arr)){
			return ans + 1;
		}
		else{
			return ans;
		}
	}
	for(int i = 0; i < v.size(); i++){
		arr[idx[idx.size()-1]] = v[i];
		vector<int> idx2 = idx;
		vector<int> v2 = v;
		idx2.pop_back();
		v2.erase(v2.begin()+i);
		ans = perm(v2,idx2,arr,ans);
	}
	return ans;
}

int main(){
	vector<int> v = vector<int>(9);
	vector<int> idx = vector<int>();
	for(int i = 0; i < 9; i++){
		v[i] = i+1;
	}
	for(int i = 0; i < 9; i++){
		cin >> A[i];
		B[i] = A[i];
		if(A[i] != -1){
			for(int j = 0; j < v.size(); j++){
				if(v[j] == A[i]){
					v.erase(v.begin()+j);
					break;
				}
			}
		}
		else{
			idx.push_back(i);
		}
	}
	cout << perm(v,idx,B) << endl;

	return 0;
}



Measured memory_bytes: 3156
using System;
using System.Collections;
using System.Linq;

namespace AOJ {
    public class Probrem {
        public static void Main() {
            var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(data);
            Console.WriteLine(data[0] + " " + data[1] + " " + data[2]);
        }
    }
}


Measured memory_bytes: 9652
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  double N, K;
  cin >> N >> K;
  vll A(N);
  REP(i, 0, N) {
    cin >> A[i];
  }

  if (N <= K) {
    cout << 1 << endl;
    return 0;
  }

  cout << (ll)ceil((N - 1) / (K - 1)) << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

typedef long long ll;

int main(void) {
    ll L, R;
    scanf("%lld %lld", &L, &R);

    if (R - L + 1 > 2019) {
        printf("%d\n", 0);
        return 0;
    }
    ll min = 10000000000;
    for (ll i=L; i<R; i++) {
        for (ll j=i+1; j<=R; j++) {
            ll num = (i * j) % 2019;
            if (num == 0) {
                printf("%d\n", 0);
                return 0;
            }
            if (min > num) {
                min = num;
            }
        }
    }
    printf("%d\n", (int)min);

    return 0;
}



Measured memory_bytes: 128
import java.util.Scanner;

/**
 * TITLE : The Number of Even Pairs
 * URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
 */
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        sc.close();
        int answer = 0;
        for (int i = 1; i < N; i++) {
            for (int j = i; j < N; j++) {
                answer++;
            }
        }
        for (int i = 1; i < M; i++) {
            for (int j = i; j < M; j++) {
                answer++;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

int n, k;
vector<int> a;

bool ok(int L) {
	int cnt = 0;
	for (int i = 0; i < n; ++i)
		cnt += (a[i] - 1) / L;
	return cnt <= k;
}

int main() {
	cin >> n >> k;
	a.resize(n);
	for (int& e : a) cin >> e;
	int l = 0, r = 1e9;
	while (r - l > 1) {
		int mid = (l + r) >> 1;
		if (ok(mid)) r = mid;
		else l = mid;
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 4020
#include <iostream>

int main()
{
    int a, b, c, d, e, k;
    std::cin >> a >> b >> c >> d >> e >> k;

    if ((e - a) <= k)
    {
        std::cout << "Yay!" << std::endl;
    }
    else
    {
        std::cout << ":(" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    scan.close();

    long sum = 0;
    for(int a=1; a<=N; a++) {
      for(int b=1; b<=N; b++) {
        for(int c=1; c<=N; c++) {
          sum += gcd(a, gcd(b,c));
        }
      }
    }
    System.out.println(sum);
  }

  public static int gcd(int a, int b) {
    int r = a % b;
    while(r != 0) {
      a = b;
      b = r;
      r = a % b;
    }
    return b;
  }
}

Measured memory_bytes: 27236
N = int(input())
A = list(map(int, input().split()))
minus_cnt = 0
for i in range(len(A)):
    if A[i] < 0:
        minus_cnt += 1
        A[i] = -A[i]
if minus_cnt % 2 == 0:
    print(sum(A))
else:
    tmp = float("inf")
    for a in A:
        if tmp > abs(a):
            tmp = a
    print(sum(A) - 2 * tmp)


Measured memory_bytes: 14412
S = list(raw_input())

array=[]

if len(S) == 1:
    print 0
else:
    cnt = 0
    for i in range(len(S)):
#        print "--", i
        if i == 0:
            cnt = 1
        else:
            if S[i-1] == S[i]:
                array.append(cnt)
                cnt = 1
            else:
                cnt += 1
    array.append(cnt)
#    print "array:",array
    even = [n for i,n in enumerate(array) if i % 2 == 0]
    odd  = [n for i,n in enumerate(array) if i % 2 == 1]

#    print even
#    print odd
    
    if sum(even) > sum(odd):
        print sum(odd)
    else:
        print sum(even)


Measured memory_bytes: 7436
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const int N = 2*1e5;

template <class T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int arr[N];
bool vis[N+1];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h, n, x;
	int sum = 0;
	cin >> h >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		sum += x;
	}
	if (sum >= h) cout << "Yes" << '\n';
	else cout << "No" << '\n';
}


Measured memory_bytes: 3616
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
typedef pair<P, int> PI;

void color(vector<PI> &points, vector<int> &c, int D) {
	if (D % 2 == 1) {
		for (PI p : points) {
			c[p.second] = (p.first.first + p.first.second) % 2;
		}
	}
	else if (D % 4 == 2) {
		for (PI p : points) {
			c[p.second] = p.first.first % 2;
		}
	}
	else {
		vector<PI> v[2][2];
		for (PI p : points) {
			v[p.first.first % 2][p.first.second % 2].emplace_back(P(p.first.first / 2, p.first.second / 2), p.second);
		}
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) color(v[i][j], c, D / 4);
		}
	}
}
int main() {
	int N, D1, D2;
	cin >> N >> D1 >> D2;
	vector<PI> points;
	vector<int> c1(4 * N*N), c2(4 * N*N);
	for (int i = 0; i < 2 * N; i++) {
		for (int j = 0; j < 2 * N; j++) {
			points.emplace_back(P(i, j), i*(2 * N) + j);
		}
	}
	color(points, c1, D1);
	color(points, c2, D2);
	vector<PI> group[4];
	for (PI p : points) {
		group[c1[p.second] * 2 + c2[p.second]].push_back(p);
	}
	for (int i = 0; i < 4; i++) {
		if (group[i].size() >= N * N) {
			for (int j = 0; j < N*N; j++) {
				cout << group[i][j].first.first << " " << group[i][j].first.second << endl;
			}
			return 0;
		}
	}
}


Measured memory_bytes: 20540
using System;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var sp = Console.ReadLine().Split(' ');
            var x = long.Parse(sp[0]);
            var k = long.Parse(sp[1]);
            var d = long.Parse(sp[2]);
            x = Math.Abs(x);

            var b = x / d;
            if (b >= k)
            {
                Console.WriteLine((x - (d * k)));
            }
            else
            {
                x -= b * d;
                if (((k-b)%2)==0)
                {
                    Console.WriteLine(x);
                }
                else
                {
                    Console.WriteLine(Math.Abs(x-d));
                }
            }
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27512
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
diff=[V[i]-C[i] for i in range(N)]
diff.sort(reverse=True)
x=0
for i in range(N):
    if diff[i]<0:
        break
    x+=diff[i]
print(x)


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

using namespace std;

int sz, N, M, Q, globalX, sg[200009], val[200009], comp[200009];
bool fixedX, ap[200009];
vector < pair < int, int > > v[200009];

void Ans (bool x)
{
    if (x) printf ("Yes\n");
    else printf ("No\n");
    exit (0);
}

void dfs (int nod, int sg2, int val2)
{
    if (ap[nod])
    {
        if (sg2 == sg[nod] && val2 != val[nod]) Ans (0);
        if (sg2 != sg[nod])
        {
            ///X*sg2+val2=X*sg[nod]+val[nod]
            ///X*(sg2-sg[nod])=val[nod]-val2
            int sus = val[nod] - val2, jos = sg2 - sg[nod];
            if (sus % jos != 0) Ans (0);
            int currX = sus / jos;
            if (fixedX)
            {
                if (globalX != currX) Ans (0);
            }
            else globalX = currX, fixedX = 1;
        }
        return ;
    }
    comp[++sz] = nod;
    ap[nod] = 1, sg[nod] = sg2, val[nod] = val2;
    for (auto it = v[nod].begin (); it != v[nod].end (); it ++)
        dfs (it->first, -sg[nod], it->second - val[nod]);
        ///sg[nod] * X + val[nod] + s2 * X + v2 = it->second
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
scanf ("%d", &Q);
for (int i=1; i<=Q; i++)
{
    int x, y, val;
    scanf ("%d %d %d", &x, &y, &val), y += N;
    v[x].push_back (make_pair (y, val));
    v[y].push_back (make_pair (x, val));
}
for (int i=1; i<=N + M; i++)
    if (ap[i] == 0)
    {
        fixedX = 0, sz = 0;
        dfs (i, 1, 0);
        int mi = 2e9, ma = -2e9;
        for (int j=1; j<=sz; j++)
        {
            int nod = comp[j];
            if (fixedX)
            {
                int curr = globalX * sg[nod] + val[nod];
                if (curr < 0) Ans (0);
            }
            else
            {
                if (sg[nod] == -1 && val[nod] < mi) mi = val[nod];
                if (sg[nod] == 1 && -val[nod] > ma) ma = -val[nod];
            }
        }
        if (fixedX == 0 && mi < ma) Ans (0);
    }
Ans (1);
return 0;
}


Measured memory_bytes: 13312
from collections import Counter
import math

def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
S = [[s for s in input()] for _ in range(n)]
for i in range(n):
    tmp = ''.join(sorted(S[i]))
    S[i] = tmp

ans = 0
for v in Counter(S).values():
    if v!=1: ans += cc(v,2)
print(ans)


Measured memory_bytes: 30604
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

int D[21][21];

int main() {
	int N; cin >> N;
	int M; cin >> M;
	int start, goal;
	int y1, y2;
	rep(i,N) rep(j,N) {
		D[i][j] = INF / 10;
		D[j][i] = INF / 10;
	}
	cin.ignore();
	rep(i,M) {
		string line;
		getline(cin, line);
		rep(j,line.size()) if(line[j] == ',') line[j] = ' ';
		istringstream is(line);
		for(int a, b, c, d; is >> a >> b >> c >> d;) {
			a--, b--;
			D[a][b] = c;
			D[b][a] = d;
		}
	}
	

	string line;
	getline(cin, line);
	rep(j,line.size()) if(line[j] == ',') line[j] = ' ';
	istringstream is(line);
	
	is >> start >> goal >> y1 >> y2;
	start--, goal--;
	rep(k,N) rep(i,N) rep(j,N) D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
#if 0
	debug(D[start][goal]);
	debug(D[goal][start]);
#endif
	cout << y1 - (y2 + D[start][goal] + D[goal][start]) << endl;;
}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def M(n): return ModInt(n)
def MI(): return M(I())

class ModInt():
    def __init__(self, n):
        self.n = n

    def __add__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n+x) % mod)

    def __sub__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n-x) % mod)

    def __mul__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n*x) % mod)

    def __truediv__(self, x):
        x = ModInt.xn(x)
        return ModInt(self.n * pow(x, mod-2, mod) % mod)

    @classmethod
    def xn(cls, x):
        if isinstance(x, ModInt):
            return x.n
        return x

    def __str__(self):
        return str(self.n)

def main():
    n = I()
    a = LI_()
    b = [-1] * n
    t = 1
    for i in range(n+1):
        c = a[i]
        if b[c] >= 0:
            t = i - b[c]
            break
        b[c] = i

    rr = [n]
    nb = M(n+1)
    nt = M(1)
    for i in range(2,n+2):
        nb *= n-i+2
        nb /= i

        tr = nb.n
        if n-t >= i-1:
            nt *= n-t-i+2
            nt /= i-1
            tr -= nt.n
            tr %= mod
        rr.append(tr)
    return '\n'.join(map(str, rr))

print(main())





Measured memory_bytes: 25924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  for(int i=0;i<H+2;i++){
    if(i==0 || i==H+1){
      vector<string> vec(W+2,"#");
      for(int j=0;j<W+2;j++){
        cout<<vec.at(j);
      }
      cout<<endl;
    }
    else{
      string str;
      cin>>str;
      cout<<"#"<<str<<"#"<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a=sc.nextInt();
				int b,c,d,e,f;
				b=a/3600;
				e=a%3600;
				c=e/60;
				d=e%60;
		System.out.println(""+b+":"+c+":"+d+"");
	}
}

Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
int main()
{string s,t;
 cin>>s>>t;
 int count=0;
 for(int i=0;i<s.length();i++)
 {
   if(s[i]!=t[i])
     count++;
 }
 cout<<count;
  return 0;
}

Measured memory_bytes: 3832
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N, Q;
    scan(N, Q);
    auto G = new long[][](N);
    foreach (_; 0 .. N - 1)
    {
        long a, b;
        scan(a, b);
        a--, b--;
        G[a] ~= b;
        G[b] ~= a;
    }
    auto counter = new long[](N);
    foreach (_; 0 .. Q)
    {
        long p, x;
        scan(p, x);
        p--;
        counter[p] += x;
    }
    auto visited = new bool[](N);
    auto Queue = new DList!long();
    Queue.insertBack(0);
    while (!Queue.empty())
    {
        long v = Queue.front();
        Queue.removeFront();
        visited[v] = true;
        foreach (child; G[v])
            if (!visited[child])
            {
                counter[child] += counter[v];
                Queue.insertBack(child);
            }
    }
    counter.map!(to!string).join(' ').writeln();
}


Measured memory_bytes: 54396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Piramide_de_luz
{
    class Program
    {

        static long MCD(long a, long b)
        {
            return b == 0 ? a : MCD(b, a % b);
        }

        static void Main(string[] args)
        {
            long[] r = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

            Console.WriteLine((long)3 * (r[0] - MCD(r[0], r[1])));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  double ans = 0;
  rep(i, 0, n) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY")
      ans += x;
    else
      ans += x * 380000;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdio>
using namespace std;

static const int INF=100000;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N;
    cin >> N;
    int ans=0;
    for(int i=1;i<=N;i++){
        int tmp=0;
        int res=i;
        while(true){
            if(res==0) break;
            res=res/10;
            tmp++;
        }
        if(tmp%2==1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
program preparing_boxes
    implicit none
    integer(4):: n, i, j, all
    integer(4), allocatable:: a(:), b(:)
    

    read*, n
    allocate(a(n), b(n))
    read*, a(:)
    b(:)=0
    do i=n, 1,-1
        all = 0
        do j=i,n,i
            all = xor(all,b(j))
        end do
        b(i) = xor(a(i),all)
    end do

    print'(i0)', sum(b(:))
    do i=1,n
        if (b(i)==1) print*, i 
    end do
end program preparing_boxes

Measured memory_bytes: 3712
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

h, w = Is()
A = LSR(h)
H = list(all(x == '.' for x in A[i]) for i in range(h))
W = list(all(x[j] == '.' for x in A) for j in range(w))
for i in range(h):
    if H[i]:
        continue
    for j in range(w):
        if W[j]:
            continue
        print(A[i][j], end='')
    print()


Measured memory_bytes: 68308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H1 = sc.nextInt();
		int M1 = sc.nextInt();
		int H2 = sc.nextInt();
		int M2 = sc.nextInt();
		int K = sc.nextInt();

		int subH = H2 - H1;
		int subM = M2 - M1;
		System.out.println(60 * subH + subM - K);

	}

}


Measured memory_bytes: 35824
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  vs <- map read.words <$> getLine
  cs <- map read.words <$> getLine
  let vc = zip vs cs
      ls = map (\l -> (sum (map fst l)) - (sum (map snd l))) $ subsequences vc
  print $ maximum ls


Measured memory_bytes: 1148
N , M = map(int, input().split())

A,B,C,D = [],[],[],[]
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
for i in range(M):
    c,d = map(int, input().split())
    C.append(c)
    D.append(d)

for n in range(N):
    a,b = A[n],B[n]
    ind = 0
    for m in range(M):
        c,d = C[m],D[m]
        diff = abs(a-c) + abs(b-d)

        if ind == 0:
            ind = 1
            ans = diff
        elif diff < ans:
            ind = m+1
            ans = diff

    print(ind)


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
int c[500], s[500], f[500];

int main(){
    cin >> n;
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n-1) {
        int ans = s[i]+c[i];
        for (int j = i+1; j < n-1; j++) {
            if (ans < s[j]) {
                ans = s[j]+c[j];
            } else {
                int r = (ans-s[j])%f[j];
                if (r) ans += f[j]-r;
                ans += c[j];
            }
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
}
































Measured memory_bytes: 256
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut km = Vec::new();
    for _ in 0..m {
        let mut k = read::<usize>();
        k.remove(0);
        km.push(k);
    }

    let pm = read::<usize>();
    let mut ans = 0;

    for i in 0..1 << n {
        let mut sw = Vec::new();
        let mut on = 0;
        for j in 0..n {
            if i & (1 << j) != 0 { sw.push(j + 1); }
        }

        for j in 0..m {
            let mut cnt = 0;
            for s in sw.iter() {
                if km[j].contains(&s) { cnt += 1; }
            }

            if cnt % 2 == pm[j] { on += 1; }
        }
        if on == m { ans += 1; }
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//10min
int main(void){
  int n;
  int a[101];
  int tmp;
  int alice = 0, bob = 0;

  scanf("%d", &n);

  for(int cnt = 1; cnt <= n; cnt++){
    scanf("%d", &a[cnt]);  
  }

  //昇順作る
  for(int i = 1; i <= n; i++){
    for(int j = i; j <= n; j++){
      if(a[i] < a[j]){
	tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
      }
    }
  }

  for(int cnt = 1; cnt <= n; cnt++){
    if(cnt % 2 == 1){
      alice += a[cnt];
    }else{
      bob += a[cnt];
    }
  }

  printf("%d\n", alice - bob);
  
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+9;
const ll p = 1000003;
long long compute_hash(vll v){
    ll ans = 0;
    ll p_pow = 1;
    for(int i =0;i<5;i++){
        ans = (ans + v[i] * p_pow) % MOD;
        p_pow = (p_pow * p)%MOD;
    }
    return ans;
}
int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
  

ll a[N];
void solve(){
    ll n;    
    cin >> n;
    for(int i =1;i<=n;i++) cin >> a[i-1];
    cout<<MinimumNumIncreasingSubsequences(a,n) << endl;

}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

 
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

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

int main()
{

  int A, B, C;
  cin >> A >> B >> C;

  if (A == B && A == C)
  {
    cout << "No" << endl;
  }
  else if (A != B && B != C && C != A)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#define inf 1000000001
using namespace std;

int n;
int A[200000];
unsigned long long c = 0;

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    int L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];

    L[n1] = R[n2] = inf;
    int i = 0, j = 0;
    for (int k = left; k < right; k++)
    {
        if (L[i] <= R[j])
        {
            A[k] = L[i++];
        }
        else
        {
            A[k] = R[j++];
            c += n1 - i;
        }
    }
}

void mergeSort(int A[], int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];

    mergeSort(A, 0, n);
    cout << c << "\n";
    return 0;
}


Measured memory_bytes: 4552
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL long long

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const LL mod=1e9+7;
LL n,k,ans,l,r;

int main()
{
	n=read();k=read();
	for(LL i=k;i<=n+1;++i)
	{
		l=((i-1)*i/2);
		r=((n-i+1+n)*i/2);
		ans=(ans+(r-l+1))%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3764
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  a, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  c, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  d, _ := strconv.Atoi(sc.Text())

  a--

  cc := c
  dd := d

  x := cc * dd

  if cc < dd {
    cc, dd = dd, cc
  }


  r := cc % dd
  for r != 0 {
    cc = dd
    dd = r
    r = cc % dd
  }

  x = x / dd

  acdiv := a / c
  addiv := a / d
  bcdiv := b / c
  bddiv := b / d

  acddiv := a / x
  bcddiv := b / x

  fmt.Println(b - a - (bcdiv + bddiv - bcddiv - acdiv - addiv + acddiv))

}



Measured memory_bytes: 640
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

d = {}
for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1
count = 0
for i in d.keys():
    if d[i]%2 ==1:
        count +=1
print(count)

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

int main() {
    int N; cin >> N;
    int P = 0;
    int min = 200000;
    int ans = 0;

    for (int i = 0; i < N; ++i) {
        cin >> P;
        if (P <= min){
            min = P;
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
I=lambda:map(int,input().split())
D,G=I()
P={};C={};S={}
R=range(D)
for i in R:P[i],C[i]=I();S[i]=-~i*100*P[i]+C[i]
r=1e9+7
for k in range(1<<D):
 h=str(bin(k))[2:].rjust(D,'0');p=0;s=0
 for i in R:
  if h[i]=='1':p+=P[i];s+=S[i]
 if s>=G:r=min(r,p);continue
 for i in R[::-1]:
  j=-~i*100
  if h[i]=='0'and G-s<j*P[i]:r=min(r,p+(G-s+j-1)//j);break
print(r)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if (a % 2 != b % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a+b)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int y=s.length(); 
    if(y<=k)
    {
        cout<<s;
    }
    else
    {
        for(int i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"...";
    }
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	
	
	
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		
		long a[] = new long[n+1];
		Arrays.fill(a, 2);
		a[1]=1;
		for(int i=2;i<=n/2;i++) {
			for(int j=2*i;j<=n;j+=i) {
				a[j]++;
			}
		}
		long sum = 0;
		for(int i=1;i<=n;i++) {
			//System.out.print(a[i]+" ");
			sum+=i*a[i];
		}
		System.out.println(sum);
		
	}

}


Measured memory_bytes: 116160