akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator - () {
		x = (-x % Mod + Mod) % Mod;
	}
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator ++ () {
		*this += 1;
	}
	void operator ++(int) {
		operator++();
	}
	void operator -= (const mll& a) {
		if ((x += Mod - a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	void operator /= (const mll& a) {
		mll b = a.inv();
		(x *= b.x) %= Mod;
	}
	mll operator + (const mll& a) const {
		mll ans = *this;
		ans += a;
		return ans;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	mll inv() const {
		long long a = x, b = Mod, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= Mod;
		if (u < 0) u += Mod;
		a = u;
		return mll(a);
	}

};
int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	mll sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	mll ans = sum * sum;
	for (int i = 0; i < N; i++) ans -= A[i] * A[i];
	ans /= 2;
	cout << ans.x << endl;

}


Measured memory_bytes: 4840
N,X,Y=map(int,input().split())

ans=[]
for i in range(N-1):
    ans.append(N-1-i)

#G=[[0 for _ in range(N)] for i in range(N)]
K=[0]*(N)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        b=abs(i-X)+1+abs(j-Y)
        c=abs(i-Y)+1+abs(j-X)
        val=min(a,b,c)
        K[val]+=1
for i in range(len(K)):
    if i==0:
        continue
    print(K[i])

Measured memory_bytes: 48220
using System;
namespace ITP1_5_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string[] S = Console.ReadLine().Split();
                int H = int.Parse(S[0]);
                int W = int.Parse(S[1]);
                int i;
                int j;
                if(H == 0 && W == 0)
                {
                    break;
                }
                for(i = 0; i < H; i++)
                {
                    for(j = 0; j < W; j++)
                    {
                        if((j + i ) % 2 == 0)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 15888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,n) for(int i=0;i<n;i++);
#define fore(i,a,b) for(int i=a;i<b;i++);


int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(ceil((float)c/b)<=ceil((float)a/d)){
        cout<<"Yes"<<endl;
       }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
#define ll long long int
#define ld long double
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define sz size()
#define ff first
#define ss second
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define inf LLONG_MAX
#define f(i,a,b) for(i=a;i<b;i++)
#define PI 3.141592653589793238
const ll mod=1000000007; 
// const ll high=1e5+5;
using namespace std;
ll lcm(ll n,ll m)
{
    return (n*m)/__gcd(n,m);
}
void solve()
{
    ll n,i,j,w;
    cin>>n>>w;
    ll v[n+1]={0},wi[n+1]={0};
    f(i,1,n+1)cin>>wi[i]>>v[i];
    ll dp[n+1][w+1]={0};
    f(i,0,n+1)
    {
        
        f(j,0,w+1)
        {
            if(i==0||j==0)dp[i][j]=0;
            else if(j<wi[i])dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(v[i]+dp[i-1][j-wi[i]],dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
}
int32_t main()
{
    fast
    ll q=1;
    // cin>>q;
    while(q--)solve();
    return 0;
}

Measured memory_bytes: 79232
/*
* @author:  codancer
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
const int N = 6e5+100;
struct Seg{
    ll sum[N<<1],add[N<<1];
    inline void pushup(ll rt){
        sum[rt]=sum[rt<<1]+sum[rt<<1|1];
    }
    inline void pushdown(ll rt,ll l,ll r){
        if(add[rt]){
            ll mid=(l+r)>>1;
            sum[rt<<1]=sum[rt<<1]+add[rt]*(mid-l+1);
            sum[rt<<1|1]=sum[rt<<1|1]+add[rt]*(r-mid);

            add[rt<<1]+=add[rt];
            add[rt<<1|1]+=add[rt];

            add[rt]=0;
        }
        return ;
    }
    inline void buildtree(ll rt,ll l,ll r){
        add[rt]=0;
        if(l==r){
            sum[rt]=0;
            return ;
        }
        ll mid=(l+r)>>1;
        buildtree(rt<<1,l,mid);
        buildtree(rt<<1|1,mid+1,r);
        pushup(rt);
    }
    inline void modify(ll rt,ll l,ll r,ll nl,ll nr,ll k){//区间[nl,nr]+k
        if(nl<=l&&r<=nr){
            add[rt]+=k;
            sum[rt]+=k*(r-l+1);
            return ;
        }
        ll mid=(l+r)>>1;
        pushdown(rt,l,r);
        if(nl<=mid) modify(rt<<1,l,mid,nl,nr,k);
        if(nr>mid) modify(rt<<1|1,mid+1,r,nl,nr,k);
        pushup(rt);
    }
    inline ll querysum(ll rt,ll l,ll r,ll nl,ll nr){
         if(nl<=l&&r<=nr){
            return sum[rt];
        }
        ll ans=0;
        ll mid=(l+r)>>1;
        pushdown(rt,l,r);
        if(nl<=mid) ans+=querysum(rt<<1,l,mid,nl,nr);
        if(nr>mid) ans+=querysum(rt<<1|1,mid+1,r,nl,nr);
        return ans;       
    }
}tree[26];
char s[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n>>(s+1);
	for(int i=0;i<26;i++){
		tree[i].buildtree(1,1,n);
	}
	for(int i=1;i<=n;i++){
		tree[s[i]-'a'].modify(1,1,n,i,i,1);//+1
	}
	int m;
	cin>>m;
	int op,l,r;
	char ss;
	while(m--){
		cin>>op;
		if(op==2){
			cin>>l>>r;
			int ans=0;
			for(int i=0;i<26;i++){
				if(tree[i].querysum(1,1,n,l,r)) ++ans;
			}
			cout<<ans<<endl;
		}else{
			cin>>l>>ss;
			tree[s[l]-'a'].modify(1,1,n,l,l,-1);
			tree[ss-'a'].modify(1,1,n,l,l,1);
			s[l]=ss;
		}
	}
	return 0;
}


Measured memory_bytes: 487680
// https://atcoder.jp/contests/agc018/tasks/agc018_a
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

template <class T>
T calcgcd(T x, T y)
{
    if (x < y)
    {
        std::swap(x, y); //小さい方をyとする
    }
    T r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

int main()
{
    int N, K;
    cin >> N >> K;
    int maxval = -1;
    vector<int> A(N);
    REP(i, N) 
    {
        cin >> A[i];
        maxval = max(maxval, A[i]);
    }
    int c = A[0];
    for (int i = 1; i < N; ++i)
    {
        c = calcgcd(c, A[i]);
    }
    if (K <= maxval && K % c == 0)
    {
        cout << "POSSIBLE\n";
        return 0;
    }

    cout << "IMPOSSIBLE\n";
    
    return 0;
}

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

using namespace std;

using ll = long long;

int Solve() {
    int n, ma, mb;
    cin >> n >> ma >> mb;

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

    const int MAX_C = 100 * 1000, MAX_A = 500, MAX_B = 500;
    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(MAX_A,
                                   vector<int>(MAX_B, MAX_C)));
    dp[0][0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < MAX_A; ++j) {
            for (int k = 0; k < MAX_B; ++k) {
                if (MAX_C <= dp[i][j][k]) continue;

                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                if (j + a[i] < MAX_A && k + b[i] < MAX_B)
                    dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]],
                                                        dp[i][j][k] + c[i]);
            }
        }
    }

    int res = MAX_C;
    for (int i = 1; i < MAX_A; ++i) {
        for (int j = 1; j < MAX_B; ++j) {
            if (dp[n][i][j] < MAX_C && (i * mb == j * ma))
                res = min(res, dp[n][i][j]);
        }
    }

    return (res < MAX_C ? res : -1);
}

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

    cout << Solve() << endl;

    return 0;
}


Measured memory_bytes: 42112
//
//  main.cpp
//  ITP1_4-A
//
//  Created by Saicj on 2015/07/14.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
using namespace std;
#include <stdio.h>

int main()
{

    int a,b;
    
    cin >> a >> b;
    
//    if (b == 0){
//        b = 1;
//    }
    
    double f1 = a / b;
    double f2 = a % b;
    double f3 = 1.0 * a/b;
    
    printf("%.0lf ", f1);
    printf("%.0lf ", f2);
    printf("%.5lf\n",f3);
    
    
    return 0;
}

//int main() {
//    int a,b;
//    scanf("%d %d",&a, &b);
//    int d = a/b;
//    int r = a%b;
//    double f = double(a)/double(b);
//    
//    printf("%d %d %lf\n", d, r, f);
//    
//    return 0;
//}

Measured memory_bytes: 1192
#include <iostream>
#include <queue>
#include <utility>
using namespace std;


using PII = pair<int,int>;
int h, w;
char s[51][51];
int d[51][51];
queue<PII> Q;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void push(int i, int j, int v) {
  Q.push(make_pair(i, j));
  d[i][j] = v;
}

void BFS() {
  for (int i=1; i<=h; i++) for(int j=1; j<=w; j++) d[i][j] = -1;
  push(1, 1, 1);
  while (!Q.empty()) {
    PII v = Q.front(); Q.pop();
    if (v.first==h && v.second==w) break;
    for (int i=0; i<4; i++) {
      int x = v.first+dx[i]; int y = v.second+dy[i];
      if (1<=x&&x<=h && 1<=y&&y<=w && s[x][y]=='.' && d[x][y]==-1) {
        push(x, y, d[v.first][v.second]+1);
      }
    }
  }
}



int main() {
  cin >> h >> w;
  int count = 0;
  for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) {
    cin >> s[i][j];
    if (s[i][j] == '.') count++;
  }
  BFS();
  
  if (d[h][w] == -1) cout << -1 << endl;
  else cout << count - d[h][w] << endl;
  return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
int dp[10009];
signed main(){
	int n,m;
	cin>>n>>m;
	int num[10]={inf,2,5,5,4,5,6,3,7,6};
	int nm[10]={inf,inf,inf,inf,inf,inf,inf,inf,inf,inf};
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		nm[x]=num[x];
	}
	for(int i=0;i<=n;i++){
		dp[i] = -inf;
	}
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<10;j++){
			if(i-nm[j]>=0){
				dp[i] = max(dp[i],dp[i-nm[j]]+1);
			}
		}
	}
	int dig = dp[n];
	int cur = n;
	//for(int i=0;i<n;i++){cout<<i<<":"<<dp[i]<<endl;}
	for(int i=0;i<dig;i++){
		//cout<<i<<" "<<cur<<endl;
		int nex=0;
		for(int j=0;j<10;j++){
			if(cur >= nm[j] && ( dp[cur-nm[j]] + 1 == dp[cur] )){
				nex = max(nex,j);
			}
		}
		cout<<nex;
		cur -= nm[nex];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

string s, t;
int K;
int dp[305][305][305];
int dpmax[305][305];

int main(void)
{
	cin >> s >> K;
	int n = s.size();
	t = s;
	reverse(t.begin(), t.end());
	s = "#" + s, t = "#" + t;
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= K; k++){
				dp[i][j][k] = -1e9;
			}
		}
	}
	dp[0][0][0] = 0;
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k <= K; k++){
				if(i > 0 && j > 0){
					if(s[i] == t[j]) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k]+1);
					if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-1]+1);
				}
				if(i > 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
				if(j > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
			}
		}
	}
	
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			dpmax[i][j] = -1e9;
			for(int k = 0; k <= K; k++) dpmax[i][j] = max(dpmax[i][j], dp[i][j][k]);
		}
	}
	
	int ans = 0;
	for(int i = 0; i <= n; i++){
		ans = max(ans, dpmax[i][n-i]*2);
		if(i > 0) ans = max(ans, dpmax[i-1][n-i]*2 + 1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 110848
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

typedef pair<int,int> P;
const int MAX = 101;
const int H = 31;
const int INF = (1<<25);

struct State{
  int t,day,pos;
  State(){}
  State(int t, int day, int pos):t(t),day(day),pos(pos){}
  bool operator < (const State& s) const {return t > s.t;}
};

int T[H][MAX];
vector<int> Habit,V[MAX];
int N;

void init(){
  Habit.clear();
  for(int i = 0; i < MAX; i++) V[i].clear();
  fill(T[0],T[0]+H*MAX,INF);
}

void input(){
  Habit.resize(N);
  for(int i = 0; i < N; i++)
    cin >> Habit[i];

  int m;
  cin >> m;
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    V[a].push_back(b);
  }
 
  for(int i = 0; i < MAX; i++) sort(V[i].begin(),V[i].end());

}

void solve(){
  priority_queue<State> Q;
  Q.push(State(0,0,-1));
  T[0][0] = 0;

  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
    if(T[now.pos][now.day] < now.t) continue;
    if(now.day >= MAX-1) break;

    //use caffeine
    State nex = now;
    nex.day++;
    nex.pos = 0;
    nex.t++;
    if(V[nex.day].size() == 0){
      if(T[nex.pos][nex.day] > nex.t){
	T[nex.pos][nex.day] = nex.t;
	Q.push(nex);
      }
    }else if(V[nex.day][0] >= Habit[nex.pos] && T[nex.pos][nex.day] > nex.t){
      T[nex.pos][nex.day] = nex.t;
      Q.push(nex);
    }

    //do not use caffeine
    nex = now;
    nex.day++;
    nex.pos = (nex.pos+1)%Habit.size();
    if(V[nex.day].size() == 0){
      if(T[nex.pos][nex.day] > nex.t){
	T[nex.pos][nex.day] = nex.t;
	Q.push(nex);
      }
    }else if(V[nex.day][0] >= Habit[nex.pos] && T[nex.pos][nex.day] > nex.t){
      T[nex.pos][nex.day] = nex.t;
      Q.push(nex);
    }
  }

  int ans = INF;

  for(int i = 0; i < H; i++)
    ans = min(ans,T[i][MAX-1]);

  cout << ans << endl;
}


int main(){
  while(cin >> N && N){
    init();
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

const int mod=1000000007;

int *fact=NULL;
int *iFact=NULL;
void init(const int n){
  fact=(int *)calloc(n+1,sizeof(int));
  fact[0]=1;
  for(int i=1;i<=n;i++) fact[i]=(int64)i*fact[i-1]%mod;
  int t=1;
  int a=fact[n];
  while(a>1){
    t=(int64)t*(mod-mod/a)%mod;
    a=mod%a;
  }
  iFact=(int *)calloc(n+1,sizeof(int));
  iFact[n]=t;
  for(int i=n-1;i>=0;i--) iFact[i]=(int64)iFact[i+1]*(i+1)%mod;
}

int comb(int n,int k){
  if(!(0<=k && k<=n)) return 0;
  return (int64)fact[n]*iFact[k]%mod*iFact[n-k]%mod;
}

typedef struct point{
  int x,y;
  int way;
} point;

int calc(int k,point *p,int n){
  if(p[k].way>=0) return p[k].way;
  int local=comb(p[k].x+p[k].y-2,p[k].x-1);
  for(int i=0;i<n;i++){
    if(i==k) continue;
    if(p[i].x<=p[k].x && p[i].y<=p[k].y){
      int t=(int64)calc(i,p,n)*comb(p[k].x-p[i].x+p[k].y-p[i].y,p[k].x-p[i].x)%mod;
      local=(local+mod-t)%mod;
    }
  }
  p[k].way=local;
  return local;
}

void run(void){
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  init(h+w);
  point *p=(point *)calloc(n+1,sizeof(point));
  int i;
  for(i=0;i<n;i++){
    int r,c;
    scanf("%d%d",&r,&c);
    p[i]=(point){r,c,-1};
  }
  p[n]=(point){h,w,-1};
  int ans=calc(n,p,n+1);
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long now=10;
int main()
{
	long long n,sum;
	long long ans=0;
	cin>>n;
	if(n%2==0)
	{
		while(now<=n)
		{
			sum=n/now;
			ans+=sum;
			now*=5;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
const bool DEBUG = false;

signed main() {
	int a, b, h; cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
	return 0;
}

Measured memory_bytes: 384
def prime_factors(n):
    i = 2
    factors = []
    while i**2 <= n:
        if n % i != 0:
            i += 1
        else:
            factors.append(i)
            n = n // i
    if n > 1:
        factors.append(n)
    return factors

def resolve():
    N = int(input())
    factors = []
    for i in range(1, N+1):
        factors.extend(prime_factors(i))
    import collections
    cnter = collections.Counter(factors)
    
    n_over_74 = 0
    n_over_24 = 0
    n_over_14 = 0
    n_over_4 = 0
    n_over_2 = 0
    for k, cnt in cnter.items():
        if cnt >= 74:
            n_over_74 += 1
        if cnt >= 24:
            n_over_24 += 1
        if cnt >= 14:
            n_over_14 += 1
        if cnt >= 4:
            n_over_4 += 1
        if cnt >= 2:
            n_over_2 += 1
    
    ans = 0
    if n_over_74 >= 1:
        ans += n_over_74
    if n_over_4 >= 1 and n_over_14 >= 1:
        ans += n_over_14*(n_over_4-1)
    if n_over_24 >= 1 and n_over_2 >= 1:
        ans += n_over_24*(n_over_2-1)
    if n_over_4 >= 2 and n_over_2 >= 3:
        ans += int((n_over_4*(n_over_4-1)/2)*(n_over_2-2))
    print(ans)

    
        

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rs(a, b) ((a) >> (b))
#define ls(a, b) ((a) << (b))
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

int sum[300001];
int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    map<char, int> m;
    for (int i = 0; i < s.ln; i++)
        m[s[i]]++;
    if (m.sz == 2)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
#define INF 999999999
typedef  long long ll;
 
int main() {
	int n = 0, k = 0, ar[100000] = {};
	int count = 0,f = 1;
	std::cin >> n >> k;
	for (int i = 0; i < n; i++) {
		std::cin >> ar[i];
	}
	while (f<n) {	
		count++;
		f += k-1;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int L = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    int last = -1;
    for (int i = 0; i < N - 1; i++) {
      if (a[i] + a[i + 1] >= L) last = i;
    }
    if (last < 0) {
      System.out.println("Impossible");
      return;
    }
    System.out.println("Possible");
    for (int i = 0; i < last; i++) System.out.println(i + 1);
    for (int i = N - 2; i > last; i--) System.out.println(i + 1);
    System.out.println(last + 1);
  }
}


Measured memory_bytes: 69392
#include <bits/stdc++.h>
using namespace std;
 
typedef struct s {
    int Key;
    s *Parent;
    s *Left;
    s *Right;
} Node;
 
Node *root,*NIL;
 
void insert(int Key){
    Node *x = root;//?§????????????¢?????¬???
    Node *y = NIL;//??¢?????¬???????????????????????¨????????????NIL??§?????????
    Node *z;//??¬???
     
    z = (Node *)malloc(sizeof(Node));
    z -> Key = Key;
    z -> Left = NIL;
    z -> Right = NIL;
     
    //x???NIL????????????
    while (x != NIL) {
        y = x;
        if (z -> Key < x -> Key) {
            x = x -> Left;
        }else{
            x = x -> Right;
        }
    }
     
    z -> Parent = y;
    //root??????NIL??????????????£?????´???
    //
    if (y == NIL) {
        root = z;
    }else{
        if (z -> Key < y -> Key) {
            y -> Left = z;
        }else{
            y -> Right = z;
        }
    }
}
 
void inoder(Node *n){
    if (n == NIL) return;
    inoder(n -> Left);
    cout << " " << n -> Key;
    inoder(n -> Right);
}
 
void preoder(Node *n){
    if (n == NIL) return;
    cout << " " << n -> Key;
    preoder(n -> Left);
    preoder(n -> Right);
}
 
int main(){
    root = NIL;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string com;
        cin >> com;
        if (com == "insert") {
            int num;
            scanf("%d",&num);
            insert(num);
        }else{
            inoder(root);
            cout << endl;
            preoder(root);
            cout << endl;
        }
    }
    return 0;
}


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

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

  if (c < a) {
    cout << "No"<<endl;
  }
  else if (c > b) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e6 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 123456789;
const int maxx = 1005;
ll q, t, n, m, T, k, ans, a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, str, sa, sb;

char ss[maxx][maxx];

struct dang
{
    ll val, sl;
};
dang st[maxn];
bool lt(const dang &x, const dang &y)
{
    return x.val < y.val;
}
ll ns, nsa, nsb;
void test()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)
    {
        cin >> m;
        for(int j = 1; j <= m; j ++)
        {
            cin >> t;
            ++a[t];
        }
    }
    ans = n;
    for(int i = 1; i <= n; i ++)
    {
        if(a[i] > 0)--ans;
    }
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    test();
}



Measured memory_bytes: 3680
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
vector<vector<int> > g;
int res = 0;
bool DFS(int u, int p) {
	int ret = 0;
	int cnt = 0;
	for (int i = 0; i<g[u].size(); ++i)
		if (g[u][i] != p) {
			ret += DFS(g[u][i], u);
			++cnt;
		}
	res += max(0, cnt - 1 - ret);
	return ret || cnt - 1>0;
}
int main()
{
	scanf("%d", &n);
	res = 0;
	g.clear();
	g.resize(n);
	for (int i = 1, a, b; i < n; ++i) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bool ok = false;
	for (int i = 0; i < n; ++i)
		if (g[i].size() > 2) {
			if (!DFS(i, -1))
				++res;
			ok = true;
			break;
		}
	if (!ok)
		res = 1;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 9088
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void) {
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
def solve():
    N,X = map(int, input().split())
    r = [abs(X-i) for i in map(int, input().split())]
    ans = r.pop()
    for i in r:
        while ans%i != 0:
            ans,i = i,ans%i
        ans = i
    return ans

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

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

const int MAXN = 11;
const int MAXM = 11;

int N, M;
string P[MAXN], Q[MAXM];

bool isValid(int r, int c, int s) {
  int nr, nc, ns;
  nr = nc = ns = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j <= P[i].size(); ++j) {
      if(j == P[i].size() || P[i][j] != '.') {
        if(r*nr + c*nc + s*ns != j) return false;
        break;
      }
    }
    for(int j = 0; j < P[i].size(); ++j) {
      if(P[i][j] == '(') ++nr;
      if(P[i][j] == ')') --nr;
      if(P[i][j] == '{') ++nc;
      if(P[i][j] == '}') --nc;
      if(P[i][j] == '[') ++ns;
      if(P[i][j] == ']') --ns;
    }
  }
}

int main() {
  while(cin >> N >> M && (N|M)) {
    cin.ignore();
    for(int i = 0; i < N; ++i) {
      getline(cin, P[i]);
    }
    for(int i = 0; i < M; ++i) {
      getline(cin, Q[i]);
    }

    vector<vector<int> > v;
    for(int r = 1; r <= 20; ++r) {
      for(int c = 1; c <= 20; ++c) {
        for(int s = 1; s <= 20; ++s) {
          if(isValid(r,c,s)) {
            vector<int> u(3);
            u[0]=r; u[1]=c; u[2]=s;
            v.push_back(u);
          }
        }
      }
    }

    int nr, nc, ns;
    nr = nc = ns = 0;
    for(int i = 0; i < M; ++i) {
      set<int> s;
      for(int j = 0; j < v.size(); ++j) {
        s.insert(v[j][0]*nr + v[j][1]*nc + v[j][2]*ns);
      }
      if(i) cout << " ";
      if(s.size() == 1) {
        cout << *s.begin();
      } else {
        cout << -1;
      }
      for(int j = 0; j < Q[i].size(); ++j) {
        if(Q[i][j] == '(') ++nr;
        if(Q[i][j] == ')') --nr;
        if(Q[i][j] == '{') ++nc;
        if(Q[i][j] == '}') --nc;
        if(Q[i][j] == '[') ++ns;
        if(Q[i][j] == ']') --ns;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1628
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
string S, T;
int main(){
	cin >> N;
	cin >> S >> T;
	rep(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    long long dp[n+1][4][4][4]={};
    int A=0,T=1,G=2,C=3;
    dp[0][3][3][3]=1;
    long long mod=1e9+7;
    for(int i=0;i<n;i++)
    for(int c1=0;c1<4;c1++)for(int c2=0;c2<4;c2++)for(int c3=0;c3<4;c3++){
        for(int k=0;k<4;k++){
            if(c2==A && c3==G && k==C) continue;
            if(c2==A && c3==C && k==G) continue;
            if(c2==G && c3==A && k==C) continue;
            if(c1==A && c3==G && k==C) continue;
            if(c1==A && c2==G && k==C) continue;
            dp[i+1][c2][c3][k]+=dp[i][c1][c2][c3];
            dp[i+1][c2][c3][k]%=mod;
        }
    }

    long long ans=0;
    for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++){
        ans+=dp[n][i][j][k];
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())

n,k = map(int, stdin.readline().rstrip().split())
A = list(map(int, stdin.readline().rstrip().split()))

if n == k:
    print(1)
elif (n-k)%(k-1) == 0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1) + 1)


Measured memory_bytes: 13880
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n){
    if(a[i]&1&&i%2==0)res++;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    string S;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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, ll> 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);
	int n;
	cin >> n;
	rep(i,n){
		int a;
		cin >> a;
		if(a%2 == 1){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B;

    cin>>A>>B;

    if(A>=13){
        cout<<B<<endl;
    }
    else if(A<=5){
        cout<<"0"<<endl;
    }
    else{
        cout<<B/2<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
 
int main() {
  int N;
  while(cin >>N && N){
    REP(i, N){
      int m, e, j; cin >>m >>e >>j;
      if(m == 100 || e == 100 || j == 100) cout <<"A" <<endl;
      else if(((double)m + e) / 2.0 >= 90) cout <<"A" <<endl;
      else if(((double)m + e + j) / 3.0 >= 80) cout <<"A" <<endl;
      else if(((double)m + e + j) / 3.0 >= 70) cout <<"B" <<endl;
      else if(((double)m + e + j) / 3.0 >= 50 && (m >= 80 || e >= 80)) cout <<"B" <<endl;
      else cout <<"C" <<endl;
    }
  }
  return 0;
}

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

using namespace std;

int main(){
	while(1){
		int m,a,b;
		cin >> m >> a >> b;
		if(m == 0) break;
		
		vector<int> prime;
		
		for(int i = 2;i < m;i++){
			bool isprime = true;
			for(int j = 2;j<i;j++){
				if(j*j > i) break;
				if(i % j == 0){
					isprime = false;
					break;
				}
			}
			if(isprime) prime.push_back(i);
		}
		
		int s = 0;
		int p,q;
		for(int i = 0;i < prime.size();i++){
			for(int j = 0;j <= i && prime[i]*prime[j] <= m;j++){
				int size = prime[i]*prime[j];
				if(size > s && (prime[j]*1.0)/prime[i] >= (a*1.0)/b){
					s = size;
					p = prime[j];
					q = prime[i];
				}
			}
		}
		
		cout << p << " " << q << endl;
	}
	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
                     
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
const ll mod = 1e9+7;
ll mult(ll a,ll b){return ((a%mod)*(b%mod))%mod;}

ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
ll sub(ll a,ll b){return ((a%mod)-(b%mod)+mod)%mod;} 
ll dp[3003][3003];
int solve(){
    ll n;string s;
    cin>>n;cin>>s;

    // memset(dp, -1, sizeof(dp));
    
    // cout<<"doje";
    for(int i=0;i<=n-1;++i){
        dp[0][i] = 1;
    }
    for(int pos=1;pos<n;++pos){
        if(s[pos-1]=='<'){
            ll ans = 0;
            for(int badacount=n-1; badacount >= 0; --badacount){
                ans =  add(ans, dp[pos-1][badacount+1]);
                // cout<<pos-1<<" "<<badacount+1<<" = "<<dp[pos-1][badacount+1]<<endl;
                dp[pos][badacount] = ans;
            }
        }
        else{
            ll ans = 0;
            for (int badacount = 0; badacount <= n - 1 && n - pos - badacount > 0; ++badacount){
                ans = add(ans, dp[pos - 1][badacount]);
                dp[pos][badacount] = ans;
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<n;++i){
        ans = add(ans, dp[n-1][i]);
    }
    cout<<ans;
    return 0;
}
int main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);


// AGC011A - Airport Bus
int main(){
  int N, C, K; // 1 <= N <= 1e5, 1 <= C,K <= 1e9
  // 飛行機でくる乗客数N人
  // バスの定員C人
  // Ti + K = 許容時間
  cin >> N >> C >> K;
  map<int64_t, int> T;// 1 <= Ti <= 1e9
  {
    int64_t ti;
    for (int i = 1; i <= N; ++i) {
      cin >> ti;
      T[ti]++;
    }
  }
  int num = 0;

  int baset = 0; // base time
  int wp = 0; // wait person num
  for (const auto& p: T) {
    if (baset == 0) {
      baset = p.first;
    }
    if (wp > 0 && baset + K < p.first) {
      // 時間切れなので、待機している人を全員バスに乗せたことにする
      num += (wp % C == 0) ? (wp / C) : (wp / C + 1);
      wp = 0;
      baset = p.first;
    }
    wp += p.second;
    if (wp >= C || ((wp > 0) && baset + K == p.first)) {
      num += wp / C;
      wp = wp % C;
      if (wp == 0) {
        baset = 0;
      }
    }
    //cout << "N:" << N << ",C:" << C << ",K:" << K << ",num:" << num << ",wp:" << wp << ",baset:" << baset << endl;
  }
  if (wp > 0) {
    num += (wp % C == 0) ? (wp / C) : (wp / C + 1);
    //cout << "extra N:" << N << ",C:" << C << ",K:" << K << ",num:" << num << ",wp:" << wp << ",baset:" << baset << endl;
  }

  cout << num << endl;
  return 0;
}



Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int k,x;
	cin>>k>>x;
	k--;
	for(int i=x-k;i<=x+k;i++){
		cout<<i<<' ';
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    string s;
    cin>>n>>s;
    int a=1;
    rep(i,n-1)a+=s[i]!=s[i+1];
    cout<<a<<endl;
}

Measured memory_bytes: 512
if (__name__ == '__main__'):
    n = int(input())
    
    a = [0]
    b = [0]
    c = [0]

    aa = input().strip().split()
    for i in range(n):
        a.append(int(aa[i]))
    bb = input().strip().split()
    for i in range(n):
        b.append(int(bb[i]))
    cc = input().strip().split()
    for i in range(n-1):
        c.append(int(cc[i]))

    sum = b[a[1]]
    lastmenu = a[1]

    for i in range(2, n+1):
        sum = sum + b[a[i]]
        if (a[i] == lastmenu+1):
            sum = sum + c[lastmenu]
        lastmenu = a[i]

    print(sum)


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

int main ()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    int n, data;
    string command;
    list<int> mylist;
    list<int>::iterator it;
    
    cin >> n;
    while(n--)
    {
        cin >> command;
        if (command == "insert")
        {
            cin >> data;
            mylist.push_front(data);
        }
        else if (command == "delete")
        {
            cin >> data;
            for (it = mylist.begin();it != mylist.end();it++)
            {
                if (*it == data)
                {
                    mylist.erase(it);
                    break;
                }
            }
        }
        else if (command == "deleteFirst")
        {
            mylist.pop_front();
        }
        else if (command == "deleteLast")
        {
            mylist.pop_back();
        }
    }
    
    for (it = mylist.begin();it != mylist.end();it++)
    {
    	if (it != mylist.begin()) cout << " ";
        cout << *it;
    }
    cout << "\n";
    
    return 0;
}



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

using namespace std;
int main()
{
    int n;
    cin>>n;
    double sm=0;
    for(int i=0;i<n;i++){
        double t;
        cin>>t;
        sm+=(1.0/t);
    }
    cout<<1.0/sm<<endl;
    return 0;
}


Measured memory_bytes: 256
# encoding: "utf-8"

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def main():
    s = input()
    r = "".join([c for (i,c) in enumerate(s) if i % 2 == 0])
    print(r)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3572
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include <array>
#include <chrono>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
// VAR(int, x);
#define VAR(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { std::cin >> first; Scan(rest...); }
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
#define PAIR std::pair<int, int>
#define IN(a, x, b) (a<=x && x<=b)
#define IN2(a0, y, a1, b0, x, b1) (a0<=y && y<a1 && b0<=x && x<b1)
#define SHOW(d) {std::cout << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cout << #v << "\t:";for(const auto& i : v){std::cout << i << " ";}std::cout << "\n";}
#define SHOWVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout << j << " ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR2(v) {std::cout << #v << "\t:\n";for(const auto& i : v){for(const auto& j : i){std::cout<<'('<<j.first<<", "<<j.second<<") ";}std::cout << "\n";}}
#define SHOWPAIRVECTOR(v) {for(const auto& i:v){std::cout<<'('<<i.first<<", "<<i.second<<") ";}std::cout<<"\n";}
#define CHECKTIME(state) {auto start=std::chrono::system_clock::now();state();auto end=std::chrono::system_clock::now();auto res=std::chrono::duration_cast<std::chrono::nanoseconds>(end-start).count();std::cerr<<"[Time:"<<res<<"ns  ("<<res/(1.0e9)<<"s)]\n";}

//#define int ll
using ll = long long;
constexpr int INFINT = 1 << 30;
constexpr ll INFLL = 1LL << 60;
constexpr double EPS = 0.0000001;
constexpr int MOD = 1000000007;

int checkNum(int n) {
	int res = 0;
	while (n != 0) {
		res |= (1 << (n % 10));
		n /= 10;
	}
	return res;
}

signed main() {
	INIT;
	VAR(int, n, k);
	int ng = 0;
	REP(i, k) {
		VAR(int, d);
		ng |= (1 << d);
	}
	FOR(i, n, 100000) {
		if ((checkNum(i)&ng) == 0) {
			OUT(i)BR;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int c=1e5+5;
const ll mod=1e9+7,M=998244353;
vector<ll>sold;
vector<ll>enem;
int n,k;
ll ans=1e18;
ll arr[c];
ll dp[c];
ll solve (int i)
{
    if(i==n-1)
    {
        return 0;

    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    ans=abs(arr[i]-arr[i+1])+solve(i+1);
    for(int j=2;j<=k;j++){
    if(i<n-j){
     ans=min(ans,abs(arr[i]-arr[i+j])+solve(i+j));

    }
}
return dp[i]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    memset(dp,-1,sizeof dp);

    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
#define mod 1000000007;

int main(){
  int n, m;
  cin >> n >> m;
  long long height = 0;
  long long width = 0;
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    height += -(n-i-1) * k + i * k;
    height %= mod;
  }
  for (int i = 0; i < m; i++) {
    long long k;
    cin >> k;
    width += -(m-i-1) * k + i * k;
    width %= mod;
  }
  long long ans = height * width;
  ans %= mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256