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

ll div(ll n,ll C,ll D){
    ll nC = n/C;
    ll nD = n/D;

    ll r = C % D;
    ll t = C * D;
    while (r != 0) {
        C = D; D = r; r = C % D;
    }
    return n - (nC + nD) + n / (t / D);
}

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(C<D){
        ll tmp = C; C = D; D = tmp;
    }
    cout << div(B,C,D) - div(A-1,C,D) << "\n";
}

Measured memory_bytes: 256
from sys import stdin

def printGraph(hen, graphList):
  print(hen)
  for (i,j) in graphList:
    print("{} {}".format(i, j))

N,K = map(int,stdin.readline().rstrip().split())

maxNum = (N-1)*(N-2)/2
if K > maxNum:
  print("-1")
  exit()

# star
graphList=[]
for i in range(1,N,1):
  graphList.append((i,N))

counter=0
hen=N-1
for i in range(1,N,1):
  for j in range(1,N,1):
    if counter == maxNum - K:
      printGraph(hen,graphList)
      exit()       
    if i < j:
      graphList.append((i,j))
      counter+=1
      hen+=1   

Measured memory_bytes: 42856
import itertools
import numpy as np
X=int(input())
t=0
for i in range(0,1000):
    if t==-1:
        break
    for j in range(-1000,1000):
        #print(i,end=" ")
        #print(j)
        if i**5-j**5==X:
            print(i,end=" ")
            print(j)
            t=-1
            break

Measured memory_bytes: 27080
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n;
  cin>>n;

  vector<int> dp(n+1,100000);
  dp[0]=0;
  int mon[12] = { 1,6,36,216,1296,7776,46656,9,81,729,6561,59049};

  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<12;j++)
    {
      if((i+mon[j])<=n) dp[i+mon[j]]=min(dp[i]+1,dp[i+mon[j]]);
    }
  }

  cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a = []
if n % k == 0:
  print(0)

elif n // k == 0 :
  if -(n - k) > n :
    print(n)
  else :
    print(-(n - k))

else :
  if n % k > (n % k) - k :
    print(-((n % k) - k))
  else :
    print(n % k) 

Measured memory_bytes: 3060
def solve():
    N, K = map(int, input().split())
    
    m_max = (N - 1) * (N - 2) // 2
    if m_max < K:
        print(-1)
        exit()
    
    M = 0
    graph = [[] for _ in range(N + 1)]
    for i in range(2, N + 1):
        graph[1].append(i)
        M += 1
    
    cnt = m_max - K
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            if cnt == 0:
                break
            graph[i].append(j)
            cnt -= 1
            M += 1
        else:
            continue
        break
    
    print(M)
    for parent in range(1, N + 1):
        for child in graph[parent]:
            print(parent, child)


if __name__ == '__main__':
    solve()


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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    //-----------------------------------
    int ans=0;
    rep(i,N){
        while(A[i]%2==0){
            ans++;
            A[i]/=2;
        }
    }


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

Measured memory_bytes: 256
program main
	implicit none
    integer(8)::a,b,c,d,e,f
    integer(8)::g,h,i
    read(*,*) a,b,c
    if(a>b)then
    	d=a-b
    else
    	d=b-a
    end if
    if(c>b)then
    	e=c-b
    else
    	e=b-c
    end if
    if(a>c)then
    	f=a-c
    else
    	f=c-a
    end if
    
    if (d==0 .and. e==0 .and. f==0)then
    	if(mod(a,2)==0)then
    		write(*,*) -1
        else
        	write(*,*) 0
        end if
    
    else
    	if (d==0)then
        	g=1000000000
        else
        	g=0
    		do while(mod(d,2)==0)
    			d=d/2
            	g=g+1
        	end do
        end if
        if (e==0)then
        	h=1000000000
        else
        	h=0
    		do while(mod(e,2)==0)
    			e=e/2
            	h=h+1
        	end do
        end if
        if (f==0)then
        	i=1000000000
        else
        	i=0
    		do while(mod(f,2)==0)
    			f=f/2
            	i=i+1
        	end do
        end if
        
        write(*,*) min(g,min(h,i))
    end if
    stop
