akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

signed main(){
    int N;
    cin>>N;
    vint P(N);
    rep(i,N)cin>>P[i];
    int ans=0;
    rep(i,N-2)if((P[i]<P[i+1]&&P[i+1]<P[i+2])||(P[i+2]<P[i+1]&&P[i+1]<P[i]))ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
 
 
#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define rjm	rep(j,m)


#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}


#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007


vector<string> split(const string &str, char delim){
	istringstream iss(str); string tmp; vector<string> res;
	while(getline(iss, tmp, delim)) res.push_back(tmp);
	return res;
}

li interval[11];
li v[2];

inline li stoi(string s){
	return atoi(s.c_str());
}

int main(){
	string s;
	while(cin>>s){
		if(s=="h")break;
		vector<string> ss=split(s, ',');
		rep(i,10)interval[i]=stoi(ss[i]);
		rep(i,2)v[i]=stoi(ss[i+10]);

		li sum=0;
		rep(i,10)sum+=interval[i];
		double ans=(double)sum*v[0]/(v[0]+v[1]);
		//cout<<ans<<endl;
		li now=0;
		rep(i,10){
			now+=interval[i];
			if(now>=ans){
				cout<<i+1<<endl;
				break;
			}
		}
	}
	
	return 0;
}

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

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            PriorityQueue<long> myQueue = new PriorityQueue<long>(n, (x, y) => y - x);
            for(int i = 0; i < n; i++)
            {
                myQueue.Enqueue(a[i]);
            }
            
            for(int i = 0; i < m; i++)
            {
                var tmp = myQueue.Dequeue();
                tmp /= 2;
                myQueue.Enqueue(tmp);
            }
            var sum = 0L;
            for(int i = 0; i < n; i++)
            {
                sum += myQueue.Dequeue();
            }
            Console.WriteLine(sum);
            
        }
    }
    class PriorityQueue<T>
    {
        private readonly List<T> m_list;
        private readonly Func<T, T, long> m_compare;
        private int m_count;
        public PriorityQueue(int capacity, Func<T, T, long> compare)
        {
            m_list = new List<T>(capacity);
            m_compare = compare;
            m_count = 0;
        }
        private int Add(T value)
        {
            if (m_count == m_list.Count)
            {
                m_list.Add(value);
            }
            else
            {
                m_list[m_count] = value;
            }
            return m_count++;
        }
        private void Swap(int a, int b)
        {
            T tmp = m_list[a];
            m_list[a] = m_list[b];
            m_list[b] = tmp;
        }
        public void Enqueue(T value)
        {
            int c = Add(value);
            while (c > 0)
            {
                int p = (c - 1) / 2;
                if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
                c = p;
            }
        }
        public T Dequeue()
        {
            T value = m_list[0];
            m_list[0] = m_list[--m_count];
            int p = 0;
            while (true)
            {
                int c1 = p * 2 + 1;
                int c2 = p * 2 + 2;
                if (c1 >= m_count) { break; }
                int c = (c2 >= m_count || m_compare(m_list[c1], m_list[c2]) < 0) ? c1 : c2;
                if (m_compare(m_list[c], m_list[p]) < 0) { Swap(p, c); } else { break; }
                p = c;
            }
            return value;
        }
    }
}


Measured memory_bytes: 33116
n = gets.chomp.to_i
nodes = {}
ps = []
lrs = []
n.times do
    p, l, r = gets.chomp.split.map(&:to_i)
    nodes[p] = { p: p, l: l, r: r }
    ps.push(p)
    lrs.push(l, r)
end
Nodes = nodes
lrs.uniq!.sort!
root = (ps - lrs)[0]

def preParse(u)
    return if u == -1
    print " #{u}"
    preParse(Nodes[u][:l])
    preParse(Nodes[u][:r])    
end

def inParse(u)
    return if u == -1
    inParse(Nodes[u][:l])
    print " #{u}"
    inParse(Nodes[u][:r])
end

def postParse(u)
    return if u == -1
    postParse(Nodes[u][:l])
    postParse(Nodes[u][:r])
    print " #{u}"
