akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

typedef long long ll;

int n;

struct Hash{
    ll MOD;
    ll B;
    vector <ll> pot; 
    vector <ll> H;
    int n;
    Hash(string &s, ll _B, ll _MOD){
        n = s.length(); 
        B = _B;
        MOD = _MOD;
        pot.resize(n+1);
        H.resize(n);
        H[n-1] = s[n-1];
        for(int i = n-2; i>=0; i--){
            H[i] = (s[i] + H[i+1]*B)%MOD;
        }
        pot[0] = 1;
        for(int i=1; i<n+1; i++){
            pot[i] = (pot[i-1]*B)%MOD;
        }
    }

    void print(){
        for(int i=0; i<n; i++){
            cout << H[i] << ' ';
        } cout << endl;
        for(int i=0; i<n; i++){
            cout << pot[i] << ' ';
        } cout << endl;
    }

    ll hash(int i, int j){
        ll resta;
        if(j == n-1) resta = 0;
        else resta = H[j+1]*pot[j-i+1]%MOD;
        return (H[i] - resta + MOD)%MOD;
    }

};

bool test(int L, Hash &h1){
    map <ll, vector<int>> hashes;
    bool can = false;
    for(int i=0; i+L-1<n; i++){
        if(can) break;
        ll get_hash = h1.hash(i, i+L-1);
        if(hashes.find(get_hash) == hashes.end()){
            vector <int> tmp = {i};
            hashes[get_hash] = tmp;
        }
        else{
            for(int x : hashes[get_hash]){
                if(x + L <= i){
                    can = true;
                    break;
                }
            }
        }
    }
    return can;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    string s; cin >> s;
    Hash h1(s, 127, 1e9+7);
    int L = 1, R = n/2, mid;
    while(L < R){
        mid = (L+R)/2;
        map <ll, vector<int>> hashes;
        if(!test(mid, h1)){
            R = mid; 
        }
        else{
            L = mid+1;
        } 
    }
    if(test(L,h1)){
        cout << L << '\n';
    }
    else if(test(L-1, h1)){
        cout << L-1 << '\n';
    }
    else{
        cout << 0 << '\n';
    }
    /*
    for(int i=1; i<=n/2; i++){
        cout << test(i,h1) << ' ';
    } cout << endl;
    */
    return 0;
}


