akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll MOD=1e9+7;

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	
	for(ll i=0;i<n;i++)
		cin>>a[i];
	vector<ll> cnt(n,0);
	if(n%2==0)
	{
		for(ll i=0;i<n;i++)
		{
			cnt[a[i]]++;
			if (a[i]>=n || a[i]%2==0 || cnt[a[i]]>2) 
			{
				cout<<0<<endl;
				return;
			}
		}
	}
	else
	{
		for (ll i=0;i<n;i++) 
		{
			cnt[a[i]]++;
			if (a[i]>=n || a[i]%2==1 || cnt[0]>1 || cnt[a[i]]>2) 
			{
				cout<<0<<endl;
				return;
			}
		}
	}
	ll ans=1;
		for(ll i=0;i<n/2;i++)
			ans*=2,ans%=MOD;
		cout<<ans;
	
	return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 4664
N = gets.chomp.to_i
rest = []
N.times do |n|
  a, b = gets.chomp.split()
  rest.push([a, b.to_i, n+1])
end

rest = rest.sort_by {|x| x[1] }.reverse.sort_by {|x| x[0] }


N.times do |n|
  puts rest[n][2]
end

Measured memory_bytes: 1916
from itertools import accumulate
def main():
	n, k, *a = map(int, open(0).read().split())
	acc = [0] + list(accumulate(a))
	ps = [acc[j] - acc[i] for i in range(n) for j in range(i + 1, n + 1)]
	ans = 0
	for i in range(max(ps).bit_length(), -1, -1):
		x = ans + (1 << i)
		if sum(y & x == x for y in ps) >= k:
			ans = x
	print(ans)

if __name__=="__main__":
	main()


Measured memory_bytes: 22960
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7; 
int main(){
	IOS;
	ll s, d, t;
	cin>>d>>t>>s;
	if(s*t>=d)
	cout<<"Yes";
	else
	cout<<"No";
	
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;
int main()
{
	char szStr[5];
	memset(szStr, NULL, sizeof(szStr));
	cin >> szStr;

	int nCnt = 0;
	for(int i=0; i<4; i++)
	{
		if (szStr[i] == '2')
			nCnt++;
	}
	cout << nCnt;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int K,S;
cin >> K >>S;
int count = 0;
  for(int x = 0; x<=K; x++){
    for(int y = 0; y<=K; y++){
        int z = S -x -y;
        if(z>=0&&z<=K){
            count++;
        }
            
    }
  }
    
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
import itertools
N,M,Q = map(int,input().split())

A=[i for i in range(1,M+1)]
#c = itertools.combinations(A, N)
c = itertools.combinations_with_replacement(A, N)

data=[None]*Q

for i in range(Q):
    data[i] = list(map(int,input().split()))

ans=0
for p in c:
    tmp=0
    for d in data:
        if p[d[1]-1] - p[d[0]-1] == d[2]:
            tmp+=d[3]
    ans=max(ans,tmp)
print(ans)

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

int main()
{
  
  ll n;
  cin>>n;
  map<string,ll>m;
  while(n--)
  {
    string str;
    cin>>str;
    m[str]++;
  }
  cout<<"AC x "<<m["AC"]<<'\n';
  cout<<"WA x "<<m["WA"]<<'\n';
  cout<<"TLE x "<<m["TLE"]<<'\n';
  cout<<"RE x "<<m["RE"]<<'\n';
  return 0;
}

Measured memory_bytes: 3636
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
from math import pi, ceil, floor
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
from bisect import bisect_left, bisect_right, insort_left, insort_right
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    qa = deque(input())
    qb = deque(input())
    qc = deque(input())
    s = qa.popleft()
    while qa or qb or qc:
        if s == 'a':
            s = qa.popleft()
            if not qa:
                print('A')
                exit()
        elif s == 'b':
            s = qb.popleft()
            if not qb:
                print('B')
                exit()
        else:
            s = qc.popleft()
            if not qc:
                print('C')
                exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 12456
A = []
for _ in range(3):
    A.append(list(map(int, input().split())))

N = int(input())

C = [[False for _ in range(3)] for _ in range(3)]
for i in range(N):
    B = int(input())
    for j in range(3):
        if B in A[j]:
            bi = A[j].index(B)
            C[j][bi] = True

ans = 'No'

# TATE
for i in range(3):
    if C[0][i] + C[1][i] + C[2][i] == 3:
        ans = 'Yes'

# YOKO
for i in range(3):
    if C[i][0] + C[i][1] + C[i][2] == 3:
        ans = 'Yes'

# NANAME
if C[0][0] + C[1][1] + C[2][2] == 3:
    ans = 'Yes'

if C[0][2] + C[1][1] + C[2][0] == 3:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long balance = 100;
        int out = 0;
        while(balance < x){
            balance *= 1.01;
            out++;
        }
        System.out.println(out);
    }
}


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

