akhauriyash/Code-Regression huggingface dataset:
/*
 * FileName:     C
 * CreatedDate:  2020-03-22 20:59:55 +0900
 * LastModified: 2020-03-22 21:50:39 +0900
 */

#include <stdio.h>

int main(void){
    long double L;
    scanf("%Lf",&L);
    printf("%Lf\n",(L/3.0)*(L/3.0)*(L/3.0));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()

 
int main() {
  ll N,M,X;
  cin>>N>>M>>X;
  vector<ll> A(M+1);
  A[0]=X;
  for(ll i=1;i<=M;i++) {
    cin>>A[i];
  }
  sort(all(A));
  ll index;
  for(ll i=0;i<M+1;i++) {
    if(A[i]==X) {
      index=i;
    }
  }
  
  cout<<min(index,M-index)<<endl;
}



  
  

Measured memory_bytes: 3580
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


a = input()
if(a.islower()):
    print('a')
else:
    print('A')


Measured memory_bytes: 27084
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_as_vec<T: FromStr>(&mut self) -> Vec<T> {
    self.iter.clone().map(|v| v.parse().ok().unwrap()).collect()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  loop {
    sc.new_line();
    let n = scan!(sc; usize);
    if n == 0 {
      break;
    }
    let mut a = 0.0;
    sc.new_line();
    let s: Vec<i64> = sc.get_as_vec();
    let m: f64 = s.iter().sum::<i64>() as f64 / n as f64;
    for i in 0..n {
      a += (s[i] as f64 - m).powf(2.0);
    }
    a = (a / n as f64).sqrt();
    println!("{}", a);
  }
}



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

int main(){
    int n,m;
    cin>>n>>m;
    
    vv road(n, vi (n,0));
    
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        road[a][b] = 1;
        road[b][a] = 1;
    }
    
    vi p(n);
    rep(i,n)p[i]=i;
    
    int ans = 0;
    
    do{
        bool ok = true;
        if(p[0]!=0)continue;
        for(int i=1; i<n; i++){
            if(road[p[i-1]][p[i]])continue;
            ok = false;
            break;
        }
        if(ok)ans++;
    } while(next_permutation(p.begin(), p.end()));
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3584
n,m=[int(j) for j in input().split()]
dp=[10**18]*(2**(n))
dp[0]=0
cost=[]
for i in range(m):
    x,y=[int(j) for j in input().split()]
    tmp=set([int(j) for j in input().split()])
    ind=0
    for j in range(1,n+1):
        if j in tmp:
            ind|=2**(j-1)
    dp[ind]=x
    cost.append((ind,x))

for i in range(2**n):
    for j in range(m):
        dp[i|cost[j][0]]=min(dp[i|cost[j][0]],dp[i]+cost[j][1])

if dp[-1]!=10**18:
    print(dp[-1])
else:
    print(-1)


Measured memory_bytes: 47704
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll> A(N,0ll),B(N,0ll);
  for(int i=0;i<N;i++)cin>>A[i];

  B[0]=0ll;
  for(int i=1;i<N;i++){
    B[i]=2*A[i-1]-B[i-1];
  }
  ll diff=B[0]/2+B[N-1]/2-A[N-1];

  for(int i=0;i<N;i++){
    if(i%2){
      cout<<B[i]+diff<<" ";
    }else{
      cout<<B[i]-diff<<" ";
    }
  }
  cout<<endl;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string>
using namespace std;
struct Res{
    int no;
    int grade;
    string citi;
};
int n;
Res r[100];
void swap(Res &a,Res &b){
    Res tmp;
    tmp=a;
    a=b;
    b=tmp;
}
void Solve(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>r[i].citi>>r[i].grade;
        r[i].no=i+1;
    }
    for(int i=0;i<n;i++)
    for(int j=0;j<n-1;j++){
        if(r[j].citi>r[j+1].citi) swap(r[j],r[j+1]);
        else if(r[j].citi==r[j+1].citi){
            if(r[j].grade<r[j+1].grade)
                swap(r[j],r[j+1]);
        } 
    }
    for(int i=0;i<n;i++) cout<<r[i].no<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll W,H;
	while(cin>>H>>W) {
		vector<string> m(H);
		REP(i, H) cin>>m[i];
		REP(y, H) REP(x, W) if(m[y][x]=='.') {
			ll co = 0;
			RANGE(dy, -1, 2) RANGE(dx, -1, 2) if(!(dx==0 && dy==0)) {
				ll X = x+dx;
				ll Y = y+dy;
				if(IN(X, 0, W) && IN(Y, 0, H) && m[Y][X]=='#') co++;
			}
			m[y][x] = co+'0';
		}
		
		REP(y, H) cout<<m[y]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split())
if x >= a**2 * b / 2:
    print(math.atan(2*(b-x/(a**2))/a) * 180 / math.pi)
else:
    print(math.atan((a*(b**2))/(2*x)) * 180 / math.pi)

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


int64_t fight(int64_t n) {
    if(n==1) return 1;
    else {
        int64_t m = n/2;
        return 2*fight(m)+1;
    }
}


int main() {
    int64_t h;
    cin>>h;

    int64_t ans = fight(h);

    cout<<ans<<endl;


    return 0;
}

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

#define endl '\n'
#define int long long

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	char ch; cin >> ch;
	if(ch >= 'A' and ch <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;

	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n];
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
    sum%=MOD;
  }
  int ans=0;
  rep(i,n){
    sum-=a[i];
    if(sum<0) sum+=MOD;
    int num=a[i]*sum%MOD;
    ans=(ans+num)%MOD;
  }
  cout<<ans<<endl;
  


  return 0;
}


