akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;

	auto numWhite = 0;
	vector<string> s(H);
	for (auto i = 0; i < H; ++i)
	{
		cin >> s[i];
		for (auto j = 0; j < W; ++j)
		{
			if (s[i][j] == '.')
			{
				++numWhite;
			}
		}
	}

	vector<vector<bool>> used(H, vector<bool>(W));
	queue<pair<int, int>> q;
	q.push({ 0, 1 });
	used[0][0] = true;
	int offset[4][2] = { {0, 1}, {1, 0}, {0, -1}, {-1, 0} };
	auto minNum = -1;
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();

		auto x = p.first % W;
		auto y = p.first / W;
		auto num = p.second;
		for (auto i = 0; i < 4; ++i)
		{
			auto nx = x + offset[i][0];
			auto ny = y + offset[i][1];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H)
			{
				continue;
			}
			if (s[ny][nx] != '.')
			{
				continue;
			}
			if (used[ny][nx])
			{
				continue;
			}
			used[ny][nx] = true;
			q.push({ ny * W + nx, num + 1 });
			if (nx == W - 1 && ny == H - 1)
			{
				minNum = num + 1;
			}
		}
	}

	if (minNum < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << numWhite - minNum << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a+b+c >= 22){
    printf("bust");
  }
  else if(a+b+c <= 21){
    printf("win");
  }
  return 0;
}

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

#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<(a); i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pow2(x) (1ll<<(x))

using namespace std;

const int Mod=1e9+7;

ll ans(ll x, ll y, ll n){
	if((x-y)%2==0) return abs((x-y)/2);
	if(x>y) swap(x,y);
	ll ans1,ans2;
	ans1=x+ans(1,y-x,n);
	ans2=n-y+1+ans(n+x-y+1,n,n);
	return min(ans1,ans2);
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	ll a,b,n;
	cin >> n >> a >> b;
	cout << ans(a,b,n) << "\n";
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    Graph G(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v; cin >> v;
            G[u].push_back(v);
        }
    }

    vector<int> dist(n + 1, -1);
    queue<int> que;

    dist[1] = 0;
    que.push(1);

    while (!que.empty())
    {
        int v = que.front();
        que.pop();

        for(int nv : G[v]){
            if(dist[nv] != -1) continue;

            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    
    for (int i = 1; i <= n; i++)
    {
        cout << i << " " << dist[i] << endl;
    }
    
}


Measured memory_bytes: 3168
a,b,k=map(int,(input().split()))
s=[]
for i in range(k):
    if(a+i<=b):
        s.append(a+i)
for i in range(k):
    if(b-(k-i)+1>=a):
        s.append(b-(k-i)+1)
ans=set(s)
tmp=sorted(ans)
for i in tmp:
    print(i)

Measured memory_bytes: 3064
def resolve():

    S = input()
    ans = 0
    ACGT = {"A", "C", "G", "T",}

    for i in range(len(S)):
        ss = S[i:]
        cnt = 0
        for s in ss:
            if s in ACGT:
                cnt += 1
            else:
                break
        ans = max(ans, cnt)
    return print(ans)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x){
    //topを加算してからその位置へ挿入
    S[++top] = x; //前置増分演算子であるから、増分した「後」の値が手に入る
}