end

puts "Preorder"
preParse(root)
puts ""

puts "Inorder"
inParse(root)
puts ""

puts "Postorder"
postParse(root)
puts ""


Measured memory_bytes: 8876
use proconio::input;

fn main() {
	input!(o: String);
	input!(e: String);

	let vo: Vec<char> = o.chars().collect();
	let ve: Vec<char> = e.chars().collect();

	for i in 0..ve.len() {
		print!("{}{}", vo[i], ve[i]);
	}
	if vo.len() > ve.len() {
		print!("{}", vo[vo.len()-1]);
	}
	println!("");
}



Measured memory_bytes: 2164
#include <iostream>
#include <algorithm>
#define roop(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,a[100],ans;
signed main(){
  cin>>n>>x;
  roop(i,n)cin>>a[i];
  sort(a,a+n);
  roop(i,n){
    if(x>=a[i]){
	  if(i!=n-1){
      x-=a[i];
      ans++;
	  }
	  else if(a[i]==x){
		  ans++;
	  }
    }
  }
  cout<<ans<<endl;
}

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

int main() {
 
  string A;
  string B;
  cin >> A >> B;
  string C = A + B;
  int D = 0;
  D = stoi(C);
  
  for (int i=1; i<=1000; i++) {
    if (D == i*i){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3612
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const s: number = +input[0];

console.log(s*s);



Measured memory_bytes: 9420
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

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

int n;

int main() {
  cin >> n;
  vector<int> l(2 * n);

  rep (i, 2*n) {
    cin >> l[i];
  }

  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());

  int ans = 0;
  rep (i, n) {
    ans += min(l[2*i], l[2*i+1]);
  }

  cout << ans << endl;
}


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

int main(){
    long long k,a,b;
    cin >> k >> a >> b;
    if(b-a>2){
        if(k<=a)cout << k+1 << endl;
        else{
            cout << b + (b-a)*((k-a-1)/2) + (k-a+1)%2 << endl;
        }
    }
    else{cout << k+1 << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char str[201];
  int i,j;
  scanf("%s",str);
  i=0;
  while(str[i]!='\0') i++;
  str[i-1]='\0';

  while(1){
    if(i%2==0){
      str[i-2]='\0';
    }
    i=0;
    while(str[i]!='\0') i++;

    for(j=0;j<i/2;j++){
      if(str[j]!=str[i/2+j]){
        break;
      }
    }
    if(j==i/2){
      printf("%d\n",i);
      break;
    }


    str[i-1]='\0';

    if(i==0){
      break;
    }

  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<pll> AB(N);
    for(auto& in:AB) cin >> in.first >> in.second;
    
    vector<ll> A(N),B(N);
    for(int i = 0; i < N;i++){
        A[i] = AB[i].first;
        B[i] = AB[i].second;
    }
    
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    
    if(N%2 == 1){
        ll L = A[N/2];
        ll R = B[N/2];
        res = R-L+1;
    }else{
        ll L = A[N/2-1] + A[N/2];
        ll R = B[N/2-1] + B[N/2];
        
        res = R-L+1;
    }
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 9532
#include <iostream>
#include <unordered_set>

int main()
{
	int n;
	std::cin >> n;
	
	std::unordered_set<int> set;
	
	for (int i = 0; i < n; ++i)
	{
		int x;
		std::cin >> x;
		set.insert(x);
	}
	
	std::cout << set.size();
}

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

int n;
int a[25];
int ans;

int main(){

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

    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i+2<n;i++){
        int b[3];
        b[0]=a[i];
        b[1]=a[i+1];
        b[2]=a[i+2];
        sort(b,b+3);
        if(a[i+1]==b[1])ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = ""
S = []
for i in range(N):
    s = input()
    S.append(s)
M = int(input())
t = ""
T = []
for i in range(M):
    t = input()
    T.append(t)
#青いカードSi * N 赤いカードTi * M
S = sorted(S)
T = sorted(T)
W = []
c = -1
num = []
for i in range(N):
    if not(S[i] in W):
        W.append(S[i])
        num.append(0)
        c += 1
        for j in range(i,N):
            if W[c] == S[j]:
                num[c] += 1
        for j in range(M):
            if W[c] == T[j]:
                num[c] -= 1
num.append(0)
print(max(num))


Measured memory_bytes: 9232
#include<iostream>
#include<string.h>

using namespace std;

int ans = 0;
int length = 0;
string s;

void calc(int i, int score, int ng, int np) {
  if (i == length) {
    ans = (ans > score) ? ans : score;
    return;
  }

  if (ng > np) {
    if (s[i] == 'g') {
      //calc(i + 1, score, ng + 1, np);
      calc(i + 1, score + 1, ng, np + 1);
    } else {
      //calc(i + 1, score - 1, ng + 1, np);
      calc(i + 1, score, ng, np + 1);
    }
  } else {
    if (s[i] == 'g') {
      calc(i + 1, score, ng + 1, np);
    } else {
      calc(i + 1, score - 1, ng + 1, np);
    }
  }
}



int main() {
  int ng = 0, np = 0;
  int score = 0;

  cin >> s;

  length = s.length();

  calc(0, 0, 0, 0);

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 512
from itertools import product


def main():
    n, a, b, c = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    ans = 10**4
    for p in product(range(4), repeat=n):
        abc = [[], [], []]
        for i, pi in enumerate(p):
            if pi > 0:
                abc[pi - 1].append(i)
        fl = False
        for i in abc:
            fl |= len(i) == 0
        if fl:
            continue
        cost = 0
        for i in range(3):
            cost += abs(sum(l[j] for j in abc[i]) - (a, b, c)[i]) + 10 * (len(abc[i]) - 1)
        ans = min(ans, cost)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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 int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int H,W,K;
char c[6][6];
signed main(){
	cin>>H>>W>>K;
	rep(i,H)rep(j,W)cin>>c[i][j];
	int ans=0;
	rep(i,1<<(H+W)){
		char d[6][6];
		rep(j,H)rep(k,W)d[j][k]=c[j][k];
		rep(j,H+W){
			if(j<H&&(i>>j&1)){
				rep(k,W)d[j][k]='R';
			}
			if(j>=H&&(i>>j&1)){
				rep(k,H)d[k][j-H]='R';
			}
		}
		int cnt=0;
		rep(j,H)rep(k,W)cnt+=d[j][k]=='#';
		if(cnt==K)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

#define KIND_OF_CARD		(4)
#define RANK_NUMBER_OF_CARD	(13)

/* ????????¨??°??? */
static int cards_array[KIND_OF_CARD][RANK_NUMBER_OF_CARD];

int main(void)
{
	int index1;
	int index2;
	int numberOfCards;
	char input_kindOfCards;
	int input_numberOfCards;

	/* ????????? */
	for(index1 = 0; index1 < KIND_OF_CARD; index1++){
		for(index2 = 0; index2 < RANK_NUMBER_OF_CARD; index2++){
			cards_array[index1][index2] = 0;
		}
	}

	/* ??\????????° */
	scanf("%d", &numberOfCards);

	for(index1 = 0; index1 < numberOfCards; index1++){
		/* ????????¨??°????????\??? */
		scanf(" %c %d", &input_kindOfCards, &input_numberOfCards);

		/* ????????????????????????????????°????¨???? */
		switch(input_kindOfCards){
			case 'S':
				cards_array[0][input_numberOfCards - 1] = 1;
				break;
			case 'H':
				cards_array[1][input_numberOfCards - 1] = 1;
				break;
			case 'C':
				cards_array[2][input_numberOfCards - 1] = 1;
				break;
			case 'D':
				cards_array[3][input_numberOfCards - 1] = 1;
				break;
			default:
				return -1;
		}
	}

	/* ?¶???????????????????????????? */
	for(index1 = 0; index1 < KIND_OF_CARD; index1++){
		for(index2 = 0; index2 < RANK_NUMBER_OF_CARD; index2++){
			if(cards_array[index1][index2] == 0){
				switch(index1){
					case 0:
						printf("S %d\n", index2 + 1);
						break;
					case 1:
						printf("H %d\n", index2 + 1);
						break;
					case 2:
						printf("C %d\n", index2 + 1);
						break;
					case 3:
						printf("D %d\n", index2 + 1);
						break;
					default:
						return -1;
				}
			};
		}
	}

	return 0;
}

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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define inf 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

int gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}

typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

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

  int same[] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1};

  string s;
  while(cin >> s, s != "#") {
    int ans = 0;
    int num = same[s[0] - 'a'];
    rep(i, 1, s.size()) {
      if(num != same[s[i] - 'a']) {
        ans++;
        num = same[s[i] - 'a'];
      }
    }
    cout << ans << endl;
  }
}



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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

long double r;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> r;
  cout << 2*acos(-1.0)*r << "\n";
}


Measured memory_bytes: 3756
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　| 　_　 _ l
　 　　　／` ミ＿xノ
　　 　 /　　　 　 |　見ちゃだめだよ！
　　　 /　 ヽ　　 ﾉ　　
　 　 │　　|　|　|　　
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)__)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  char now = s[0];
  int count = 0;
  for (int i = 1; i < s.size(); i++) {
    if (now != s[i]) {
      now = s[i];
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long X, Y;
       

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReaderL();
            X = input[0];
            Y = input[1];
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = 1;
            long cur = X;
            while (2 * cur <= Y)
            {
                ans++;
                cur *= 2;
            }

            Console.WriteLine(ans);

            //Console.Out.Flush();

        }

       
    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int max_n = 100000;
    pint n_even[100001];
    pint n_odd[100001];
    for (int i = 1; i <= N; i++)
    {
        int tmp;
        cin >> tmp;
        if (i % 2 == 0)
        {
            n_even[tmp].first++;
            n_even[tmp].second = tmp;
        }
        else
        {
            n_odd[tmp].first++;
            n_odd[tmp].second = tmp;
        }
    }

    sort(n_even, n_even + 100001, greater<pint>());
    sort(n_odd, n_odd + 100001, greater<pint>());

    int max_odd = n_odd[0].first;
    int max_even = n_even[0].first;

    if (n_odd[0].second == n_even[0].second)
    {
        if (n_odd[1].first > n_even[1].first)
        {
            max_odd = n_odd[1].first;
        }
        else
        {
            max_even = n_even[1].first;
        }
    }
    int ans = N - max_even - max_odd;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public void print(String str, int a, int b) {
        String buf = str.substring(a, b + 1);
        System.out.println(buf);
    }
    public String replace(String str, int a, int b, String p) {
        String buf1 = str.substring(0, a);
        String buf2 = str.substring(b + 1, str.length());
        return buf1.concat(p).concat(buf2);
    }
    public String reverse(String str, int a, int b) {
        char[] bufString = str.toCharArray();
        char[] tmp = new char[b - a + 1];
        for (int i = 0; i < b - a + 1; i++) {
            tmp[i] = bufString[a + i];
        }
        for (int i = 0; i < b - a + 1; i++) {
            bufString[b - i] = tmp[i];
        }
        return String.valueOf(bufString);

    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Main app = new Main();
        String pattern = scan.next();
        int numOfQ = Integer.parseInt(scan.next());

        for (int i = 0; i < numOfQ; i++) {
            String com = scan.next();
            switch (com) {
                case "print":
                    int a = Integer.parseInt(scan.next()), b = Integer.parseInt(scan.next());
                    app.print(pattern, a, b);
                    break;
                case "replace":
                    int c = Integer.parseInt(scan.next()), d = Integer.parseInt(scan.next());
                    String p = scan.next();
                    pattern = app.replace(pattern, c, d, p);
                    break;
                case "reverse":
                    int e = Integer.parseInt(scan.next()), f = Integer.parseInt(scan.next());
                    pattern = app.reverse(pattern, e, f);
                    break;
            }
        }

    }
}



Measured memory_bytes: 28876
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;

string out[] = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};

int main(){
	string s;
	while(cin>>s,s!="0"){
		int t = 0;
		for(int i = 1; i <= 6; i++){
			t *= 16;
			if('a' <= s[i] && s[i] <= 'f')
				t += s[i] - 'a' + 10;
			else
				t += s[i] - '0';
		}
		int id = -1;
		int ans = INF;
		FOR(i,8){
			int buf = t;
			int d = 0;
			FOR(j,3){
				int a = buf & 255;
				int b = (i&(1<<j)) ? 255 : 0;
				d += (a-b)*(a-b);
				buf /= 256;
			}
			if(ans > d){
				id = i;
				ans = d;
			}
		}
		cout << out[id] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
K, N = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
A.sort()
max_dis = 0
dis = 0
for i in range(len(A)):
    if i == len(A)-1:
        temp = (K-A[i])+A[0]
        if temp > max_dis:
            max_dis = temp
        dis += temp
    else:
        if A[i+1]-A[i] > max_dis:
            max_dis = A[i+1]-A[i]
        dis += A[i+1]-A[i]

print(dis-max_dis)

Measured memory_bytes: 26444
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		long a = 1;
		for (long i = 1; i <= n; i++) {
			a = a * i % 1000000007;
		}
		System.out.println(a);
	}
	
}

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

#define fi first
#define se second
#define all(X) X.begin(),X.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 300 +5;
const int lg = 20;
const int mod = 1e9 + 7;

template<class T>
void smin(T &_x, const T &_y){
	_x = min(_x, _y);
}
template<class T>
void smax(T &_x, const T &_y){
	_x = max(_x, _y);
}

string s;
bool mark[maxn];

int main(){
	ios_base::sync_with_stdio(false);cin.tie();
	cin>>s;
	int n = s.size();
	for(int i = 0; i < n; i++) mark[s[i]]= true;
	if((mark['S'] ^ mark['N']) || (mark['E'] ^ mark['W'])) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>
using namespace std;

int main() {
	int n, sum = 0;
	cin>>n;
	int b[n - 1], a[n];
	for(int i = 0; i < n - 1; i++)
		cin>>b[i];
	a[0] = b[0];
	a[1] = b[0];
	for(int i = 1; i < n - 1; i++){
			if(b[i] >= b[i - 1])
				a[i + 1] = b[i];
			else{
				a[i] = b[i];
				a[i + 1] = b[i];
			}
	}
	for(int i = 0; i < n; i++)
		sum += a[i];
	cout<<sum;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int cnt = 0;
        String a = sc.next();

        for (int i = 0; i < 3; i++) {
            String str = String.valueOf(a.charAt(i));
            if (String.valueOf(str).equals("1")) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define pb push_back
using namespace std;
namespace IO
{
    char ibuf[(1<<21)+1],*iS,*iT;
    char Get(){return (iS==iT? (iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT? EOF:*iS++)):*iS++);}
    int read(){int x=0;char ch=Get();while(ch>57||ch<48)ch=Get();while(ch>=48&&ch<=57)x=x*10+(ch^48),ch=Get();return x;}
}
using namespace IO;
const int N=100007;
vector<P>E[N];int s[N],n,Size,Root;ll ans=0;
int max(int a,int b){return a>b? a:b;}
int min(int a,int b){return a<b? a:b;}
void dfs(int u,int fa,int f)
{
    s[u]=1;int v,mx=0;
    for(P x:E[u]) if((v=x.first)^fa) dfs(v,u,f),mx=max(mx,s[v]),s[u]+=s[v],ans+=2ll*f*s[v]*x.second;
    mx=max(mx,n-s[u]),Size>mx? Size=mx,Root=u:0;
}
int main()
{
    Size=n=read();int i,u,v,w,r,f,mn=1e9;
    for(i=1;i<n;++i) u=read(),v=read(),w=read(),E[u].pb(P(v,w)),E[v].pb(P(u,w));
    dfs(1,0,0),dfs(r=Root,f=0,1);
    for(P x:E[r]) if(s[x.first]<<1==n) f=1,ans-=x.second;
    if(f) return !printf("%lld",ans);
    for(P x:E[r]) mn=min(mn,x.second);
    return !printf("%lld",ans-mn);
}


Measured memory_bytes: 16128
#include <iostream>

using namespace std;


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

	int n;
	cin >> n;

	long long a;
	long long sum = 1;
	bool flag = false;
	long long max = 1000000000000000000;
	while (n--) {
		cin >> a;

		if (a == 0) {
			cout << 0 << '\n';
			return 0;
		}

		if (max / a < sum) {
			flag = true;
		}

		sum *= a;
	}

	if (flag) cout << -1 << '\n';
	else cout << sum << '\n';
	

	return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(string a, string b)
{
    string c;
    c = a + b;
    long long num;
    long long nm;
    num = stoi(c);
    nm = sqrt(num);
    if (nm * nm == num)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string a;
    string b;
    cin >> a >> b;
    solve(a, b);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

ll solve(ll a,ll b){
    if(a>b)swap(a,b);
    if(b%a!=0){
        return solve(a,b%a)+2*(b/a)*a;
    }
    else{
        return a*(2*(b/a)-1);
    }
}

int main(void){

    ll n,x;
    cin>>n>>x;

    cout<<solve(x,n-x)+n<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main () {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int cost[] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  vector<int> dp(n+1, -1);
  dp[0] = 0;
  FOR(i, 1, n+1) {
    rep(j, m) {
      if (i-cost[a[j]-1] < 0) continue;
      dp[i] = max(dp[i], dp[i-cost[a[j]-1]]+1);
    }
  }
  int k = n;
  rep(i, dp[n]) {
    rep(j, m) {
      if (k-cost[a[j]-1] < 0) continue;
      if (dp[k] == dp[k-cost[a[j]-1]]+1) {
        cout << a[j];
        k -= cost[a[j]-1];
        break;
      }
    }
  }
  cout << endl;
}

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

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

    int one;
    one = B + C;
    int two;
    two = one - A;

    if (two <= 0){
        cout << "0" << endl;
    }

    else if (two >= 0){
        cout << two << endl;
    }



}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(n);
  int x;
  vector<vector<int>> a(n, vector<int>(0));
  for (int i = 0; i < n; i++) {
    cin >> k.at(i);
    for (int j = 0; j < k.at(i); j++) {
      cin >> x;
      a.at(i).push_back(x);
    }
  }
  vector<int> ans = a.at(0);
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < ans.size(); j++) {
      for (int l = 0; l < k.at(i); l++) {
        if (ans.at(j) == a.at(i).at(l)) break;
        if (l == k.at(i) - 1) {
          ans.erase(ans.begin() + j);
          j--;
          if (ans.size() == 0) {
            cout << 0 << endl;
            return 0;
          }
        }
      }
    }
  }
  cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N, P; cin >> N >> P;
    map<long long, int> D;
    for (long long i = 2; i * i <= P; i++) {
        while (P % i == 0) {
            D[i]++;
            P /= i;
        }
    }
    if (P != 1) D[P]++;
    long long ans = 1;
    for (auto p : D) {
        while (p.second >= N) {
            ans *= p.first;
            p.second -= N;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def one_stroke_path(path, graph, i):
    if len(path) == N:
        return 1
    if not graph[i]:
        return 0
    if graph[i] in path:
        return 0
    res = 0
    for node in graph[i]:
        if not node in path:
            res += one_stroke_path(path + [node], graph, node)
    return res

N, M = map(int, input().split())
graph = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

ans = 0
path = [0]
i = 0

print(one_stroke_path(path, graph, i))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<pair<ll, int>> menu(N); // d, t 
  rep(i, N) cin >> menu[i].second >> menu[i].first;

  sort(menu.begin(), menu.end());
  reverse(menu.begin(), menu.end());  // dが大きい順

  // menu を 初期解 ... 確定ネタ、被りネタ
  // と、交代ネタ　と、 使わないネタに分ける
  ll S0 = 0; // 確定ネタと初期被りネタの d の和
  priority_queue<ll> S1_r; // 被りネタのd * -1
  priority_queue<ll> T; // 交代ネタのd

  map<int, int> used; // <id, 使用数>
  // menu の最初のK個は 初期解になる
  int neta = 0;
  rep(i, K) {
    int id = menu[i].second;
    if(used[id]==0) {
      used[id] = 1;
      S0 += menu[i].first;
      neta++;
    } else if(used[id]==1) {
      S0 += menu[i].first;
      S1_r.push(-1 * menu[i].first);
    }
  }
  // menu のK+1個目以降は、各ネタで最高d のみ交代ネタに入る
  rep2(i, K, N) {
    int id = menu[i].second;
    if(used[id]==0) {
      T.push(menu[i].first);
      used[id] = 1;
    }
  }

  vector<ll> f(N+1, -1e18);
  f[neta] = S0;
  int neta0 = neta;

  while(!S1_r.empty() && !T.empty()) {
    f[neta+1] = f[neta] + S1_r.top() + T.top();
    S1_r.pop();
    T.pop();
    neta++;
  }

 
  ll ans = 0;
  rep2(i, neta0, neta+1) {
    //cout << f[i] << ' ';
    ans = max(ans, f[i] + (ll)i*i);
  }
  // cout << endl;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7672
import sys
def ipnput():
    return sys.stdin.readline()[:-1]
from _collections import deque
n,m=map(int,input().split())
edg=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edg[a].append(b)
    edg[b].append(a)
dep=[-1]*(n+1)
dep[1]=0
data=deque([1])
while len(data)>0:
    p=data.popleft()
    for i in edg[p]:
        if dep[i]==-1:
            dep[i]=dep[p]+1
            data.append(i)
print("POSSIBLE" if dep[n]==2 else "IMPOSSIBLE")


Measured memory_bytes: 111892
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc158_a.cpp
 * time   : Sat May  2 19:39:16 2020
 * quest  : A - Station and Bus
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  cout << ((s[0] != s[1] || s[1] != s[2]) ? "Yes\n" : "No\n");
  return 0;
}


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector< vector<bool> > done;

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

    int H, W;
    cin >> H >> W;
    done.resize(H, vector<bool>(W, false));

    char aznable;
    queue< pair<int, int> > q;
    rep (i, H)
    {
        rep (j, W)
        {
            cin >> aznable;
            if (aznable == '#')
            {
                q.push(make_pair(i, j));
                done[i][j] = true;
            }
        }
    }

    int ans = 0;
    while (!q.empty())
    {
        ++ans;
        int s = q.size();
        rep (i, s)
        {
            int xx = q.front().first;
            int yy = q.front().second;
            q.pop();
            if (xx + 1 < H && !done[xx + 1][yy]) { done[xx + 1][yy] = true; q.push(make_pair(xx + 1, yy)); }
            if (xx - 1 >= 0 && !done[xx  - 1][yy]) { done[xx - 1][yy] = true; q.push(make_pair(xx - 1, yy)); }
            if (yy + 1 < W && !done[xx][yy + 1]) { done[xx][yy + 1] = true; q.push(make_pair(xx, yy + 1)); }
            if (yy - 1 >= 0 && !done[xx][yy - 1]) { done[xx][yy - 1] = true; q.push(make_pair(xx, yy - 1)); }
        }
    }
    cout << ans - 1 << "\n";
    return 0;
}



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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int n, m; cin >> n >> m;
  vector<int> b(n, 1);
  vector<bool> f(n, false);
  f[0] = true;
  REP(i,m) {
    int x, y; cin >> x >> y;
    x--; y--;
    b[x]--; b[y]++;
    if (f[x]) f[y] = true;
    if (b[x] == 0) f[x] = false;
  }
  int ans = 0;
  REP(i,n) {
    if (f[i] && b[i] > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2,tune=native")

#include <x86intrin.h>
#include <bits/stdc++.h>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    long long N, A[5];
    cin >> N >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
    sort(A, A + 5);
    cout << (long long) ceil((double) N / (double) A[0]) + 4;
    return 0;
}

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

void Main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a%2==0 && (a%3!=0 && a%5!=0)) {
            cout << "DENIED" << endl;
            return;
        }
    }
    
    cout << "APPROVED" << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 2;
const llong inf = 1e18 + 9;

using namespace std;

llong n, k, dp[mxn], sum = 0, w, c;
vector <llong> v1, v2;

int main(){
    sanyes
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> w >> c;
        sum += c;
        v1.pb(w);
        v2.pb(c); 
    }for (int i = 1; i <= sum; i ++){
        dp[i] = inf;
    }for (int i = 0; i < n; i ++){
        for (int j = sum; j >= v2[i]; j --){
            dp[j] = min(dp[j], dp[j - v2[i]] + v1[i]);
        }
    }for (int i = sum; i >= 0; i --){
        if(dp[i] <= k){
            cout << i;
            return 0;
        }
    }return 0;
}

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

const ll INF = 1001001001;
const ll mod = 1000000007;

int main(){
    int n, u, v; cin >> n >> u >> v;
    --u; --v;
    if(u == v){
        cout << 0 << endl;
        return 0;
    }
    vector<int> dist_u(n, -1), dist_v(n, -1);
    vector<vector<int>> G(n);
    for(int i = 0; i < n - 1; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que;
    que.push(u);
    dist_u[u] = 0;
    dist_v[v] = 0;
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int nv : G[v]){
            if(dist_u[nv] != -1) continue;
            dist_u[nv] = dist_u[v] + 1;
            que.push(nv);
        }
    }
    que.push(v);
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int nv : G[v]){
            if(dist_v[nv] != -1) continue;
            dist_v[nv] = dist_v[v] + 1;
            que.push(nv);
        }
    }
    set<int> st;
    for(int i = 0; i < n; i++){
        if(dist_u[i] < dist_v[i]) st.insert(dist_v[i]);
    }
    sort(dist_v.begin(), dist_v.end(), greater<int>());
    for(int i = 0; i < n; i++){
        if(st.count(dist_v[i])){
            cout << dist_v[i] - 1 << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 12964
x, n = map(int, input().split())
p = list(map(int, input().split()))

set_p = set(p)

num = 2000
ans = 0
for i in range(200, -1 , -1):
    if i not in set_p:
        if num >= abs(x - i):
            num = abs(x - i)
            ans = i

print(ans)

Measured memory_bytes: 9036
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
static decimal result;
static List<int> s=new List<int>();
  static int N,A,B;
    static void Main()
    {
      //N=int.Parse(Console.ReadLine());
      Read();
      if(N*A>B){result=B;}else{result=N*A;}
                    Console.WriteLine(result.ToString());
    }

static void Read()
{
  string[] tmp=Console.ReadLine().Split(' ');
for(int i=0;i<3;i++){s.Add(int.Parse(tmp[i]));}
        N=s[0];
      A=s[1];
      B=s[2];
}
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include <cfenv>
#include <cmath>
#include <utility>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

typedef pair<int, int> pair;

int main(){
    ll N;
    ll ans=0;
    cin >> N;
    vector<ll> A(N,0);
    vector<ll> B(2,0);
    vector< vector<ll> > V(N,B);
    for (int i = 0; i < N; i++){
        cin >> A[i];
        if(i+A[i] < N) V[i+A[i]][1] += 1;
        if(i-A[i] >= 0) V[i-A[i]][0] += 1;
    }
    for (int i = 0; i < N; i++){
        // cout << i;
        if(V[i][0] > 0 && V[i][1] > 0){
            ans += V[i][0] * V[i][1];
        }
    }
    cout << ans << endl;
}

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

int main(){
	int t=0,s=0;
  	string S;cin>>S;
  	for(int i=0;i<S.size();i++){
    	if(S[i]=='T'){
          if(s>0)s--;
          else t++;
        }else{
    	 s++;	
        }
    }
      cout<<s+t<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll OO = 1e9+7;
using namespace std;
int main() {
    IO;
    int n; cin>>n;
  ll sum=0;
    forr(i,1,n){
        if(i%3==0 || i%5==0) continue;
        sum+=i;
    }
    cout<<sum;


    


}

Measured memory_bytes: 3652