Measured memory_bytes: 5212
def kakaka():
    a = list(map(int, input().split()))
    b = map(int, input().split())
    c = int(input())

def start_process():
    return
def main():
    a = int(input())
    b = list(map(int, input().split()))
    count = 0
    min_data = -1
    for i in range(a):
        if b[i] >= min_data:
            min_data = b[i]
            count += 1
    print(count)




if __name__ == '__main__':
    main()


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

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


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

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  
  auto G=make_v<Int>(n,n);
  const Int INF = 1e15;
  fill_v(G,INF);
  for(Int i=0;i<n;i++) G[i][i]=0;

  Int ans=0;
  vector<Int> c(n);
  for(Int i=0;i<m;i++){
    Int s,t,d;
    cin>>s>>t>>d;
    chmin(G[s][t],d);
    chmin(G[t][s],d);
    c[s]++;c[t]++;
    ans+=d;
  }
  
  for(Int k=0;k<n;k++)
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
	chmin(G[i][j],G[i][k]+G[k][j]);

  vector<Int> dp(1<<n,INF);
  Int x=0;
  for(Int i=0;i<n;i++) x|=(c[i]&1)<<i;
  dp[x]=0;
  for(Int b=(1<<n)-1;b>=0;b--){
    for(Int i=0;i<n;i++){
      for(Int j=0;j<i;j++){
	if((~b>>i)&1) continue;
	if((~b>>j)&1) continue;
	chmin(dp[b^(1<<i)^(1<<j)],dp[b]+G[i][j]);
      }
    }
  }
  
  cout<<ans+dp[0]<<endl;
  return 0;
}



Measured memory_bytes: 3228
import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class Main {

    static int recur(int[] a, int start, int max, int N, List<Integer> list, List<List<Integer>> Q) {
        if(list.size() == N) {
            int _max = verify(Q, list);
            if(_max > max) max = _max;
            return max;
        }
        for(int i = start; i < a.length; i++) {
            List<Integer> clone = new ArrayList<>();
            for(int k = 0; k < list.size(); k++) {
                clone.add(list.get(k));
            }
            clone.add(a[i]);
            int _max = recur(a, i, max, N, clone, Q);
            if(_max > max) max = _max;
        }
        return max;
    }

    private static int verify(List<List<Integer>> Q, List<Integer> list) {
        int sum = 0;
        for(int i = 0; i < Q.size(); i++) {
            List<Integer> l = Q.get(i);
            int a = l.get(0);
            int b = l.get(1);
            int c = l.get(2);
            int d = l.get(3);
            if(list.get(b - 1) - list.get(a - 1) == c) {
                sum += d;
            }
        }
        return sum;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String[] s = in.readLine().split(" ");
        int N = Integer.parseInt(s[0]);
        int M = Integer.parseInt(s[1]);
        int Q = Integer.parseInt(s[2]);
        List<List<Integer>> Ql = new ArrayList<>();
        while(Q-- > 0) {
            List<Integer> l = new ArrayList<>();
            s = in.readLine().split(" ");
            l.add(Integer.parseInt(s[0]));
            l.add(Integer.parseInt(s[1]));
            l.add(Integer.parseInt(s[2]));
            l.add(Integer.parseInt(s[3]));
            Ql.add(l);
        }
        int[] a = new int[M];
        for(int i = 0; i < M; i++) {
            a[i] = i + 1;
        }
        System.out.println(recur(a, 0, Integer.MIN_VALUE, N, new ArrayList<>(), Ql));
    }
}