int pop(){
    top--;//topをデクリメント
    //topが元々指していた要素を返す
    return S[top+1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[100];
    for (int i=0; i < n; i++){
        cin >> a[i];
    }
    for(int i=n-1; i>=0; i-- ){
        if(i == 0 ) cout << a[0];
        else cout << a[i] <<" ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
const int maxn=1100;
char c3[10][10]=
{
	{'a','a','.'},
	{'.','.','a'},
	{'.','.','a'}
};
char c4[10][10]=
{
	{'a','a','b','c'},
	{'d','d','b','c'},
	{'b','c','a','a'},
	{'b','c','d','d'}
};
char c5[10][10]=
{
	{'a','a','b','b','a'},
	{'b','c','c','.','a'},
	{'b','.','.','c','b'},
	{'a','.','.','c','b'},
	{'a','b','b','a','a'}
};
char c6[10][10]=
{
	{'a','a','b','c','.','.'},
	{'d','d','b','c','.','.'},
	{'.','.','a','a','b','c'},
	{'.','.','d','d','b','c'},
	{'b','c','.','.','a','a'},
	{'b','c','.','.','d','d'}
};
char c7[10][10]=
{
	{'a','a','b','b','c','c','.'},
	{'d','d','.','d','d','.','a'},
	{'.','.','d','.','.','d','a'},
	{'.','.','d','.','.','d','b'},
	{'d','d','.','d','d','.','b'},
	{'.','.','d','.','.','d','c'},
	{'.','.','d','.','.','d','c'}
};
char mp[maxn][maxn];
int n;
void tag(char c[][10],int a,int b,int d)
{
	for(int i=0;i<d;i++)
	{
		for(int j=0;j<d;j++)
		{
			mp[a+i][b+j]=c[i][j];
		}
	}
	return;
}
void taga(char c[][10],int x,int d)
{
	for(int i=x;i<n;i+=d) tag(c,i,i,d);
	return;
}
int main()
{
	memset(mp,'.',sizeof(mp));
	scanf("%d",&n);
	if(n==2) printf("-1\n");
	else
	{
		if(n==3) tag(c3,0,0,3);
		else 
		{
			if(n%4==0) taga(c4,0,4);
			else if(n%4==1) tag(c5,0,0,5),taga(c4,5,4);
			else if(n%4==2) tag(c6,0,0,6),taga(c4,6,4);
			else  tag(c7,0,0,7),taga(c4,7,4);
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++) printf("%c",mp[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    Vector v;
    cin >> n;
    int a;
    
    if(n % 2){
        //数が奇数
        rep(i, n){
            cin >> a;
            if(i % 2){
                v.push_back(a);
            }else{
                v.insert(v.begin(), a);
            }
        }
    }else{
        //数が偶数
        rep(i, n){
            cin >> a;
            if(i % 2){
                v.insert(v.begin(), a);
            }else{
                v.push_back(a);
            }
        }
    }
    
    rep(i, v.size()){
        if(i){
            cout << " " << v[i];
        }else{
            cout << v[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3060
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { n:usize, a:usize, b:usize, c:usize, d:usize, }
    let c1 = ((n + a - 1) / a) * b;
    let c2 = ((n + c - 1) / c) * d;
    println!("{}", std::cmp::min(c1, c2));
}



Measured memory_bytes: 5036
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vll           vector<ll> 
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int x,n; cin>>x>>n;
  int w;
  vector<bool> u(102,0);
  rep(i,0,n)
    cin>>w,u[w]=1;
  w=x;
  while (w>=0&&u[w]) w--;
  int ans=w;
  w=x;
  while (w<=101&&u[w]) w++;
  if (abs(x-ans)>abs(x-w))
    ans=w;
  cout<<ans<<'\n';
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int cnt[101];

int main() {
  int v;
  while (cin >> v) {
    cnt[v]++;
  }
  int maxv = 0;
  for (int i = 1; i <= 100; i++) {
    maxv = max(maxv, cnt[i]);
  }
  for (int i = 1; i <= 100; i++) {
    if (cnt[i] == maxv) {
      cout << i << "\n";
    }
  }
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  ll sum = accumulate(a.begin(),a.end(),0);
  if(sum%10!=0){cout<<sum<<endl;return;}
  sort(a.begin(),a.end());
  rep(i,n){
    if((sum-a[i])%10!=0){
      cout<<sum-a[i]<<endl;
      return;
    }
  }
  cout<<0<<endl;

}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,a,b,c;cin>>n>>a>>b>>c;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin>>s[i];
  vector<char> ans(n);
  int f=0;
  int ppa,ppb,ppc,pa=a,pb=b,pc=c;
  for(int i=0;i<n;i++){
    ppa=pa,ppb=pb,ppc=pc;
    pa=a,pb=b,pc=c;
    //cout<<i<<" "<<ppa<<" "<<ppb<<" "<<ppc<<" "<<pa<<" "<<pb<<" "<<pc<<" "<<a<<" "<<b<<" "<<c<<endl;
    if(s[i]=="AB"){
      if((a>b)^(f==2))a--,b++,ans[i]='B';
      else a++,b--,ans[i]='A';
    }
    if(s[i]=="BC"){
      if((b<c)^(f==2))b++,c--,ans[i]='B';
      else b--,c++,ans[i]='C';
    }
    if(s[i]=="AC"){
      if((a<c)^(f==2))a++,c--,ans[i]='A';
      else a--,c++,ans[i]='C';
    }
    if(min({a,b,c})<0){
      if(f||!i)fin("No");
      f=2;i-=2;a=ppa;b=ppb,c=ppc;
    }
    else f/=2;
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
}


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

const int mxN = 1e5 + 5;
vector<int> adj[mxN], tree[mxN];
vector<ll> pref[mxN], suf[mxN];
ll up[mxN], down[mxN];
int parent[mxN], N, M;

void dfs(int node, int par) {
	parent[node] = par;
	for (auto it : adj[node]) {
		int next = it;
		if (next != par) {
			tree[node].push_back(next);
			dfs(next, node);
		}
	}
	return;
}

void solve_down(int node) {
	int size = tree[node].size();
	pref[node].resize(size);
	suf[node].resize(size);
	down[node] = 1;
	for (auto it : tree[node]) {
		int next = it;
		solve_down(it);
		down[node] = (down[node] * (1 + down[next])) % M;
	}
	for (int i = 0; i < size; i++) {
		int child = tree[node][i];
		pref[node][i] = 1 + down[child];
		if (i >= 1) {
			pref[node][i] = (pref[node][i] * pref[node][i - 1]) % M;
		}
	}
	for (int i = size - 1; i >= 0; i--) {
		int child = tree[node][i];
		suf[node][i] = 1 + down[child];
		if (i < size - 1) {
			suf[node][i] = (suf[node][i] * suf[node][i + 1]) % M;
		}
	}
	return;
}

void solve_up(int node) {
	if (node == 1) {
		up[node] = 1;
	}
	int size = tree[node].size();
	for (int i = 0; i < size; i++) {
		int par = tree[node][i];
		up[par] = up[node];
		if (i > 0) {
			up[par] = (up[par] * pref[node][i - 1]) % M;
		}
		if (i < size - 1) {
			up[par] = (up[par] * suf[node][i + 1]) % M;
		}
		up[par]++;
		up[par] = up[par] % M;
		solve_up(par);
	}
	return;
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> N >> M;
	int x, y;
	for (int i = 0; i < N - 1; i++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(1, 0);
	solve_down(1);
	solve_up(1);
	for (int i = 1; i <= N; i++) {
		ll answer = (up[i] * down[i]) % M;
		cout << answer << '\n';
	}

	return 0;
}

Measured memory_bytes: 33200
import copy

n = int(input())

judge = []
ans3 = 3
ans5 = 5
ans7 = 7
ans35 = []
ans37 = []
ans57 = []
ans357 = []

for i in range(8):
  key = []
  for v in ans357:
    key.append(v*10+3)
    key.append(v*10+5)
    key.append(v*10+7)
  for v in ans35:
    key.append(v*10+7)
  for v in ans37:
    key.append(v*10+5)
  for v in ans57:
    key.append(v*10+3)
  ans357 = copy.deepcopy(key)
  
  key = [ans3*10+5, ans5*10+3]
  for v in ans35:
    key.append(v*10+3)
    key.append(v*10+5)
  ans35 = copy.deepcopy(key)
    
  key = [ans3*10+7, ans7*10+3]
  for v in ans37:
    key.append(v*10+3)
    key.append(v*10+7)
  ans37 = copy.deepcopy(key)
  
  key = [ans5*10+7, ans7*10+5]
  for v in ans57:
    key.append(v*10+5)
    key.append(v*10+7)
  ans57 = copy.deepcopy(key)
  
  ans3 = ans3*10+3
  ans5 = ans5*10+5
  ans7 = ans7*10+7
  
  judge = judge+ans357
ans = 0
for v in judge:
  if v <= n:
    ans += 1
print(ans)

Measured memory_bytes: 10624
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans=LINF;
signed main(){
	vector<int> v;
	cin>>n>>m;
	
	if(m-n+1>=2019){
		v.push_back(0);
		v.push_back(1);
	}
	else if(n%2019<m%2019){
		for(int i=n%2019;i<=m%2019;i++){
			v.push_back(i);
		}
	}
	else if(n%2019==m%2019){
		v.push_back(0);
		v.push_back(1);
	}
	else{
		for(int i=n%2019;i<2019;i++){
			v.push_back(i);
		}
		for(int i=0;i<=m%2019;i++){
			v.push_back(i);
		}
	}
	rep(i,v.size()){
		rep(j,v.size()){
			if(i==j)continue;
			ans=min(ans,(v[i]*v[j])%2019);
		}
	}
	cout<<ans<<endl;
}


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

vector<ll> enumDivisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i<=n;++i){
        if(n%i!=0)continue;
        res.push_back(i);
        if(i*i!=n)res.push_back(n/i);
    }
    return res;
}

int main(void){
    ll n;
    cin>>n;
    int ans=0;
    for(ll x:enumDivisor(n)){
        if(x==1)continue;
        ll tmp=n;
        while(tmp%x==0)tmp/=x;
        tmp%=x;
        if(tmp==1)++ans;
    }
    ans+=enumDivisor(n-1).size()-1;
    cout<<ans<<endl;    
    return 0;
}


Measured memory_bytes: 384
#pragma warning (disable : 4996)
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <utility>
using namespace std;
#define omajinai ios::sync_with_stdio(false);cin.tie(nullptr);

#pragma region typedef 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> P;
#pragma endregion

#pragma region define
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#pragma endregion

#pragma region const
const ld PI = 3.141592653589793;
const ll INF18 = 1e18;
#pragma endregion

#pragma region function
template<class T>inline bool chmin(T& a,T b){
    if(a>b){a=b;return true;}return false;}
template<class T>inline bool chmax(T& a,T b){
    if(a<b){a=b;return true;}return false;}
#pragma endregion



int main() {
omajinai;

  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int dx[] = { 1,-1,0,0 };
const int dy[] = { 0,0,-1,1 };
const int maxn = 510;
int G[maxn][maxn];

int main()
{
#ifdef FOO_
    freopen("foo", "rt", stdin);
#endif
    int h,w;
    while (cin >> h >> w) {
        FOR(i,1,h+1) FOR(j,1,w+1)
            cin >> G[i][j];
        typedef tuple<int,int,int,int> Move;
        vector<Move> ans;
        FOR(i,1,h+1) FOR(j,1,w+1) if (G[i][j]&1) {
            FOR(d,0,4) {
                const int x = i+dx[d];
                const int y = j+dy[d];
                if (0 < x && x <= h && 0 < y && y <= w) {
                    if ((G[x][y]&1) || d == 0 || d == 3) {
                        G[x][y]++, G[i][j]--;
                        ans.push_back(Move(i,j,x,y));
                        break;
                    }
                }
            }
        }
        const int n = ans.size();
        printf("%d\n",n);
        FOR(i,0,n) {
            int a,b,c,d;
            tie(a,b,c,d) = ans[i];
            printf("%d %d %d %d\n",a,b,c,d);
        }
    }
    return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

const int MAX_N = 16;
const int INF = 100000000;

int g[MAX_N][MAX_N];
int dp[1 << MAX_N][MAX_N];
int n;

int tsp(int visited, int v) {
  int& res = dp[visited][v];
  if (res != -1) return res;

  if (visited == (1 << n) - 1 && v == 0) return 0;

  res = INF;

  rep(u, n) {
    if (visited & (1 << u)) continue;
    res = min(res,
      tsp(visited | (1 << u), u) + g[v][u]);
  }
  return res;
}

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

  rep(i, n) rep(j, n) g[i][j] = INF;
  rep(i, 1 << n) rep(j, n) dp[i][j] = -1;

  rep(i, m) {
    int s, t, d;
    cin >> s >> t >> d;

    g[s][t] = d;
  }

  int ans = tsp(0, 0);
  if (ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}

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

int main() {
    long n, k, ans;
    cin >> n >> k;
    vector<pair<int, int>> number(n);
    rep(i, n) {
        cin >> number.at(i).first >> number.at(i).second;
    }
    sort(number.begin(), number.end());
    for(pair<int, int> p : number) {
        k -= p.second;
        if(k <= 0) {
            ans = p.first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct values
{
	int a,b,c;
};
int solve(vector<values>v,int n)
{
	int dp[n+1][3];
	dp[1][0] = v[1].a;
	dp[1][1] = v[1].b;
	dp[1][2] = v[1].c;

	for(int i=2;i<=n;i++)
	{
		dp[i][0] = v[i].a + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = v[i].b + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = v[i].c + max(dp[i-1][0],dp[i-1][1]);
	}

	return max(dp[n][0],max(dp[n][1],dp[n][2]));

}
int main()
{
	int n;
	cin>>n;
	vector<values>v(n+1);
	for(int i=1;i<=n;i++)
	{
		cin>>v[i].a>>v[i].b>>v[i].c;
	}
	cout<<solve(v,n);
}

Measured memory_bytes: 6688
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin >> N >> M;
    if(N==M)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, K;

int main(){
  scanf("%d%d", &N, &K);
  int a, b, dis;
  rep(i, K){
    scanf("%d%d", &a, &b); a--; b--;
    if(a > b && a + b >= N) dis = N-1-a;
    else if(a > b && a + b < N) dis = b;
    else if(a <= b && a + b >= N) dis = N-1-b;
    else dis = a;
    printf("%d\n", (dis%3) + 1);
  }
  return 0;
}

Measured memory_bytes: 1188
package main

import (
	"fmt"
	"math"
	"sort"
)

type Array []int64

func (a Array) Len() int {
	return len(a)
}

func (a Array) Less(i, j int) bool {
	return a[i] < a[j]
}

func (a Array) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func main() {

	var (
		x int
		y int
		z int
		k int
	)

	fmt.Scan(&x, &y, &z, &k)

	a := make([]int64, x)
	b := make([]int64, y)
	c := make([]int64, z)

	for i := 0; i < x; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < y; i++ {
		fmt.Scan(&b[i])
	}
	for i := 0; i < z; i++ {
		fmt.Scan(&c[i])
	}

	ab := make(Array, x*y)

	for i := 0; i < x; i++ {
		for j := 0; j < y; j++ {
			ab = append(ab, a[i]+b[j])
		}
	}
	sort.Sort(sort.Reverse(ab))

	var abc Array
	for i := 0; i < int(math.Min(float64(3000), float64(len(ab)))); i++ {
		for j := 0; j < z; j++ {
			abc = append(abc, ab[i]+c[j])
		}
	}

	sort.Sort(sort.Reverse(abc))

	for i := 0; i < k; i++ {
		fmt.Println(abc[i])
	}
}


Measured memory_bytes: 127360
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define N 66666
#define M 1000000007
using namespace std;
typedef long long LL;

LL a[N];
int c = 0, b[N];

int main()
{		
	int n, k, t, i, j, jj;
	
	scanf("%d%d", &n, &k);
	t = sqrt(n);
	for(i = 1; i < t; i++){
		b[c++] = 1;
	}
	for(; i <= n; i = j){
		j = n / (n / i) + 1;
		b[c++] = j - i;
	}
	for(i = 0; i < c; i++) a[i] = 1;
	for(i = 1; i <= k; i++){
		for(j = 1, jj = 0; j < c; jj = j++){
			a[j] = (a[jj] + a[j] * (LL)b[j]) % M;
		}
		reverse(a, a + c);
	}
	printf("%lld\n", a[0]);
			
	return 0;
}

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

typedef long long ll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vector<int> a(n + 1, 0), b(n + 1, 0);
    F0R(i, n) {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    F0R(i, n) {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }
    int ans = 0;
    FOR(i, 1, n + 1) {
        int ta = a[i] + b[n] - b[i - 1];
        ans = max(ans, ta);
    }
    cout << ans << nl;
}

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

int main(){
    int N,M,Ai,A_total=0;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> Ai;
        A_total += Ai;
    }
    if(A_total > N) cout << -1 << endl;
    else cout << N - A_total << endl;
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int P[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    int l[N];
    rep(i, N) {
        cin >> l[i];
    }

    ll ans = INF;
    int cnt = 0;

    while (1) {
        int sum = 0;
        int a = 0, b = 0, c = 0;
        int a_c = -1, b_c = -1, c_c = -1;
        if (P[N] == 1) {
            break;
        }
        cnt++;

        rep(i, N) {
            if (P[i] == 0) continue;
            else if (P[i] == 1) {
                a += l[i];
                a_c++;
            }
            else if (P[i] == 2) {
                b += l[i];
                b_c++;
            }
            else {
                c += l[i];
                c_c++;
            }
        }

        if (a != 0 && b != 0 && c != 0) {
            ll cost = 0;
            cost += abs(A - a) + abs(B - b) + abs(C - c) + 10 * (a_c + b_c + c_c);
            ans = min(cost, ans);
        }

        int next = 1;
        rep(i, N + 1) {
            P[i] += next;
            if (P[i] >= 4) {
                P[i] = 0;
                next = 1;
            }
            else {
                next = 0;
            }
        }
    }

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

Measured memory_bytes: 256
/*@authored by: Subham Pratap*/

/* ************************************************************************************************************************** */

#include <bits/stdc++.h>
using namespace std;
#define PKMKB ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define lli long long int
#define ull unsigned long long
#define INT_MAX 2147483647
#define all(a) begin(a),end(a)
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define MOD 1000000007
#define MAXN 10000005

  int main()
  {
    PKMKB;
    lli t;
    cin >> t;
    lli a[t+10];
    lli count = 0;
    for(lli i=0;i<t;i++)
    {
        cin >> a[i];
    }
    for(lli i=0;i<t-2;i++)
    {
       lli p =max(a[i],max(a[i+1],a[i+2]));
       lli q =min(a[i],min(a[i+1],a[i+2]));
       if(a[i+1]!=p && a[i+1]!=q)
            count++;
    }
    cout << count ;
	return 0;
}


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

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int MAXH = 1010, MAXW = 1010;

char grid[MAXH][MAXW];
int dp[MAXH][MAXW];
bool visited[MAXH][MAXW];

int h, w;

ll solve(int x, int y){
	if(x >= h || y >= w) return 0;
	if(grid[x][y] == '#') return 0;
	if(visited[x][y]) return dp[x][y];
	if(x == h-1 && y == w - 1) return dp[x][y] = 1;
	
	visited[x][y] = true;
	return dp[x][y] = (solve(x+1,y) + solve(x,y+1))%MOD;
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
	
	
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++)
			cin >> grid[i][j];
	}
	ll ans = solve(0,0);
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 9556
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a;cin>>a;
  if(a==22)cout << "Christmas Eve Eve Eve";
  if(a==23)cout << "Christmas Eve Eve";
  if(a==24)cout << "Christmas Eve";
  if(a==25)cout << "Christmas";
  cout << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

a = a + [0]
b = 1000
c = 0
for i in range(1, n):
    numb = a[i-1]
    numa = a[i]
    numaa = a[i+1]
    if numb < numa and b > c*100:
        c = b//numb
        b = b%numb
    if numa > numaa:
        b += c*numa
        c = 0

print(b)


Measured memory_bytes: 9184
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(n) cin >> a[i];

    int maxa = *max_element(all(a)), mina = *min_element(all(a));
    int alone  = count(all(a), mina);
    if(maxa - mina >= 2){
        cout << "No";
    }else if(maxa - mina == 1){
        if(2*(maxa-alone) <= (n-alone) && alone <= mina){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }else{
        if(maxa == n-1 || maxa <= n/2){
            cout << "Yes";
        }else{
            cout << "No";
        }
    }

}


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

void Main()
{
  ll H; cin >> H;
  ll cur = H;
  ll cnt = 0;
  ll monsternum = 1;
  while (cur > 0) {
    if (cur > 1) {
      cnt += monsternum;
      monsternum *= 2;
    } else cnt += monsternum;
    cur /= 2;
  }
  cout << cnt << endl;
}

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


Measured memory_bytes: 3640
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2) 
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


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

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    string ans = "Yes";
    H[0]--;
    for(int i=1; i<N; i++) {
        if (H[i-1] <= H[i]-1) {
            H[i]--;
        } else if (H[i-1] > H[i]) {
            ans = "No";
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,i,j;
  int X[100];
  int min,sum;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&X[i]);
  }
  for(i=1;i<101;i++){
    sum=0;
    for(j=0;j<N;j++){
      sum=sum+(X[j]-i)*(X[j]-i);
    }
    if(sum<min || i==1) min=sum;
  }
  printf("%d",min);
  return 0;
}

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

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
   int N;
   cin >> N;
   int sum = findSumOfDigits(N);

   if (N%sum == 0) {
       cout << "Yes" << endl;
   }
   else {
       cout << "No" << endl;
   }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	set<int> s;
	int n, m;
	cin >> n;
	while (n--)
	{
		scanf("%d", &m);
		s.insert(m);
	}
	cin >> m;
	int ans = 0;
	while (m--)
	{
		scanf("%d", &n);
		if (s.find(n) != s.end())
			++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3264
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    for (int i = 0; i < H; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << "#" << A[i] << "#" << endl;
    }
    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    return 0;
}

Measured memory_bytes: 3608
// Made by Luis Miguel Baez
// es.luismiguelbaez@gmail.com

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

#define endl '\n'
#define precise(n,k) fixed << setprecision(k) << n
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define uint  unsigned int
#define ll    long long
#define ull   unsigned long long
#define ld    long double

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define X  first
#define Y  second

#define debug(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(const pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

// add templates here

template <typename T>
string to_string(const vector<T> &v) {
    bool first = true;
    string res = "{";
    for (const T &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string((T)x);
    }
    res += "}";
    return res;
}

template<class T>
void println(const T &data) {
#ifndef ONLINE_JUDGE
    cout << to_string((T)data) << endl;
#endif
}

const int MOD = int(1e9+7);
const ll oo  = (ll)(1e9+20);
const ll lloo  = (ll)(1e18)+40;

class Task {
public:
    ll N;
    string S;    
    ll solve(std::istream &in, std::ostream &out) {
        in >> N;
        in >> S;
        ll ans = 0;
        for(ll i = 1; i < N; ++i) {
            if(S[i-1] != S[i]) ans++;
        }
        return ans + 1;
    }
    void run(std::istream &in, std::ostream &out) {
        int t;
        in >> t;
        while(t--) {
            out << solve(in, out) << endl;
        }
    }
    
    void run_void(std::istream &in, std::ostream &out) {
        int t;
        in >> t;
        while(t--) {
            solve(in, out);
        }
    }
};
    
auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    cout << solver.solve(in, out) << endl;
    //solver.run(in, out);
    return 0;
}


Measured memory_bytes: 3780
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

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

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,N,x,sum=0;
  cin>>N;
  bitset<4000002> b(1);
  rep(i,N){
    cin>>x;
    sum+=x;
    b|=b<<x;
  }
  For(i,(sum+1)/2,inf){
    if(b[i]){
      print(i);
      return 0;
    }
  }
}

Measured memory_bytes: 1792
/*************************************************************************
    > File Name: c.cpp
    > Author: samcompu
    > Mail: admin@samcompu.com
    > Created Time: 2018年05月05日 星期六 20时04分21秒
************************************************************************/

#include<bits/stdc++.h>

using namespace std;
/*Constant*/
const int MAXN = 50;
const int MAXM = 50;
int fx[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

/*Class*/

/*Variable*/
bool need[MAXN + 1][MAXM + 1];

/*Declare*/

int main() {
  int N;
  int M;
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    char buff[MAXM + 1];
    scanf("%s", buff);
    for (int j = 0; j < M; j++) {
      if (buff[j] == '#') need[i][j + 1] = true;
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      if (need[i][j]) {
        bool have = false;
        for (int k = 0; k < 4; k++) {
          if (need[i + fx[k][0]][j + fx[k][1]]) have = true;
        }
        if (!have) {
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}

/*Define*/



Measured memory_bytes: 384