end program main

        
        


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 = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    int K; cin >> K;
    for(int i = 0; i < S.length(); i+=K) cout << S[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int x,int k)
{
    int r=1;
    while(k)
    {
        if(k&1)r=1ll*r*x%mod;
        k>>=1;x=1ll*x*x%mod;
    }
    return r;
}
int n;
int a[200200];
int d[200200];
int D[200200];

struct Node{
    int sum,cnt;
    Node operator + (const Node &o)const{
        Node res;
        res.sum=add(sum,o.sum);
        res.cnt=cnt+o.cnt;
        return res;
    }
    Node operator - (const Node &o)const{
        Node res;
        res.sum=add(sum,mod-o.sum);
        res.cnt=cnt-o.cnt;
        return res;
    }
};
struct Bit{
    Node C[2000200];
    int lb(int x){return x&(-x);}
    void ins(int x,Node v)
    {
//        cout<<"ins: sum: "<<v.sum<<endl;
        while(x<=n)C[x]=C[x]+v,x+=lb(x);
    }
    void clear(int x){while(x<=n)C[x]=(Node){0,0},x+=lb(x);}
    Node ask(int x)
    {
        Node r;r.sum=r.cnt=0;
        while(x)r=r+C[x],x-=lb(x);
        return r;
    }
    Node query(int l,int r){return ask(r)-ask(l-1);}
}bit;
struct B2{
    int C[2000200];
    int lb(int x){return x&(-x);}
    void ins(int x){while(x<=n)C[x]++,x+=lb(x);}
    int ask(int x)
    {
        int r=0;
        while(x)r+=C[x],x-=lb(x);
        return r;
    }
    int query(int l,int r){return ask(r)-ask(l-1);}
}b2;

int pos[200200];
bool cmp(int x,int y){return a[x]<a[y];}
int zero[200200];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
        scanf("%d",&a[i]),d[a[i]]++,pos[i]=i;
    for(int i=n;i;--i)d[i]+=d[i+1];
    int S=1;
    D[0]=1;
    for(int i=1;i<=n;++i)
    {
        d[i]=max(0,d[i]-n+i);
        int tmp=1ll*(d[i]-1)*qpow(d[i],mod-2)%mod;
        if(!tmp)zero[i]=zero[i-1]+1,D[i]=D[i-1];
        else zero[i]=zero[i-1],D[i]=1ll*D[i-1]*tmp%mod;
        S=1ll*S*d[i]%mod;
    }
//    for(int i=1;i<=n;++i)cout<<d[i]<<" ";cout<<endl;
//    for(int i=1;i<=n;++i)cout<<D[i]<<" ";cout<<endl;
    if(!S){puts("0");return 0;}