Measured memory_bytes: 45668
# include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	string N;
  	cin >> N;
    int l = N.length();
    int digit[l + 1];
    for (int i = 0; i < l; ++i) digit[i] = N[l - 1 - i] - '0';
    digit[l] = 0;
    
    int ans = 0;
  	for (int i = 0; i <= l; ++i) {
      int num = digit[i];
      if (num < 5) {
        ans += num; 
        continue;
      }
      
      if (num > 5) {
        digit[i + 1] += 1;
        ans += 10 - num; 
        continue;
      }
      
      if (digit[i + 1] >= 5) digit[i + 1] += 1;
      ans += num; 
    }
  
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5252
import java.util.*;
class Main{
 public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int d = sc.nextInt();
      int t = 0;
   for(int i = 0;i <= a;i++){
    for(int q = 0;q <= b;q++){
      for(int h = 0; h <= c; h++){
        if(d == i * 500 + q * 100 + h * 50){
        t++;
        }
      }  
     }
    }
   System.out.println(t);
 } 
}

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

int main() {

  int N;
  cin >> N;
  vector<int>a(N);
  for (int i=0; i<N;i++){
    cin >> a.at(i);
  }
  vector<int>b(N+1);
  b.at(0) = 1;
  for (int j=0;j<N+1;j++){
    if(j>0)
    b.at(j) = a.at(b.at(j-1)-1);
    if (b.at(j) == 2){
      cout << j << endl;
      break;
    }
    else if(j == N)
      cout <<-1 << endl;
    else
      continue;
  }}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long       ll;
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define deb(x)			  cerr << "# " << (#x) << " = " << (x) << endl;
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int INF = 1234567890;

int res[10010];

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ll n;
    cin >> n;
    clr(res, 0);
    for (ll x = 1; x <= 100; x++) {
    	for (ll y = 1; y <= 100; y++) {
    		for (ll z = 1; z <= 100; z++) {
    			ll sum = x*x 
    			       + y*y 
    			       + z*z 
    			       + x*y 
    			       + x*z 
    			       + y*z;
    			if (sum > n) break;
    			res[sum]++;
    		}
    	}
    }
    fore(i, 1, n+1) {
    	cout << res[i] << '\n';
    }
    return 0;
}
// Dinosaurs are cool

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

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

ll X,Y;

