akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};


int main() {
    int h,w; cin >> h >> w;
    int si,sj; cin >> si >> sj;
    int ti,tj; cin >> ti >> tj;
    --si; --sj; --ti; --tj;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> dist(h,vector<int>(w,INF));
    deque<P> que;
    dist[si][sj] = 0;
    que.emplace_back(si,sj);
    while (!que.empty()) {
        int i = que.front().first;
        int j = que.front().second;
        que.pop_front();
        int d = dist[i][j];
        rep(v,4) {
            int ni = i+di[v], nj = j+dj[v];
            if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
            if (s[ni][nj]=='#') continue;
            if (dist[ni][nj]<=d) continue;
            dist[ni][nj] = d;
            que.emplace_front(ni,nj);
        }
        for (int ei=-2; ei<=2; ei++) {
            for (int ej=-2; ej<=2; ej++) {
                int ni=i+ei, nj=j+ej;
                if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
                if (s[ni][nj]=='#') continue;
                if (dist[ni][nj]<=d+1) continue;
                dist[ni][nj] = d+1;
                que.emplace_back(ni,nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if (ans==INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9528
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    long N;
    cin >> N;
    cout << ((N%2)?N*2:N) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5+100;
int pre[maxn];
void init(int n)
{
    for(int i = 1;i<=n;++i)
        pre[i] = i;
}
int Find(int x)
{
    int t = x;
    while(pre[x]!=x)
    {
        x = pre[x];
    }
    pre[t] = x;
    return x;
}
bool un(int x,int y)
{
    int x1 = Find(x);
    int y1 = Find(y);
    if(x1==y1)
    {
        return false;
    }
    else
    {
        pre[x1] =y1;
        return true;
    }
}
int main()
{
   int n,m;
   scanf("%d %d",&n,&m);
   int ans = 0;
   init(n);
   while(m--)
   {
       int x,y;
       scanf("%d %d",&x,&y);
       if(un(x,y))
            ++ans;
   }
   printf("%d\n",n-ans-1);
    return 0;
}


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

using namespace std;

int main() {
    unsigned int x;
    cin >> x;

    bitset<32> bst(x);
    cout << bst << endl;
    cout << ~bst << endl;
    cout << (bst << 1) << endl;
    cout << (bst >> 1) << endl;
    return 0;
}


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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)

ll ext_gcd(ll a, ll b, ll&x, ll&y){
  if(b==0){
    x=1;y=0;return a;
  }
  ll q=a/b;
  ll g=ext_gcd(b,a-q*b,x,y);
  ll z=x-q*y;
  x=y;y=z;
  return g;
}

ll invmod(ll a, ll m){
  ll x,y;
  ext_gcd(a,m,x,y);
  x%=m;
  if(x<0)x+=m;
  return x;
}


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

  vector<ll> comb(N,1);
  vector<ll> perm(N,1);

  ll z=1000000007;
  FOR(i,1,N){
    perm[i]=perm[i-1]*i%z;
  }
  FOR(i,0,N){
    if(2*i-N<0) comb[i]=0;
    else if(2*i-N==1)comb[i]=i-1;
    else if(2*i-N==0)comb[i]=1;
    else comb[i]=perm[i-1]*invmod(perm[N-i-1],z)%z*invmod(perm[2*i-N],z)%z;
  }

//  coutv(comb,0,N);
  ll res=0;
  FOR(i,1,N){
//    cout<<res<<endl;
    res += (comb[i]*perm[i]%z*perm[N-1-i]%z-comb[i-1]*perm[i-1]%z*perm[N-i]%z+z)%z*i%z;

  // cout<<comb[i]*perm[i]%z*perm[N-i-1]%z<<endl;
    //cout<<comb[i-1]*perm[i-1]%z*perm[N-i]%z<<endl;
    //cout<<i<<endl;
  }
  cout<<res%z<<endl;
}


Measured memory_bytes: 15872
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def lcm(a, b):
  return a * b // gcd(a, b)

A, B, C, D = map(int, input().split())
b_num = B//C + B//D - B//lcm(C,D)
a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C,D)

print((B-A+1) - (b_num - a_num))

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  set<int> s;
  int X, N;
  int p;
  cin >> X >> N;
  for (int i = -1000; i <= 1000; i++)
    s.insert(i);
  rep(i, N) {
    cin >> p;
    s.erase(p);
  }
  // if (s.lower_bound(X) == s.begin())
  //   cout << *s.lower_bound(X) << endl;
  // else {
  int s1 = *s.lower_bound(X);
  int s2 = *(--s.lower_bound(X));
  if (s1-X >= X-s2)
    cout << s2 << endl;
  else
    cout << s1 << endl;
  // }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(m+1, 0);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        while(k--){
            int a;
            cin >> a;
            v[a]++;
        }
    }
    int ans = 0;
    for(auto i: v)
        if(i == n)
            ans++;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

ll mp[10010];

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

	ll ans = 0;
	if (P == 2) {
		for (ll i = 0;i < N;i++) {
			if (S[i] % 2 == 0)
				ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}
	if (P == 5) {
		for (ll i = 0;i < N;i++) {
			if (S[i] == '5' || S[i] == '0')
				ans += i + 1;
		}
		cout << ans << endl;
		return 0;
	}

	ll roll = 0;

	for (int i = 0;i < P;i++)mp[i] = 0;
	mp[0] = 1;
	ll d10 = 1;
	for (int i = N - 1;i >= 0;i--) {
		roll += ((ll)S[i] - 48) * d10;
		roll %= P;
		mp[roll]++;
		d10 *= 10;
		d10 %= P;
	}
	

	for (int i = 0;i < P;i++) {
		ans += mp[i] * (mp[i] - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 644
# -*- coding utf-8 -*-

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key = lambda x: x[1], reverse = True)    # sort by d

mp_max = 0
op = 0
taberu_ind = set()
pop_cands = []
t_taberu = set()
# greedy for delicious point
for i in range(k):
    op += sushi[i][1]

    t = sushi[i][0]
    if t_taberu.isdisjoint({t}):    # new type
        t_taberu.add(t)
    else:
        pop_cands.append(i)

    taberu_ind.add(i)
mp_max = op + len(t_taberu)**2

# reduce dericious, gain variety
i += 1
j = i
for i in range(i, n):
    if len(pop_cands) == 0:
        break

    pop_ind = pop_cands.pop()
    taberu_ind.remove(pop_ind)

    for j in range(j, n):
        t = sushi[j][0]
        if t_taberu.isdisjoint({t}):
            t_taberu.add(t)
            break
    else:
        break
    
    # calc points
    op -= sushi[pop_ind][1]
    op += sushi[j][1]
    mp = op + len(t_taberu)**2
    mp_max = max(mp_max, mp)

    taberu_ind.add(i)    # not necessary actually
print(mp_max)



Measured memory_bytes: 39632
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};


//////////////////////////////////////////////////



int main() {
    string s, t; cin >> s >> t;
    string a = t+ s;
    cout << a << endl;

    return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    long long cost[n], height[n];

    for (int i = 0; i < n; i++)
        cin >> height[i];
    cost[0] = 0;
    for (int i = 1; i < n; i++)
    {
        long long q =9223372036854775807;
        for (int j = i - 1; j > i - min(k, i) - 1; j--){
            q = min((long long)(fabs(height[i] - height[j]) + cost[j]), q);
        }
        cost[i] = q;
    }

    cout << cost[n - 1];
}


Measured memory_bytes: 5108
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Point{
	ll x,y;
};

ll W,H,V,T,X,Y,P,Q,R;
ll num_row,num_col,center_row,center_col;
Point center;

Point calc_loc(ll row,ll col){

	Point point;
	point.x = col*W;

	if(abs(center_col-col)%2 == 0){
		point.x += P;
	}else{
		point.x += (W-P);
	}

	point.y = (row*H);

	if(abs(center_row-row)%2 == 0){
		point.y += Q;
	}else{
		point.y += (H-Q);
	}
	return point;
}


ll calc_dist(Point a,Point b){
	return ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

ll calc_left(ll row){

	ll left = 0,right = center_col,m = (left+right)/2;
	ll res = BIG_NUM;

	Point point;

	while(left <= right){
		point = calc_loc(row,m);

		if(calc_dist(point,center) <= R*R){
			res = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	return res;
}

ll calc_right(ll row){

	ll left = center_col,right = num_col-1,m = (left+right)/2;
	ll res = num_col;

	Point point;

	while(left <= right){
		point = calc_loc(row,m);

		if(calc_dist(point,center) > R*R){
			res = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	return res;
}

int main(){

	scanf("%lld %lld %lld %lld %lld %lld %lld %lld",&W,&H,&V,&T,&X,&Y,&P,&Q);

	R = V*T;

	num_row = 2*(R/H+1)+1;
	num_col = 2*(R/W+1)+1;

	center.x = W*(R/W+1)+X;
	center.y = H*(R/H+1)+Y;

	center_row = (R/H+1);
	center_col = (R/W+1);

	ll ans = 0,left,right;

	for(ll row = num_row-1; row >= 0; row--){
		left = calc_left(row);
		if(left == BIG_NUM)continue;
		right = calc_right(row);
		ans += (right-left);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> c(n,n);
    rep(i,n){
        cin >> a[i];
    }
    rep(j,k){
        vector<int> d(n+1);
        rep(i,n){
            d[max(i-a[i],0)]++;
            d[min(i+a[i]+1,n)]--;
        }
        vector<int> e(n,d[0]);
        rep(i,n-1){
            e[i+1]=e[i]+d[i+1];
        }
        a=e;
        if (c==e){
            break;
        }
    }
    rep(i,n-1){
        cout << a[i] << ' ';
    }
    cout << a[n-1] << endl;
    return 0;
}


Measured memory_bytes: 6420
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

const int mod = 998244353;

int mul(int a, int b) {
  return (long long) a * b % mod;
}

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

const int maxn = (int) 4e6 + 5;
int f[maxn], inv[maxn], finv[maxn];

void precalc() {
  f[0] = 1;
  for (int i = 1; i < maxn; i++) {
    f[i] = mul(f[i - 1], i);
  }
  inv[1] = 1;
  for (int i = 2; i < maxn; i++) {
    inv[i] = (mod - (long long) (mod / i) * inv[mod % i] % mod) % mod;
  }
  finv[0] = 1;
  for (int i = 1; i < maxn; i++) {
    finv[i] = mul(finv[i - 1], inv[i]);
  }
}

int c(int n, int k) {
  if (!k) {
    return 1;
  }
  if (k < 0 || k > n) {
    return 0;
  }
  return mul(f[n], mul(finv[k], finv[n - k]));
}

int n, m;

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  return true;
}

void solve() {
  int res = c(3 * m + n - 1, 3 * m);
  {
    int big = mul(n, c(m - 1 + n - 1, m - 1));
    add(res, mod - big);
  }
  {
    int odd = 0;
    for (int i = m + 1; i <= n && i <= 3 * m; i++) {
      int rem = 3 * m - i;
      if (rem & 1) {
        continue;
      }
      rem /= 2;
      int cur = c(n, i);
      cur = mul(cur, c(rem + n - 1, rem));
      add(odd, cur);
    }
    add(res, mod - odd);
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 47104
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

while True:
    d = [int(i) for i in input().split()]
    if d[0] == 0 and d[1] == 0 and d[2] == 0:
        break

    d.sort()
    cheese = d[0] * d[0] + d[1] * d[1]

    N = int(input())
    for l in range(N):
        R = int(input())*2
        if cheese < R*R:
            print("OK")
        else:
            print("NA")



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll M[100005];

int main()
{
    ll N, K, Q;
    cin >> N >> K >> Q;
    memset(M, 0, sizeof(M));
    REP(i, Q)
    {
        cin >> A[i];
        M[A[i] - 1]++;
    }

    REP(i, N)
    {
        if (K - (Q - M[i]) > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<char> S(N);
  REP(i, N) cin >> S[i];
  bool flag = false;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'Y') {
      flag = true;
      break;
    }
  }
  if(flag)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
  return 0;
}

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

using namespace std;

struct edge{
  int b,c,h,r;
};

int main(){
  for(int N,M,H,K;cin>>N>>M>>H>>K,N|M|H|K;){
    vector<edge> edges[123];
    for(int i=0;i<M;i++){
      int a,b,c,h,r;
      cin>>a>>b>>c>>h>>r;
      edges[a].push_back({b,c,h,r});
      edges[b].push_back({a,c,h,r});
    }
    int S,T;
    cin>>S>>T;
    int P;
    cin>>P;
    int p[1<<9];
    fill(begin(p),end(p),1e9);
    p[0]=0;
    for(int i=0;i<P;i++){
      int l,d;
      cin>>l>>d;
      int b=0;
      while(l--){
	int k;
	cin>>k;
	b|=1<<k;
      }
      p[b]=d;
    }
    for(int i=0;i<1<<8;i++){
      for(int j=0;j<1<<8;j++){
	if(!(j&~i)){
	  for(int k=0;k<1<<8;k++){
	    if(!(k&~i)&&(j|k)==i){
	      p[i<<1]=min(p[i<<1],p[j<<1]+p[k<<1]);
	    }
	  }
	}
      }
    }
    int ans=1e9;
    for(int i=0;i<1<<9;i++){
      int dp[99][123];
      fill(*begin(dp),*end(dp),1e9);
      dp[0][S]=p[i];
      for(int j=0;j<H;j++){
	for(int k=0;k<=N;k++){
	  dp[j+1][k]=min(dp[j+1][k],dp[j][k]);
	  for(auto e:edges[k]){
	    dp[j+e.h][e.b]=min(dp[j+e.h][e.b],dp[j][k]+((i>>e.r&1)?0:e.c));
	  }
	}
      }
      ans=min(ans,dp[H][T]);
    }
    cout<<((ans<1e8)?ans:-1)<<endl;
  }
}

	    

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  bool f = 1;
  for (int i = 0; i < n/2; ++i) {
    if (s[i] != s[n/2-i-1] || s[n/2-i-1] != s[n/2+i+1] || s[n/2+i+1] != s[n-i-1]) f = 0;
  }
  if (f) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m;
  	ci(n>>m);
  ll s=10000;
  FOR(i,0,n){
    ll a;
    	ci(a);
    m-=a;
    s=rM(a,s);
  }
  co(n+m/s)
}

Measured memory_bytes: 256
n = int(input())
a = sorted([int(input()) for _ in range(n)])
ans = 0
tmp = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
    else:
        if tmp%2 == 1:
            ans += 1
        tmp = 1
if tmp%2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 8284
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 100001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<int> a(MAX);
    int b;
    for (int i = 0; i < N; i++) {
        cin >> b; a[b]++;
    }
    int maxCnt = 0;
    for (int i = 0; i < MAX - 2; i++) {
        int tmp = a[i] + a[i+1] + a[i+2];
        maxCnt = max(maxCnt, tmp);
    }
    cout << maxCnt << '\n';
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    S=input()
    R,G,B=S.count('R'),S.count('G'),S.count('B')
    ALL = R*G*B
    for a in range(N):
        for b in range(a+1, N):
            c = b + (b-a)
            if c >= N:
                continue
            if S[a] != S[b] and S[b] != S[c] and S[c] != S[a]:
                ALL -= 1
    print(ALL)



main()



Measured memory_bytes: 10004
#include <stdio.h>

int kensa(int A[]);

int main(void)
{
	int A[10];
	int i;
	int n;
	int i2;
	
	scanf("%d", &n);
	
	for (i=0; i < n; i++){
		for (i2 = 0; i2 < 10; i2++){
			scanf("%d", &A[i2]);
		}
	
	i2 = kensa(A);
	
	if (i2 == 1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	}
	return (0);
}

int kensa(int A[])
{
	int i;
	int a,b;
	int n;
	
	a = 0;
	b = 0;
	
	for (i=0; i < 10; i++){
		n = A[i];
		if (n > a ){
			a = n;
		}
		else if (n > b){
			b = n;
		}
		else if (n < a && n < b){
			return (0);
		}
	}
	
	return (1);
}

Measured memory_bytes: 576
N = int(input())
p = list(map(int, input().split()))
tmp = 100

for i in range(len(p) - 1):
    for j in range(i + 1, len(p)):
        if p[i] > p[j]:
            tmp = min(tmp, p[j])

    if tmp != 100:
        for k in range(len(p)):
            if p[k] == tmp:
                p[k], p[i] = p[i], p[k]
                break
        break

if p == sorted(p):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 38256
def main():
    n = int(input())
    if n % 10 == 3:
        print('bon')
    elif n % 10 == 0 \
        or n % 10 == 6 \
        or n % 10 == 1 \
        or n % 10 == 8:
        print('pon') 
    else:
        print('hon')
if __name__ == '__main__':
    main()

Measured memory_bytes: 9108
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

ll N;
ll ct[100001];

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

  cin >> N;
  rep(i,N){
    ll inp; cin >> inp;
    ct[inp]++;
  }

  ll ans = 0;
  ll minus=0;
  rep(i,100001){
    if(ct[i] > 0) ans++;
    if(ct[i]>0 && (ct[i]%2==0))
      minus++;
  }
  cout << ans - (minus%2) << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,s;
int a[N];
inline int gcd(int x,int y){return y?gcd(y,x%y):x;}
int read()
{
	int x=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}
int main()
{
	n=read();s=read();
	for(int i=1;i<=n;++i) a[i]=abs(read()-s);
	if(n==1){printf("%d\n",a[1]);return 0;}
	int cd=gcd(a[1],a[2]);
	for(int i=3;i<=n;++i) cd=gcd(cd,a[i]);
	cout<<cd<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,m,k,arr[N];

void solve()
{
    cin>>n;
    forn(i,1,n)
    {
    	cin>>arr[i];
    }
    int mx = arr[1];
    int ans  = 0;
    forn(i,1,n)
    {
    	if(mx>=arr[i])ans++;
    	mx = min(mx,arr[i]);
    }
    cout<<ans;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    string s;
    ll k;
    cin >> s;
    cin >> k;
    ll cnt = 1;
    ll one = 0;
    REP(i,s.size() - 1){
        if(s[i] == s[i + 1]){
            cnt++;
        }else{
            one += cnt / 2;
            cnt = 1;
        }
    }
    one += cnt / 2;
    string t = s + s;
    cnt = 1;
    ll two = 0;
    REP(i,t.size() - 1){
        if(t[i] == t[i + 1]){
            cnt++;
        }else{
            two += cnt / 2;
            cnt = 1;
        }
    }
    two += cnt / 2;
    t += s;
    cnt = 1;
    ll three = 0;
    REP(i,t.size() - 1){
        if(t[i] == t[i + 1]){
            cnt++;
        }else{
            three += cnt / 2;
            cnt = 1;
        }
    }
    three += cnt / 2;
    if(one * 2 == two){
        cout << one * k << endl;
    }else{
        if(three == one + two){
            cout << one * ((k + 1) / 2) + (two - one) * (k - (k + 1) / 2) << endl;
        }else{
            cout << one + (two - one) * (k - 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		java.util.Scanner in = new java.util.Scanner(System.in);
		int n = in.nextInt();
		String name = in.next();
		int cnt = 0; //当てはまる個数
		for (int i=0; i<n; i++) {
			String board = in.next(); //古い看板
			boolean check = false;
			int same1 = 0; // nameと1文字目が同じ添字を格納
			int same2 = 0; //nameと2文字目が同じ添字を格納
			for(int j=0; j<board.length();j++) {
				if (name.charAt(0) == board.charAt(j)) { //1文字目の判定
					same1 = j;
					for(int k=j+1; k<board.length();k++) {
						if (name.charAt(1) == board.charAt(k)) { //2文字目の判定
							same2 = k;
							int diffe = same2 - same1; //文字間隔
							for (int l=2; l<name.length();l++) {
								if (same2 + diffe*(l-1) < board.length()) {
									if (name.charAt(l) == board.charAt(same2 + diffe*(l-1))) { //3文字目以降を判定
										if (l == name.length()-1) { //nameの長さと同じ
											cnt++;
//											System.out.println(i);
											check = true;
											break;
										}
									}
									else break;
								}
								else break;
							}
							if (check == true) break;
						}
						if (check == true) break;
					}
					if (check == true) break;
				}
				if (check == true) break;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 20904
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MAX = 55;
const int MOD = 1e9+7;
ll N, K;
vvi A;

vvi mult(vvi A, vvi B) {
    vvi C;
    REP (i, N) {
        C.push_back(vi(N));
        REP (j, N) {
            REP (k, N) C[i][j] += A[i][k] * B[k][j] % MOD;
            C[i][j] %= MOD;
        }
    }
    return C;
}

vvi exp(vvi A, ll k) {
    if (k == 1) return A;
    vvi B = exp(A, k/2);
    B = mult(B, B);
    if (k&1) B = mult(A, B);
    return B;
}

int main () {
    cin >> N >> K;
    REP (i, N) {
        A.push_back(vi(N));
        REP (j, N) cin >> A[i][j];
    }
    A = exp(A, K);
    ll ans = 0;
    REP (i, N) REP (j, N) ans += A[i][j];
    cout << ans % MOD << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ll long long
int cost[10][10];
int main()
{
    int n,m;
    cin>>n>>m;
    int i,j,k;
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            cin>>cost[i][j];
        }
    }
    for(k=0;k<10;k++)
    {
        for(i=0;i<10;i++)
        {
            for(j=0;j<10;j++)
            {
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
            }
        }
    }
    int t=0;
    int ans=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>t;
            if(t==-1 || t==1)
            {
                continue;
            }
            ans+=cost[t][1];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static int res = 0;
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int q = Integer.parseInt(str[2]);

        int[][] Q = new int[q][5];
        for(int i=0; i<q; ++i){
            str = br.readLine().split(" ");
            for(int j=1; j<=4; ++j){
                Q[i][j] = Integer.parseInt(str[j-1]);
            }
        }
        dfs(0,new ArrayList<Integer>(n), n,m,q,Q);
        System.out.println(res);
    }
    public static void dfs(int idx, List<Integer> A, int n,int m, int q,int[][] Q){
        if(idx == n){
            if(A.size() < n) return;
            int score = 0;
            for(int i=0; i<q; ++i){
                if(A.get(Q[i][2]-1) - A.get(Q[i][1]-1) == Q[i][3])
                    score += Q[i][4];
            }
            res = Math.max(res, score);
            return;
        }
        int val = 1;
        if(idx-1 >= 0) {
            val = A.get(idx - 1);
        }
        for(int i=val; i<=m; ++i){
            A.add(i);
            dfs(idx+1,A,n,m,q,Q);
            A.remove(A.size()-1);
        }
    }
}


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

int main(){
  char s[28];  scanf("%s", s);
  for(int i=0; i<strlen(s); i++){
    for(int j=strlen(s)-1; j>i; j--){
      if(s[i] == s[j]){
	printf("no\n");
	return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			int n=int.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		WF=new int[N+1][];
		for(int i=0;i<=N;i++){
			WF[i]=new int[N+1];
			for(int j=0;j<=N;j++){
				WF[i][j]=Arr[i][j]!=0?Arr[i][j]:(i==j?0:INF);
			}
		}
		//Warshall-Floyd
		for(int kk=0;kk<=N;kk++){
			for(int ii=0;ii<=N;ii++){
				for(int jj=0;jj<=N;jj++){
					WF[ii][jj]=Math.Min(WF[ii][jj],WF[ii][kk]+WF[kk][jj]);
				}
			}
		}
		//MinCostを求めておく。求まらなければ"impossible";
		DCost=new int[q];
		for(int i=0;i<q;i++){
			DCost[i]=INF;
			for(int j=0;j<=N;j++){
				if(D[j].ContainsKey(Okaimono[i])){
					DCost[i]=Math.Min(D[j][Okaimono[i]],DCost[i]);
				}
			}
			if(DCost[i]==INF){
				Console.WriteLine("impossible");
				return;
			}
		}
		
		//各店でゲットできる品物をビットマスク化しておく。
		int[] bmask=new int[N+1];
		for(int i=0;i<=N;i++){
			for(int j=0;j<q;j++){
				if(D[i].ContainsKey(Okaimono[j]) && D[i][Okaimono[j]]==DCost[j]){
					bmask[i]=bmask[i]|(0x1<<j);
				}
			}
		}
		
		
		//dp[n][m]:n地点にmだけ買い物終わって居るのに必要な移動距離のMin
		//　　　　今いる地点から次の地点に向けて配るDPする。
		
		int[][] dp=new int[N+1][];
		for(int i=0;i<=N;i++){
			dp[i]=new int[0x1<<q];
			for(int j=0;j<(0x1<<q);j++)dp[i][j]=INF;
		}
		
		dp[0][0]=0;
		for(int m=0;m<(0x1<<q);m++){
			for(int f=0;f<=N;f++){
				for(int t=0;t<=N;t++){
					dp[t][m|bmask[t]]=Math.Min(dp[t][m|bmask[t]],dp[f][m]+WF[f][t]);
				}
			}
		}
		
		int TotalCost=0;
		for(int i=0;i<q;i++){
			TotalCost+=DCost[i];
		}
		Console.WriteLine("{0} {1}",TotalCost,dp[0][(0x1<<q)-1]);
	}
	
	
	int[] DCost;
	int[][] WF;
	
	int N;
	Dictionary<String,int>[] D;
	List<String> Okaimono;
	int[][] Arr;
	int q;
	int E;
	int INF;
	
	public Sol(int n_){
		INF=(int)1e9;
		N=n_;
		D=new Dictionary<String,int>[N+1];
		D[0]=new Dictionary<String,int>();
		for(int i=1;i<=N;i++){
			var ss=rsa();
			D[i]=new Dictionary<String,int>();
			for(int j=1;j<ss.Length;j+=2){
				D[i].Add(ss[j],int.Parse(ss[j+1]));
			}
		}
		Okaimono=new List<String>();
		q=ri();
		for(int i=0;i<q;i++){
			Okaimono.Add(rs());
		}
		E=ri();
		Arr=new int[N+1][];
		for(int i=0;i<=N;i++)Arr[i]=new int[N+1];
		for(int i=0;i<E;i++){
			var d=ria();
			Arr[d[0]][d[1]]=Arr[d[1]][d[0]]=d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 7240
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
 
int main(){
  long int N;
  std::cin >> N;
  std::vector<long int> A(N+1), B(N);
  for (int i=0; i<N+1; i++) { std::cin >> A[i]; }
  for (int i=0; i<N; i++) { std::cin >> B[i]; }
  long int ans = 0;
/*  ans  += std::min(B[0], A[0]);
  B[0] -= std::min(B[0], A[0]);
  A[0] -= std::min(B[0], A[0]);*/
  for (int i=0; i<N; ++i) {
    long int left = std::min(B[i], A[i]);
    ans  += left;
    B[i] -= left;
    A[i] -= left;
    long int right = std::min(B[i], A[i+1]);
    ans    += right;
    B[i]   -= right;
    A[i+1] -= right;
  }
/*    if (B[i] > A[i+1]) { 
      ans += A[i+1];
      B[i] -= A[i+1];
      A[i+1] = 0;
      if (B[i] > A[i]) { 
        ans += A[i];
        B[i] -= A[i];
        A[i] = 0;
      }
      else {
        ans += B[i];
        A[i] -= B[i];
        B[i] = 0;
      }
    }
    else {
      ans += B[i];
      A[i+1] -= B[i];
      B[i] = 0;
    }
  }*/
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	int ans = mp.size();
	dunk(ans);
	return 0;
}


Measured memory_bytes: 19224
#include <stdio.h>
#include <math.h>

#define INPUT_NUMBER 3

int main(void){
    int a,b;
    char trash;
    char op;
    int not_zero=1;
    while(not_zero){
        scanf("%d",&a);
        scanf("%c",&trash);
        scanf("%c",&op);
        scanf("%c",&trash);
        scanf("%d",&b);

        if(op=='?'){
            not_zero=0;
        }else if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else{
            printf("%d\n",a/b);
        }
    }
}


Measured memory_bytes: 1952
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %f", d, r, f);
	}
}

Measured memory_bytes: 17344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; 
  cin >> n;
  
  int mai = n / 1000;
  if (n % 1000 != 0) {
    mai++;
  }
  
  int ans = 1000 * mai - n;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto& a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

void Main() {
  int n, k;  // [3,2e5], [2,1e9]
  cin >> n >> k;
  combination com(n);
  mint ans = 1;
  REP(i, 1, min(n, k) + 1)
  ans += com(n, i) * com(n - 1, n - 1 - i);
  cout << ans.x << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
    string s;cin>>s;
    if((s[0]=='A'&&s[1]=='A'&&s[2]=='A')||(s[0]=='B'&&s[1]=='B'&&s[2]=='B'))
    cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


int main()
{

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

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

}

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

main()
{
  int a[10000];
  int i, j, length, count = 0, flag = 0;

  scanf("%d", &length);

  for(i = 0; i < length; i++)
    {
      scanf("%d", &a[i]);
    }

  for(i = 0; i < length; i++)
    {
      for(j = 2; j <= sqrt(a[i]); j++)
	    {
	      if(a[i] % j == 0)
		{
		  flag = 1;
		  break;
		}
	      flag = 0;
	    }
      if(flag == 0)
	{
	  count++;
	}
      flag = 0;
    }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 632
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int L = sc.nextInt();
		int taste = 0;
		int min=Integer.MAX_VALUE;
		int minabs=Integer.MAX_VALUE;
		for(int i=1;i<=N;i++) {
			taste += L+i-1;
			if(minabs> Math.abs(L+i-1)) {
				minabs = Math.abs(L+i-1);
				min = L+i-1;
			}
		}
		taste-=min;
		System.out.println(taste);
	}
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int H,W;
  int i;
  cin >> H >> W;
  vector<string> s(H);
  for(i=0; i<H; i++)
    cin >> s.at(i);
  for(i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
  for(i=0; i<H; i++)
    cout << "#"+s.at(i)+"#" << endl;
  for(i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
}
  

Measured memory_bytes: 256
def slimes(n, s):
   
  u_slime = [s[-1]]
  for i in range(n-1):
    if not s[i] == s[i+1]:
      u_slime.append(s[i])
  
  print(len(u_slime))

if __name__ == "__main__":
  n = int(input())
  s = input()
  slimes(n, s)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	cout << fixed << setprecision(20);
	const double pi = acos(-1);
	double a,b,h,m; cin>>a>>b>>h>>m;
	double ah=m*6;
	//cout<<k<<endl;
	double al=(30*h)+(0.5*m);
	//cout<<l<<endl;
	double ang=abs(ah-al);
	//cout<<ang<<endl;
	long double c=cos(pi*ang/180);
	//cout<<c<<endl;
	double a2=a*a;
	double b2=b*b;
	long double ans=a2+b2-(2*a*b)*c;
	cout<<sqrt(ans);
	
	return 0;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s,t;
    cin>>s>>t;
    int n=s.length();
    vector<int>p[27];
    bool s1[27]={0},s2[27]={0};
    for(int x=0;x<s.length();x++){
        s1[s[x]-'a'+1]=1;
        p[s[x]-'a'+1].pb(x+1);
    }
    int c[27]={0};
    for(int x=1;x<27;x++){
        c[x]=p[x].size();
    }
    for(int x=0;x<t.length();x++){
        s2[t[x]-'a'+1]=1;
    }
    for(int x=1;x<=26;x++){
        if(s2[x]==1&&s1[x]==0){
            cout<<-1;
            return 0;
        }
    }

    int ans=0;
    int cnt[27]={0};
    for(int x=0;x<t.length();x++){
        int r=ans%n;
        auto itr=upper_bound(p[t[x]-'a'+1].begin(),p[t[x]-'a'+1].end(),r);
        if(itr==p[t[x]-'a'+1].end()||*itr<=r){
            ans=ceil(ans/(1.0*n))*n+p[t[x]-'a'+1][0];
        }else{
            ans+=*itr-r;
        }


    cnt[t[x]-'a'+1]++;
    }
    cout<<ans;








	
return 0;
}


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

int main(){
  int N, x;
  cin >> N >> x;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    if (x > 0) {
      x -= vec.at(i);
      count++;
    }
  }
  if (x != 0) {
    count--;
  }
  
  cout << count << endl;
  
  
}

Measured memory_bytes: 256
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)


Measured memory_bytes: 61848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn=2e5+10;
char num[27];
int sum[100];


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	num[0]='z';
	for(int i=1;i<26;i++)
    {
        num[i]=char(i-1+'a');
    }
	cin>>n;
	int i=0;
	while(n)
    {
        if(n%26==0)
        {
            sum[i]=0;
            i++;
            n/=26;
            n--;
            continue;
        }
        sum[i]=n%26;
        i++;
        n/=26;
    }
    for(i--;i>=0;i--)
    {
        cout<<num[sum[i]];
    }
    cout<<'\n';


}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
const int M=1e9+7;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	long long sum=0;
	for(int i=0; i<n; i++) cin >> a[i], sum+=a[i];
	long long res=0;
	long long temp=0;
	for(int i=0; i<n; i++){
		temp+=a[i];
		(res+=1ll*a[i]*((sum-temp)%M)%M)%=M;
	}
	cout << res;
}

Measured memory_bytes: 4428
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
vector<int>p[100010];
const int mod=998244353;
inline int ad(int x){return x>=mod?x-mod:x;}
int pw[100010],sum[3][100010],sg[100010],mx[3];
bool v[100010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    pw[1]=1;
    for(int i=1;i<=18;i++)pw[1]=1LL*pw[1]*10%mod;
   	int n=read(),ans=0;
   	for(int i=2;i<=n;i++)pw[i]=1LL*pw[i-1]*pw[1]%mod;
	for(int T=0;T<3;T++)
	{
		int m=read();
		for(int i=1;i<=n;i++)p[i].clear(),sg[i]=0;
		for(int i=1;i<=m;i++)
		{
			int x=read(),y=read();if(x>y)swap(x,y);
			p[x].push_back(y);
		}sum[T][0]=ad(sum[T][0]+pw[n]);
		for(int i=n-1;i>=1;i--)
		{
			int now=0;
			for(int j=0;j<p[i].size();j++)v[sg[p[i][j]]]=true;
			while(v[now]==true)now++;mx[T]=max(mx[T],now),sg[i]=now;sum[T][now]=ad(sum[T][now]+pw[i]);
			for(int j=0;j<p[i].size();j++)v[sg[p[i][j]]]=false;
		}
	}
	for(int i=0;i<=mx[0];i++)
	{
		for(int j=0;j<=mx[1];j++)ans=ad(ans+1LL*sum[0][i]*sum[1][j]%mod*sum[2][i^j]%mod);
	}pr2(ans);
    return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main()
{
	string str;
	cin >> str;
		
	set<char> s;
	bool isdup = false;
	for( char c : str ) {
		auto r = s.insert( c );
		isdup = !r.second;
		if( isdup ) {
			break;
		}
	}

	cout << ( !isdup ? "yes" : "no" ) << endl;
	return 0;
}


Measured memory_bytes: 256