//    cout<<"S: "<<S<<endl;

    sort(pos+1,pos+n+1,cmp);
    int p,ans=0;
    int mul,sum;
    int inv2=qpow(2,mod-2);
    Node cur;
    for(int i=1,la=1;i<=n;++i)
    {
        p=pos[i];//a[p]从小到大插入p
        if(zero[a[p]]-zero[a[pos[i-1]]])//i和上一个之间有0
        {
//            cout<<"zero: "<<a[p]<<endl;
            for(int j=la;j<i;++j) bit.clear(pos[j]);
            la=i;
        }
//        cout<<endl;
//        cout<<"i: "<<i<<" p: "<<p<<" a[p]: "<<a[p]<<endl;
        mul=1ll*S*D[a[p]]%mod;
        cur=bit.query(1,p-1);
//        cout<<"j<p,a[j]<a[p]: cnt: "<<cur.cnt<<" sum: "<<cur.sum<<endl;
//        cout<<"ade: "<<1ll*cur.sum*mul%mod*inv2%mod<<endl;
        ade(ans,1ll*cur.sum*mul%mod*inv2%mod);

        cur=bit.query(p+1,n);
        ade(ans,1ll*b2.query(p+1,n)*S%mod);
        ade(ans,mod-1ll*cur.sum*mul%mod*inv2%mod);
//        if(zero[a[p]]==zero[a[p]-1])
            bit.ins(p,(Node){qpow(D[a[p]],mod-2),1});
        b2.ins(p);
    }
    printf("%d\n",ans);
    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  vector<int> p = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

  int n;
  while (cin >> n) {
    vector<int> v;
    each (i, p) if (i <= n) v.push_back(i);

    map<int, int> fact;
    for (int x = 2; x <= n; ++x) {
      int y = x;
      each (i, v) {
        while (y % i == 0) {
          y /= i;
          ++fact[i];
        }
      }
    }

    const int N = 100;
    const int M = 100;
    int dp[N][M];
    fill(&dp[0][0], &dp[N - 1][M - 1] + 1, 0);
    dp[0][1] = 1;
    for (int i = 0; i < v.size(); ++i) {
      for (int j = 0; j < M; ++j) {
        for (int k = 0; k <= fact[v[i]]; ++k) {
          if (j * (k + 1) < M) {
            dp[i + 1][j * (k + 1)] += dp[i][j];
          }
        }
      }
    }
    cout << dp[v.size()][75] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import scala.annotation.tailrec
object Main extends App {

  import scala.io.StdIn._
  val mod = 1000000007L
  val Array(n, k) = readLine.trim.split(' ').map(_.toInt)
  var result = 0L
  for (i <- k to n + 1) {
    result += 1 + sum(n, i) % mod
    result += mod - sum(i - 1) % mod
    result %= mod
  }
  println(result)

  def sum(n: Long): Long = {
    n * (n + 1) / 2
  }
  def sum(upper: Long, count: Long): Long = {
    sum(upper) - sum(upper - count)
  }
}

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

int main() {
  ll N;
  cin >> N;
  Graph g(N+1);
  for (int i = 2; i <= N; i++) {
    ll a;
    cin >> a;
    g.at(a).push_back(i);
  }
  for (int i = 1; i <= N; i++) {
  	cout << g.at(i).size() << endl;
  }
}

Measured memory_bytes: 13960
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll sum = 0;
    sum += min(K, A);
    if (A + B < K) {
        sum -= min(K - A - B, C);
    }
    cout << sum << endl;
    return 0;
}



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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int ans = 0;
  for(int sum = 0; sum < N; sum = sum + X){
    ans = ans + T;
  }
  cout << ans << endl;

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3592
import java.util.*;
import javax.lang.model.util.ElementScanner6;
import java.lang.Math;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        int m = sc.nextInt();

        // 処理
        //n
        int np = 0;
        if ( n >= 2){
            np = n * (n - 1) / 2;
        }
        //m
        int mp = 0;
        if ( m >= 2){
            mp = m * (m - 1) / 2;
        }

        int out = np + mp;

        // 出力
        System.out.println(out);
    }
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int main() {
   int a, b;
   cin >> a >> b;
   cout << max({a+b, a-b, a*b}) << endl;

   return 0;
}

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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 2.1e6);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}