int main(){
    cin >> X >> Y;
    if(X*2 > Y || X*4 < Y){
        cout << "No" << endl;
        return 0;
    }
    if(Y % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <vector>

constexpr int DAY_COUNT = 31;

struct BipartiteMatching {
    std::vector<std::vector<int>> G;
    std::vector<int> match;
    std::vector<bool> used;

    BipartiteMatching(int V) : G(V), match(V, -1), used(V, false) {}
    
    void add_edge(int u, int v)
    {
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    bool dfs(int v)
    {
        used[v] = true;
        for (int i = 0; i < (int)G[v].size(); i++) {
            int u = G[v][i], w = match[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }

    int matching()
    {
        int res = 0;
        for (int v = 0; v < (int)G.size(); v++) {
            if (match[v] < 0) {
                used.assign(used.size(), false);
                if (dfs(v)) {
                    res++;
                }
            }
        }
        return res;
    }
};

int main()
{
    int N, a, b;
    std::cin >> N;
    BipartiteMatching bm(N + DAY_COUNT);
    for (int i = 0; i < N; i++) {
	std::cin >> a >> b; a--; b--;
	for (int j = a; j <= b; j++) {
	    bm.add_edge(j, i + DAY_COUNT);
	}
    }
    
    int K = bm.matching();
    std::cout << 50 * (DAY_COUNT - K) + 100 * K << std::endl;
    
    return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,x,ans=0;
	cin>>n>>x;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(i==n-1&&x>a[i])break;
		if(x>=a[i]){
			x-=a[i];
			ans++;
		}
		else break;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

// N行M列, カード
// 初期状態: すべて表
// すべてのカードについて、そのカードと周囲8枚のカードを裏返す
// 最終状態で裏のカードを数えよ
//
// ほぼすべてのカードが自分と周りの計9枚によって裏返される
// よって裏
// あとは残りのカードをちゃんと調べるだけ

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;

    ll ans = 0;
    if (N == 1 && M == 1)ans = 1;
    else if (N == 1)ans = M - 2;
    else if (M == 1)ans = N - 2;
    else ans = (N - 2)*(M - 2);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,i,s=0;
   cin>>n;
   for(i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
        s=s+i;
    }
   }
   cout<<s<<endl;
   return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <array>

using ar = std::array<std::array<char, 50>, 50>;

bool finder(const ar& a, const ar& b, const int M, const int i, const int j);

int main() {
	ar a = {};
	ar b = {};

	int N, M;
	std::cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			char c;
			std::cin >> c;
			a[i][j] = c;
		}
	}
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < M; ++j) {
			char c;
			std::cin >> c;
			b[i][j] = c;
		}
	}

	int m = N - M;
	for (int i = 0; i <= m; ++i) {
		for (int j = 0; j <= m; ++j) {
			if (finder(a, b, M, i, j)) {
				std::cout << "Yes" << std::endl;
				return 0;
			}
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

bool finder(const ar& a, const ar& b, const int M, const int i, const int j) {
	for (int k = 0; k < M; ++k) {
		for (int l = 0; l < M; ++l) {
			if (a[i + k][j + l] != b[k][l]) {
				return false;
			}
		}
	}
	return true;
}


Measured memory_bytes: 256
n,y = map(int,input().split())
y //= 1000

for i in range(n+1):
    for j in range(n-i+1):
        if 10*i + 5*j + (n-i-j) == y:
            print(i,j,n-i-j)
            exit()
print('-1 -1 -1')

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, a, b;
vi e[114514], r;
bool t[1919810];

void dfs(int v) {
	t[v] = true;
	r.pb(v);
	rep(i,e[v].size()) {
		if (!t[e[v][i]]) {
			dfs(e[v][i]);
			break;
		}
	}
}

int main() {
	cin >> n >> m;
	rep(i,m) {
		cin >> a >> b;
		a--, b--;
		e[a].pb(b), e[b].pb(a);
	}
	// 適当な点から始まって、ある頂点で行ける点がなくなったらその頂点から行ける点は全てパスに含まれてるってことなので条件を満たす
	dfs(0);
	reverse(all(r));
	r.pop_back();
	dfs(0);
	cout << r.size() << ln;
	rep(i,r.size()) cout << r[i]+1 << (i==r.size()-1 ? '\n' : ' ');
}

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

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

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

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

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<int> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

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

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


int main() {
    int n;
    cin >> n;
    vector<ll> prices(n);
    rep(i, n) cin >> prices[i];
    vector<ll> mins(n);
    vector<ll> maxs(n);
    mins[0] = prices[0];
    rep(i, n - 1) mins[i + 1] = min(mins[i], prices[i + 1]);
    reverse(prices.begin(), prices.end());
    maxs[0] = prices[0];
    rep(i, n - 1) maxs[i + 1] = max(maxs[i], prices[i + 1]);
    reverse(maxs.begin(), maxs.end());
    ll ans = -INF;
    rep(i, n - 1) cmax(ans, maxs[i + 1] - mins[i]);

    cout << ans << endl;
}



Measured memory_bytes: 7500
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    string s; cin >> s;
    ll n = s.size();
    ll r0=0,r1=0,l0=0,l1=0;
    ll iseven = 1;
    vl ans(n,0);
    rep(i,n){
        if(s[i] == 'L'){
            iseven = 1;
            ans[i-1] += r0;
            ans[i] += r1;
            r0 = 0;
            r1 = 0;
        }else{
            if(iseven){
                r0++;
                iseven = 0;
            }else{
                r1++;
                iseven = 1;
            }
        }
    }
    iseven = 1;
    for(ll i=n-1; i>=0; i--){
        if(s[i] == 'R'){
            iseven = 1;
            ans[i+1] += l0;
            ans[i] += l1;
            l0 = 0;
            l1 = 0;
        }else{
            if(iseven){
                l0++;
                iseven = 0;
            }else{
                l1++;
                iseven = 1;
            }
        }
    }
    rep(i,n) cout << ans[i] << " ";
    cout << endl;
}

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


int main() {
    int A, B;
    cin >> A >> B;
    for(int i = 1; i < 10000000; i++){
        int aa = i * 0.08;
        int bb = i * 0.1;
        if(aa == A && bb == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct edge {
    int s, t, w;

    bool operator< (const edge& other) const {
        if (w != other.w) {
            return w < other.w;
        } else if (s != other.s) {
            return s < other.s;
        } else {
            return t < other.t;
        }
    }
};

constexpr int inf = numeric_limits<int>::max();
pair<bool, vector<int>> bellman_ford(int n, int s, const vector<edge>& edges) {
    vector<int> d(n, inf);
    bool n_cycle = false;

    d[s] = 0;
    REP(i, n) {
        bool update = false;
        for (const edge & e : edges) {
            if (d[e.s] != inf && d[e.s] + e.w < d[e.t]) {
                d[e.t] = d[e.s] + e.w;
                update = true;
            }
        }

        if (i == n-1 && update) n_cycle = true;
    }

    return {n_cycle, d};
}

int main() {
    int v, e, r; cin >> v >> e >> r;
    vector<edge> edges(e);

    REP(i, e) {
        int s, t, w; cin >> s >> t >> w;
        edges[i] = {s, t, w};
    }

    auto ret = bellman_ford(v, r, edges);

    if (!ret.first) {
        for (int d : ret.second) {
            if (d != inf) {
                cout << d << endl;
            } else {
                cout << "INF" << endl;
            }
        }
    } else {
        cout << "NEGATIVE CYCLE" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n,k,c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<int> L(k+1,-1), R(k+1,-1);
  int cnt = 1;
  rep(i,n) {
    if (s[i] == 'o') {
      L[cnt++] = i+1;
      i += c;
    }
    if (cnt == k+1) break;
  }
  cnt = k;
  for (int i = n-1; i >= 0; --i) {
    if (s[i] == 'o') {
      R[cnt--] = i+1;
      i -= c;
    }
    if (cnt == 0) break;
  }
  for (int i = 1; i <= k; ++i) {
    if (L[i] == R[i] && L[i] != -1) cout << L[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 5024
/**
 * Tree - Binary Trees
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	static final int NIL = -1;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line;

		int n = parseInt(br.readLine());
		Node[] T = new Node[n];

		StringTokenizer st;
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(br.readLine());
			int id = parseInt(st.nextToken());
			T[id] = new Node();
			T[id].node = id;
			T[id].left = parseInt(st.nextToken());
			T[id].right = parseInt(st.nextToken());
		}
		// set parent
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL) T[T[i].left].parent = i;
			if (T[i].right != NIL) T[T[i].right].parent = i;
		}
		// set depth
		int root = 0;
		while (T[root].parent != NIL) root++;
		Deque<Node> stack;

		stack = new ArrayDeque<Node>();
		stack.push(T[root]);
		while (!stack.isEmpty()) {
			Node u = stack.pop();
			if (u.left != NIL) {
				T[u.left].depth = u.depth + 1;
				stack.push(T[u.left]);
			}
			if (u.right != NIL) {
				T[u.right].depth = u.depth + 1;
				stack.push(T[u.right]);
			}
		}
		// set height
		stack = new ArrayDeque<Node>();
		stack.push(T[root]);
		while (!stack.isEmpty()) {
			Node u = stack.pop();
			if (u.height == -1) {
				u.height = 0;
				stack.push(u);
				if (u.left != NIL) stack.push(T[u.left]);
				if (u.right != NIL) stack.push(T[u.right]);
			} else {
				u.height = Math.max(
						u.left != NIL ? T[u.left].height + 1 : 0,
						u.right != NIL ? T[u.right].height + 1 : 0
				);
			}
		}
		// set sibling
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL && T[i].right != NIL) {
				T[T[i].left].sibling = T[i].right;
				T[T[i].right].sibling = T[i].left;
			}
		}
		// set degree
		for (int i = 0; i < n; i++) {
			if (T[i].left != NIL) T[i].degree++;
			if (T[i].right != NIL) T[i].degree++;
		}
		// set type
		for (int i = 0; i < n; i++) {
			if (T[i].parent == NIL) {
				T[i].type = "root";
			} else if (T[i].left != NIL || T[i].right != NIL) {
				T[i].type = "internal node";
			} else {
				T[i].type = "leaf";
			}
		}
		// print
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(T[i].toString());
		}
		System.out.print(sb.toString());
	} //end main
}

class Node {
	int node;
	int parent = -1;
	int left = -1;
	int right = -1;
	//
	int degree = 0;
	int sibling = -1;
	int depth = 0;
	int height = -1;
	String type;

	public String toString() {
		return String.format(
				"node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",
				node,
				parent,
				sibling,
				degree,
				depth,
				height,
				type);
	}
}

Measured memory_bytes: 17080
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
using namespace std;


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && a == c)
		cout << 1;
	else if (a != b && b != c && c != a)
		cout << 3;
	else
		cout << 2;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int d = sc.nextInt();
			int e = sc.nextInt();
			if(d==0 && e==0) break;
			double min = Double.MAX_VALUE;
			for(int i=0;i<d;i++) min = Math.min(min, Math.abs(e-Math.sqrt(i*i+(d-i)*(d-i))));
			System.out.println(min);
		}
	}
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	cout << (e-a <= k ? "Yay!" : ":(") << endl;

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  if (S.length() % 2 == 0) {
    for (int i = 0; i < S.length() / 2; i++) {
      cout << S[i * 2];
    }
  }
  else {
    for (int i = 0; i < S.length() / 2 + 1; i++) {
      cout << S[i * 2];
    }
  }
}

Measured memory_bytes: 512
program main
      implicit none
      integer(4) :: n, m, i
      integer(4), allocatable :: a(:)
      integer(8) :: cnt

      read *, n, m
      allocate( a(m) )
      read *, a

      cnt = 0
      do i = 1, m
        cnt = cnt + a(i)
      end do
      if ( cnt > n ) then
              print *, -1
      else
              print *, n - cnt
      end if

end program main


Measured memory_bytes: 2944
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(final InputReader in, final PrintWriter out) {
        String s = in.next();

        long ans = 0;
        for (int i = 0; i < (1 << s.length() - 1); i++) {
            StringBuilder sb = new StringBuilder(String.valueOf(s.charAt(0)));
            for (int j = 0; j < s.length() - 1; j++) {
                if (((i >> j) & 1) == 1) {
                    sb.append("+");
                }
                sb.append(s.charAt(j + 1));
            }

            String[] ss = sb.toString().split("\\+");
            for (String tmpS : ss) {
                ans += Long.parseLong(tmpS);
            }
        }

        out.println(ans);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

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

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 21972
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n := scanInt(stdin)
	stdin.Scan()
	sort := scanIntArray(stdin)

	fmt.Println(strings.Trim(fmt.Sprint(sort), "[]"))

	for i := 1; i < n; i++ {
		v := sort[i]
		j := i - 1
		for j >= 0 && sort[j] > v {
			sort[j+1] = sort[j]
			j--
		}
		sort[j+1] = v
		fmt.Println(strings.Trim(fmt.Sprint(sort), "[]"))
	}
}

func scanInt(sc *bufio.Scanner) int {
	t := sc.Text()
	i, err := strconv.Atoi(t)
	if err != nil {
		panic(err)
	}
	return i
}

func scanIntArray(sc *bufio.Scanner) []int {
	t := sc.Text()
	ss := strings.Split(t, " ")
	is := []int{}
	for _, s := range ss {
		i, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		is = append(is, i)
	}
	return is
}



Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, a[200008];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	ll sum = 0;
	rep(i, 1, n){
		cin >> a[i];
		sum += a[i];
	}
	a[0] = 0;
	ll mid = sum/2;
	ll amid;
	rep(i, 1, n){
		a[i] += a[i-1];
	}
	rep(i, 1, n){
		if(a[i] >= mid){
			amid = i;
			break;
		}
	}
	ll ans = sum-2*a[amid-1];
	if(2*a[amid]-sum <= a[amid]-amid){
		ans = min(2*a[amid]-sum, ans);
	}
	ans = min(2*a[amid]-sum, ans);
	if(sum-2*a[amid-1] <= sum-a[amid-1]-(n-amid+1)){
		ans = min(sum-2*a[amid-1], ans);
	}
	print(ans)
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,n){
        if(i+1<n && s[i]=='B' && s[i+1]=='W') ans++;
        if(i+1<n && s[i]=='W' && s[i+1]=='B') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]
con = [1 for _ in range(n+1)]
uni = UnionFind(n+1)


for i in range(m):
    a, b = ab[i]
    con[a] += 1
    con[b] += 1
    uni.Unite(a, b)

for i in range(k):
    c, d = cd[i]
    if uni.isSameGroup(c,d):
        con[c] += 1
        con[d] += 1

result = []
for i in range(1, n+1):
    result.append(uni.Count(i)-con[i])
print(*result)

Measured memory_bytes: 60676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    ll sum = 0;
    rep(i, n)sum += a[i];
    if(sum == x)cout << n << endl;
    else{
        int ans = 0;
        sort(a.begin(), a.end());
        rep(i, n-1){
            if(x >= a[i]){
                x -= a[i];
                ans++;
            }
        }
        cout << ans << endl;
    }
    
}

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

using namespace std;

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


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

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

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

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

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

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


vector<vector<int>> ab;
int main(){

    int n, m; cin >> n >> m;
    ab.resize(m+1);
    vector<int> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    rep(i, n){
        if(m-a[i] < 0) continue;
        ab[m-a[i]].emplace_back(b[i]);
    }
    ll ans = 0;
    priority_queue<ll> pq;
    for(int i = m; i >= 0; --i){
        rep(j, (int)ab[i].size()){
            pq.push(ab[i][j]);
        }
        if(!pq.empty()){
            ans += pq.top(); pq.pop();
        }
    }
    ppp(ans);



    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPR(i,n) for(int i=n-1; i>=(int)(0); i--)
#define FOR(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define FORR(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); i--)
#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()
//**関数リスト**//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) {
	ll keta = 1;
	while (F / 10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll isPrime(ll x) {
	ll i;
	if (x < 2) {
		return 0;
	}
	else if (x == 2) {
		return 1;
	}
	else if (x % 2 == 0) {
		return 0;
	}
	else {
		for (i = 3; i * i <= x; i += 2) {
			if (x % 1 == 0) {
				return 0;
			}
		}
		return 1;
	}
}
void eratos(vl isPrime) {
	//(注)isPrimeのサイズはN+1にする！実際にはmain内に配置して使用
	ll i, j;
	REP(i, isPrime.size()) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0; isPrime[1] = 0;
	for (i = 2; i * i <= isPrime.size() - 1; i++) {
		if (isPrime[i] == 1) {
			j = i * 2;
			while (j <= isPrime.size() - 1) {
				isPrime[j] = 0;
				j = j + i;
			}
		}
	}
}
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void bitSearch(ll n) {
	//実際にはコピーして中身を改変して使う
	ll i;
	REP(i, pow(2, n)) {
		ll p = i;
		REP(i, n) {
			cout << p % 2;
			p /= 2;
		}
		cout << endl;
	}
}

void bfs(ll now) {
	//中身は毎回書き換えて使用
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		//ll v=;
		//Q.push(v);
	}
}
//**定義場所**//
ll i, j, k, l, m, n;
ll N, M, K, H, W;
ll MOD = 1000000007;
ll ans = 0;
//***********//

int main() {
	cin >> N;
	vl P(N);
	vl Q(N);
	for (i = 0; i < N; i++) {
		cin >> P[i];
		Q[i] = P[i];
	}
	sort(Q.begin(), Q.end());
	ll flag = 0;
	for (i = 0; i < N; i++) {
		if (P[i] != Q[i]) {
			flag++;
		}
	}
	if (flag <= 2) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
V, E = map(int, input().split())
inf = float('inf')
dps = [[inf for _ in range(V)] for _ in range(V)]

for _ in range(E):
    s, t, d = map(int, input().split())
    dps[s][t] = d


for i in range(V):
    dps[i][i] = 0
for v in range(V):
    for i in range(V):
        for j in range(V):
            dps[i][j] = min(dps[i][j], dps[i][v] + dps[v][j])
# print(dps)
flag = False
for i in range(V):
    if dps[i][i] < 0:
        flag = True
if flag:
    print('NEGATIVE CYCLE')
else:
    for dp in dps:
        print(*['INF' if num == inf else num for num in dp])



Measured memory_bytes: 6284