akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	N := p.NextInt()
	S := p.Next()

	if N == 2 {
		if S == "WE" {
			p.PrintInt(1)
		} else {
			p.PrintInt(0)
		}
		return
	}

	rightE := strings.Count(S[1:], "E")
	min := strings.Count(S[:N], "W")
	if rightE < min {
		min = rightE
	}

	var prevLeft int
	for i := 1; i < N; i++ {
		//right := S[i+1:]
		leader := S[i : i+1]
		if leader == "E" {
			rightE--
		}
		if S[i-1:i] == "W" {
			prevLeft++
		}
		//cnt := prevLeft + strings.Count(right, "E")
		cnt := prevLeft + rightE
		if cnt < min {
			min = cnt
		}
	}
	p.PrintInt(min)
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 2304
#include<stdio.h>
int main(void){
    int x;
    int h, m, s;
    int ha;
    scanf("%d", &x);
    h = x / 3600;
    ha = x % 3600;
    m = ha / 60;
    s = x % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
int _main(){
  int N;
  cin>>N;
  vi A(N+1), B(N);
  for(int i=0; i<N+1; i++)cin>>A[i];
  for(int i=0; i<N; i++)cin>>B[i];
  ll ans = 0;
}

int main(){
  int N;
  cin>>N;
  vi A(N+1),B(N);
  for(int i=0; i<N+1; i++){
    cin>>A[i];
  }
  for(int i=0; i<N; i++){
    cin>>B[i];
  }
  ll ans = 0;
  for(int i=0; i<N; i++){
    if(A[i] >= B[i]){
      ans += B[i];
    }else if(A[i] < B[i]){
      ans += A[i];
      int r = B[i] - A[i];
      if(A[i+1] >= r){
        ans += r;
        A[i+1] -= r;
      }else if(A[i+1] < r){
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int i;
	int cnt=0;
	char S[27];
	char T[27];
	scanf("%s",S);
	scanf("%s",T);
	for(i=0;i<=2;i++)
	{
		if(S[i]==T[i])
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

typedef pair<long long, long long> P;
void solve(int m, int t, int p, int r){
	int a[t][p][2];
	for(int i=0; i<t; ++i)
		for(int j=0; j<p; ++j)
			for(int k=0; k<2; ++k)
				a[i][j][k] = 0;
	for(int i=0; i<r; ++i){
		int b[4];
		for(int j=0; j<4; ++j)
			cin >> b[j];
		--b[1];
		--b[2];
		if(b[3] == 0) a[b[1]][b[2]][0] = (b[0] == 0 ? -1 : b[0]);
		else ++a[b[1]][b[2]][1];
	}
	int c[t][2] = {{}};
	for(int i=0; i<t; ++i)
		for(int j=0; j<p; ++j)
			if(a[i][j][0] != 0){
				++c[i][0];
				c[i][1] += (a[i][j][0] == -1 ? 0 : a[i][j][0]) + a[i][j][1] * 20;
			}
	vector<P> v;
	for(int i=0; i<t; ++i)
		v.push_back(P((p-c[i][0])*50000+c[i][1], 2*t-i-1));
	sort(v.begin(), v.end());
	cout << 2*t-v[0].second;
	for(int i=1; i<t; ++i)
		cout << (v[i].first == v[i-1].first ? "=" : ",") << 2*t-v[i].second;
	cout << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int m, t, p, r;
		cin >> m >> t >> p >> r;
		if(m+t+p+r==0) return 0;
		solve(m, t, p, r);
	}
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep0(i,b) for(int i=0 ; i< b ;i++)
#define rep1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007
# define M_PI     3.14159265358979323846

using namespace std;


int main()
{
  int n,sum=0;
  string str;
  std::map<string, int> map;
  cin >>n;
  rep0(i,n){
    cin >> str;
    if(!map.count(str))
        map[str] = 1;
  }

  for(auto const& x : map)
    sum += x.second;

  cout<<sum;

  return 0 ;
}


Measured memory_bytes: 19084
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
  C[i][0],C[i][1] = C[i][1],C[i][0]
A.sort(key = lambda x:(-x[0],-x[1]))
C.sort(key = lambda x:(x[0],x[1]))
check  = [False]*N
from bisect import *
ans = 0
for x,y in A:
  ind = bisect_right(C,[y,x])
  while ind<N and (check[ind] == True or x>=C[ind][1]):
    ind += 1
  if ind==N:
    continue
  ans += 1
  check[ind]=True
print(ans)

Measured memory_bytes: 9264
#include <iostream>

using namespace std;

int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H')
    {
        if(b=='H') cout<<'H'<<endl;
        else cout<<'D'<<endl;
    }
    else if(a=='D')
    {
        if(b=='H') cout<<'D'<<endl;
        else cout<<'H'<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

def gcd(a, b):
    if b == 0:
        return a
    a1 = b
    b1 = a % b
    return gcd(a1, b1)

while True:
    n = int(input())
    if n == 0:
        break
    line = []
    for loop in range(n):
        x1, y1, x2, y2 = list(map(int, input().split()))
        # ax + by + c = 0
        a = y1 - y2
        b = x2 - x1
        c = -x1 * a - y1 * b
        line.append((a, b, c))
    ans = n + 1
    m = {}
    for i in range(n):
        for j in range(i + 1, n):
            l1 = line[i]
            l2 = line[j]
            det = l1[0] * l2[1] - l1[1] * l2[0]
            deta = int(abs(det))
            if det == 0:
                continue
            x = l2[1] * l1[2] - l1[1] * l2[2]
            y = -l2[0] * l1[2] + l1[0] * l2[2]
            if x > -100 * deta and x < 100 * deta and y > -100 * deta and y < 100 * deta:
                ans += 1
                G = gcd(gcd(int(abs(x)), int(abs(y))), int(abs(det)))
                x //= G
                y //= G
                det //= G
                if det < 0:
                    x *= -1
                    y *= -1
                    det *= -1
                if (x, y, det) in m:
                    m[(x, y, det)] += 1
                else:
                    m[(x, y, det)] = 1
    for p in m:
        S = 0
        cnt = 0
        while True:
            S += cnt
            if m[p] == S:
                ans -= cnt * (cnt - 1) // 2
                break
            cnt += 1
    print(ans)


Measured memory_bytes: 7220
#include <algorithm>
#include <complex>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  int count = 0;
  for (auto x : a) {
    while (x % 2 == 0) {
      x /= 2;
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1016
// 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 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")
    };
}

fn main() {
    input! {
        n: usize, a: usize, b: usize
    }
    let ans: usize = (1..(n + 1))
        .collect::<Vec<usize>>()
        .iter().filter(|&n| {
            let s = n.to_string();
            let sum = s.chars().map(|ch| ch.to_digit(10).unwrap() as usize).sum();
            a <= sum && sum <= b
        })
        .sum();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    do{
        auto m = iota(8).map!(_=>countUntil(readln().chomp(),'1')).array().filter!"a>=0"().array();
        char c='Z';
        switch(m.length)
        {
        case 1:
            c = 'C';
            break;
        case 2:
            if(m[0]==m[1]) c='A';
            else if(m[0]<m[1]) c='E';
            else c='G';
            break;
        case 3:
            c = m[0]>m[1]?'D':'F';
            break;
        case 4:
        default:
            c = 'B';
            break;
        }
        writeln(c);
    }while(readln().length);
}

Measured memory_bytes: 1048
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
  int n;
  ll ans = 0;
  string s;
  map<string, int> mp;
  cin >> n;
  rep(i, n){
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
    if(mp[s] > 1) ans += (ll)mp[s] - 1;
  }
  cout << ans << endl;
}



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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;



int main() {
    int X, A; cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b==c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

vector<bool> vis;
vector<int> v[N];
void dfs(int i, int p, int& n) {
  vis[i] = true;
  n++;
  for(auto it: v[i]) {
    if(!vis[it] && it!=p) {
      dfs(it,i,n);
    }
  }
}
void solve() {
  int n, m, x, y;
  cin >> n >> m;
  vis.resize(n+1);
  REP(i,1,m) {
    cin >> x >> y;
    v[x].pb(y);
    v[y].pb(x);
  }
  int ans = 0;
  REP(i,1,n) {
    int curr_component_size = 0;
    if(!vis[i]) {
      dfs(i,i,curr_component_size);
      ans = max(ans, curr_component_size);
    }
  }
  cout << ans;
}

int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 27100
#include <stdio.h>
#define MAX 100
#define WHITE -1
#define GRAY -2
#define BLACK -3

int color[MAX];
int d[MAX],f[MAX],n,time,a[MAX][MAX];

void visit(int u){
  int i;
  
  color[u] = GRAY;
  d[u] = ++time;
  for(i = 0; i < n; i++){
    if(a[u][i] == 0){
      continue;
    }
    if(color[i] == WHITE){
      visit(i);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}


void dfs(){
  int i,u;
  for(u = 0; u < n; u++){
    color[u] = WHITE;
  }
  time = 0;
  for(u = 0; u < n; u++){
    if( color[u] == WHITE ){
      visit(u);
    }
  }
  for(i = 0; i < n; i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }

}


int main(){
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      a[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      a[i][v-1] = 1;
    }
  }

  dfs();

  
  return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

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

	ll k;
	ll x = max(a, b);
	ll y = min(a, b);
	if ((x - y) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N;
  string s, t, u;
  cin >> N >> u;

  REP(i, 2*N){
    if(i < N) s += u[i];
    else t += u[i];
  }

  reverse(ALL(t));
  map<pair<string, string>, int> m1;
  map<pair<string, string>, int> m2;

  for(int i = 0; i < (1 << N); i++){
    string a, b, c, d;
    REP(j, N){
      if((i >> j)&1){
        a += s[j];
        c += t[j];
      }else{
        b += s[j];
        d += t[j];
      }
    }
    m1[make_pair(a, b)]++;
    m2[make_pair(c, d)]++;
  }

  int ans = 0;
  for(auto p : m1){
    ans += p.second*m2[p.first];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 108288
#include <stdio.h>
#include <math.h>
#define C 100
#define INF 1000000
int G[C+1][C+1];
int l[C+1];
int E[C+1];
void Search(int pi,int t){
  int i;
  E[pi]=t;
  for(i=1;i<=l[pi];++i){
    if(t+1<E[G[pi][i]]){
      Search(G[pi][i],t+1);
    }
  }
}
int main(){
  int x,n,i,j;
  scanf("%d",&n);
  for(i=1;i<=n;++i){
    E[i]=INF;
    scanf("%d",&x);
    scanf("%d",&l[x]);
    for(j=1;j<=l[x];++j)scanf("%d",&G[x][j]);
  }
    Search(1,0);
    for(i=1;i<=n;++i)printf("%d %d\n",i,(E[i]==INF) ? -1 :E[i]);
    return 0;
  }


    


Measured memory_bytes: 2032
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  rep(i,n){
    if(-d*i+c*(n-1-i)<=b-a&&b-a<=-c*i+d*(n-1-i)){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
using namespace std;
typedef long long LL;
int main(){
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);
	for(RI i = max(a, b); i >= 1 ; --i)
		if(a % i == 0 && b % i == 0){
			if(k == 1){
				printf("%d\n", i);
				break;
			}
			else --k;
		}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, K, ans = 0;
  cin >> N >> K;
  vector<int> d(K);
  vector<bool> memo(N, false);
  for (int i=0; i<K; i++) {
    cin >> d[i];
    vector<int> A(d[i]);
    for (int j=0; j<d[i]; j++) cin >> A[j];
    for (int j=0; j<d[i]; j++) memo[A[j]-1] = true;
  }
  for (int i=0; i<N; i++) {
    if (!memo[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
    sp[i].append(i+1)
    sp[i][1] = int(sp[i][1])
    
sp.sort(key = lambda x: x[1],reverse = True)
sp.sort(key = lambda x: x[0])
for i in range(n):
    print(sp[i][2])




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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W; cin >> H >> W;

  vector<string> red(H, string(W, '.')), blue(H, string(W, '.'));
  REP(i, H) red[i][0] = blue[i][W-1] = '#';
  REP(i, W-1) red[0][i] = red[H-1][i] = '#';
  FOR(i, 1, H-1) FOR(j, 1, W-1) (i % 2 == 0 ? red : blue)[i][j] = '#';

  REP(i, H) {
    string row; cin >> row;
    REP(j, W) if (row[j] == '#') red[i][j] = blue[i][j] = '#';
  }

  for (string row : red) cout << row << endl;
  cout << endl;
  for (string row : blue) cout << row << endl;
  return 0;
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x - a) < abs(x - b)) cout << "A" << endl;
    else cout << "B" << endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
    string geng[100];
    int nen[100],getu[100],day[100];
    int i = 0;
    cin >> geng[i];
    while(geng[i] != "#"){
        cin >> nen[i] >> getu[i] >> day[i];
        if(nen[i] >= 32){
            cout << '?' << ' ' << nen[i] - 30 << ' ' << getu[i] << ' ' << day[i] << endl;
        }else{
            if(nen[i] == 31 && getu[i] >= 5){
                cout << '?' << ' ' << nen[i] - 30 << ' ' << getu[i] << ' ' << day[i] << endl;
            }else{
                cout << "HEISEI" << ' ' << nen[i] << ' ' << getu[i] << ' ' << day[i] << endl;
            }
        }
        i++;
        cin >> geng[i];
    }
    return 0;
}


Measured memory_bytes: 3080
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}
ll sm(ll n)
{
	ll i;
	ll k=0;
	while(n>0)
	{
		k=k+n%10;
		n=n/10;
	}
	return k;
}
vector<ll>v[100001];
ll dp[100001];
ll vis[100001];
void dfs(ll k)
{
	vis[k]=1;
	for(ll i=0;i<v[k].size();i++)
	{
		if(!vis[v[k][i]])
		dfs(v[k][i]);
	dp[k]=max(dp[k],1+dp[v[k][i]]);
}
}
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=0,q=0,y=100000000000,m,w;
  	cin>>n>>m;
  	for(i=0;i<m;i++)
  	{
  		cin>>k>>l;
  		v[k].pb(l);
	  }
	  for(i=1;i<=n;i++)
	  {if(!vis[i])
	  	 dfs(i);
	  }
	  ll ans=0;
	  for(i=1;i<=n;i++)
	  ans=max(ans,dp[i]);
	  cout<<ans<<endl;
	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  


Measured memory_bytes: 13224
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

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

    ll mod = 1e9+7;

    vector<vector<int> > b(N, vector<int>(60));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 60; j++) {
            b[i][j] = a[i] % 2;
            a[i] /= 2;
        }
    }
    

    vector<vector<ll> > p(N, vector<ll>(60)), q(N, vector<ll>(60));
    for (int k = 0; k < 60; k++) {
        p[N-1][k] = (1-b[N-1][k]);
        q[N-1][k] = b[N-1][k];

        for (int i = N-1; i > 0; i--) {
            p[i-1][k] = p[i][k] + (1-b[i-1][k]);
            q[i-1][k] = q[i][k] + b[i-1][k];
        }
    }
    

    ll ans = 0, tmp = 1;
    for (int k = 0; k < 60; k++) {
        ans += tmp * p[0][k] % mod * q[0][k] % mod;
        ans %= mod;
        tmp *= 2;
        tmp %= mod;
    }

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

Measured memory_bytes: 392240
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int a;
	string s;
	cin>>a;
	cin>>s;
	if(a>=3200)
		cout<<s<<"\n";
	else
		cout<<"red\n";
}
int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

using namespace std;


int main()
{
  int N, M;
  double P;
  int g[14][14] = {{}};
  double dp[1 << 14] = {};

  cin >> N >> M >> P;
  P /= 100.0;
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    ++g[--a][--b];
    ++g[b][a];
  }

  double mat[14][14];
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      mat[i][j] = 1.0;
      for(int k = 0; k < g[i][j]; k++) mat[i][j] *= P;
    }
  }
  for(int i = 1; i < 1 << N; i++) {
    dp[i] = 1.0;
    for(int latte = (i - 1) & i; latte >= 1; latte = (latte - 1) & i) {
      int malta = i ^latte;
      if(latte < malta) break;
      double ret = dp[latte];
      for(int j = 0; j < N; j++) {
        if(~(latte >> j) & 1) continue;
        for(int k = 0; k < N; k++) {
          if((malta >> k) & 1) ret *= mat[j][k];
        }
      }
      dp[i] -= ret;
    }
  }
  cout << fixed << setprecision(10) << dp[(1 << N) - 1] << endl;
}

Measured memory_bytes: 3404
n,x,y = map(int, input().split())
a = [0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        if i<=x and y<=j:
            a[x-i+j-y] += 1
        elif abs(x-i)+abs(y-j)+1<j-i:
            a[abs(x-i)+abs(y-j)]+=1
        else:
            a[j-i-1]+=1
for i in a:
    print(i)

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

int main(void)
{
    int W, H, N;

    cin >> W >> H >> N;

    int xl=0, yl=0;
    int xh=W, yh=H;

    for(int i = 0; i < N; ++i)
    {
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1) xl = max(x, xl);
        if(a == 2) xh = min(x, xh);
        if(a == 3) yl = max(y, yl);
        if(a == 4) yh = min(y, yh);
        
    }
    if(xh-xl > 0 && yh-yl > 0) cout << (xh - xl)*(yh - yl) << endl;
    else cout << 0 << endl;

    return 0;
}



Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int l = sc.nextInt();
        
        //理想のパイ
        int allPie = makePie(n,l,n+1);
        
        int min = 0;//絶対値比較変数。初回に絶対上書きする必要あり
        int Pie =0;
        int outPie = 0;
        int eatNum = 0;
        for(int i=0;i<n;i++){
         Pie = makePie(n,l,i);//i番目を食べたパイ
         if(i==0){//初回は上書き
           min = Math.abs(Math.abs(allPie)-Math.abs(Pie));
           outPie = Pie;
           eatNum = i;
         }
           if(Math.abs(min)> Math.abs(Math.abs(allPie)-Math.abs(Pie))){
             min = Math.abs(Math.abs(allPie)-Math.abs(Pie));
             outPie = Pie;
             eatNum = i;
           }
        }
        // 出力
		//System.out.println(allPie+""+outPie+" "+min+" "+eatNum);
        System.out.println(outPie);
	}
  
  //アップルパイ作成関数※林檎総数、おいしさ定数、食べた林檎※n+1以上指定で全使用
  public static int makePie(int n,int l,int eatNum){
    int sum=0;
    for(int i=0;i<n;i++){
      if(i==eatNum) continue;
      sum+=l+(i+1)-1;//配列は0からなので
      
    }
    return sum;
  }
}

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

int main(void){
	while(1){
		char str[110];
		int a=0, b=0, i=1;
		
		scanf(" %s", str);
		if(strcmp(str, "0") == 0) break;
		
		while(str[i] != '\0'){
			if(str[i] == 'A') a++;	
			else if(str[i] == 'B') b++;
			i++;
			
			//printf("%d : %d\n", a, b);
		}
		
		if(a<b) b++;
		else a++;
		
		printf("%d %d\n", a, b);
	}

	return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    string s;
    cin >> s;
    bool check = false;
    
    for(int i=0; i<s.size(); i++){
        if(i%2 == 0 && s[i] == 'L'){
            check = true;
            break;
        }    
        if(i%2 != 0 && s[i] == 'R'){
            check = true;
            break;
        }
    }
    if(check)
        cout << "No";
    else
        cout << "Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int mod(int a,int b){
	return a % b;
}
int main(){
	string S,T;
	cin >> S >>T;
	int s = (int)S.size();
	bool result = false;
	for (int i = 0; i < s; ++i)
	{
		bool tmp = true;
		for (int j = 0; j < s; ++j)
		{
			if(S[mod(j,s)] != T[mod(j + i,s)]){
				tmp = false;
			}
		}
		if(tmp)result = true;
	}
	if(result){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<utility>
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	int b =0;
	b=a[0]*100+a[1]*10+a[2];
	if(b%4==0)
	cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}




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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

char s[510][510];

void Work(){
	REP(i,1,n){
		REP(j,1,m-1)if(j==1||i%2==1||s[i][j]=='#')printf("#");else printf(".");
		puts(".");
	}
	puts("");
	REP(i,1,n){
		printf(".");
		REP(j,2,m)if(j==m||i%2==0||s[i][j]=='#')printf("#");else printf(".");
		puts("");
	}
}

void Init(){
	read(n,m);
	REP(i,1,n)scanf("%s",s[i]+1);
}

int main(){
	Init();
	Work();
	return 0;
}


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

#define rep(i,n) for( (i)=0;(i)<(n);++(i) )
#define repr(i,n) for( (i)=(n);(i)>0;==(i) )
#define FOR(i,j,n) for( (i)=(j);(i)<(n);++(i) )
#define forr(i,j,n) for( (i)=(j);(i)>(n);--(i) )
#define debg(a) cout<<(a)<<endl;
#define INF 9999999
#define int long long 
int i,j,k;
int dx,dy;
int a,b,c,x,y,n,m,cnt=0,ans=0;
string s,t;

signed main(){ 
  cin>>a>>b>>x;
  cout<<( a==0?b/x+1:b/x-(a-1)/x )<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

struct Node{
  int key;
  Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(Node* z){

  Node* y;
  Node* x;

  y = NIL;
  x = root;
  //cout << "insert key" << z->key <<endl;
  //printf("root:%x nill:%x",root,NIL);

  while(x != NIL){
    
    //cout << "in while" <<endl;
    y = x;

    if(z->key < x->key){
      x = x->left;
    }

    else{
      x = x->right;
    }
  }
  
  z->parent = y;
  //cout << "set parent";
  if(y == NIL){
    //cout << "decision root" << endl;
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
    


}


bool find(int key){
  Node* curPos = root;
  while(curPos != NIL){
    if(curPos->key == key){
      return true;
    }
    else if(curPos->key > key){
      curPos = curPos->left;
    }
    else{
      curPos = curPos->right;
    }
  }
  return false;
}
void inorder(Node* u){
  if(u == NIL){return;}

  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);

}

void preorder(Node* u){
  if(u == NIL){return;}
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

int main(){

  long ii,jj,kk;
  vector<int> a;
  int n;

  cin >> n;

  string command;
  int key;
  Node* z;

  //root = (Node*)malloc(sizeof(Node));
  //NIL  = (Node*)malloc(sizeof(Node));

  for(ii=0;ii<n;ii++){
    cin >> command ;

    if(command == "insert"){

      cin >> key;
      z = (Node*)malloc(sizeof(Node));
      z->key = key;
      z->left = NIL;
      z->right = NIL;
      insert(z);
    }
    else if(command == "find"){
      cin >> key;
      if(find(key)){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
    else{
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;  
    }

  }



  return 0;
}



Measured memory_bytes: 21968
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < L.length; ++i) {
            L[i] = sc.nextInt();
        }

        System.out.println(solve(L) ? "Yes" : "No");

        sc.close();
    }

    static boolean solve(int[] L) {
        return Arrays.stream(L).max().getAsInt() * 2 < Arrays.stream(L).sum();
    }
}

Measured memory_bytes: 36164
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int a = 0, r = 10;
  for(int i = 0; i < 5; i++){
    int A;
    cin >> A;
    a += (A + 9) / 10;
    int re = A % 10;
    if(re == 0) re = 10;
    r = min(r, re);
  }
  cout << 10 * a - 10 + r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	int count = 1;
	rep(i,n-1) {
		if(s[i]!=s[i+1]) count++;
	}
	print(count);
	return 0;
}


Measured memory_bytes: 512
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    A, B = MAP()
    A -= 1
    B -= 1
    print(ceil(B / A, 1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
r = 1
a.sort!
if a.first == 0
  puts 0
  exit
end
a.each do |val|
  r *= val
  if r > 10**18
    puts -1
    exit
  end
end

puts r

Measured memory_bytes: 24180
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int V, x, y;
    cin >> V >> x >> y;
    --x; --y;
    vector<int> ans(V);
    for(int i = 0; i < V - 1; ++i){
        for(int j = i + 1; j < V; ++j){
            /*if(!(j < x || i > y)){*/
                int d1 = abs(x - i) + 1 + abs(j - y);
                int d2 = abs(x - j) + 1 + abs(i - y);
                int d3 = j-i;
                int d = min(min(d1, d2), d3);
                ans[d]++;
            /*}*/
            /*else{*/
                /*int dist = j - i;*/
                /*ans[dist]++;*/
            /*}*/
        }
    }
    for(int i = 1; i < V; ++i){
        cout << ans[i] << endl;
    }

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){

    int i = 1,x =1;

    while(i>0){

    scanf("%d",&x);

    if( x != 0){

        printf("Case %d: %d\n",i,x);
        i++;

     } else{
        break;
    }

}

    return 0;
}  






Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    int N,Q;
	int t;
	string str;
	queue<pair<string,int> > que;
	cin>>N>>Q;
	for(int i=0;i<N;i++){
		cin>>str>>t;
		que.push(pair<string,int>(str,t));
	}
	for(int i=Q;!que.empty();i+=Q){
		que.front().second-=Q;
		if(que.front().second<=0){
			i+=que.front().second;
			cout<<que.front().first<<' '<<i<<endl;
			que.pop();
		}else{
			que.push(que.front());
			que.pop();
		}
	}
}

Measured memory_bytes: 4404
#include <iostream>
#include <string>
#include <cstdlib>


int main(void){
    char a[2], b[2];
    a[0] = getchar();
    a[1] = '\0';
    getchar();
    b[0] = getchar();
    b[1] = '\0';
    std::string aaa, bbb;
    aaa.clear();
    bbb.clear();

    for(int i = 0;i < std::atoi(b);++i){
        aaa.push_back(a[0]);
    }
    for(int i = 0;i < std::atoi(a);++i){
        bbb.push_back(b[0]);
    }

    if(aaa < bbb){
        std::cout << aaa << std::endl;
    }else{
        std::cout << bbb << std::endl;
    }

    //std::cout << std::atoi(a) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

int n,k;

int main()
{
	scanf("%d%d",&n,&k);
	LL ans=0;
	for (int i=k+1;i<=n;i++)
	{
		ans+=i-max(k,1);
		ans+=(LL)(n/i-1)*(i-k);
		ans+=max(0,n%i-k+1);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_138
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            double[] vals = ReadDoubles();
            Array.Sort(vals);
            double res = vals[0];
            for(int i = 1; i < n; i++)
            {
                res = (res + vals[i]) / 2;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11348
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] x = new int[N];
        for (int i=0;i<N;i++){
            x[i] =sc.nextInt();
        }
        int min =0;
        for (int i=0;i<N;i++){
            if(Math.abs(K-x[i])*2>= x[i]*2){
                min +=x[i]*2;
            }else{
                min +=Math.abs(K-x[i])*2;
            }
        }
        System.out.println(min);
    }
}

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> vec1;
    vector<int> vec2;
    for(int i = 0;i < M;i++){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            vec1.push_back(b);
        }
        if(b == 1){
            vec1.push_back(a);
        }
        if(a == N){
            vec2.push_back(b);
        }
        if(b == N){
            vec2.push_back(a);
        }
    }
    if(vec1.size() * vec2.size() == 0){
        cout << "IMPOSSIBLE" << endl;
        ED
    }
    SORT(vec1);
    SORT(vec2);
    int i = 0;
    int j = 0;
    while(true){
        if(vec1.at(i) == vec2.at(j)){
            cout << "POSSIBLE" << endl;
            ED
        }
        else{
            if(vec1.at(i) > vec2.at(j)){
                j++;
                if(j >= vec2.size()){
                    cout << "IMPOSSIBLE" << endl;
                    ED
                }
                continue;
            }
            else{
                i++;
                if(i >= vec1.size()){
                    cout << "IMPOSSIBLE" << endl;
                    ED
                }
                continue;
            }
        }
    }
}


Measured memory_bytes: 1276