int n;
int a[3055];

long long dp[3055][3055][2];

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for (int i = n - 1; i >= 0; i--) {
		for (int j = i; j < n; j++) {
			for (int player = 0; player < 2; player++) {
				long long &res = dp[i][j][player];
				
				if (i == j) {
					if (player == 0) res = a[i];
					else res = -a[i];
					continue;
				}
				
				if (player == 0) {
					// maximize
					
					res = max(dp[i + 1][j][1] + a[i], dp[i][j - 1][1] + a[j]);
				} else {
					res = min(dp[i + 1][j][0] - a[i], dp[i][j - 1][0] - a[j]);
				}
			}
		}
	}
	
	cout << dp[0][n - 1][0];
}


Measured memory_bytes: 143616
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

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


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    bp = list(reversed([2**i for i in range(2, 32)]))
    C = Counter(A)
    ans = 0
    A.sort(reverse=True)
    for k in A:
        if C[k] <= 0:
            continue
        C[k] -= 1
        r = (1 << k.bit_length()) - k
        if C[r] > 0:
            ans += 1
            C[r] -= 1

    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))

    # N = 2*(10**5)
    # # A = [random.randint(1, 10**9) for _ in range(N)]
    # A = list(range(1, N+1))
    # print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 122880
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;
#define matrix(T) vector<vector<T>>
#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define pqueue priority_queue
#define pushb push_back
#define fi first
#define se second
#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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;
}

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

ll nPr(ll n, ll r) {
	if(n<r) return 0;

	ll result=1LL;
	for(ll i=0; i<r; i++) result*=n-i;
	return result;
}

