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

template<typename T, typename E> struct LazySegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;
  using P = function<E(E, int)>;

  int n;
  T ti;
  E ei;
  F f;
  G g;
  H h;
  P p;
  vector<T> data;
  vector<E> lazy;

  LazySegmentTree(int n_, F f, G g, H h, T ti = INT_MAX, E ei = INT_MAX,
                  P p = [](E a, int b) { return a; })
      : f(f), g(g), h(h), ti(ti), ei(ei), p(p) {
    init(n_);
  }
  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    data.assign(n * 2 - 1, ti);
    lazy.assign(n * 2 - 1, ei);
  }
  void build(vector<T> v) {
    for (int i = 0; i < v.size(); ++i) data[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i) {
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }
  inline void eval(int len, int k) {
    if (lazy[k] == ei) return;
    if (k * 2 + 1 < n * 2 - 1) {
      lazy[k * 2 + 1] = h(lazy[k * 2 + 1], lazy[k]);
      lazy[k * 2 + 2] = h(lazy[k * 2 + 2], lazy[k]);
    }
    data[k] = g(data[k], p(lazy[k], len));
    lazy[k] = ei;
  }
  T update(int a, int b, E x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return data[k];
    if (a <= l && r <= b) {
      lazy[k] = h(lazy[k], x);
      return g(data[k], p(lazy[k], r - l));
    }
    T vl = update(a, b, x, k * 2 + 1, l, (l + r) / 2);
    T vr = update(a, b, x, k * 2 + 2, (l + r) / 2, r);
    return data[k] = f(vl, vr);
  }
  T query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    eval(r - l, k);
    if (b <= l || r <= a) return ti;
    if (a <= l && r <= b) return data[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }
};

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

  int n, q; cin >> n >> q;
  const int INF = INT_MAX;
  LazySegmentTree<int, int>::F f = [&](int a, int b) { return min(a, b); };
  LazySegmentTree<int, int>::G g = [&](int a, int b) { return (b == INF) ? a : b; };
  LazySegmentTree<int, int>::H h = [&](int a, int b) { return (b == INF) ? a : b; };
  LazySegmentTree<int, int>::P p = [&](int a, int b) { return (a == INF) ? a : a * b; };

  LazySegmentTree<int, int> seg(n, f, g, h);
  for (int i = 0; i < q; ++i) {
    int com; cin >> com;
    if (com) {
      int s, t; cin >> s >> t;
      cout << seg.query(s, t + 1) << endl;
    } else {
      int s, t, x; cin >> s >> t >> x;
      seg.update(s, t + 1, x);
    }
  }
  return 0;
}



Measured memory_bytes: 4968
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define inf 0x3f3f3f3f
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn],mx[maxn],mn[maxn];
int q[maxn];
int n,k;
int main()
{
	n=read(); k=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	int h=1,t=0;
	for(int i=1;i<=n;i++){
		while(h<=t&&q[h]<i-k)++h;
		while(h<=t&&a[i]>a[q[t]])--t;
		q[++t]=i;
		if(i>k)mx[i]=q[h];
	}
	h=1; t=0;
	for(int i=1;i<=n;i++){
		while(h<=t&&q[h]<i-k)++h;
		while(h<=t&&a[i]<a[q[t]])--t;
		q[++t]=i;
		if(i>k)mn[i]=q[h];
	}
	int cnt=0,flag=0,ans=1;
	for(int i=2;i<=k;i++)
		cnt+=(a[i]>a[i-1]);
	if(cnt==k-1)flag=1;
	for(int i=k+1;i<=n;i++){
		cnt+=(a[i]>a[i-1])-(a[i-k+1]>a[i-k]);
		if(cnt==k-1){
			if(!flag)++ans;
			flag=1;
		}
		else if(mx[i]!=i||mn[i]!=i-k)++ans;
	}
	writeln(ans);
//	for(int i=1;i<=n;i++)
//		printf("%d %d %d\n",i,mx[i],mn[i]);
	return 0;
}

Measured memory_bytes: 3328
# AOJ 0114: Electro-Fly
# Python3 2018.6.18 bal4u

def gcd(a, b):
	if a < b: a, b = b, a
	while b > 0:
		r = a % b
		a, b = b, r
	return a

while True:
	a1, m1, a2, m2, a3, m3 = list(map(int, input().split()))
	if a1 == 0: break
	n = 0
	b1, b2, b3 = 1, 1, 1
	a, b, c = 0, 0, 0
	while True:
		if a == 0: b1 = (b1 * a1) % m1
		if b == 0: b2 = (b2 * a2) % m2
		if c == 0: b3 = (b3 * a3) % m3
		n += 1
		if a == 0 and b1 == 1: a = n
		if b == 0 and b2 == 1: b = n
		if c == 0 and b3 == 1: c = n
		if a != 0 and b != 0 and c != 0: break
	
	ans = a // gcd(a,b) * b
	ans = ans // gcd(ans, c) * c
	print(ans)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define ll long long 