Measured memory_bytes: 896
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>s>>s2;
}
void src(){
    cout<<(s==s2? 'H':'D');
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            long[] divisors = new long[N + 1];
            Arrays.fill(divisors, 1);
            
            // For each no, increment the no of divisors for each of it's multiples
            for(int i = 2; i <= N; i++) {
                for(int j = i; j <= N; j += i) {
                    divisors[j]++;
                }
            }

            long res = 0;
            for(int i = 1; i <= N; i++) {
                res += i * divisors[i];
            }
            
            out.println(res);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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


int main(){
  int N, L;
  cin >> N >> L;
  
  int total = (L - 1) * N + N * (N+1) /2;
  int ans = 0;
  
  if (0 < L) ans = total - L;
  else if (L + N - 1 < 0) ans = total - (L + N - 1);
  else ans = total;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_ints() -> Vec<i32> {
    let line = read_line();
    let split : Vec<&str> = line.trim().split(' ').collect();
    split.into_iter().map(|s| s.to_string().parse().unwrap()).collect()
}

// https://abc079.contest.atcoder.jp/tasks/abc079_a
 
fn main(){
    // let array : Vec<i32> = split.into_iter().map(|c| c.to_string().parse().unwrap()).collect();
    let array = read_ints();
    let (h,w)  = (array[0] as usize,array[1] as usize);
    let mut table = Vec::new();
    let mut map = Vec::new();
    
    for i in 0..10{
        table.push(read_ints());
    }
    
    for i in 0..h{
        map.push(read_ints());
    }
    
    let mut flag = true;
    
    while flag{
        
        flag = false;
        //println!("a");
        for i in 0..10{
            for j in 0..10{
                for k in 0..10{
                    if table[i][k] > table[i][j]+table[j][k]{
                        flag = true;
                        table[i][k] = table[i][j]+table[j][k];
                    }
                }
            }
        }
    }
    
    let mut ans = 0;
    
    for i in 0..h{
        for j in 0..w{
            if map[i][j] < 0{
                continue;
            }
            
            ans += table[map[i][j] as usize ][1];
        }
    }
    
    println!("{}",ans);
    //println!("{}",table[8][1]);
 
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n; cout << (n - 1) / 2;
	return 0;
}
 



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

int main()
{
  int s;
  cin >> s;
  vector<bool> is_exsisted(1000000, false);
  is_exsisted[s] = true;
  int count = 1;
  while (true)
  {
    count++;
    if (s % 2 == 0)
      s /= 2;
    else
      s = 3 * s + 1;
    if (is_exsisted[s])
    {
      cout << count << endl;
      return 0;
    }
    is_exsisted[s] = true;
  }

  return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;
int N;
int v[300005];

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= 3 * N; i++)
        scanf("%d", &v[i]);
    sort(v + 1, v + 3 * N + 1);

    LL ans = 0;
    for(int i = 3 * N - 1; i > N; i -= 2)
        ans += v[i];
    printf("%lld\n", ans);


    return 0;
}


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

ans=0
tmp=a[0]
for i in range(n-1):
    tmp=max(a[i],a[i+1])
    if tmp>a[i+1]:
        ans+=tmp-a[i+1]
        a[i+1]=tmp
print(ans)


Measured memory_bytes: 32116
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string N;
    bool res = false;

    cin >> N;

    for (int i = 0; i < N.length(); i++) {
        if (N.at(i) == '7') {
            res = true;
            break;
        }
    }
    if (res) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
N,Q = map(int,input().split())
STX = [tuple(map(int,input().split())) for i in range(N)]
D = [int(input()) for i in range(Q)]

starts = []
ends = []
for i,(s,t,x) in enumerate(STX):
    starts.append((s-x,i))
    ends.append((t-x,i))
starts.sort(key=lambda x:x[0], reverse=True)
ends.sort(key=lambda x:x[0], reverse=True)

import heapq
hq = []
heapq.heapify(hq)
delset = set()

ans = []
for d in D:
    while starts and starts[-1][0] <= d:
        _,i = starts.pop()
        x = STX[i][2]
        heapq.heappush(hq, x*N+i)
    while ends and ends[-1][0] <= d:
        _,i = ends.pop()
        delset.add(i)
    while hq:
        i = hq[0]%N
        if i in delset:
            heapq.heappop(hq)
        else:
            break
    if len(hq)==0:
        ans.append(-1)
    else:
        ans.append(hq[0]//N)

print(*ans, sep='\n')

Measured memory_bytes: 113828
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#ifdef LOCAL
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" s << "\033[0m"
#else
#define cerr(s)
#endif
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12

void _main(int tc) {
  string s, t;
  cin >> s >> t;

  vector<vector<int>> mem(s.size() + 1, vector<int>(t.size() + 1, -1));

  function<int(int, int)> lcs = [&](int i, int j) -> int {
    if (i == s.size() or j == t.size()) return 0;
    if (mem[i][j] != -1) return mem[i][j];
    if (s[i] == t[j])
      return mem[i][j] = 1 + lcs(i + 1, j + 1);
    else
      return mem[i][j] = max(lcs(i + 1, j), lcs(i, j + 1));
  };

  

  int i = 0, j = 0;
  string ans;
  ans.reserve(lcs(0, 0));
  while (i < s.size() && j < t.size()) {
    if (s[i] == t[j])
      ans += s[i], i++, j++;
    else if (mem[i + 1][j] > mem[i][j + 1])
      i++;
    else
      j++;
  }
  std::cout << ans << endl;

#ifdef LOCAL
  cerr(<< setw(4) << " ");
  rep(i, t.size()) cerr(<< setw(4) << t[i]);
  cerr(<< endl);
  rep(i, s.size() + 1) {
    if (i < s.size())
      cerr(<< setw(4) << s[i]);
    else
      cerr(<< setw(4) << " ");
    rep(j, t.size() + 1) cerr(<< setw(4) << mem[i][j]);
    cerr(<< endl);
  }
#endif
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

bool is_prime(int x){
  for(int i = 2; i < x; i++){
    if(x%i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int x;
  cin >> x;
  int sum = x;
  while(!is_prime(sum)) sum++;
  std::cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    if(a > b)cout << 0 << endl;
    else if(n == 1 && a != b)cout << 0 << endl;
    else cout << a + b * (n-1) - b - a * (n-1) + 1 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef complex<double> Point;
#define ALL(x) x.begin(), x.end()
const double EPS = 1e-9;
char A[606][606];
char pat[4][2][2] = {
    {{'#', '.'}, {'.', '.'}}, {{'.', '#'}, {'#', '#'}}, {{'.', '.'}, {'.', '#'}}, {{'#', '#'}, {'#', '.'}}};

int check(int x, int y) {
    vector<bool> same(4, true);
    REP(k, 4) {
        REP(i, 2) REP(j, 2) {
            if (A[x + i][y + j] != pat[k][i][j]) same[k] = false;
        }
    }
    if (same[0] || same[1])
        return 1;
    else if (same[2] || same[3])
        return -1;
    else
        return 0;
}
const double PI = acos(-1);
void solve() {
    int H, W;
    cin >> H >> W;
    REP(i, H + 2) REP(j, W + 2) { A[i][j] = '.'; }
    REP(i, H) {
        REP(j, W) { cin >> A[i + 1][j + 1]; }
    }
    H += 2, W += 2;
    vector<pair<double, int>> v;
    vector<pair<double, pair<int, int>>> v2;
    REP(i, H - 1) {
        REP(j, W - 1) {
            int c = check(i, j);
            if (c == 0) continue;
            // cout << i << " " << j << " " << c << endl;
            double x = j, y = H - i - 2;
            Point p = {x, y};
            double theta = atan2(y, x);
            // cout << theta * 180 / PI << endl;
            v.push_back({theta, c});
            v2.push_back({theta, {i, j}});
        }
    }
    sort(ALL(v));
    // v.push_back({100, 0});
    int M = v.size();
    int ans = 2;
    int cur = 1;
    sort(ALL(v2));
    REP(i, M) {
        cur += v[i].second;
        // if (abs(v[i + 1].first - v[i].first) < EPS) continue;
        // if (cur == 9) {
        //     cout << v[i].first * 180 / PI << endl;
        //     int x = v2[i].second.first, y = v2[i].second.second;
        //     cout << v2[i].second.first << " " << v2[i].second.second << endl;
        //     A[x][y] = 'o';
        // }
        ans = max(ans, cur);
    }

    // REP(i, H) {
    //     REP(j, W) { cout << A[i][j]; }
    //     cout << endl;
    // }
    // cout << cur << endl;
    cout << ans << endl;
}
signed main() { solve(); }


Measured memory_bytes: 6732
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (ll i = 0; i < N; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    ll curr_num = 0;
    ll curr_value = -1;
    for (ll i = 0; i < N; i++) {
        if (a[i] == curr_value) {
            curr_num++;
        } else {
            ans += curr_num / 2;

            curr_value = a[i];
            curr_num = 1;
        }
    }
    ans += curr_num / 2;

    cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){
    return (a%b+b)%b;
}
ll gcd(ll a, ll b){
    return b ? gcd(b, a%b) : a;
}
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}
void Yes(){
    cout << "Yes" << endl;
}
void No(){
    cout << "No" << endl;
}
void Judge(bool b){
    b ? Yes() : No();
}
void YES(){
    cout << "YES" << endl;
}
void NO(){
    cout << "NO" << endl;
}
void JUDGE(bool b){
    b ? YES() : NO();
}
ll powmod(ll b, ll e){
    ll r = 1; while(e > 0) {if(e&1) r = (r%MOD)*(b%MOD)%MOD; b = (b%MOD)*(b%MOD)%MOD; e >>= 1;} return r;
}
double distance(ll x1, ll y1, ll x2, ll y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

template<class T>bool chmax(T &a, const T &b) {
    if(a < b) { a = b; return 1; } return 0;
}
template<class T>bool chmin(T &a, const T &b) {
    if(b < a) { a = b; return 1; } return 0;
}
template<typename T>
void ppp(T n){
    cout << n << endl;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for(int i = 0; i < len; ++i) {
        s << v[i]; if(i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa {
    aaa(){
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
} fastio;

int main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) scanf("%d", &a[i]);
    vector<int> s(n+2), t(n+2);
    partial_sum(a.begin(), a.end(), s.begin()+1,
                [](int x, int y){return max(x, y);});
    partial_sum(a.rbegin(), a.rend(), t.rbegin()+1,
                [](int x, int y){return max(x, y);});
    rep(i, n) printf("%d\n",max(s[i], t[i+2]));
    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 2005

using namespace std;
typedef long long ll;
const int mod = 1000000007;

inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,m,s[maxn],t[maxn],f[maxn][maxn];
int main(){
  n = getint(), m = getint();
  for(int i = 1;i <= n;i++) s[i] = getint();
  for(int i = 1;i <= m;i++) t[i] = getint();
  for(int i = 0;i <= n;i++) f[i][0] = 1;
  for(int i = 1;i <= m;i++) f[0][i] = 1;
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= m;j++){
      f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;
      if(s[i] != t[j]) f[i][j] = (f[i][j] - f[i - 1][j - 1] + mod) % mod;
    }
  }
  printf("%d\n",f[n][m]);
  return 0;
}


Measured memory_bytes: 16000
alphaList = sorted(list(map(int, input().split())))
a, b, c = alphaList[0], alphaList[1], alphaList[2]

cnt = int((b-a)/2)
a += cnt * 2

if b - a == 1:
    cnt += 1
    a += 1
    c += 1

cnt += c - a
a, b = c, c

print(cnt)


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

int main(){
    int D, N; cin >>D >> N;
    int S=1; for(int i=0; i<D; i++) S*=100;
    if(N<100){
    cout << N*S << endl;
    }
    else{
        cout << 101*S << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

const int inf = 2e9;

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

	vector<int> h(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	vector<int> dp(n + 2, inf);
	dp[0] = 0;
	for (int i = 0; i < n - 1; i++) {
		dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
		dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
	}

	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

int n; 
int useCount[100010];

int main()
{
	
	scanf("%d", &n);
	
	if (n == 1)
	{
		printf("Yes\n");
		printf("2\n");
		printf("1 1\n");
		printf("1 1\n");
		return 0;
	}
	
	if (n == 3)
	{
		printf("Yes\n");
		printf("3\n");
		printf("2 1 2\n");
		printf("2 2 3\n");
		printf("2 1 3\n");
		return 0;
	}	
	
//	if (n == 6)
//	{
//		printf("Yes\n");
//		printf("4\n");
//		printf("3 1 2 3\n");
//		printf("3 3 4 5\n");
//		printf("3 5 6 1\n");
//		printf("3 2 4 6\n");
//		return 0;
//	}
	
//	if (n == 10)
//	{
//		printf("Yes\n");
//		printf("4\n");
//		printf("4 1 2 3 4\n");
//		printf("4 4 5 6 7\n");
//		printf("4 1 5 8 10\n");
//		printf("4 2 6 8 9\n");
//		printf("4 3 7 9 10\n");
//		return 0;
//	}
	
	int m = n * 2;
	int p = 2;
	while ((p * (p + 1)) < m)
	{
		p++;
	}
	
	if ((p * (p + 1)) != m)
	{
		printf("No\n");
		return 0;
	}
	
	printf("Yes\n");
	printf("%d\n", p + 1);
	int limit = p + 1;
	
//	memset(useCount, 0, sizeof(useCount));
	std::queue<int> q[10010];
	printf("%d ", p);
	for (int j = 1 ; j <= p ; j++)
	{
		printf("%d ", j);
//		usedCount[j]++;
		q[1].push(j);
	}
	printf("\n");
	int newP = p + 1;
	
	for (int i = 1 ; i < limit ; i++)
	{
		printf("%d ", p);
		int oneCount = 1;
		int j = 1;
		while (oneCount <= i)
		{
			int temp = q[oneCount].front();
			printf("%d ", temp);
			q[oneCount].pop();
			oneCount++;
		}
		
		while (oneCount <= p)
		{
			printf("%d ", newP);
			q[i + 1].push(newP);
			newP++;
			oneCount++;
		}
		printf("\n");
	}
	
	return 0;
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

bool check(int i, set<int> &hates) {
    while (i != 0) {
        int k = i % 10;
        if (contain(hates, k)) {
            return false;
        }
        i /= 10;
    }
    return true;
}

int main() {
    int n, k;
    cin >> n >> k;
    set<int> hates;
    rep(i, k) {
        int x;
        cin >> x;
        hates.insert(x);
    };
    for (int i = n; i <= n * 100; i++) {
        if (check(i, hates)) {
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n[2];
  cin >> n[0] >> n[1] >> n[2];
  sort(n, n + 3);
  cout << n[0] << ' ' << n[1] << ' ' << n[2] << endl;
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define f(i,n) for(int i=1;i<=n;i++)
#define mkp make_pair
double dp[301][301][301];
double solve(int x,int y,int z,int &n)  
{
         if(x<0||y<0||z<0)return 0;
         if(x==0&&y==0&&z==0) return 0;
         if(dp[x][y][z]>-0.9)
         return dp[x][y][z];
         double exp=n+x*solve(x-1,y,z,n)+y*solve(x+1,y-1,z,n)+z*solve(x,y+1,z-1,n);
         return dp[x][y][z]=exp/(x+y+z);   
	}                   
int32_t main()
{
 int t=1;
 //cin>>t;
while(t--)
{
	int n;
    cin>>n;
    int x=0,y=0,z=0;
    for(int i=1;i<=n;i++)
    {
		int v;
		cin>>v;
	    if(v==1)x++;
	    if(v==2)y++;
	    if(v==3)z++; 
	}
    memset(dp,-1,sizeof(dp));
    cout<<fixed<<setprecision(10)<<solve(x,y,z,n)<<endl;
    
    
}
   
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll t[2];
    ll a[2];
    ll b[2];
    cin>>t[0]>>t[1];
    cin>>a[0]>>a[1];
    cin>>b[0]>>b[1];
    ll x,y;
    x=(a[0]-b[0])*t[0];
    y=x+(a[1]-b[1])*t[1];
    ll ans;
    if(y==0){
        cout<<"infinity"<<endl;
    }else if((x>0 && y>0) || (x<0 && y<0)){
        cout<<0<<endl;
    }else{
        x=abs(x);
        y=abs(y);
        ll n;
        if(x%y==0){
            n=(x/y);
            ans=2*n;
            cout<<ans<<endl;
        }else{
            n=(x/y)+1;
            ans=2*n-1;
            cout<<ans<<endl;
        }
        
        
        
        
    }
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
ll x[10005];
typedef pair<ll,ll>pi;
//vector<pi>adj[1005];
int adj[204][204];
ll dis[1005];
#define inf 900000000
ll n,m,r;
bool vis[1004];
vector<int>per;
int ans;
void rec(int i)
{
    if(i==r)
    {
        int sum=0;
        for(int k=1;k<r;k++)
        {
            sum+=adj[per[k-1]][per[k]];
        }
//        cout<<endl;
        ans=min(ans,sum);
        return;
    }
    for(int j=0;j<r;j++)
    {
        if(vis[j]==0)
        {
            vis[j]=1;
            per.pb(x[j]);
            rec(i+1);
            per.pop_back();
            vis[j]=0;
        }
    }
}

int main()
{
    cin>>n>>m>>r;
    for(int i=0;i<r;i++)
    {
        int a;cin>>a;
        x[i]=a;
    }
    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)adj[i][j]=inf;
    for(ll i=0;i<m;i++)
    {
        ll u,v,w;
        cin>>u>>v>>w;
        adj[u][v]=w;
        adj[v][u]=w;
    }
    for(int k=1;k<=n;k++)
    {
        int val=x[k];
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                adj[i][j]=min(adj[i][j],adj[i][k]+adj[k][j]);
    }
    ans=inf;
    rec(0);
    cout<<ans<<endl;
}
/*

6 7 3
4 2 5

1 4 3
1 2 3
2 6 5
2 3 2
2 3 4
3 6 2
3 5 3
*/


Measured memory_bytes: 384
#include <cstdio> 
#define For(x) for (int h=head[x],o=V[h]; h; o=V[h=to[h]])
#define add(u,v) (to[++num]=head[u],head[u]=num,V[num]=v)
int num,head[100005],to[200005],V[200005];
int Q,n,m,v[100005],d[100005],c[100005],cl[100005],rg[100005];

void dfs(int x,int ran,int col){
	if (rg[x]>=ran || ran<=0) return;
	rg[x]=ran;
	if (!cl[x]) cl[x]=col;
	For(x) dfs(o,ran-1,col);
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1,x,y; i<=m; i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	scanf("%d",&Q);
	for (int i=1; i<=Q; i++) scanf("%d%d%d",&v[i],&d[i],&c[i]);	
	for (int i=Q; i; i--) dfs(v[i],d[i]+1,c[i]);
	for (int i=1; i<=n; i++) printf("%d\n",cl[i]);
}

//http://agc012.contest.atcoder.jp/tasks/agc012_b

Measured memory_bytes: 4480
// good-integer.rs ---
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
    }

    let ans = n % 1110 < 10 || n % 1000 % 111 == 0;
    println!("{}", if ans { "Yes" } else { "No" });
}


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

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


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

   vector<mint> c(200005);
   vector<mint> d(200005);

   mint p=1;
   mint q=1;
   rep(i,200005){
      c[i]=p;
      d[i]=q;
      p=p*(n-i)/(i+1);
      q=q*(n-1-i)/(i+1);
   }

   mint ans=0;
   rep(i,min(k,n)+1){
      ans+=c[i]*d[i];
   }
   cout<<ans.x<<endl;
}

Measured memory_bytes: 6424
#include<stdio.h>
#include<stdlib.h>
 
int main(){
    char line[128];
 
    while (gets(line) != NULL)
    {
        int a, b, c;
        char *sp;
        sp = strchr(line, ' ');
        *sp = '\0';
        a = atoi(line);
        b = atoi(sp+1);
        c = a + b;
        sprintf(line, "%d", c);
        printf("%d\n", strlen(line));
    }
    return 0;
}

Measured memory_bytes: 536
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

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

	REP(syzygy, n) {
		int x = 0, y = 0;
		int tempx = x, tempy = y;
		int maxx = 0, maxy = 0;

		int dx, dy;
		while(cin >> dx >> dy, (dx || dy)) {
			tempx += dx;
			tempy += dy;

			if(maxx*maxx+maxy*maxy < tempx*tempx+tempy*tempy) {
				maxx = tempx;
				maxy = tempy;
			} else if(maxx*maxx+maxy*maxy == tempx*tempx+tempy*tempy && tempx > maxx) {
				maxx = tempx;
				maxy = tempy;
			}
		}

		cout << maxx << " " << maxy << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
#include <sstream> 
using namespace std; 
typedef long long ll;
typedef pair< ll , ll > pll;
typedef pair< ll , pll > plll;
typedef priority_queue< plll , vector< plll > , greater<plll> > min_heap;
#define ft first
#define sd second
#define maxx 3000
int main() 
{ 
		ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
		
	    char c;
	    cin >> c;
	     c += 1;
	    cout << c << endl;

	 return 0;
 }

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

int w, h, n; 
int dp[20][20];// x y
bool memo[20][20];// x y
int main(void){
	while(1){
		rep(i, 20)rep(j, 20){//?????????
			dp[i][j] = 0;
			memo[i][j] = false;
		}

		cin >> w >> h;
		if(w == 0 && h == 0) return 0;
		cin >> n;
		rep(i, n){
			int x, y; cin >> x >> y;
			x--; y--;
			memo[x][y] = true;//??\???
		}
		dp[0][0] = 1;// x = 0, y = 0???????????????????????§????????????????????°
		for (int x = 0; x < w; ++x){
			for (int y = 0; y < h; ++y){
				if(memo[x][y]) continue;
				//?????????dp
				if(0 <= x - 1 && x - 1 < w){
					dp[x][y] += dp[x - 1][y];
				}
				if(0 <= h - 1 && h - 1 < h){
					dp[x][y] += dp[x][y - 1];
				}
			}
		}
		cout << dp[w - 1][h - 1] << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main(){
    int n,m;cin>>n>>m;
    vector<int>pena(n);
    vector<bool>ac(n,false);
    int res1 = 0,res2 = 0;
    while(m--){
        int p;
        p--;
        string s;cin>>p>>s;
        if(s == "WA")pena[p]++;
        else if(s == "AC"){
            if(ac[p])continue;
            ac[p] = true;
            res1++;
            res2 += pena[p];
        }
    }
    cout<<res1<<" "<<res2<<endl;
}



Measured memory_bytes: 640
//----------------------------------------------------------------
//G-2

#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const long long INF = 1LL<<60;

// 入力
int N, M;
vector<vector<int> > G; // グラフ
vector<int> deg; // 各頂点の入次数

int dp[100100];
int main() {
    // 入力受け取り, 入次数も管理する
    cin >> N >> M;
    G.assign(N, vector<int>());
    deg.assign(N, 0);
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y;
        --x, --y; // 0-indexed にする
        G[x].push_back(y);
        deg[y]++;
    }

    // source をキューに突っ込む
    queue<int> que;
    for (int v = 0; v < N; ++v) if (deg[v] == 0) que.push(v);

    // BFS
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            deg[nv]--; // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                que.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                dp[nv] = max(dp[nv], dp[v] + 1); // さらにソースから nv までの再長距離が確定する
            }
        }
    }

    // 答え
    int res = 0;
    for (int v = 0; v < N; ++v) res = max(res, dp[v]);
    cout << res << endl;
}

Measured memory_bytes: 9492
import sys
from itertools import product

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


class PathFinder:
    def __init__(self, num_dst, border):
        if num_dst == 4:
            self.dx = (-1, 0, 0, 1)
            self.dy = (0, -1, 1, 0)
        elif num_dst == 8:
            self.dx = (-1, -1, -1, 0, 0, 1, 1, 1)
            self.dy = (-1, 0, 1, -1, 1, -1, 0, 1)
        self.border = border

    # 周辺探索
    def find_neighbours(self, current_x, current_y):
        for neighbour in zip(self.dx, self.dy):
            neighbour_x = current_x + neighbour[0]
            neighbour_y = current_y + neighbour[1]
            if (
                self.border[0] <= neighbour_x < self.border[1]
                and self.border[2] <= neighbour_y < self.border[3]
            ):
                yield neighbour_x, neighbour_y


def solve():

    H, W = il()
    S = imi(H, str)
    finder = PathFinder(4, (0, H, 0, W))
    for i, j in product(range(H), range(W)):
        flag = 0
        for x, y in finder.find_neighbours(i, j):
            if S[i][j] == "#" and S[x][y] == ".":
                flag += 1
        if flag == 4:
            return "No"
    return "Yes"


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


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	string a, b, c; cin >> a >> b >> c;
	cout << char(a[0] - 32) << char(b[0] - 32) << char(c[0] - 32) << "\n";


	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;

int main(){
    int N;
    cin >> N;
    vector<int> a(N - 1), b(N - 1), c(N - 1);
    for(int i = 0; i < N - 1; ++i){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    vector<int> x(Q), y(Q);
    for(int i = 0; i < Q; ++i){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    
    vector<ll> dist(N, INF);
    vector<bool> used(N, false);
    dist[K] = 0;
    used[K] = true;
    
    struct edge{
        int to, cost;
    };
    vector<vector<edge>> ed(N);
    for(int i = 0; i < N; ++i){
        edge temp;
        temp.to = b[i];
        temp.cost = c[i];
        ed[a[i]].push_back(temp);
        temp.to = a[i];
        ed[b[i]].push_back(temp);
    }
    
    queue<int> que;
    que.push(K);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        
        for(int i = 0; i < ed[now].size(); ++i){
            int to = ed[now][i].to;
            if(used[to])         continue;
            
            dist[to] = dist[now] + ed[now][i].cost;
            used[to] = true;
            que.push(to);
        }
    }
    
    for(int i = 0; i < Q; ++i){
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    int a[N], cnt[N+10];
    for (int i=0; i<N; i++){
        cin >> a[i];
    }

    for (int i=0; i<N+10; i++) cnt[i] = 0;
    
    int ans=0;
    for (int i=0; i<N; i++) {
        cin >> a[i];
        if (a[i] > N) ans++;
        else cnt[a[i]]++;
    }
    
    for (int i=0; i<=N; i++) {
        if (cnt[i] != 0){
            if (cnt[i] > i) ans += cnt[i]-i;
            else if (cnt[i] < i) ans += cnt[i];
        }
    }

    cout << ans << endl;
}


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

int main(){
	int n;
	int s[100];
	int sum;
	
	cin >> n;
	while(n > 2){
		for(int i=0; i<n; ++i){
			cin >> s[i];
		}
		
		sort(s, s+n);
		
		sum=0;
		for(int i=1; i<(n-1); ++i){
			sum+=s[i];
		}
		
		cout << sum/(n-2) << endl;
		cin >> n;
	}
	
	return 0;
}

Measured memory_bytes: 3124
package main
 
import(
  "fmt"
	"bufio"
	"os"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}
 
func abc143c(N int, S string){
	var state rune
	count := 0
	/*
	for i := 0; i < N; i++{
		if state != S[i]{
			state = S[i]
			fmt.Print(state)
		}
	}
	*/
	for pos, r := range S{
		if state != r{
			state = r
			count++
		}
		pos++
	}
	fmt.Println(count)
}	
 
func main(){
	N := 0
	S := ""
	fmt.Scan(&N)
	fmt.Scan(&S)
	abc143c(N,S)
}

Measured memory_bytes: 1280
class PriorityQueue
    @heap
    @size
    def initialize()
        @heap = Array.new()
        @size = 0
    end

    def push(x)
        i = @size
        @size+=1
        @heap.append(x)
        while i>0 do
            par = (i-1)/2
            break if(@heap[par]<=x)
            @heap[i] = @heap[par]
            i = par
        end

        @heap[i] = x
    end

    def pop()
        ret = @heap[0]
        @size -= 1
        x = @heap[@size]
        i = 0
        while 2*i + 1<@size do
            a = 2*i+1
            b = 2*i+2
            a = b if b<@size and @heap[b] < @heap[a]
            break if @heap[a] >= x

            @heap[i] = @heap[a]
            i = a
        end

        @heap[i] = x
        @heap.pop

        return ret
    end

    def top()
        return @heap[0]
    end

    def size()
        return @size
    end

    def empty()
        return @size == 0
    end
end

#高橋くんは N個の品物を1個ずつ順番に買う予定です。
#i番目に買う品物の値段は A_i円です。
#高橋くんは M枚の割引券を持っています。
#品物を買う際に割引券を好きな枚数使うことができます。
#X円の品物を買う際に 
#Y枚の割引券を使った場合、その品物を 
#X/2^Y円(小数点以下切り捨て)で買うことができます。
#最小で何円あれば全ての品物を買うことができるでしょうか。

#input
#N M
#A_1 A_2 ... A_N
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

pq = PriorityQueue.new()

for x in a do
    pq.push(-x)
end
m.times do
    x = pq.pop()
    x+=1 if x&1 == 1
    x /= 2
    pq.push(x)
end

ans = 0
while !pq.empty do
    ans += -pq.pop()
end

puts ans

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define lint long long
using namespace std;

int main(){
	int N;
	cin >> N;
	int *a;
	a = new int[N];
	rep(i,N) cin >> a[i];
	sort(a,a+N);
	int diffs=0;
	rep(i,N){
		if(i%2) diffs+=a[i]; //Aliceの番
		else diffs-=a[i]; //Bobの番
	}
	cout << abs(diffs) << endl;
	return 0;
}

Measured memory_bytes: 256
/*
بسم الله الرحمن الرحيم
اللہ کے نام سے شروع جو بڑا مہربان اور نہایت رحم والا ہے
Allah in the name of The Most Affectionate, the Merciful
अल्लाह के नाम से जो दयालु और कृपाशील है

                            |		MD BAHAUDDIN aka Mujahid	|
                            |			NIT JAMSHEDPUR			|	
                            |		linkedin.com/in/bahau/		|
*/

//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(t,val) memset(t,val,sizeof(t));
#define f first
#define s second
#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define endl '\n'
#define mod 1000000007



int main()
{
    fastio;

    #ifndef ONLINE_JUDGE
    // input from input.txt
    freopen("input.txt", "r", stdin);
    // output to output.cpp
    freopen("output.cpp", "w", stdout);
    #endif

    int t=1; //cin>>t;
    while(t--)
    {
        int n; cin>>n;
        if(n==1) cout<<0;
        else cout<<1;

    }
    return 0;
} 







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

int main() {
  char S[100100];
  cin >> S;

  int N = strlen(S);
  int A[26] = {0};
  for (int i = 0; i < N; ++i) {
    int pos = S[i] - 'a';
    ++A[pos];
  }

  char ch = 0;
  for (int i = 0; i < 26; ++i) {
    if (!A[i]) {
      ch = i + 'a';
      break;
    }
  }

  if (ch) {
    cout << ch << endl;
  } else {
    cout << "None" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
red_str_list=[]
blue_str_list=[]

blue_cnt=int(input())

for _  in range(blue_cnt):
  red_str_list.append(input())
  
red_cnt=int(input())
for _  in range(red_cnt):
  blue_str_list.append(input())
  
ans=0
dic = dict()

for i in red_str_list:
  if (i in dic.keys()):
    dic[i]+=1
  else:
    dic[i]=1
    
for i in blue_str_list:
  if (i in dic.keys()):
    if dic[i]>0:
      dic[i]-=1

print(max(dic.values()))

  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
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;
}
const long long INF = 1LL << 60;

int main()
{
    int H, W;
    int h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string M = a[0];
            string N = a[1];
            if (M == N) { Console.WriteLine("Yes"); }else { Console.WriteLine("No"); }
        }
    }
}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

const double eps = 1e-10;
const int MOD = 1000000007;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  string x; cin >> x;
  string s = "";
  REP(i, SZ(x)) {
    if(s == "" || !(s[SZ(s)-1] == 'S' && x[i] == 'T')) {
      s.pb(x[i]);
    } else {
      s.erase(SZ(s)-1, 1);
    }
  }

  cout << SZ(s) << endl;
}


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

int main()
{
    int N, M;
    scanf("%d%d", &N, &M);
    int l[M], r[M];
    int i, min = 100000, max = 0;
    for (i = 0; i < M; i++)
    {
        scanf("%d%d", &l[i], &r[i]);
        if (l[i] > max)
        {
            max = l[i];
        }
        if (r[i] < min)
        {
            min = r[i];
        }
    }
    if (min - max >= 0)
    {
        printf("%d\n", min - max + 1);
    }
    else
    {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 896