ll nPrP(ll n, ll r, ll p) { // mod pにおけるnPr
	if(n<r) return 0;

	ll result=1LL;
	for(int i=0; i<r; i++) {
		result*=n-i;
		result%=p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int A,B,C,K;
ll res=0;

void input() {
	cin>>A>>B>>C>>K;
}

void solve() {
	res+=min(A,K);
	K-=A+B;
	if(K>0) res-=K;
	cout<<res<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 3624
#include <stdio.h>

int N;
void swap(int *n1, int *n2){int tmp = *n1; *n1 = *n2; *n2 = tmp;}
void sort(int array[]);

int main(void)
{
	int i, L[210], ans = 0;
	scanf("%d", &N);
	for (i = 0; i < 2 * N; i++){
		scanf("%d", &L[i]);
	}

	sort(L);

	for (i = 0; i < 2 * N; i += 2){
		ans += L[i];
	}
	printf("%d\n", ans);

	return 0;
}

void sort(int array[])
{
	int i, j;
	for (i = 2 * N - 1; i > 0; i--){
		for (j = 0; j < i; j++){
			if (array[j] > array[j + 1])
				swap(&array[j], &array[j + 1]);
		}
	}
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.trim_right();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, k) = parse_line!(u64, u64);

    let r = n % k;

    println!("{}", std::cmp::min(r, k - r));
}


Measured memory_bytes: 4352
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const LL inf = 0x3f3f3f3f;
int main(void){
    int k,v,u;
    cin>>k;
    vector<int> dp(k,46);
    dp[1] = 1;
    queue<int> deq;
    deq.push(1);
    while(!deq.empty()){
        v=deq.front();
        deq.pop();
        u = (v*10)%k;
        if(dp[u] > dp[v]){
            dp[u] = dp[v];
            deq.push(u);
        }
        u = (v+1)%k;
        if(dp[u] > dp[v]+1){
            dp[u] = dp[v]+1;
            deq.push(u);
        }
    }
    cout<<dp[0]<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n, x, m[100], sum = 0, min = 1000, rest, count = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
		if (m[i] < min) {
			min = m[i];
		}
	}
	rest = x - sum;
	while (rest >= min) {
		rest -= min;
		count++;
	}
	cout << n + count << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != ',')
      cout << s[i];
    else
      cout << " ";
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    // 最短距離を示す双方向グラフについて，
    // 各最短経路を維持できる辺の最小合計値を求める
    // 入力が不正な最短距離の場合は-1を返す
    public static long GetMinDistanceSum(long[][] dist)
    {
        long sum = 0;
        var first = 0;
        var n = dist.Length;

        // 辺ijを自身の辺を通らずkを経由したもので代替できるかチェック
        for (int i = first; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                long d = long.MaxValue;
                for (int k = first; k < n; k++)
                {
                    if (i == k || j == k)
                    {
                        continue;
                    }
                    if (dist[i][k] == long.MaxValue || dist[k][j] == long.MaxValue)
                    {
                        continue;
                    }
                    d = Math.Min(d, dist[i][k] + dist[k][j]);
                }
                // 代替不可であれば，必要な辺
                if (dist[i][j] < d)
                {
                    sum += dist[i][j];
                }
                // 直通経路が最短ではない．入力不正
                else if (dist[i][j] > d)
                {
                    return -1;
                }
            }
        }
        return sum;
    }

    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var graph = new long[n][];
        for (int i = 0; i < n; i++)
        {
            graph[i] = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        var sum = GetMinDistanceSum(graph);
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 21464
import java.util.Scanner;


public class Main {

	static int H,W;
	static int[][]map;
	static Scanner sc = new Scanner(System.in);
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		while(read())	solve();
	}
	
	public static boolean read() {
		String s;
		String[] str = new String[2];
		if(sc.hasNext()) {
			s = sc.nextLine();
			str = s.split(" ");
			W = Integer.parseInt(str[0]);
			H = Integer.parseInt(str[1]);
		}
		if ((W==0)||(H==0)) return false;
		
		map = new int[W][H];	//初期化
		for(int i=0 ; i<W ; i++) {
			s = sc.nextLine();
			for(int j=0 ; j<H ; j++) {
				// < 1
				// ^ 2
				// > 3
				// v 4
				switch(s.charAt(j)) {
				case '<':
					map[i][j] = 1;
					break;
				case '^':
					map[i][j] = 2;
					break;
				case '>':
					map[i][j] = 3;
					break;
				case 'v':
					map[i][j] = 4;
					break;
				case '.':
					map[i][j] = 0;
					break;
				default:
					break;
					//System.exit(2);
				}
			}
		}
		return true;
	}
	public static void solve() {
		int x=0,y=0;
		for(int i=0; i<W*H ; i++) {
			if((x<0||x>W)||(y<0||y>H)) {
				System.out.println("LOOP");
				return;
			}
			switch(map[x][y]) {
			case 1:
				y--;
				break;
			case 2:
				x--;
				break;
			case 3:
				y++;
				break;
			case 4:
				x++;
				break;
			case 0:
				System.out.println(y + " " + x);
				//System.out.println("i=" + i);
				return;
			default:
				return;
			}
		}
		System.out.println("LOOP");
		return;
	}

}

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