#define endl "\n"
using namespace std;
ll int a,b,n,res,x;
void solve()
{
	//Enter code here Tanmay::
	cin>>n;
	res=pow(n,3);
	cout<<res;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
  
    // extract current character from buffer 
    c = getchar(); 
    if (c=='-') 
    { 
        // number is negative 
        negative = true; 
  
        // extract the next character from the buffer 
        c = getchar(); 
    } 
  
    // Keep on extracting characters if they are integers 
    // i.e ASCII Value lies from '0'(48) to '9' (57) 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
  
    // if scanned input has a negative sign, negate the 
    // value of the input number 
    if (negative) 
        number *= -1; 
} 

Measured memory_bytes: 384
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let (n, k) = {
    let v: Vec<usize> = read_vec();
    (v[0], v[1])
  };
  let mut l: Vec<usize> = read_vec();

  l.sort_by(|a, b| b.cmp(&a));
  let ans = l.iter().take(k).fold(0, |acc, x| acc + x);
  
  println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
H = list(map(int,input().split()))
m = H[0]
for i in range(n-1):
    if H[i] < H[i+1]:
        H[i+1] -= 1
    elif H[i] > H[i+1]:
        print("No")
        break
else:
    print("Yes")
        

Measured memory_bytes: 14396
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
typedef pair<int,pii>ppii;
typedef pair<ppii,ppii> d_pii;
ppii cal(string s){
    ppii temp;
    string a,b,c;
    a=s[0]; a+=s[1];
    b=s[3];b+=s[4];
    c=s[6];c+=s[7];
    temp.first=stoi(a);
    temp.second=pii(stoi(b),stoi(c));
    return temp;
}
int main(){
    int n;
    while(cin>>n,n){
        vector<pair<ll,ll>>v;
        rep(i,n){
            string s,e; cin>>s>>e;
            ppii start,end;
            start=cal(s);
            end=cal(e);
            ll _start=start.first*3600+start.second.first*60+start.second.second;
            ll _end=end.first*3600+end.second.first*60+end.second.second;
            //cout<<start.first<<":"<<start.second.first<<":"<<start.second.second<<endl;
            //cout<<end.first<<":"<<end.second.first<<":"<<end.second.second<<endl;
            v.push_back(make_pair(_start,_end));
        }
        sort(all(v));
        vl u(v.size());
        rep(i,v.size())u[i]=v[i].first;
        ll ans=0;
        ll base=0;
        u.push_back(INF);
        v.push_back(pii(INF,INF));
        rep(i,u.size()){
            ans++;
            base=v[i].second;
            while(true){
                bool update=false;
                vector<ll>::iterator itr=lower_bound(u.begin(), u.end(),base);
                if(itr!=u.end()){
                    int index=(int)(itr-u.begin());
                    update=true;
                    //cout<<*itr<<endl;
                    u.erase(itr);
                    base=v[index].second;
                    v.erase(v.begin()+index);
                }
                if(!update)break;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
#define INF 1e18
using namespace std;

//-----------------------------------------------------------------------

int dp[105][10005];

signed main()
{   
    int N,W; cin>>N>>W;
    vector<int> v(N),w(N);
    REP(i,N){
        cin>>v[i]>>w[i];
    }

    for(int j=0;j<=W;j++) dp[0][j]=0;
    REP(i,N) for(int j=0;j<=W;j++){
        if(j<w[i])
            dp[i+1][j]=dp[i][j];
        else
            dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
    cout<<dp[N][W]<<endl;
 
}



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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A;
  ld B;
  cin >> A >> B;

  // main procedure
  ll B_100times = (ll)(B * 100 + 0.1);

  ll ans = (A * B_100times) / 100;
  // output
  WRITE_N(ans);

  return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>

using namespace std;

int main() {
	//int x, t;
	long x, t;

	cin >> x >> t;

	if ((x - t) < 0) {
		cout << 0 << endl;
	}
	else {
		cout << x - t << endl;
	}



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rer(i, a, b) for(ll i=a-1; i>=b; i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;

signed main(){
    cin >> n;
    ll sum=0, l[MAX_N]={};
    rep(i, 0, n){
        cin >> l[i];
        sum += l[i];
    }
    sort(l, l+n, greater<ll>());
    if(sum > 2*l[0]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());

      if(a<10 && b<10){
        System.out.println(a*b);
      }
      else{
        System.out.println("-1");
      }

    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	int N; cin >> N;
	if (N % 2 == 0) {
		cout << N / 2 - 1 << endl;
	}
	else {
		cout << N / 2 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readIntegerList()
    val lampInfoArray = Array(m) { readIntegerList() }
    val pList = readIntegerList()

    var ans = 0
    for (switchState in 0 until (1 shl n)) {
        if (isAllOn(switchState, n, m, lampInfoArray, pList)) {
            ans++
        }
    }

    println(ans)
}

fun isAllOn(switchState: Int, n: Int, m: Int, lampInfoArray: Array<List<Int>>, pList: List<Int>): Boolean {
    for (i in 0 until m) {
        if (isOff(switchState, lampInfoArray[i], pList[i])) {
            return false
        }
    }

    return true
}

fun isOff(switchState: Int, lampInfo: List<Int>, p: Int): Boolean {
    var count = 0
    for (i in lampInfo.drop(1)) {
        if (((switchState shr (i - 1)) and 1) == 1) {
            count++
        }
    }

    return if ((count % 2) == p) false else true
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 38000
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'


int main()
{
	ll n;
	cin>>n;
	cout<<(n*(n-1))/2LL<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long int dFactz(long long int n) 
{  
    long long int cnt = 0; 
    for (long long int i = 5; n / i >= 1; i *= 5) 
        cnt += n / i; 
  
    return cnt; 
} 
int main()
{
	long long int n;
	cin>>n;
	if((n%2)==1)
	{
		cout<<"0\n";
		return 0;
	}	
	long long df=dFactz(n/2);
	cout<<df<<"\n";
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

A.append(X)
A.sort()

front = []
back = []

while len(A) > 0:
    pop = A.pop(0)
    if pop == X:
        while len(A) > 0:
            back.append(A.pop(0))
    else:
        front.append(pop)

print(min(len(front), len(back)))

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int M = 1e9+7;

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

    vector<ll> s;
    for(int i = 1; i*i <= n; i++){
        s.push_back(i);
        s.push_back(n/i);
    }

    sort(s.begin(),s.end());
    ll msize = (ll)s.size();
    s.erase(unique(s.begin(),s.end()),s.end());
    vector<vector<ll>> dp(k+1,vector<ll>(msize));

    
    map<ll,ll> mp;
    for(int i = 0; i < msize; i++) mp[s[i]] = i;
    dp[0][mp[n]] = 1;
    
    vector<ll> ML(msize);
    for(int i = 0; i < msize-1; i++){
        ML[i] = (n/s[i] - n/s[i+1])%M;
    }

    ML[msize-1] = 1;
    for(int i = 0; i < k; i++){
        for(int j = msize-2; j >= 0; j--) dp[i][j]+=dp[i][j+1]%M;
        for(int j = 0; j < msize; j++){
            int nj=mp[n/s[j]];
            dp[i+1][j]+=dp[i][nj]%M*ML[j]%M;
            dp[i+1][j]%=M;
        }
    }
    ll ans = 0;
    for(int i = 0; i < msize; i++){
        ans+=dp[k][i]%M;
    }
    cout<<ans%M;
}





Measured memory_bytes: 55304
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
vector<int> h;
ll ans = 0;
void Solve(int left, int right)
{
    int min_num = INF;
    vector<pair<int, int>> next;
    for(int i = left; i < right; i++) min_num = min(h[i], min_num);
    if(min_num == 0 || min_num == INF) return;
    ans += min_num;
    for(int i = left; i < right; i++) h[i] -= min_num;
    int l = INF;
    for(int i = left; i < right; i++)
    {
        l = min(i, l);
        if(h[i] == 0)
        {
            next.push_back(make_pair(l, i));
            l = INF;
        }
    }
    if(l != INF) next.push_back(make_pair(l, right));
    for(int i = 0; i < next.size(); i++) Solve(next[i].first, next[i].second);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    h.resize(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    h.push_back(0);
    vector<pair<int, int>> next;
    int l = INF;
    for (int i = 0; i < n; i++)
    {
        l = min(i, l);
        if (h[i] == 0)
        {
            next.push_back(make_pair(l, i));
            l = INF;
        }
    }
    if(l != INF) next.push_back(make_pair(l, n));
    for (int i = 0; i < next.size(); i++)
        Solve(next[i].first, next[i].second);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a=input()
i=0
n=[]
while i<len(a):
  n.append(a[i])
  i+=1
pd=n[0]+n[1]
sd=n[2]+n[3]
pd=int(pd)
sd=int(sd)
if sd==0 and pd==0:
  print('NA')
elif pd>12:
  if sd>=1 and sd<=12:
    print('YYMM')
  elif sd>12:
    print('NA')
  elif sd<1:
    print('NA')
elif pd==0:
  if sd>12:
    print('NA')
  elif sd>0 and sd<=12:
    print('YYMM')
elif pd<=12 and pd!=0:
  if sd>12:
    print ('MMYY')
  elif sd==0:
    print('MMYY')
  elif sd<=12 and sd!=0:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    long long k; cin >> k;
    int n = 50; 
    long long ops = k / n;
    long long res[n]{};
    for (int i = 0; i < n; i++)
    {   
        res[i] = ops + i;
    }   
    k -= ops * n;
    int index = 0;
    while (k > 0)
    {   
        res[index] += n;
        for (int i = 0; i < n; i++)
        {
            if (i != index)
            {
                res[i]--;
            }
        }
        index++;
        k--;
    }   
    cout << n << '\n';
    for (int i = 0; i < n; i++)
    {   
        cout << res[i] << ' ';
    }   
    cout << '\n';
    return 0;
}

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

template< typename T >
T mod_pow(T x, T n, const T &p) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= p;
        (x *= x) %= p;
        n >>= 1;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> people(N);
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        for (int j = 0; j < A; ++j) {
            int x, y;
            cin >> x >> y;
            x--;
            people[i].push_back(make_pair(x, y));
        }
    }
    int p = (1 << N) - 1;
    int m = 0;
    for (; p >= 0; --p) {
        bool flag = true;
        bitset<15> bit = p;
//        cout << bit << endl;
        for (int i = 0; i < N; ++i) {
            if (!bit[i]) continue;
            for (const auto& t : people[i]) {

                if (t.second == 1 && !bit[t.first]) {
                    flag = false;
                    break;
                }
                else if (t.second == 0 && bit[t.first]) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
        }
        if (flag) {
            m = max(m, (int)bit.count());
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<n;++i)
#define Sort(a) sort(a.begin(),a.end())
const int INF = 1e9+7;

int main(){
  string o,e;
  cin >> o >> e;
  if(o.size()-e.size()==0){
    rep(i,o.size()){
      cout << o.at(i) << e.at(i);
    }
    cout << endl;
  }else{
    rep(i,e.size()){
      cout << o.at(i) << e.at(i);
    }
    cout << o.at(o.size()-1) << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from itertools import accumulate
 
N,M = [int(i) for i in input().split()]
ans = [0]*(N+1)
for _ in range(M):
    L,R = [int(i)-1 for i in input().split()]
    ans[L] += 1
    ans[R+1] += -1
 
ans = list(accumulate(ans))
 
count = ans.count(M)
 
print(count)

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

#define i64 long long int
#define ran 101101

int n;
i64 m;
int a[ran];
i64 s[ran];

i64 calc(int lim) {
	i64 res = 0LL;
	for(int i=0;i<n;i++) {
		int p = lower_bound(a, a+n, lim-a[i]) - a;
		int cnt = n-p;
		res += cnt;
	}
	return res;
}

int main() {
	scanf("%d%lld", &n, &m);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a,a+n);
	
	int l = 0, r = a[n-1]+a[n-1], lim = 0;
	while(l<=r) {
		int mid = (l+r)/2;
		if(calc(mid)>=m) {
			l = mid+1;
			lim = mid;
		} else r = mid-1;
	}
	s[n] = 0;
	for(int i=n-1;i>=0;i--)
		s[i] = a[i] + s[i+1];
	
	i64 ans = 0LL, tot_count = 0LL;
	for(int i=0;i<n;i++) {
		int p = lower_bound(a, a+n, lim-a[i]) - a;
		int cnt = n-p;
		ans += 1LL * a[i] * cnt;
		ans += s[p];
		tot_count += cnt;
	}
	ans -= (tot_count - m) * lim;
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 1408
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = [0 * n for i in range(n)]
for i in range(n-1):
  b[i] = a[i+1] - a[i]

b[-1] = a[0] + (k - a[-1])

print(k - max(b))

Measured memory_bytes: 26444
s = input()
L = "ACGT"
ans = ""
ss = ""
for i in range(len(s)):
  if s[i] in L:
    ans += s[i]
    if i == len(s)-1:
        if len(ans)>len(ss):
            ss = ans
            #print(len(ss))
  else:
    if len(ans)>len(ss):
      
      ss = ans
      #print(ans,ss)
      ans = ""
print(len(ss))

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); 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; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  rep(i, s.size()-1) {
    if (s[i] == s[i+1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;

}

Measured memory_bytes: 256
s = input()
n = int(s)

count = 0
divisors = 0

arrays = []
for i in range(n+1):
    arrays.append(False)

for i in range(n+1):
    if i % 2 == 1:
        divisors = 0
        for j in range(len(arrays)):
            arrays[j] = False
        for j in range(1,i+1):
             if i % j == 0:
                 arrays[j] = True
        for j in range(len(arrays)):
            if arrays[j]:
                divisors += 1
        if divisors == 8:
            count += 1

print(count)

Measured memory_bytes: 9132
N, M = map(int, input().split())
is_good = [True] * N
H = list(map(int, input().split()))
for _ in range(M):
    A, B = map(lambda n: int(n) - 1, input().split())
    is_good[A] &= (H[A] > H[B])
    is_good[B] &= (H[A] < H[B])
print(sum(is_good))


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
if n == 1:
    print(a[0])
    exit()
if n % 2 == 0:
    for i in reversed(range(n // 2)):
        print(a[2 * i + 1], end=" ")
    for j in range(n // 2):
        print(a[2 * j], end=" ")
else:
    for i in reversed(range(n // 2 + 1)):
        print(a[2 * i], end=" ")
    for j in range(n // 2):
        print(a[2 * j + 1], end=" ")


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

// sum[l,r)= 0 <=> sum[0,l)= sum[0,r) を利用して数え上げる
// sum[0,r)= 0 の場合は l=0 もありうることに注意
int main(){
  int N;
  cin >> N;

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  unordered_map<int64_t, int64_t> freq_cumsum;
  int64_t cumsum= 0;
  for(int i=0; i<N; i++){
    cumsum+= data.at(i);

    if(freq_cumsum.count(cumsum)){ freq_cumsum.at(cumsum)++; }
    else                         { freq_cumsum[cumsum]= 1; }
  }

  int64_t ans= 0;
  for(auto [cs, freq]:freq_cumsum){
    int64_t diff= (cs==0) ? freq*(freq+ 1)/ 2
                          : freq*(freq- 1)/ 2;
    ans+= diff;
  }

  cout << ans << endl;
}

Measured memory_bytes: 12760
import Data.List

--   1
-- 4 2 3 5 ??? 1????????¢???2?????£??¢
--   6

mov :: (Int,Int,Int,Int,Int,Int) -> Char -> (Int,Int,Int,Int,Int,Int)
mov (p1,p2,p3,p4,p5,p6) 'N' = (p2,p6,p3,p4,p1,p5)
mov (p1,p2,p3,p4,p5,p6) 'S' = (p5,p1,p3,p4,p6,p2)
mov (p1,p2,p3,p4,p5,p6) 'W' = (p3,p2,p6,p1,p5,p4)
mov (p1,p2,p3,p4,p5,p6) 'E' = (p4,p2,p1,p6,p5,p3)

ini :: [Int] -> (Int,Int,Int,Int,Int,Int)
ini (a:b:c:d:e:f:_) = (a,b,c,d,e,f)

-- ?????¢???????????????
m1 :: (Int,Int,Int,Int,Int,Int) -> Int -> (Int,Int,Int,Int,Int,Int)
m1 i@(p1,p2,p3,p4,p5,p6) n
  | p2 == n            = i
  | p4 == n || p3 == n = m1 (mov i 'E') n
  | otherwise          = m1 (mov i 'N') n

m2 :: (Int,Int,Int,Int,Int,Int) -> Int -> (Int,Int,Int,Int,Int,Int)
m2 i@(p1,p2,p3,p4,p5,p6) n
  | p1 == n            = i
  | otherwise          = m2 (mov i 'E') n

ans :: (Int,Int,Int,Int,Int,Int) -> [Int] -> Int
ans d q =
  let s1 = m1 d (q!!1)
      s2@(p1,p2,p3,p4,p5,p6) = m2 s1 (q!!0)
  in
    p3

main = do
  l <- getLine
  let d = ini $ map read $ words l
  c <- getContents
  let q = map (map read) $ map words $ drop 1 $ lines c :: [[Int]]
      o = map (ans d) q
  mapM_ print o

Measured memory_bytes: 3936
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    vector<int> s(M),c(M),num(N,-1);
    int ans;
    for(int i=0;i<M;i++){
        cin >> s[i] >> c[i];
    }
    if(N==0){ans=-1;cout << ans << endl;return 0;}
    if(M==0){
        if(N==1){
            ans=0;cout << ans << endl;return 0;
        }else{
            ans=pow(10,N-1);
            cout << ans << endl;return 0;
        }
    }

    for(int i=0;i<M;i++){
        if(N!=1 and s[i]==1 and c[i]==0){
            ans=-1;cout << ans << endl;return 0;
        }else{
            if(num[N-s[i]]==-1 or num[N-s[i]]==c[i]){
                num[N-s[i]]=c[i];
            }else{
                ans=-1; cout << ans << endl;return 0;
            }
        }
    }
    if(num[N-1]==-1){
        num[N-1]=1;
    }
    for(int i=0;i<N-1;i++){
        if(num[i]==-1){
            num[i]=0;
        }
    }
    ans=0;
    for(int i=0;i<N;i++){
        ans+=int(num[i]*pow(10,i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n, t, i, x, y, sum = 0, mm, mn;
    lli ara[100007]={0};
    vector<lli> vec;
    cin >> n;
    while(n--){
        cin >> x;
        vec.push_back(x);
        sum += x;
        ara[x]++;
    }
    n = vec.size();
    cin >> t;
    while(t--){
        cin >> x >> y;
        mn = ara[x];
        sum -= (mn*x);
        sum += (mn*y);
        ara[y] += ara[x];
        ara[x] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 4972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;
 
bool palindrone(string s){
    string t(s.rbegin(),s.rend());
    return s==t;
}
int main(){
    string s ; 
    cin>>s; 
    ll n  = s.length();
    string s1 = s.substr(0,(n-1)/2);
    string s2 = s.substr((n+1)/2);
    if((palindrone(s))&&(palindrone(s1))&&(palindrone(s2))) cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
  char s[10], t[10], u[10];
  int a,b;
  
  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s",u);
  
  if(strcmp(s,u) == 0)printf("%d %d", a-1, b);
  else printf("%d %d", a, b-1);
  
  return 0;
}

Measured memory_bytes: 128
let rec p () = Scanf.sscanf (read_line ()) "%d %s %d" (fun a op b ->
  match op with
  | "+" -> print_endline (string_of_int (a + b)); p ()
  | "-" -> print_endline (string_of_int (a - b)); p ()
  | "*" -> print_endline (string_of_int (a * b)); p ()
  | "/" -> print_endline (string_of_int (a / b)); p ()
  | _ -> ()
)
let _ = p()


Measured memory_bytes: 2452
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc;
	final int MAX=1<<15;
	
	long time(int a,int m){
		int x=1;
		for(int i=1;i<m;++i){
			if((x=(a*x)%m)==1){
				return i;
			}
		}
		return m;
	}
	
	long gcd(long a,long b){
		return a==0?b:gcd(b%a,a);
	}
	
	long lcm(long a,long b){
		return a/gcd(a,b)*b;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	void io(){
		sc=new Scanner(System.in);
		
		while(true){
			int[] a=new int[3],m=new int[3];
			long[] num=new long[3];
			boolean end=true;
			for(int i=0;i<3;++i){
				if((a[i]=ni())!=0|(m[i]=ni())!=0)end=false;
			}
			if(end)break;
			
			for(int i=0;i<3;++i)num[i]=time(a[i],m[i]);
			
			//debug(num);
			
			System.out.println(lcm(lcm(num[0],num[1]),num[2]));
		}
		sc.close();
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
	}

}

Measured memory_bytes: 20328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
  
}

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

using namespace std;

int main()
{
    string t;

    cin >> t;

    for (int bit = 0; bit < (1<<3); bit++) {
        string s(t);
        int cnt = 1, sum = 0;

        for (int i = 0; i < 3; i++) {
            if (bit & (1<<i)) {
                s.insert(s.begin()+i+cnt, '+');
            }
            else {
                s.insert(s.begin()+i+cnt, '-');
            }
            cnt++;
        }

        int fu = 1;

        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '+') {
                fu = 1;
            }
            else if (s[i] == '-') {
                fu = -1;
            }
            else {
                sum += (s[i] - '0') * fu;
            }
        }

        if (sum == 7) {
            cout << s << "=7" << endl;
            return (0);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define frr(j,i,n) for(int i=j;i<=n;++i)
using namespace std;
string s,t;
int dp[3001][3001];
void solve()
{
	cin>>s>>t;
    int n=s.length();
    int k=t.length();
    frr(0,i,n)
    {
        frr(0,j,k)
        {
            if(i==0 or j==0)
                dp[i][j]=0;
            else
            {
                if(s[i-1]==t[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
                else
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans="";
    while(n>0 and k>0)
    {
        if(s[n-1]==t[k-1])
            ans+=s[n-1],n--,k--;
        else
        {
            if(dp[n-1][k]>dp[n][k-1])
                n--;
            else
                k--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";

}
int main() 
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// #endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}



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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };
const int MOD=1e9+7;

int N;
vector<char> cs{'A','C','G','T'};
set<string> outs{"AGGC","ATGC","AGTC"};
vector<map<string, ll>> memo;

bool checker(string last4) {
  return outs.find(last4)==outs.end();
}

ll dfs(int cur, string last3) {
  if (memo[cur][last3]) return memo[cur][last3];
  if (cur==N) return 1;

  ll ret = 0;
  for (char c:cs) {
    if (checker(last3+c)) {
      ret = (ret+dfs(cur+1,last3.substr(1,2)+c))%MOD;
    }
  }
  memo[cur][last3] = ret;
  return ret;
}

int main() {
  cin>>N;
  memo.resize(N+1);

  // 並べ替えでアウトも含めて以下の文字列が出てきたらだめ
  // AGC
  // ACG
  // GAC
  // AGGC
  // AGTC
  // ATGC
  vector<string> out_three{"AGC","GAC","ACG"};
  for (string ot:out_three) {
    for (char c:cs) outs.insert(c+ot);
  }
  OUT(dfs(0,"TTT"));

  return 0;
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<unordered_map>
#include<stack>
#include<chrono>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define val         1000000007
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define PI          acos(-1.0)
#define f(i,n)		for(ll i=0;i<n;i++)
#define m(a)		memset(a,0,sizeof(a))
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld ",a)
using namespace std;
//using namespace std::chrono;

int main()
{
	FastIO;
       
	ll  a, c, r, j,i,s, k, l, m, n, t;
	cin >> n;
	for (i = 1,s=0; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
			s = s + i;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

const int N = 500010;
int c[30][N], n;
char s[N];

int lowbit(int x) {
	return x & -x;
}

void update(int x, int y, int *a) {
	for (int i = x; i <= n; i += lowbit(i)) a[i] += y;
}

int sum(int x, int *a) {
	int res = 0;
	for (int i = x; i >= 1; i -= lowbit(i)) res += a[i];
	return res;
}

int main() {
	int T;

	cin >> n >> s + 1 >> T;

	for (int i = 1; i <= n; i++) update(i, 1, c[s[i] - 'a']);

	while (T--) {
		int k; cin >> k;
		if (k == 1) {
			int p; string b;
			cin >> p >> b;
			update(p, -1, c[s[p] - 'a']);
			s[p] = b[0];
			update(p, 1, c[b[0] - 'a']);
		}
		else if (k == 2) {
			int x, y, res = 0;
			cin >> x >> y;
			for (int i = 0; i < 26; i++) res += sum(y, c[i]) - sum(x - 1, c[i]) > 0;
			cout << res << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 53504
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n;
int a[maxn];

template<typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

int main()
{
    read(n); int sum = 0, mx = 0;
    for (int i = 1; i <= n; i++) read(a[i]), sum += a[i], mx = max(mx, a[i]);

    puts(mx < (sum - mx) ? "Yes" : "No");
}

Measured memory_bytes: 256
h = int(input())
w = int(input())
n = int(input())
c = 0

if h >= w:
  if n % h == 0:
    c = n // h
  else:
    c = n // h + 1
else:
  if n % w == 0:
    c = n // w
  else:
    c = n // w + 1
print(c)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<pair<int, int>> A(N);
    rep(i, N) cin >> A[i].first, A[i].second = i;

    vec<pair<int, int>> B(N);
    rep(i, N) cin >> B[i].first, B[i].second = i;

    sort(all(A));
    sort(all(B));

    rep(i, N) if (A[i].first > B[i].first) {
        cout << "No" << endl;
        return 0;
    }

    vec<pair<int,int>> C;
    rep(i,N){
        C.push_back({A[i].second,B[i].second});
    }
    sort(all(C));


    vec<int> cycle;
    int now = 0;
    while (true) {
        cycle.push_back(now);
        now = C[now].second;
        if (now == 0) break;
    }
    if (cycle.size() != N) {
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, N - 1) {
        if (A[i + 1].first <= B[i].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 6304
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n; string s; cin >> s;
	if (s[0] == s[1]) {
		cout << "Bad" << endl;
	}
	else if (s[1] == s[2]) {
		cout << "Bad" << endl;
	}
	else if (s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
#define sqr(x) ((x) * (x))
#ifdef LOCAL
#define dbg(as...) {\
    vector<string> _v; \
    std::stringstream _ss(#as);\
    string _cur, _loc;\
    while (getline(_ss, _cur, ',')) {\
        while (count(_cur.begin(), _cur.end(), '(') != count(_cur.begin(), _cur.end(), ')')) {\
            getline(_ss, _loc, ',');\
            _cur += "," + _loc;\
        }\
    _v.pb(_cur);\
    }\
    err(_v.begin(), as);\
}
#else
#define dbg(as...)
#endif

template<typename T>
void err(vector<string>::iterator it, T a) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << '\n';
}
template<typename T, typename...Ts>
void err(vector<string>::iterator it, T a, Ts...as) {
    cerr << it->substr((*it)[0] == ' ') << " = " << a << ", ";
    err(++it, as...);
}

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(10);
        #ifdef LOCAL
        srand(300); 
        #else
        srand(time(0));
        #endif
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;


int main() {


    std::deque<int> a;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (i & 1) a.push_front(x);
        else a.push_back(x);
    }

    if (n & 1)
        reverse(a.begin(), a.end());

    for (auto & i : a)
        cout << i << ' ';
    cout << '\n';


    return 0;
}


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

using namespace std;
int sen[10000];

int main(){
  int r,c,cc;
  while(true){
		scanf("%d %d",&r,&c);
		if (!r&&!c)break;
		for(int i=0;i<c;i++)
			sen[i] = 0;
		
		for(int j=0;j<r;j++){
			for(int i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		
		int s,n,sum = 0,smax = 0,k=1;
		k <<= r-1;
		for(int i=0;i<k;i++){
			sum = 0;
			for(int j=0;j<c;j++){
				s = sen[j]^i;
				for(n=0;s>0;s >>= 1)n+=s&1;
				sum += max(n,r-n);
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

Measured memory_bytes: 920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int c[400];
int ans[400][400];

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> s(400);
  vector<vector<int>> as(400);
  for(int i=0;i<H;i++){cin >> s[i];}
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(s[i][j]=='#'){
        c[i]++; as[i].push_back(j);
      }
    }
    as[i].push_back(400);
  }
  int count=1;
  for(int i=0;i<H;i++){
    int memo1=i;
    while(i<H && c[i]==0){i++;}
    int memo2=i;
    while(i+1<H && c[i+1]==0){i++;}
    int memo3=i+1;
    int cc=1;
    for(int j=0;j<W;j++){
      if(j>=as[memo2][cc]){count++; cc++;}
      for(int k=memo1;k<memo3;k++){ans[k][j]=count;}
    }
    count++;
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){cout << ans[i][j] << " ";}
    cout << endl;
  }
}

Measured memory_bytes: 2048
function Main(input) {
  "use strict";
	const chars = input.split("");

  const count = chars.length;
  let n = 0;
  let prev = chars[0];
  for (let i = 1; i < count; i++) {
    const c = chars[i];
    if ( c === prev) {
      n++;
      prev = c === "1" ? "0" : "1";
    } else {
      prev = c;
    }
  }

  console.log(n)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, K;

signed main() {
    cin >> N >> K;
    ll ans = 0;
    FOR(b, K + 1, N + 1) {
        ll n = N / b;
        ans += n * (b - K);
        ans += max(N - (n * b) - K + 1, 0LL);
        if(K == 0) ans--;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
# -- coding:utf-8 --
n,m=map(int, input().split())
ab=[list(map(int,input().split())) for _ in range(n)]

ab.sort()

price = [0 for _ in range(m)]
ii=0

while m > 0:
    m -= ab[ii][1]
    if m >= 0:
        price[ii] = ab[ii][1] * ab[ii][0]
    else:
        price[ii] = abs(m+ab[ii][1]) * ab[ii][0]
    ii += 1
        
print(sum(price))


Measured memory_bytes: 28512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;
    cin>>n;
    vector<ll>v(9,0);
    for(int i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        if(x>=1 and x<=399)
        {
            v[0]=1;
        }
        else if(x>=400 and x<=799)
        {
            v[1]=1;
        }
        else if(x>=800 and x<=1199)
        {
            v[2]=1;
        }
        else if(x>=1200 and x<=1599)
        {
            v[3]=1;
        }
        else if(x>=1600 and x<=1999)
        {
            v[4]=1;
        }
        else if(x>=2000 and x<=2399)
        {
            v[5]=1;
        }
        else if(x>=2400 and x<=2799)
        {
            v[6]=1;
        }
        else if(x>=2800 and x<=3199)
        {
            v[7]=1;
        }
        else{
            v[8]++;
        }
    }
    ll mx=accumulate(v.begin(),v.end(),0);
    ll mn=0;
    for(int i=0;i<=7;i++)
    {
        mn+=v[i];
    }
    if(v[8]==n)
    {
        cout<<mn+1<<" "<<n<<endl;
    }
    else
    {
       cout<<mn<<" "<<mx<<endl;
    }


}



Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
	int N,l[100001],r[100001],i,ans = 0;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
	}
	for (i = 0; i < N; i++) {
		ans += r[i] + 1;
		ans -= l[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256