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

char readchar() {
  static char buf[1 << 18], *ptr = buf, *end = buf;
  if (ptr == end) ptr = buf, end = buf + fread(buf, 1, 1 << 18, stdin);
  return *ptr++;
}
void writechar(char c) {
  static char buf[1 << 18], *ptr = buf;
  if (ptr == std::end(buf) or c == '\0')
    fwrite(buf, 1, ptr - buf, stdout), ptr = buf;
  *ptr++ = c;
}
__attribute__((destructor)) void destructor() { writechar('\0'); }
template <class T = int>
T getint() {
  char c{};
  while (c < '-') c = readchar();
  bool neg = c == '-';
  T res = neg ? 0 : c - '0';
  while ((c = readchar()) >= '0') res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class T>
void putint(T a, char delim = '\n') {
  if (a < 0) writechar('-'), a = -a;
  char buf[sizeof(T) * 3], *ptr = buf;
  do
    *ptr++ = '0' + a % 10;
  while (a /= 10);
  while (ptr-- > buf) writechar(*ptr);
  writechar(delim);
}
#define cin void(0)
#define cout void(0)

template <class T>
struct fenwick {
  fenwick() {}
  template <class Generator>
  fenwick(int n, Generator gen) : tree(n) {
    for (int i = 0; i < n; ++i) tree[i] = gen(i);
    for (int i = 0; i < n; ++i)
      if (int j = i | (i + 1); j < n) tree[j] += tree[i];
  }

  int size() const { return std::size(tree); }
  void add(int i, T a) {
    assert(0 <= i), assert(i < size());
    for (; i < size(); i |= i + 1) tree[i] += a;
  }
  T sum(int i) const {
    assert(0 <= i), assert(i <= size());
    T res{};
    for (; i; i &= i - 1) res += tree[i - 1];
    return res;
  }
  T sum(int l, int r) const {
    assert(0 <= l), assert(l <= r), assert(r <= size());
    return sum(r) - sum(l);
  }
  int kth(T k) const {
    static_assert(std::is_integral_v<T> and not std::is_same_v<T, bool>);
    assert(k >= 0);
    int i = 0;
    for (int w = 1 << std::__lg(size()); w; w >>= 1)
      if (i + w <= size() and tree[i + w - 1] <= k) k -= tree[(i += w) - 1];
    return i;
  }

 private:
  std::vector<T> tree;
};

int main() {
  using namespace std;
  int n = getint();
  int q = getint();
  fenwick<int64_t> f(n, [](int) { return getint(); });
  while (q--) {
    if (getint() == 0) {
      int p = getint();
      int x = getint();
      f.add(p, x);
    } else {
      int l = getint();
      int r = getint();
      putint(f.sum(l, r));
    }
  }
}


Measured memory_bytes: 8468
#include <bits/stdc++.h>
using namespace std;
const int Maxn=100005;
int n,m,q,vt[Maxn],d[Maxn],c[Maxn],i,dp[Maxn],col[Maxn];
vector <int> g[Maxn];
void dfs(int v,int d,int c)
{
	if (!col[v]) col[v]=c;
	if (dp[v]>=d || d==0) return;
	dp[v]=d;for (int i=0;i<g[v].size();++i)
		dfs(g[v][i],d-1,c);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=0;i<m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	scanf("%d",&q);
	for (i=0;i<q;i++) scanf("%d%d%d",vt+i,d+i,c+i);
	for (i=q-1;i>=0;i--) dfs(vt[i],d[i],c[i]);
	for (i=1;i<=n;i++) printf("%d\n",col[i]);
	return 0;
}

Measured memory_bytes: 8440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
const ll mod = 1e9 + 7;
int n, K;
ll ans;
int mu[N], p[N], tot;
bool flg[N];
void getMu() {
	mu[1] = 1;
	for (int i = 2; i < N; ++i) {
		if (!flg[i]) p[++tot] = i, mu[i] = -1;
		for (int j = 1; j <= tot && i * p[j] < N; ++j) {
			flg[i * p[j]] = 1;
			if (i % p[j] == 0) {
				mu[i * p[j]] = 0;
				break;
			}
			mu[i * p[j]] = -mu[i];
		}
		mu[i] += mu[i - 1];
	}
}
ll Pow(ll a, int b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = res * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return res;
}
ll cal(int k) {
	ll res = 0;
	for (int l = 1, r; l <= k; l = r + 1) {
		r = k / (k / l);
		res = (res + Pow(k / l, n)*(mu[r] - mu[l - 1]) % mod) % mod;
	}
	return res;
}
int main() {
	getMu();
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= K; i++) {
		ans = (ans + i * cal(K / i)) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4812
n = input()
l = int(len(n))
ans = 0
if l == 1:
    print(n)
elif l % 2 ==1:
    ans += int(n) - 10**(l-1)+1
    for i in range(1,l):
        if i %2 ==1:
            ans += 9*(10**(i-1))
        else:
            ans = ans
    print(ans)
else:
    for i in range(1,l):
        if i %2 ==1:
            ans += 9*(10**(i-1))
        else:
            ans = ans
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int x;
    int ans;
    cin >> x;
    if(x)ans = 0;
    else ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
# include <bits/stdc++.h>
using namespace std;
int main() {
   // freopen("input.txt","r",stdin);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=a[i]*a[j];
        }
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	string t = "AKIHABARA";
	int idx = 0;
	for(int i = 0; i < s.size(); ){
		if(idx == 9){
			cout << "NO" << endl;
			return 0;
		}
		if(s[i] == t[idx]){
			++idx;
			++i;
		}
		else if(t[idx] == 'A') ++idx;
		else{
			cout << "NO" << endl;
			return 0;
		}
	}
	if(idx < 8) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cmath>
#include <unordered_map>

size_t A[200000];
int main(void) {
  int n;

  std::cin >> n; /* 1 to 3*10^5 */

  //int* A = new int[n];
  for (size_t i = 0; i < n; i++) {
    std::cin >> A[i];
  }

  size_t count = 0;

  size_t lsum = 0;
  size_t rsum = 0;
  size_t l, r;
  size_t offset = 0;
  size_t i = 0;
  while(i < n) {
    size_t lcount = 0;
    for (size_t j = i + offset; j < n; ++j) {
      l = lsum ^ A[j];
      r = rsum + A[j];
      if (l != r) {
        break;
      }
      lcount++;
      lsum = l;
      rsum = r;
    }

    count += lcount + offset;

    if (lcount + offset > 1) {
      offset = lcount + offset - 1;
    } else {
      offset = 0;
    }
#if 0 
    if (offset) {
      --offset;
    }
    offset += lcount;
#endif
    lsum ^= A[i];
    rsum -= A[i];
    ++i;
  }

  std::cout << count << std::endl;;

  return 0;
}

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

int main() {
  ll N,D,ans=0;
  cin >> N >> D;
  rep(i,N) {
    ll X,Y;
    cin >> X >> Y;
    if(X*X+Y*Y<=D*D) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<long long> a;
    for (int i = 0; i < x; i++) {
        long long h;
        cin >> h;
        a.push_back(h);
    }
    
    vector<long long> b;
    for (int i = 0; i < y; i++) {
        long long h;
        cin >> h;
        b.push_back(h);
    }
    vector<long long> c;
    for (int i = 0; i < z; i++) {
        long long h;
        cin >> h;
        c.push_back(h);
    }
    vector<long long> ab;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(ab.rbegin(), ab.rend());
    sort(c.rbegin(), c.rend());
    vector<long long> abc;
    for (int i = 0; i < min(k, x*y); i++) {
        for (int j = 0; j < z; j++) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.rbegin(), abc.rend());
    for (int i = 0; i < k; i++) {
        cout << abc[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43384
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------


int main()
{
    Phuong_; /// <3333
    ll d,k,x;
    cin >> x >> k >> d;
    if (abs(x)%d == 0) {
        if (abs(x)/d > k) cout << abs((x < 0 ? (x + k*d) : (x-k*d))); else {
            k-= abs(x)/d ;
            if (k&1) cout << d; else
            cout << 0;
        }
    } else {
        if (abs(x)/d > k ) cout << abs((x < 0 ? (x + k*d) : (x-k*d))); else {
            ll num = abs(x) / d;
            if (x<0) x += num*d; else {
                x -= num*d;
            }
            k-=num;
            if (k&1) {
                if (x<0) x+=d;
                else x-=d;
                cout << abs(x);
            } else cout << abs(x);
        }
    }
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll N, T;
    cin >> N >> T;
    vector<pair<ll, ll>> data(N, pair<ll, ll>(0, 0));
    REP(i, N) cin >> data[i].first >> data[i].second;
    sort(data.begin(), data.end());
    
    vector<vector<ll>> dp(N+1, vector<ll>(T,0));

    FOR(i, 1, N + 1) {
        FOR(j, 0, T) {
            if (j - data[i-1].first < 0) {
                dp[i][j] = dp[i - 1][j];
                continue;
            }
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-data[i-1].first] + data[i-1].second);
        }
    }

    int ret;
    FOR(i, 0, N) {
        chmax(ret, dp[i][T - 1] + data[i].second);
    }
    cout << ret;
    return;
}

signed main() {
    solve();
    return 0;
}

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


int main()
{  
   int n;
   cin>>n;
   n = n-1;
   vector<int> arr(n);
   ll ans = 0;
   for(int i = 0 ; i < n ; i++)
   {
       cin>>arr[i];
       if(i == 0) ans += arr[i];
       if(i == (n-1)) ans += arr[i];
   }
   for(int i = 0 ; i < n-1  ; i++)
   {
       ans += min(arr[i],arr[i+1]);
   }
   cout<<ans<<endl;
        
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    string s;
    cin >> s;
    rep(i,3){
        cout << s[i];
    }
    cout << endl;
}

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

using namespace std;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> l[i];
    }

    int ans;
    int cnt=1;
    d[0] = 0;
    for (int i = 0; i < n; i++)
    {
        d[i+1] = d[i] + l[i];
        if (d[i+1]<=x)
        {
            cnt++;
        }
        
    }

    cout << cnt <<endl;
    
    
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

  ll D; cin >> D;
  vector<ll> c(26);
  REP(i, 26)cin >> c[i];
  vector<vector<ll>> s(D, vector<ll>(26));
  REP(i, D)REP(j, 26)cin >> s[i][j];
  vector<ll> last(26, 0);

  vector<ll> t(D);
  REP(i, D){
    cin >> t[i];
    t[i]--;
  }

  ll ans = 0;

  REP(i, D){
    //i日目に増えるスコア
    ll score;
    score = s[i][t[i]];
    last[t[i]] = i+1;
    // cout << score << endl;

    //i日目に減るスコア
    ll bye_score = 0;
    REP(j, 26){
      bye_score += c[j] * (i+1-last[j]);
    } 
    ans += score - bye_score;
    cout << ans << endl;
    // break;
  }


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

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; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	ll n;
	cin >> n;
	vector<string> s(n);
	rep(i,n)cin >> s[i];
	sort(all(s));
	//cout << endl;rep(i,n)cout << s[i] << endl;

	vector<pair<ll, string>> p;
	ll cnt = 1,m = 0;
	rep(i,n-1){
		if(s[i] == s[i+1])cnt++;
		else{
			p.push_back(make_pair(cnt, s[i]));
			cnt = 1;
		}
		m = max(m, cnt);
	}
	p.push_back(make_pair(cnt, s[n-1]));
	//cout << m << endl;
	ll k = p.size();
	//cout << k << endl;
	rep(i,k)if(p[i].first == m)cout << p[i].second << endl;


	return 0;
}

Measured memory_bytes: 18420
S = input()
if S == "SUN":
  r = 7
if S == "MON":
  r = 6
if S == "TUE":
  r = 5
if S == "WED":
  r = 4
if S == "THU":
  r = 3
if S == "FRI":
  r = 2
if S == "SAT":
  r = 1
print(r)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  in(a),in(b)
#define in3(a,b,c)  in2(a,b),in(c)
#define in4(a,b,c,d)  in2(a,b),in2(c,d)
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/

int main(){
	ll a,b,c,d;
	in4(a,b,c,d);
	if(d&1)outl(b-a);
	 else outl(a-b);
}


Measured memory_bytes: 256
from math import factorial
n,blue = map(int, input().split())
red = n-blue
MOD = 10**9+7

def comb(n,r):
  return factorial(n)//factorial(r)//factorial(n-r)

for i in range(1, blue+1):
  if red + 1- i < 0:
    print(0)
    continue
  ans = comb(red+1, i)
  ans %= MOD
  ans *= comb(blue-1, i-1)
  ans %= MOD
  print(ans)

Measured memory_bytes: 3316
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()

if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 3064
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  string S, T;
  cin >> S >> T;
  int ans = 0;

  for (int i = 0; i < S.size(); i++) {
    if(S[i] != T[i]) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int n;
    int k;
    int count=0;
    cin >> n >> k;
    int h[n];

    for (int i = 0; i < n; i++) cin >> h[i];

    for (int i = 0; i < n ; i++)
    {
        if (h[i] >= k)
        {
            count++;
        } 
    }
    cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <cstring>
#include <numeric>
#include <stack>
#include <iomanip>
#include <chrono>
using namespace std;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385

#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",mark)
#define sl(mark) scanf("%lld",&mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define setinf(mark) memset(mark,0x3f,sizeof(mark))

#define mp make_pair
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;

#ifndef KaalaNamak
#define endl '\n'
#define trace(...)
#define start_routine() 
#define end_routine()
#endif


signed main() {
    start_routine();
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    int t=1;
    // cin>>t;
    #ifdef KaalaNamak
        t=3;
    #endif
    while(t--){
        int x;
        cin>>x;
        if(x==1){
            cout<<"0\n";
        }
        else{
            cout<<"1\n";
        }
    }
    end_routine();

}

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

int main() {
  int N,sum=0;
  cin >> N;
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int l,r;
    cin >> l >>r; 
    sum += r+1-l;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> v(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    int ans = -100000000;
    for (int bit = 0; bit < (1<<N); bit++) {
        int X = 0, Y = 0;
        for (int j = 0; j < N; j++) {
            if (bit & (1<<j)) {
                X += v[j];
                Y += c[j];
            }
        }
        ans = max(ans, X - Y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {
    string x;
    stack<char> st;
    cin >> x;

    for(int i=0; i<x.size(); i++) {
        if(x[i]=='T') {
            if(st.empty() || st.top()=='T') {
                st.push('T');
            }
            else st.pop();
        }
        else {
            st.push('S');
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 644
import java.util.*;
import java.io.*;
 
public class Main {
    static char[] alps = "abcdefghijklmnopqrstuvwxyz".toCharArray();
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int[] li = new int[100001];
        for(int i = 0; i < n; i++){
            li[sc.nextInt()]++;
        }
        int dup = 0;
        for(int a : li){
            dup += Math.max(0,a-1);
        }
        System.out.println(n-(dup+dup%2));
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 32908
import sys
f = sys.stdin



func = {
'N':lambda x, y:(x, y + 1),
'S':lambda x, y:(x, y - 1),
'E':lambda x, y:(x + 1, y),
'W':lambda x, y:(x - 1, y)}

while True:
    n = int(f.readline())
    if n == 0:
        break
    gems = {tuple(map(int, f.readline().split())):False for _ in range(n)}
    m = int(f.readline())
    pos = (10, 10)
    for way, step in [f.readline().split() for _ in range(m)]:
        for i in range(int(step)):
            pos = func[way](*pos)
            try:
                gems[pos] = True
            except KeyError:
                pass

    print('Yes' if all(gems.values()) else 'No')

Measured memory_bytes: 6800
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define int long long
using namespace std;

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

    int a,b,c,k;

    cin >> a >> b >> c >> k;

    if(k%2 == 0){
        cout << a-b;
    }else{
        cout << b - a;
    }

    return 0;
}









Measured memory_bytes: 3648
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]

cnt=0
for i in range(n):
    a=ab[n-i-1][0]
    b=ab[n-i-1][1]
    a+=cnt
    amari=a%b
    shou=a//b
    if amari!=0:
        cnt+=b-amari
print(cnt)

Measured memory_bytes: 27256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int modPow(long long a, long long n, long long p) {
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}

int main(){
    ll n;
    cin >> n;
    vll d(n,0);
    rep(i, n){
        ll a;
        cin>> a;
        if(i==0){
            if(a!=0){
                cout << 0 << endl;
                return 0;
            }
        }
        d[a]++;
    }
    ll count=1;
    ll ans=1;
    ll i=1;
    if(d[0]>1){
        cout << 0 << endl;
        return 0;
    }
    while(count!=n){
        if(d[i]==0){
            cout << 0 << endl;
            return 0;
        }
        ans*=modPow(d[i-1],d[i],998244353);
        ans%=998244353;
        count+=d[i];
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=300005;

struct BIT{
  int maxn,c[N];
  inline void init(int n){
    maxn=n+1;
  }
  inline void add(int x,int r){
    x++;
    for (int i=x;i<=maxn;i+=i&-i)
      c[i]++;
  }
  inline int sum(int x){
    int ret=0;
    for (int i=x;i;i-=i&-i)
      ret+=c[i];
    return ret;
  }
  inline int sum(int l,int r){
    l++,r++;
    if (r>maxn) r=maxn;
    if (l>r) return 0;
    return sum(r)-sum(l-1);
  }
}bit1,bit2;

int n,m;

struct abcd{
  int l,r;
  int len(){
    return r-l+1;
  }
  bool operator < (const abcd &B) const{
    return r-l+1<B.r-B.l+1;
  }
}a[N];

int main(){
  scanf("%d%d",&n,&m);
  for (int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
  sort(a+1,a+n+1);
  int pnt=1,ans; bit1.init(m); bit2.init(m);
  for (int d=1;d<=m;d++){
    while (pnt<=n && a[pnt].len()<d) bit1.add(a[pnt].l-1,1),bit2.add(a[pnt].r,1),pnt++;
    ans=n-pnt+1;
    for (int x=0;x<=m/d;x++)
      ans+=x*bit2.sum(x*d,(x+1)*d-1);
    for (int x=0;x<=m/d;x++)
      ans-=x*bit1.sum(x*d,(x+1)*d-1);
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll over=0;

bool is375(ll n){
    bool a=0,b=0,c=0;
    while(n>0){
        if(n%10==3)a=1;
        if(n%10==7)b=1;
        if(n%10==5)c=1;
        n/=10;
    }
    return a&&b&&c;
}
set<ll> s;

void dfs(ll num, ll n){
    ll next=num*10+3;
    // cout<<num<<endl;
    if(next<=n){
        if(!s.count(next)){
            s.insert(next);
            dfs(next,n);
        }
    } else{
        if(is375(num)){
            over++;
            return;
        }
    }
    next+=2;
    if(next<=n){
        if(!s.count(next)){
            s.insert(next);
            dfs(next,n);
        }
    } else{
        if(is375(num)){
            over++;
            return;
        }
    }
    next+=2;
    if(next<=n){
        if(!s.count(next)){
            s.insert(next);
            dfs(next,n);
        }
    } else{
        if(is375(num)){
            over++;
            return;
        }
    }
    if(is375(num))over++;
    return;
}

int main(void) {
    
    ll n;
    cin>>n;
    dfs(3LL,n);
    dfs(5LL,n);
    dfs(7LL,n);
    fin(over);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (long long i = m; i < n; ++i)

int main() {
    long long N; cin >> N;
    rep(a, 1, 3501) rep(b, 1, 3501) {
        long long u = N * a * b;
        long long d = 4 * a * b - N * b - N * a;
        if(d <= 0) continue;
        long long c = u / d;
        if(c > 0 && c * d == u) {
            cout << a << " " << b << " " << c << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def calcSum(n, A):
    return n

def main():
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    for i in range(K + 1, N + 1): # K + 1 から N までのループ
        if (A[i - K - 1] < A[i - 1]):
            print("Yes")
        else:
            print("No")
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 31168
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

int N,K;
int A[100010];
int X=0;
int ans=0;

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
	}
	for(int i=40;0<=i;i--){
		int cnt=0;
		REP(j,N){
			if(A[j]&(1LL<<i)){
				cnt++;
			}
		}
		if(2*cnt<N&&(X|(1LL<<i))<=K){
			X|=(1LL<<i);
		}
	}
	REP(i,N){
		ans+=X^A[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

int dfs(int i, int s, int n){ // ???????????°????????????????????????????????¨????????°
  int ans = 0;
  if(i==10){
    if(s == 0 and n == 0) 
      return 1;
    else 
      return 0;
  }
  ans += dfs(i+1,s-i,n-1); // ??????
  ans += dfs(i+1,s  ,n  ); // ????????????
  return ans;
}


int main(){
  int s,n;
  while(1){
    cin >> n >> s;
    if(!s and !n) break;
    cout << dfs(0,s,n) <<  endl;
  }
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね

int main(){
    int n,k;
    cin >> n>> k;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    int asum=0;
    rep(i,n){
        asum+=a[i];
    }
    vector<int> d;
    for(int i = 1;i*i<=asum;i++){//約数を求める
        if(asum%i==0){
            d.push_back(i);
            if(asum/i!=i){
                d.push_back(asum/i);
            }
        }
    }
    sort(d.begin(),d.end(),greater<int>());//降順ソート
    int ans = 1;
    for(int e : d){//eの初期化らしい
        vector<int> r(n);
        rep(i,n){
            r[i]=a[i]%e;//割ってみたあまり
        }
        sort(r.begin(),r.end(),greater<int>());//並べてみる
        int rsum = 0;
        rep(i,n){
            rsum+=r[i];
        }
        int rn = rsum /e;
        int ksum = 0;
        rep(i,rn){
            ksum +=e-r[i];
        }
        if(ksum <= k){
            ans = e;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
def main():
    N = int(input())
    div = pow(10, 9) + 7

    if N == 1: return 1
    primes = primes1000()
    d = dict()
    for i in range(2, N+1):
        j = i
        for p in primes:
            if p > j:
                break
            else:
                while j % p == 0:
                    j = j // p
                    d[p] = d.get(p, 0) + 1

    # print(d)
    ans = 1
    for p in d:
        ans *= (d[p] + 1)
    return ans % div


def primes1000():
    pms = []
    for i in range(2, 1000+1):
        isPrime = True
        for j in range(2, int(math.sqrt(i))+1):
            if i % j == 0:
                isPrime = False
                break
        if isPrime:
            pms.append(i)
    return pms



if __name__ == '__main__':
    print(main())

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

typedef long long ll;
const int maxn = 55;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n, c, l[maxn];
double f[505][105];

int main()
{
	n = gi(); c = gi();
	for (int i = 0; i < n; ++i) l[i] = gi();
	sort(l, l + n);
	double res = 0, cnt = 0;
	do {
		for (int i = 0; i <= c * n; ++i)
			for (int s = 0; s < (1 << (n - 1)); ++s) f[i][s] = 0;
		f[l[n - 1] * n][0] = 1;
		for (int i = 1, p; i <= c * n; ++i) {
			if ((p = i % n - 1) < 0) continue;
			for (int j = i; j <= c * n; ++j)
                for (int s = 0; s < (1 << n - 1); ++s)
                    if (~s >> p & 1) f[min(c * n, max(j, i + l[p] * n))][s | (1 << p)] += f[j][s];
		}
		res += f[c * n][(1 << n - 1) - 1], ++cnt;
	} while (next_permutation(l, l + n - 1)); 

	printf("%.13lf\n", (double)res / cnt / pow(c, n - 1));
	
	return 0;
}


Measured memory_bytes: 512
N = int(input()) - 1

lb, ub = 0, 0

for n_digit in range(1, 20):
    lb = ub
    ub = (ub + 1) * 26
    # print(n_digit, lb, ub)

    if lb <= N < ub:
        off = N - lb
        ans = ['a' for _ in range(n_digit)]
        idx = 1
        while off > 0:
            ans[-idx] = chr(ord('a') + off % 26)
            off //= 26
            idx += 1
        
        print(''.join(ans))
        break

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

const int N = 100500;
int P[N], Q[N];

typedef long long llong;

int main() {
    int w, h;
    scanf("%d %d", &w, &h);
    for (int i = 0; i < w; i++) {
        scanf("%d", &P[i]);
    }
    for (int i = 0; i < h; i++) {
        scanf("%d", &Q[i]);
    }
    sort(P, P + w);
    sort(Q, Q + h);
    int p = 0, q = 0;
    llong ans = 0;

    auto movep = [&] {
        ans += (llong)P[p++] * (h - q + 1);
    };
    auto moveq = [&] {
        ans += (llong)Q[q++] * (w - p + 1);
    };

    while (p < w || q < h) {
        if (q == h) {
            movep();
        } else if (p == w) {
            moveq();
        } else {
            if (P[p] < Q[q]) {
                movep();
            } else {
                moveq();
            }
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] k = new int[M]; 
        int[] p = new int[M];
        int[][] s = new int[M][];
        //k s に値を格納
        for(int i=0; i<M; i++) {
            k[i] = Integer.parseInt(sc.next());
            int[] S = new int[k[i]];
            for(int j=0; j<k[i]; j++) {
                S[j] = Integer.parseInt(sc.next());
            }
            s[i] = S;
        }

        //pに値を格納
        for(int i=0; i<M; i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        //メイン処理
        int ans = 0;
        for(int i=0; i<Math.pow(2, N); i++) {
            int[] swit = new int[N]; //N個のスイッチ(0~N) on:1 off:0
            boolean hantei = true; //onの個数を2で割ったあまりがpiと等しいか
            for(int j=0; j<N; j++) {
                if((1&i>>j) == 1) {
                    swit[j] += 1; //on
                }else {
                    swit[j] += 0; //off
                }
            }
            
            for(int x=0; x<M; x++) {
                int count = 0;
                for(int y=0; y<k[x]; y++) {
                    if(swit[s[x][y]-1] == 1) { 
                        count++;
                    }
                }
                if(count % 2 != p[x]) {
                    hantei = false;
                }
            }
            
            
            if(hantei) ans++;
        }
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main (){
  int a,b, c;

  char s[11], t[11], x[11];

  scanf("%s %s %d %d %s", s,t, &a, &b, x);

  c=strcmp(x, s);

  if(c==0)
    printf("%d %d\n", a-1,b);
  else
    printf("%d %d\n", a, b-1);

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = n;
    
    int d = 1;
    while(m/10!=0){
      d++;
      m = m/10;
    }
    
    int count = 0;
    for(int i = 0; i < d - 1; i++){
      if(i%2==0){
        count += (int)Math.pow(10, (double)(i + 1)) - (int)Math.pow(10, (double)i);
      }
    }
    if(d%2==1){
      count += n - (int)Math.pow(10, (double)(d - 1)) + 1;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() { 
    int N, K;
    cin >> N >> K;
    string S; cin >> S;

    int happy = 0;
    int gp_ct = 1;

    for(int i=0; i<N-1; i++) {
        if(S[i] != S[i+1]) {
            gp_ct++;
        } else {
            happy++;
        }
    }
    // cout << "gp_ct: " << gp_ct << endl;
    // cout << "happy:" << happy << endl;
    // cout << "K:" << K << endl;

    REP(i, K) {
        if(gp_ct>2) {
            happy += 2;
            gp_ct-=2;
        } else if(gp_ct>1) {
            happy++;
            gp_ct--;
        } else {
            break;
        }
    }

    cout << happy << endl;
    

    return 0;
}

Measured memory_bytes: 512
N,K=map(int,input().split())
def kosuu(n,b,k):
    res = 0
    res += n//b * (b-k)
    diff = n%b - k
    if diff >= 0:
        res += diff + 1
    return res

cnt = 0
for b in range(K+1,N+1):
    ko = kosuu(N,b,K)
    # print(b,ko)
    cnt += ko

if K == 0:
    cnt -= N

print(cnt)

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

int main() {
	string s;
	cin >> s;
	bool a=false;
	bool b=false;
	if (s.substr(0,2)<="12"&&s.substr(0,2)!="00") a = true;
	if (s.substr(2,2)<="12"&&s.substr(2,2)!="00") b = true;

	if(a&&b) cout << "AMBIGUOUS" << endl;
	else if(a&&!b) cout << "MMYY" << endl;
	else if(!a&&b) cout << "YYMM" << endl;
	else cout << "NA" << endl;
}


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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> vote(n);
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        for (int j = 0; j < n; ++j) {
            if (b >= a[j]) {
                ++vote[j];
                break;
            }
        }
    }
    int flag = 0;
    int ans = -1;
    for (int i = 0; i < n; ++i) {
        if (vote[i] > flag) {
            flag = vote[i];
            ans = i;
        }
    }
    cout << ans + 1 << '\n';
}


Measured memory_bytes: 3036
#include <cstdio>
#include <cstdlib>
#include <algorithm>

using namespace std;

const int maxn = 210000;

typedef long long ll;

int a[maxn], b[maxn],c[maxn];

int main(int argc, char * argv[])
{
	int n;
	scanf("%d", &n);
	for (int i = 1;i <= n;++i) scanf("%d", &a[i]);
	for (int i = 1;i <= n;++i) scanf("%d", &b[i]);
	int ans = 0;
	for (int i = 1;i <= 29;++i)
	{
		for (int j = 1;j <= n;++j) c[j] = b[j] % (1 << i);
		sort(c + 1, c + n + 1);
		ll ones = 0;
		for (int j = 1;j <= n;++j)
		{
			if ((a[j] & (1 << (i - 1))) == 0)
			{
				ones += lower_bound(c+1,c+n+1,(1<<i)-(a[j]%(1<<i))) - lower_bound(c + 1, c + n + 1, (1 << (i-1)) - (a[j] % (1 << i)));
			}
			else
			{
				ones += lower_bound(c + 1, c + n + 1, (1 << i) -(a[j] % (1 << i))) - c - 1;
				if (i != 1)
				{
					ones += n + 1 - (lower_bound(c + 1, c + n + 1, (1 << i) + (1 << (i-1)) - (a[j] % (1 << i))) - c);
				}
			}
		}
		if (ones & 1) ans ^= (1 << (i - 1));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2560
def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True
prime = [0] * (10 ** 5 + 1)
prime[2] = 1
for i in range(3, 10 ** 5 + 1, 2):
    if is_prime(i):
        prime[i] = 1
s = [0] * (10 ** 5 + 2)
sum_ = 0
for i in range(1, 10 ** 5 + 1, 2):
    if prime[i] == 1 and prime[(i + 1) // 2] == 1:
        sum_ += 1
        s[i] = sum_
    else:
        s[i] = sum_
q = int(input())
lr = []
for i in range(q):
    lri = list(map(int, input().split()))
    lr.append(lri)
for i in range(q):
    print(s[lr[i][1]] - s[lr[i][0] - 2])

Measured memory_bytes: 29996
#include <iostream>
#include <queue>
#include <vector>
#include <sstream>
class data 
{
public:
  int arrnum;
  int num;
  data (int arrnum , int num )
  {
    this->arrnum = arrnum;
    this->num = num;
  };
};

bool operator> (const data &data1 , const data &data2)
{
  return data1.num > data2.num;
};


int main(int argc, char **argv)
{
  int N,L,i,j;
  std::stringstream ss;
  std::string s;
  
  std::cin >> N >> L;

  int *vec;
  vec = new int[N]; 

  for(i=0; i<N; i++)
    {
      std::cin >> vec[i];
    }

  std::priority_queue< data, std::vector<data>, std::greater<data> > que;

  for(i=0;i<N;i++)
    {
      que.push(data(i,vec[i]));
      if(i < L-1) continue;
      while(que.top().arrnum <= i-L)
	que.pop();
      ss << que.top().num << " ";
    }

  s = ss.str();
  s.pop_back();
 
  std::cout << s;
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 29932
n,q=map(int,input().split())
s=input()
index1=[0]*(n+2)

num=0
for i in range(len(s)):
    if s[i:i+2]=='AC':
        num+=1
    index1[i+1]=num


ans=[]

for i in range(q):
    l,r=map(int,input().split())
    if index1[l-1]==index1[l] and index1[r-1]==index1[r]:
        ans+=[index1[r]-index1[l]]
    elif index1[l-1]!=index1[l] and index1[r-1]==index1[r]:
        ans+=[index1[r]-index1[l]+1]
    elif index1[l-1]==index1[l] and index1[r-1]!=index1[r]:
        ans+=[index1[r]-index1[l]-1]
    elif index1[l-1]!=index1[l] and index1[r-1]!=index1[r]:
        ans+=[index1[r]-index1[l]]
for i in ans:
    print(i)

Measured memory_bytes: 10324
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    string s;
    cin>>s;
    string sc=s;
    if(s.size()==1){
        cout<<0<<endl;return 0;
    }
    int ans1=0;

    for(int i=1;i<s.size();i++){
        if(s[i]!=s[i-1]){

        }else{
            char c=(s[i]=='1'?'0':'1');
            s[i]=c;
            ans1++;
        }
    }
    
    int ans2=0;
    for(int i=sc.size()-2;i>=0;i--){
        if(sc[i]!=sc[i+1]){

        }else{
            char c=(sc[i]=='1'?'0':'1');
            sc[i]=c;
            ans2++;
        }
    }
   // cout<<ans1<<ans2<<endl;
    cout<<min(ans1,ans2)<<endl;


    return 0;
}


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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	if(abs(a-c)<=d) cout<<"Yes"<<endl;
	else if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256