using namespace std;
int main(){
    int n;

    cin>>n;
    int flag=0;

    for(int i=1;i<=9;i++){
        for(int j=i;j<=9;j++){
            if(n==(i*j)){
                flag=1;
            }
            if(n==1){
                flag=1;
            }

        }
    }
    if(flag==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


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

int main() {
	int a,b;
	cin >> a >> b;
	cout <<"a ";
	if(a<b){
		cout << "<";
	}else if(a>b){
		cout << ">";
	}else{
		cout << "==";
	}
	cout << " b" << endl;
	return 0;
}



Measured memory_bytes: 3104
N, K = map(int, input().split())

score = 0
for i in range(1, N+1):
    point = i
    if point >= K:
        score += 1/N
    else:
        sisuu = 0
        while point < K:
            sisuu += 1
            point = point * 2
        score += 1/N / (2**sisuu)

print(score)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {  
    int n;
    cin >> n;
    if (n < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
}




Measured memory_bytes: 3560
#include <bits/stdc++.h>
//#include "lib/bigint2.h"

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ if(a>b) a=b;}

struct Bitree {
	typedef ll btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll d, a;
	cin >>n >>d >>a;
	vector<VL> x(n, VL(2));
	rep(i, n) cin >>x[i][0] >>x[i][1];
	
	sort(all(x));
	ll ans = 0;
	Bitree bt(n+2);
	rep(i, n){
		ll sm = bt.sum(i);
		ll h = x[i][1] - sm,  ps = x[i][0];
		if(h <=0) continue;
		ll su = (h + a -1) /a;
		ans += su;
		bt.add(i, su * a);
		int zps = lower_bound(all(x), VL{ps + 2*d +1, -1}) - x.begin();
		bt.add(zps, -su * a);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		string s,t;
		cin>>s>>t;
		ll count = 0;
		for(ll i=0; i<s.size(); i++) {
			if(s[i]!=t[i]) {
				count++;
			}
		}

		cout<<count<<endl;
		return 0;
	}


Measured memory_bytes: 3868
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int M;
	cin >> M;
	cout << 24 + (24 - M);
	system("pause");
	return 0;
}

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

int main()
{
    int A,B;
    cin >> A;
    cin >> B;

    if (A == 1){
        if (B == 2){
            cout << 3 << endl;
        }
        else if (B == 3){
            cout << 2 << endl;
        }
    }
    else if (A == 2){
        if (B == 1)
        {
            cout << 3 << endl;
        }
        else if (B == 3)
        {
            cout << 1 << endl;
        }
    }
    else {
        if (B == 1)
        {
            cout << 2 << endl;
        }
        else if (B == 2)
        {
            cout << 1 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int N,Q;
int counter[200000];
vector<int> v[200000];
vector<int> map[200000];
bool flag[200000];

int main(){
    for(int i=0;i<200000;i++){
        counter[i] = 0;
        flag[i] = true;
    }
    cin >> N >> Q;
    int a,b;
    for(int i=0;i<N-1;i++){
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<Q;i++){
        cin >> a >> b;
        counter[a-1] += b;
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int t = q.front();
        q.pop();
        flag[t] = false;
        for(int i=0;i<v[t].size();i++){
            if(flag[v[t][i]]){
                q.push(v[t][i]);
                map[t].push_back(v[t][i]);
            }
        }
    }
    queue<int> qq;
    qq.push(0);
    while(!qq.empty()){
        int t = qq.front();
        qq.pop();
        for(int i=0;i<map[t].size();i++){
            qq.push(map[t][i]);
            counter[map[t][i]] += counter[t];
        }
    }
    for(int i=0;i<N;i++){
        cout << counter[i];
        if(i != N-1) cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25216
import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let n = Int(split[0])!
let k = Int(split[1])!

var nArray = Array(repeating: 0, count: n)
var kArray: [String] = []

for _ in 0..<k {
    let input_line2: String = readLine()!
    let d = Int(input_line2)!
    
    let input_line3: String = readLine()!
    let split3: [String] = input_line3.components(separatedBy: " ")
    
    for i in 0..<d {
        kArray.append(split3[i])
    }
}

let uniqueValues = Array(Set(kArray))

let ans = nArray.count - uniqueValues.count

print(ans)

Measured memory_bytes: 14436
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.lang.reflect.Modifier
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val size = 55555
    val isprime = BitSet(size)
    for (i in 2 until size) {
        isprime[i] = true
    }
    val primes = mutableListOf<Int>()
    for (i in 2 until size) {
        if (isprime[i]) {
            if (i % 5 == 1) primes.add(i)
            var j = 2
            while (i * j < size) {
                isprime[i * j] = false
                j++
            }
        }
    }
    println(primes.take(n).joinToString(" "))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 37708
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll nCr[55][55];

vector<double>vec;
double v[55];

int main(){

	int i,j;

	nCr[0][0] = 1ll;
	for (i = 1; i <= 50; i++){
		nCr[i][0] = 1ll;
		for (j = 1; j <= i; j++){
			nCr[i][j] = nCr[i - 1][j] + nCr[i - 1][j - 1];
		}
	}

	int N,A,B;

	scanf("%d %d %d",&N,&A,&B);


	for(i=0;i<N;i++){
		scanf(" %lf",&v[i]);
		vec.push_back(v[i]);
	}

	sort(vec.begin(),vec.end());

	double ans=0;

	for(i=0;i<A;i++){
		ans+=vec[N-1-i];
	}

	ans/=(double)A;

	printf("%.7f\n",ans);

	int flag=0;

	for(i=1;i<A;i++){
		if(vec[N-i]!=vec[N-1-i]){flag=1;}
	}

	if(flag==1){
		int cnt1=0;
		for(i=0;i<A;i++){
			if(vec[N-i-1]==vec[N-1-(A-1)]){cnt1++;}
		}
		int cnt2=0;
		for(i=0;i<N;i++){
			if(vec[i]==vec[N-1-(A-1)]){cnt2++;}
		}
		printf("%lld\n",nCr[cnt2][cnt1]);
	}
	else{
		int cnt1=0;
		for(i=0;i<N;i++){
			if(vec[N-i-1]==vec[N-1-(A-1)]){cnt1++;}
		}
		ll sum=0ll;
		for(i=A;i<=B;i++){
			sum+=nCr[cnt1][i];
		}
		printf("%lld\n",sum);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define ALL(c) c.begin(),c.end()
#define int LL
using namespace std;
typedef long long LL;
typedef int ut;
typedef pair<ut,ut> pr;
typedef vector<ut> VI;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=3*1e5;
const ut INF=1LL<<60;
Vpr edge[SIZE];
int N,M,a,b,c;
int reach[SIZE];
int dijkstra(){
	PQ qu;
	qu.push(pr(0,1));
	while(!qu.empty()){
		int now=qu.top().second,times=qu.top().first;
		qu.pop();
	//	cout << now <<" " << times << endl;
		if(reach[now]<times) continue;
		REP(i,edge[now].size()){
			int next=edge[now][i].first;
			int nextT=edge[now][i].second;
			if(nextT<times) continue;
			if(next==N){
				reach[next]=max(reach[next],nextT);
				continue;
			}
			if(nextT>=reach[next]) continue;
			
			reach[next]=nextT;
			qu.push(pr(nextT,next));
		}
	}
	return reach[N];
}
signed main(){
	cin.tie(0);
	cin >> N >> M;
	FOR(i,1,N+1){
		reach[i]=INF;
	}
	reach[N]=-1;
	reach[1]=0;
	REP(i,M){
		cin >> a >> b >> c;
		edge[a].PB(pr(b,c));
	}
	cout << dijkstra() << endl;
	return 0;
}

Measured memory_bytes: 17356
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> a(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    a.push_back(0);

    int cnt = 1;
    int sum = 0;
    for(int i = 0; i < n; ++i) {
        if(a.at(i) == a.at(i+1)) {
            cnt++;
        }else {
            if(cnt % 2 == 1) {
                sum++;
            }
            cnt = 1;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[26];
int main() {
	string s;
	cin>>s;
	for(ll i=0;i<26;i++){
		ll cnt=0;
		for(ll j=0;j<s.size();j++){
			ll now=s[j]-'a';
			if(now!=i){
				cnt++;
				a[i]=max(a[i],cnt);
			}
			else{
				cnt=0;
			}
		}
		a[i]=max(a[i],cnt);
	}
	ll ans=inf;
	for(ll i=0;i<26;i++){
		ans=min(ans,a[i]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n ,k , x , y ,ans;
int main()
{

    cin >> n >> k >> x >> y;
     if (n > k)
    ans = x * k + y * (n - k);
    else 
        ans = x * n;
    cout <<ans << endl;

}




Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int height(int);

struct Node{
  int p;
  int s;
  int l;
  int r;
};

struct Node T[MAX];

int main(void){
  int n,i,j,left,right,c[MAX];
  int id[MAX],p,s,deg[MAX],dep,h[MAX];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    T[i].p = -1;
    T[i].s = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for(i = 0 ; i < n ; i++){
    scanf("%d",&id[i]);
    for(j = 0 ; j < 2 ; j++){
      scanf("%d",&c[j]);
      if(j == 0){
	left = c[j];
	T[id[i]].l = c[j];
	T[c[j]].p = id[i];
      }
      else {
	right = c[j];
	T[id[i]].r = c[j];
	T[c[j]].p = id[i];
      }
      
      if((c[0] == -1) && (c[1] == -1)) deg[id[i]] = 0;
      else if((c[0] != -1) && (c[1] != -1)) deg[id[i]] = 2;
      else deg[id[i]] = 1;
      
    }   
    T[left].s = right;
    T[right].s = left;
  }
  
  for(i = 0 ; i < n ; i++){
    h[i] = height(i);
  }
  
  for(i = 0 ; i < n ; i++){
    printf("node %d: ",i);
    printf("parent = %d, ",T[i].p);
    printf("sibling = %d, ",T[i].s);
    
    printf("degree = %d, ",deg[i]);
    
    id[i] = i;
    
    for(dep = 0 ; T[id[i]].p != -1 ; dep++){
      id[i] = T[id[i]].p;
    }   
    printf("depth = %d, ",dep);
       
    printf("height = %d, ",h[i]);
       
    if(T[i].p == -1){
      printf("root\n");
    }
    else if((T[i].p != -1) && ((T[i].l != -1) || (T[i].r != -1))){
      printf("internal node\n");
    }
    else if((T[i].l == -1) && (T[i].r == -1)){
      printf("leaf\n");
    }
  }

  return 0; 
}
 
int height(int i){
  int hl=0,hr=0;
  
  if((T[i].l == -1) && (T[i].r == -1)){
    return 0;
  }
  if(T[i].l != -1){
    hl = height(T[i].l);
  }
  if(T[i].r != -1){
    hr = height(T[i].r);
  }
  if(hl > hr){
    return hl+1;
  }
  else {
    return hr+1;
  }
}

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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.
  i32 n, k;
  string str;
  cin >> n >> str >> k;

  string ret;
  REP(i, 0, n) {
    ret += str[i] == str[k - 1] ? str[i] : '*';
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
struct RUP{
  static const int MAX_N = 1 << 18;
  int n;
  P dat[2*MAX_N-1];
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    for(int i=0;i<2*n-1;i++) dat[i].first=-1,dat[i].second=INT_MAX;
  }
  int query(int k){
    k+=n-1;
    P p=dat[k];
    while(k>0){
      k=(k-1)/2;
      p=max(p,dat[k]);
    }
    return p.second;
  }
  
  void update(int a,int b,P p,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b) {
      dat[k]=p;
    }else{
      update(a,b,p,k*2+1,l,(l+r)/2);
      update(a,b,p,k*2+2,(l+r)/2,r);
    }
  }
  
  void update(int a,int b,P p){
    update(a,b,p,0,0,n);
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  RUP rup(n);
  for(int i=0;i<q;i++){
    int f;
    cin>>f;
    if(!f){
      int s,t,x;
      cin>>s>>t>>x;
      rup.update(s,t+1,P(i,x));
    }else{
      int u;
      cin>>u;
      cout<<rup.query(u)<<endl;
    }
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

//約数列挙
vi divisors(int n){
	vi res;
	for(int i=1; i*i<=n; ++i){
		if(n%i != 0) continue;
		res.push_back(i);
		if(i*i != n) res.push_back(n/i);
	}
	return res;
}

int main(){
	int N; cin>>N;
	vi A(N);
	int max_a = 0;
	rep(i, N){
		cin>>A[i];
		max_a = max(max_a, A[i]);
	}

	vi E(max_a + 1, 0);
	rep(i, N) E[A[i]]++;

	int ans = 0;
	rep(i, N){
		bool ok = true;
		for(int d:divisors(A[i]))
			if(E[d] > 1
			|| (A[i] != d && E[d] == 1)){ ok = false; break; }
		if(ok) ans++;
	}
	cout<< ans <<endl;
}


Measured memory_bytes: 7880
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
p=[int(input()) for _ in range(n)]
res=[0]*n
for i in range(n):
    res[p[i]-1]=i

k=1
x=0
if n==1:
  print(0)
  exit()
for i in range(1,n):
    if res[i-1]<res[i]:
        k+=1
    else:
        x=max(x,k)
        k=1
x=max(x,k)
print(n-x)

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


const int mx = 100005,inf = 1e9+100000;
int dp[mx],n,arr[mx];

int solve(int i)
{
    if(i<1) return inf;
    if(i==1) return 0;

    if(dp[i]!=-1) return dp[i];

    return dp[i] = min(solve(i-1)+abs(arr[i]-arr[i-1]),solve(i-2)+abs(arr[i]-arr[i-2]));
}

main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    cout<<solve(n);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
pair<double,double> dp[1005][1005];
int main(){
	int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>=13) ans=b;
    else if(a>=6&&12>=a) ans=b/2;
    OUT(ans);
	return 0;
}

Measured memory_bytes: 384
N = int(input())
arr = [[-1]*N for i in range(N)]
num = []
for i in range(N):
    a = int(input())
    num.append(a)
    for j in range(a):
        x,y = map(int,input().split())
        x -= 1
        arr[i][x] = y

ans = 0
tf = [0]*N
for bit in range(2**N):
    jdg = True
    for i in range(N):
        tf[i] = bit%2
        bit = bit >> 1
    for a in range(N):
        if tf[a] == 1:
            for i in range(N):
                if arr[a][i] != -1:
                    if arr[a][i] != tf[i]:
                        jdg = False
                        break
        if not jdg:
            break
    if jdg:
        ans = max(ans,tf.count(1))
print(ans)

Measured memory_bytes: 45036
import java.util.Scanner;

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

		int lines = Integer.parseInt(sc.nextLine());
		for (int i = 0; i < lines; i++) {
			String line = sc.nextLine();
			String[] words = line.split(" ");

			char[] nico = new char[26];
			
			int a = 0;
			int b = 0;
			for (int j = 0; j < words.length; j++) {
				String word = words[j];
				if (word.length() == 4) {
					a = word.charAt(0) - word.charAt(1);
					
					int counter = 0;
					while (((a % 12 != 0) || (a <= 0) || (a % 24 == 0) || (a % 156 == 0)) && (counter < 12)) {
						if (a > 0) counter++;
						a = a + 26;
					}
					if (counter == 12) continue;
					a = a / 12;
					
					b = word.charAt(0) - a * 19 - 'a';
					while (b < 0) {
						b = b + 26;
					}
					
					for (int k = 0; k < nico.length; k++) {
						nico[(a * k + b) % 26] = (char)(k + 'a');
					}
					
					String tt = "";
					for (int k = 0; k < 4; k++) {
						tt = tt + nico[word.charAt(k) - 'a'];
					}
					
					if (tt.equals("this") || tt.equals("that") == true) break;
				}
			}
			
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < line.length(); j++) {
				if (Character.isAlphabetic(line.charAt(j)) == true) sb.append(nico[line.charAt(j) - 'a']);
				else sb.append(line.charAt(j));
			}
			System.out.println(sb);
		}
	}
}

Measured memory_bytes: 25836
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

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

ll A[200000];
int N;
int K;
int Ans;

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

    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    
    for(int i=0; i<N; i++){
        if(A[i] >= K) Ans++;
    }
    
    cout << Ans << endl;
    
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define fi first
#define se second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
#define le(x) (int) x.length()
#define rsz resize

using namespace std;
typedef vector <int> vi;
typedef vector <vector <int> > vii;
typedef pair <int, int> pii;
typedef queue <int> qi;
typedef double db;
typedef long long ll;
typedef long double ld;
 
const long double PI=3.141592653589793238462643383279502884;
const long long PRIME1=1e9+787;
 
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll minll(ll a,ll b) {return a<=b?a:b;}
ll maxll(ll a,ll b) {return a>=b?a:b;}

int main () {
    fast;
    int n,k;
    cin>>n>>k;
    vector <ll> a(n);
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    for (int i=k; i<n; i++) {
        if (a[i]>a[i-k]) {
            cout<<"Yes"<<"\n";
        } else {
            cout<<"No"<<"\n";
        }
    }
    return 0;
}
 
 


Measured memory_bytes: 4776
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int maxn = 2e5 + 500;
int a[maxn],b[maxn];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(a + 1, a + n + 1);
	int mid = n / 2;
	for (int i = 1; i <= n; i++)
	{
		if (b[i] <=a[mid])
			cout << a[mid+1] << endl;
		else if(b[i]>a[mid])
			cout << a[mid]<< endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define show(x) cerr << #x << " = " << x << "\n";
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
#define pb(x) push_back(x)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = INF;
class mint {
public:
	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;
	}
	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;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};

ll modpow(ll x, ll n, ll p = INF) {
	if (n == 0) return 1 % p;
	if (n % 2 == 0) return modpow(x * x % p, n / 2, p);
	else return x * modpow(x, n - 1, p) % p;
}

void Main(){

	string S;
	cin >> S;
	
	ll ans = 0;
	rep2(i, 1, S.size()) if(S[i] != S[i - 1]) ans += 1;
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll t = 1;
	//cin >> t;
	rep(i, t) Main();
	return 0;
	
}





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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int a,b,c; cin >> a >> b >> c;
    int d; cin >> d;
    if(abs(c-a) <= d) cout << "Yes" << endl;
    else if(abs(a-b)<=d && abs(b-c)<=d) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
from heapq import heappush, heappop
def dijkstra(adjList, s):
    num = len(adjList)
    dist = [float("INF") for i in range(10)]
    queue = []
    heappush(queue,(0,s))
    dist[s] = 0
    
    while queue != []:
        v_cost, v = heappop(queue)
        if dist[v] < v_cost:
            continue
        for u_cost, u in adjList[v]:
            if u != v and u_cost + dist[v] < dist[u]:
                dist[u] = u_cost + dist[v]
                heappush(queue, (dist[u], u))
    return dist

 
 
from sys import stdin
def IL():return list(map(int, stdin.readline().split()))


h,w = IL()
G = [[] for i in range(10)]
def main(): 
    for i in range(10):
        l = IL()
        for j in range(10):
            G[i].append((l[j],j))
     
     
    ans = 0
    memo={}
    for i in range(h):
        for i in IL():
            if abs(i) == 1:
              pass
            elif i in memo:
              ans += memo[i]
            else:
                t = dijkstra(G, i)[1] 
                memo[i] = t
                ans += t
    print(ans)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef string sr;
typedef pair<int, int> pii;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, ans;
    bool flag = false;
    cin >> a >> b;
    for (int i = 1; i <= 1500; ++i) {
        int x = (i * 8) / 100;
        int y = (i * 10) / 100;
        if (x == a && y == b) {
            flag = true;
            ans = i;
            break;
        }
    }
    if (flag) {
        cout << ans << "\n";
    } else cout << "-1\n";
    return 0;
}

Measured memory_bytes: 256
def get_ints():
  return list(map(int,input().split()))

n = int(input())
a,b = [],[]
for i in range(n):
  x,y = get_ints()
  a.append(x+y)
  b.append(x-y)

a.sort()
b.sort()
ans = max(a[-1]-a[0], b[-1]-b[0])
print(ans)

Measured memory_bytes: 25752
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#define INF 100000000000000
using namespace std;

int main() {
    long long a,b,c;
    long long ans=0;
    cin >> a >> b >> c;
    for(long long i=a; i<=b; i++){
        if(c%i==0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}




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

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

  vector<int> E(N, 0), W(N, 0);
  for (int i = 1; i < N; i++) {
    W[i] = W[i-1] + (S[i-1] == 'W');
    E[N-i-1] = E[N-i] + (S[N-i] == 'E');
  }

  int ans = N - 1;
  for (int i = 0; i < N; i++) {
    ans = min(ans, W[i] + E[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 5005;

ll A[N][N];
ll dp[N][N][4];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    while(k--){
    	ll x, y, z;
    	cin >> x >> y >> z;
    	A[x][y] = z; 
    }
    n++;m++;
    rep(i,1,n+1)	rep(j,1,m+1)	rep(k,0,4){
    	if(A[i][j] > 0 and k != 3){
    		dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k] + A[i][j]);
    		dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + A[i][j]);
    	}
    	dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
    	dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
    }
    cout << max(max(dp[n][m][0], dp[n][m][1]), dp[n][m][2]) << endl;
 //    rep(k,0,4){
 //    	rep(i,1,n+1)	{rep(j,1,m+1)	cout << dp[i][j][k] << " "; cout << endl;}
	// 	err();
	// }
    return 0;
}

Measured memory_bytes: 377196
#include <stdio.h>

int main()
{
 int i, j, x, y;
 scanf("%d%d", &x, &y);
 while(x != 0 && y != 0) {

  for(i = 0; i < y; i++) {
   printf("#");
  }
  printf("\n");
  for(i = 0; i < x - 2; i++) {
   printf("#");
   for(j = 0; j < y - 2; j++) {
    printf(".");
   }
   printf("#\n");
  }
  for(i = 0; i < y; i++) {
   printf("#");
  }
  printf("\n");
  printf("\n");
  scanf("%d%d", &x, &y);
 }
 return 0;
}
 

Measured memory_bytes: 588