Measured memory_bytes: 70768
#include<bits/stdc++.h>
using namespace std;
typedef stack<int> stk;
int n,m;
vector<int> ga[100010];
int x,y;
int indeg[100010];
int dp[100010];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y;
		ga[x].push_back(y);
		indeg[y]++;
	}
	stk S;
	for(int i=1;i<=n;i++){
		if(indeg[i]==0)
		   S.push(i);
	}
	int ans=0;
	while(!S.empty()){
		int cur=S.top();
		S.pop();
		ans=max(ans,dp[cur]);
		for(int i=0;i<ga[cur].size();i++){
			int nxt=ga[cur][i];
			dp[nxt]=max(dp[nxt],dp[cur]+1);
			indeg[nxt]--;
			if(indeg[nxt]==0)
			   S.push(nxt);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6528
from heapq import heappop, heappush
from collections import defaultdict


class Dijkstra:
    """Graph input:
    {
    node:{node:cost,node:cost...},
    node:{node:cost,node:cost...},
    ...
    }
    """

    def __init__(self, graph: dict, N: int):
        self.graph = graph
        self.costs = [float("inf")] * N

    def calculate(self, start):
        queue = list()

        # step1: push the start point into the priority queue
        self.costs[start] = 0
        heappush(queue, (0, start))  # (cost,node)

        while queue:
            # step2: get the minimum cost node from unfixed node and fix the cost
            cost_from_start, min_node = heappop(queue)

            # step3: update the direct connected nodes
            for link, cost in self.graph[min_node].items():
                if cost_from_start + cost < self.costs[link]:
                    self.costs[link] = cost_from_start + cost
                    heappush(queue, (self.costs[link], link))

        return self.costs


n = int(input())
graph = defaultdict(dict)

for _ in range(n):
    data = [int(i) for i in input().split()]
    u = data[0]
    count = data[1]
    for j in range(1, count + 1):
        v = data[2 * j]
        w = data[2 * j + 1]
        graph[u][v] = w

dijkstra = Dijkstra(graph, n)
costs = dijkstra.calculate(0)

for i in range(n):
    print(i, costs[i])



Measured memory_bytes: 6420
#include<stdio.h>
int main(){
  int n,ans=0;
  scanf("%d",&n);
  if(n==100000){
    ans=100000-10000+1000-100+10-1;
  }
  else if(n<100000 && n>=10000){
    ans=1000-100+10-1+n-10000+1;
  }
  else if(n<10000 && n>=1000){
    ans=1000-100+10-1;
  }
  else if(n<1000 && n>=100){
    ans=10-1+n-100+1;
  }
  else if(n<100 && n>=10){
    ans=10-1;
  }
  else{
    ans=n-1+1;
  }
  printf("%d\n",ans);
  return 0;
}


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

long AT(long h){
  if(h==1) return 1;
  return 2*AT(h/2)+1;
}


int main(){
  long h; cin>>h;
  cout<<AT(h);
}

Measured memory_bytes: 256
d=[list(map(int,input().split()))for i in range(3)]
row=int(input())
num=[int(input()) for j in range(row)]
bingo=0
for a in range(3):
  if d[0][a] in num and d[1][a] in num and d[2][a] in num:
    bingo=bingo+1
  if d[a][0] in num and d[a][1] in num and d[a][2] in num:
    bingo=bingo+1
if d[1][1] in num and d[2][2] in num and d[0][0] in num:
  bingo=bingo+1
if d[1][1] in num and d[0][2] in num and d[2][0] in num:
  bingo=bingo+1
if bingo>0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	const int MAX_K = 1000;
	int N, K, a[MAX_K], b[MAX_K];
	
	scanf("%d", &N);
	scanf("%d", &K);
	for(int i = 0; i < K; i++){
		scanf("%d%d", &a[i], &b[i]);
	}
	
	for(int i = 0; i < K; i++){
		if(b[i] > (N + 1) / 2) b[i] = N - b[i] + 1;
		if(a[i] > (N + 1) / 2) a[i] = N - a[i] + 1;
		
		if(a[i] > b[i]) swap(a[i], b[i]);
		printf("%d\n", (a[i] - 1) % 3 + 1);
	}
	
	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
using Graph = vector<vector<int>>;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A==B && B == C) cout << "No" << endl;
    else if(A==B || B== C|| C == A) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  vector<int> A(3); cin >> A[0] >> A[1] >> A[2];
  int ans = 1000000000;
  do {
    int ans1 = abs(A[1] - A[0]) + abs(A[2] - A[1]);
    ans = min(ans, ans1);
  } while(next_permutation(A.begin(), A.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 char ch[1000000];
int main(){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
    	 cout<<s[i];
    }
    cout<<endl;
    return 0;
   }

Measured memory_bytes: 3600
#include <stdio.h>

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int arr[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
		if (i >= k) {
			arr[i] > arr[i - k] ? puts("Yes") : puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 2408
import java.util.Scanner;

public class Main {
	public static void main(final String[] args) {
		Scanner s = new Scanner(System.in);
		String z = s.next();
		if (z.charAt(2) == z.charAt(3) && z.charAt(4) == z.charAt(5))
		{
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<list>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<inttypes.h>
using namespace std;
#define REP(i,m,n) for(int i = (m); i < (n);i++)
#define rep(i,n) REP(i,0,n)

int main() {
	uint64_t n;
	cin >> n;
	uint64_t result = 1;
	rep(i,n) {
		result = result * (1+i) % 1000000007;
	}
	cout << result << endl;
		
	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
s, x, y = 0, 0, 0
n.times do
  n_s, n_x, n_y = gets.chomp.split.map(&:to_i)
  d_x = (n_x - x).abs
  d_y = (n_y - y).abs
  diff = (d_x + d_y) - (n_s - s)
  if diff > 0 or diff % 2 != 0
    puts "No"
    exit 0
  end
  s, x, y = n_s, n_x, n_y
end

puts "Yes"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll k; cin>>k;
    string s; cin>>s;
    if(s.size()<=k) cout<<s<<endl;
    else{
        cout<<s.substr(0, k)<<"..."<<endl;
    }
    return 0;
}

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

int t[1005], a[1005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n ; i++)
    {
        scanf("%d %d",&t[i],&a[i]);
    }
    long long x = t[0];
    long long y = a[0];
    for(int i = 1; i < n ; i++)
    {
        long long k = (x + t[i] - 1) / t[i];
        k = max(k, (y + a[i] - 1) / a[i]);
        x = t[i] * k;
        y = a[i] * k;
       // cout << x << ' ' << y << endl;
    }
    printf("%lld\n", x + y);
    return 0;
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  vector<long long> p(n), c(n);
  for (auto &x : p) {
    cin >> x;
    x--;
  }
  for (auto &x : c) cin >> x;
  long long ans = -1e18;
  for (int i = 0; i < n; ++i) {
    int j = p[i];
    int idx = 1;
    long long cur = c[j], mx = cur;
    vector<long long> gain(n+1, 0);
    gain[1] = mx;
    while (idx < k && j != i) {
      j = p[j];
      cur += c[j];
      if (cur > mx) mx = cur;
      gain[++idx] = mx;
    }
    long long cand = -1e18;
    if (j == i) {
      if (k%idx == 0) {
        cand = max(k/idx-1, 0) * cur + mx;
      } else {
        cand = max(k/idx, 0) * cur + gain[k%idx];
      }
    }
    mx = max(mx, cand);
    if (mx > ans) ans = mx;
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int w,h,n;
	cin>>w>>h>>n;
	int res[w+5][h+5];
	memset(res,0,sizeof res);
	for(int i=0;i<n;++i){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1){
			for(int i=1;i<=x;++i)
				for(int j=1;j<=h;++j)
					res[i][j]=1;
		}
		if(a==2){
			for(int i=x+1;i<=w;++i)
				for(int j=1;j<=h;++j)
					res[i][j]=1;
		}
		if(a==3){
			for(int i=1;i<=w;++i)
				for(int j=1;j<=y;++j)
					res[i][j]=1;
		}
		if(a==4){
			for(int i=1;i<=w;++i)
				for(int j=y+1;j<=h;++j)
					res[i][j]=1;
		}
	}
	int cnt=0;
	for(int i=1;i<=w;++i)
		for(int j=1;j<=h;++j)
			cnt+=res[i][j]==0;
	cout<<cnt<<'\n';

}




Measured memory_bytes: 3668
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i * 4 <= n;i++)
  {
    int sum = n - (i * 4);
    if(sum%7==0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
 
#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int o = 0;
        int point = 0;
        int stt[3] = { 0 };
        while (o < 3){
            string s;
            cin >> s;
            if (s.compare("HIT") == 0) {
                if (stt[2] == 1) {
                    point++;
                }
                for (int j = 2; j > 0; j--) {
                    stt[j] = stt[j - 1];
                }
                stt[0] = 1;
            } else if (s.compare("HOMERUN") == 0) {
                for (int j = 0; j < 3; j++) {
                    if (stt[j] == 1) {
                        point++;
                    }
                    stt[j] = 0;
                }
                point++;
            } else if (s.compare("OUT") == 0) {
                o = o++;
            }
        }
        cout << point << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
from collections import Counter
N, K = map(int , input().split())
A = list(map(int, input().split()))

c = Counter(A)

#ある数の個数が少ないものから順に数字を書き換えればよい
sort_by_nums = sorted(c.items(), key=lambda x: x[1])

ans = 0
for i in range(len(sort_by_nums) - K):
  ans += sort_by_nums[i][1]

print(ans)


Measured memory_bytes: 39352
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
from collections import Counter
import heapq

import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


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


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A = zz()
counter = Counter(A)
num_count = counter.most_common()
if (len(num_count) <= K):
    print(0)
    exit()

values, counts = zip(*num_count[K:])
print(sum(counts))


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

namespace ABCTemplate_C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var c = new ProblemC();
        }
    }

    public class ProblemC
    {
        public ProblemC()
        {
            // 整数の入力
            int l = int.Parse(Console.ReadLine());
            double pow = l * l * l;

            //出力
            Console.WriteLine(pow / 27.0);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n;
    cin >> n;

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

    vector<ll> dp(n, 0);
    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        ll min1 = dp[i - 1] + abs(h[i] - h[i - 1]);
        ll min2 = 1e18;

        if (i - 2 >= 0) {
            min2 = dp[i - 2] + abs(h[i] - h[i - 2]);
        }

        dp[i] = min(min1, min2);
    }

    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<functional>
typedef long long ll;
#define INF 99999999
int main() {
	int a = 0, b = 0, c = 0, n = 0;
	int ar[100000] = {};
	std::string str;
	std::cin >> a >> b;
	n += a - 1;
	if (b >= a) {
		n++;
	}
	std::cout << n << std::endl;
	return 0;
}


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

using namespace std;

inline int gcd(int x, int y) {
    while (x > 0 && y > 0) {
        int c = x % y;
        x = y, y = c;
    }
    return x + y;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; ++i) for (int j = 1; j <= k; ++j) for (int z = 1; z <= k; ++z) ans += gcd(i, gcd(j, z));
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 3652
//file_name:ABC71_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);


    if(abs(n-a)<abs(n-b)){
        puts("A");
    }else{
        puts("B");
    }

    return 0;
}



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

using namespace std;

int main() {
  // M: dp[i][j] is the number of ways to distribute
  // candies to the first i kids (1-idx) with j candies left over
  
  cin.tie(0);
  cin.sync_with_stdio(0);

  long long n, k; cin >> n >> k;
  long long a[n];
  for(int i = 0; i<n; ++i) {
    cin >> a[i];
  }
  long long MOD = 1e9+7;
  long long dp[n+1][k+1];
  for(int i = 0; i<=n; ++i) {
    for(int j = 0; j<=k; ++j) {
      dp[i][j] = 0;
    }
  }

  dp[0][k] = 1;

  for(int i = 0; i<n; ++i) {
    vector<int> dpsums(k+2, 0);
    for(int j = 0; j<=k; ++j) {
      dpsums[j+1] = (dpsums[j] + dp[i][j]) % MOD;
    }
    for(int j = 0; j<=k; ++j) {
      // wait a minute... this is too slow!
      // there's nk states, but a[i] transitions,
      // so it's O(n*k^2), which is way TLEing
      //
      // like imagine you've gone through the first i kids
      // and have some dp state
      // j   = 0, 1, 2, 3, 4, 5, ...
      // dp  = a, b, c, d, e, f, ...
      // so we want the next dp state to be
      // dp' = a+b+c+d+e+f+..., b+c+d+e+f+..., ...
      // which you can do with prefix sums I guess
      dp[i+1][j] = (dpsums[min(k, j+a[i])+1] - dpsums[j] + MOD) % MOD;
      // bleh
    }
  }

  cout << dp[n][0] << endl;
}


Measured memory_bytes: 79616
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <unordered_map>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll N;
    cin >> N;

    int i = 1;
    while(true){
        if(i * (i + 1) / 2 == N){
            break;
        }
        if(i * (i + 1) / 2 > N){
            cout << "No" << endl;
            return 0;
        }
        i ++;
    }
    vector<int>* vecArray = new vector<int>[i + 1]; 
    cout << "Yes" << endl;
    cout << i + 1 << endl;
    ll cnt = 0;
    for(ll j1 = 0; j1 < i; j1++){
        for(ll j2 = j1 + 1; j2 < i + 1; j2++){
            vecArray[j1].push_back(cnt + 1);
            vecArray[j2].push_back(cnt + 1);
            cnt ++;
        }
    }

    for(int vecIndex = 0; vecIndex < i + 1; vecIndex ++){
        vector<int> vec = vecArray[vecIndex];
        cout << i << " ";
        for(int index = 0; index < vec.size(); index++){
            cout << vec[index];
            if(index != vec.size() - 1){
                cout << " ";
            }
        }
        cout << endl;
    }
    
    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    ans = 3 * n * n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
l,r = map(int,input().split())

mn = 4038

if (r - l) >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            tmp = (i * j) % 2019
            if tmp < mn:
                mn = tmp
    print(mn)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll A,B,C;
  cin >> A >> B >> C;
  if (A%2 != 0 || B%2 != 0 || C%2 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (A==B&&B==C) {
    cout << -1 << endl;
    return 0;
  }
  ll ans = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    ll Ar = A;
    ll Br = B;
    ll Cr = C;
    A = (Br/2) + (Cr/2);
    B = (Cr/2) + (Ar/2);
    C = (Ar/2) + (Br/2);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n, count=0, now_p, i;
  cin >> n;
  vector<int> light(n+2);
  now_p = 1;
  
  for(i=1; i<=n; i++) cin >> light.at(i);
  
  for(i=1; i<=n; i++){
    if(light.at(now_p) == 2) {
     count++; 
     break;
    }
    else if (count == n-1){
      count = -1;
      break;
    }
    else {
     count++;
     now_p = light.at(now_p);
    }
  }  

  cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int n;
  R n;
  vector<P> v[n];
  rep(i,n-1) {
    ll x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    v[x].pb(P(y,z));
    v[y].pb(P(x,z));
  }
  ll T,z;
  cin >> T >> z;
  z--;
  ll d[n];
  fill(d,d+n,MAXL);
  d[z]=0;
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,z));
  while(!que.empty()) {
    P p=que.top();que.pop();
    ll x=p.S,c=p.F;
    if(d[x]<c) continue;
    rep(i,v[x].size()) {
      ll y=v[x][i].F,cc=v[x][i].S;
      if(d[y]>d[x]+cc) {
        d[y]=d[x]+cc;
        que.push(P(d[y],y));
      }
    }
  }
  while(T--) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    pr(d[x]+d[y]);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
namespace std{
  bool operator < (const P &a,const P &b){
    return (a.real()<b.real()||(a.real()==b.real() && a.imag()<b.imag()));
  }
}
 
double eps=1e-10;
 
double Sqrt(double x){
  return sqrt(max(0.0,x));
}
 
struct S{
  P p,q;
  S(P p,P q):p(p),q(q){}
};
 
struct C{
  P p;
  double r;
  C(P p,double r):p(p),r(r){}
  C(double x,double y,double r):p(P(x,y)),r(r){}
};
 
S getInTangent(C a,C b,double flg=1.0){
  P base=b.p-a.p;
  double w=a.r+b.r;
  double h=Sqrt(norm(base)-w*w);
  P k=base*P(w,h*flg)/norm(base);
  return S(a.p+k*a.r,b.p-k*b.r);
}
 
S getOutTangent(C a,C b,double flg=1.0){
  P base=b.p-a.p;
  double h=b.r-a.r;
  double w=Sqrt(norm(base)-h*h);
  P k=base*P(w,h*flg)/norm(base)*P(0,flg);
  return S(a.p+k*a.r,b.p+k*b.r);
}
 
vector<S> getTangent(C a,C b){
  vector<S> res;
  double dist=abs(a.p-b.p);
   
  if(dist>a.r+b.r+eps)
    res.push_back(getInTangent(a,b,1));
 
  if(dist>a.r+b.r-eps)
    res.push_back(getInTangent(a,b,-1));
 
  if(dist>abs(a.r-b.r)+eps)
    res.push_back(getOutTangent(a,b,1));
 
  if(dist>abs(a.r-b.r)-eps)
    res.push_back(getOutTangent(a,b,-1));
 
  return res;
}
 
 
 
void pr(P p){
  printf("%.10f %.10f\n",p.real(),p.imag());
}
 
int main(){
  double ax,ay,ar,bx,by,br;
  cin>>ax>>ay>>ar>>bx>>by>>br;
  vector<S> ans=getTangent(C(ax,ay,ar),C(bx,by,br));
  vector<P> vec;
  for(int i=0;i<(int)ans.size();i++)vec.push_back(ans[i].p);
  sort(vec.begin(),vec.end());
  for(int i=0;i<(int)vec.size();i++)pr(vec[i]);
  return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout(v) if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;



void Main()	
{
	int N;
	cin>>N;
	string S;
	cin>>S;
	char before=-1;
	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(before != S[i]){
			cnt++;
		}
		before = S[i];
	}
	cout<<cnt<<endl;
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int h, w;
char mp[105][105];
int j_ans[105][105];
int dx[] = { 1,0};
int dy[] = { 0,1};

/*void bfs(int a, int b) {
	queue<P> que;
	que.push(P(a, b));
	j_ans[a][b] = (mp[a][b] == '#' ? 1 : 0);
	while (!que.empty()) {
		P p = que.front(); que.pop();
		rep(i, 2) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
			if (mp[p.first][p.second] != '#' && mp[nx][ny] == '#') j_ans[nx][ny] = min(j_ans[nx][ny], j_ans[p.first][p.second] + 1);
			else j_ans[nx][ny] = min(j_ans[nx][ny], j_ans[p.first][p.second]);
			que.push(P(nx, ny));
		}
	}
	return;
}*/

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> w;
	rep(i, h)rep(j, w) cin >> mp[i][j];
	rep(i, h)rep(j, w) j_ans[i][j] = inf;
	/*bfs(0, 0);
	dunk(j_ans[h - 1][w - 1]);*/
	vector<vector<int>> dp(h + 1, vector<int>(w + 1));
	rep(i, h)rep(j, w) dp[i][j] = inf;
	dp[0][0] = (mp[0][0] == '#' ? 1 : 0);
	rep(i, h)rep(j, w)rep(k,2) {
		if (mp[i][j] == '.' && mp[i + dx[k]][j + dy[k]] == '#') {
			dp[i + dx[k]][j + dy[k]] = min(dp[i + dx[k]][j + dy[k]], dp[i][j] + 1);
			continue;
		}
		dp[i + dx[k]][j + dy[k]] = min(dp[i + dx[k]][j + dy[k]], dp[i][j]);
	}
	
	dunk(dp[h - 1][w - 1]);
	return 0;
}

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

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

Measured memory_bytes: 1156
max = [0,0,0]
for a in range(10):
    s = int(input())
    if max[0] < s:
        max[2] = max[1]
        max[1] = max[0]
        max[0] = s
    elif max[1] < s:
        max[2] = max[1]
        max[1] = s
    elif max[2] < s:
        max[2] = s
for a in max:
    print(a)


Measured memory_bytes: 5600
n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split())) + [0]
ans, tmp_b = 0, 0

for i in range(n+1):
    ans += min(al[i], tmp_b+bl[i])
    tmp_b = max(0, bl[i] - max(0, al[i]-tmp_b))
    # print(ans, tmp_b)

print(ans)



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

#define MAXN (100010)

int n;
int a[MAXN];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++ i){
		scanf("%d", a + i);
	}
	std::sort(a, n + a);
	int ans = std::unique(a, n + a) - a;
	if(!(ans & 1)) -- ans;
	printf("%d\n", ans);
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, w;
    cin >> n >> w;
    ll w1, v;
    vector<vector<ll>> we(4);
    cin >> w1 >> v;
    we[0].push_back(v);

    rep(i,n-1){
        ll a, b;
        cin >> a >> b;
        a -= w1;
        we[a].push_back(b);
    }

    rep(i,4) if(!we[i].empty()) sort(we[i].begin(), we[i].end(), greater<ll>());
    
    rep(i,4) if(!we[i].empty()) rep(j,we[i].size()-1) we[i][j+1] += we[i][j];

    ll ans = 0;
    
    for(int i = 0; i <= n; i++){
        if(i > we[0].size()) continue;
        for(int j = 0; j <= n-i; j++){
            if(j > we[1].size()) continue;
            for(int k = 0; k <= n-i-j; k++){
                if(k > we[2].size()) continue;
                for(int l = 0; l <= n-i-j-k; l++){
                    if(l > we[3].size()) continue;
                    if(w1*(i+j+k+l)+j+k*2+l*3 > w) continue;
                    ll sum = 0;
                    if(i > 0) sum += we[0][i-1];
                    if(j > 0) sum += we[1][j-1];
                    if(k > 0) sum += we[2][k-1];
                    if(l > 0) sum += we[3][l-1];
                    ans = max(ans, sum);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
N = gets.to_i
A = gets.split.map(&:to_i)

def selection_sort(a, n)
  count = 0

  0.upto(N - 1) do |i|
    min_j = i

    i.upto(N - 1) do |j|
      min_j = j if a[j] < a[min_j]
    end

    unless i == min_j
      a[i], a[min_j] = a[min_j], a[i]
      count += 1
    end

  end

  puts a.join(' ')
  puts count
end

selection_sort(A, N)

Measured memory_bytes: 8680