akhauriyash/Code-Regression huggingface dataset:
a, b, c, d = map(int, input().split())

def how_many(a, b, c):
    A, B = (a-1)//c, b//c
    return B-A

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return a*b//gcd(a, b)

cm = how_many(a, b, c)
dm = how_many(a, b, d)
cdm = how_many(a, b, lcm(c, d))
print(b-a+1-(cm+dm)+cdm)

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

int main() {
  int N;
  string S, answer;
  
  cin >> N;
  answer = "Three";
  
  for ( int i = 0; i < N; i++ ) {
    cin >> S;
    if ( S == "Y" ) {
		answer = "Four";
    }
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
N, K, S = gets_i_list

s = S == 1 ? S + 1 : S - 1

ans = [S] * K + [s] * (N - K)
puts ans.join(" ")

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

int main() {

  ll N;
  cin >> N;

  vector<ll> A(N);
  for(ll i = 0; i < N ; i++){
    cin >> A[i];
  }
  ll ans = 0;
  sort(A.begin(), A.end(), greater<ll>());


 for(ll i = 1; i < N;i++){
   ans += A[i/2];
 }
  cout << ans << endl;

return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll X,Y;
    string S;
    cin >> X>>Y;

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

    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const ld pi = 3.14159265359;

bool check(ld a, ld b, ld x, ld angle) {
    ld diag = sqrtl(a * a + b * b);
    ld ang = asin(a / diag);
    if (angle > asinl(a / diag)) {
        ld l = b - a * tanl(pi / 2 - angle);
        ld v = l * a + (b - l) * a / 2;
        if (a * (l * a + (b - l) * a / 2) > x) {
            return true;
        } else {
            return false;
        }
    } else {
        if (a * b * b * tanl(angle) / 2 > x) {
            return true;
        } else {
            return false;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ld a, b;
    cin >> a >> b;
    ld x;
    cin >> x;
    ld l = 0, r = pi / 2;
    while (fabsl(r - l) > 1e-8) {
        ld mid = (r + l) / 2;
        ld angle = (mid / pi) * 180.0;
        if (check(a, b, x, mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << fixed << setprecision(10) << 90.0 - (l / pi) * 180.0;
}


Measured memory_bytes: 256
// abc047_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int w,h,n,x,y,a,xo=0,yo=0;
  cin >> w >> h >> n;
  for(int i=0;i<n;++i) {
    cin >> x >> y >> a;
    if (a == 1) {
      xo=max(x,xo);
    } else if (a == 2) {
      w=min(w,x);
    } else if (a == 3) {
      yo=max(yo,y);
    } else {
      h=min(h,y);
    }
  }
  cout << max(0,h-yo)*max(0,w-xo) << endl;
  return 0;
}


Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/icl/interval_map.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> D;

  invec<int> c(26);
  vector<vector<int>> s(D, vector<int>(26));
  for (auto&& i : s)
    for (auto&& j : i)
      cin >> j;
  vector<int> t(D);
  int last[26] = {0};
  ll r = 0, cost = 0;

  constexpr int BEAM = 8;
  using node = tuple<int, int>;
  REP(i, 26)
    cost += c[i];
  const int tier = cost;
  REP(i, D) {
    pair<ll, int> cand = {-99999999999999999, 0};
    
    REP(j, 26)
      cand = max(cand, make_pair(r + s[i][j], j));
    t[i] = cand.second + 1;
    
    const int plan = t[i] - 1;
    r += s[i][plan];
    cost -= c[plan] * (i + 1 - last[plan]);
    last[plan] = i + 1;
    r -= cost;
    cost += tier;
    cout << t[i] << endl;
  }
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3672
package main

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

func solve(a, b int64) int64 {
	if a == 0 || b == 0 {
		return 0
	}
	if a < b && b%a == 0 {
		return (b/a)*a*2 - a
	}
	if a > b && a%b == 0 {
		return (a/b)*b*2 - b
	}
	if a < b {
		return solve(a, b%a) + (b/a)*a*2
	}
	if a > b {
		return solve(a%b, b) + (a/b)*b*2
	}
	return a
}

func main() {
	fsc := NewFastScanner()
	N, K := fsc.NextInt64(), fsc.NextInt64()
	result := solve(K, N-K) + K + (N - K)
	// fmt.Println(20 / 3)
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	ll N;
	cin >> N;
	vector<ll> vec(N);
	rep(i, N) cin >> vec[i];

	vector<ll> subsum(N + 1);
	rep(i, N + 1) {
		if (i == 0) subsum[i] = 0;
		else subsum[i] = subsum[i - 1] + vec[i - 1];
	}

	debug(subsum);

	vector<ll> L(N, 0);
	vector<ll> F(N, 0);

	F[0] = 0;
	L[0] = 2;

	for (ll i = 1; i <= N - 3; i++) {

		ll tmp = F[i - 1];

		while (1) {
			if (tmp == i - 1) break;
			if (abs(subsum[tmp + 1] - subsum[0] - subsum[i + 1] + subsum[tmp + 1]) < abs(subsum[tmp + 2] - subsum[0] - subsum[i + 1] + subsum[tmp + 2])) break;
			tmp++;
		}

		F[i] = tmp;

		tmp = L[i - 1];

		while (1) {
			if (tmp == N - 2) break;
			if (abs(subsum[tmp + 1] - subsum[i + 1] - subsum[N] + subsum[tmp + 1]) < abs(subsum[tmp + 2] - subsum[i + 1] - subsum[N] + subsum[tmp + 2])) break;
			tmp++;
		}

		L[i] = tmp;
	}

	debug(F);
	debug(L);

	ll ans = LLONG_MAX;

	for (ll i = 1; i <= N - 3; i++) {

		ll el1 = subsum[F[i] + 1] - subsum[0];
		ll el2 = subsum[i + 1] - subsum[F[i] + 1];
		ll el3 = subsum[L[i] + 1] - subsum[i + 1];
		ll el4 = subsum[N] - subsum[L[i] + 1];

		ll mx = max(el1, max(el2, max(el3, el4)));
		ll mn = min(el1, min(el2, min(el3, el4)));

		ans = min(ans, mx - mn);
	}

	cout << ans;

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


Measured memory_bytes: 6528
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

fn main() {
    input! {
        s: String,
    }
    let sc: Vec<u32> = s.chars().map(|x| x.to_digit(10).unwrap()).collect();
    let sum: u32 = sc.iter().sum();
    if sum % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 3192
main = do
    snml <- getLine
    ss <- getContents
    let nums = map (\x -> read x :: Int) $ words snml
    let (n,m,l) = (nums!!0, nums!!1, nums!!2)
    let ns = map (map (\x -> read x :: Int)) $ map words $ lines ss
    let (ma, mb) = (take n ns, drop n ns)
    let mc = matrixC ma mb n m l
    mapM_ putStrLn $ map unwords $ map (map show) mc


matrixC ma mb n m l = map (\i -> [(formula ma mb i j m) | j<-[0..l-1]]) [0..n-1]

formula ma mb i j m = sum $ map (\k -> (ma!!i!!k) * (mb!!k!!j)) [0..m-1]



Measured memory_bytes: 12316
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg

using namespace std;
typedef long long ll;

using namespace std;
int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int total_m1 = h1 * 60 + m1;
    int total_m2 = h2 * 60 + m2;

    int dif = total_m2 - total_m1;


    cout << dif - k << endl;
}



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

int main(){
    int n,m; cin >> n >> m;
    priority_queue<int> a;
    rep(i,n){
        int A;cin >> A;
        a.push(A);
    }
    rep(i,m){
        int am = a.top();
        a.pop();
        am /= 2;
        a.push(am);
    }
    ll ans = 0;
    rep(i,n){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    double n, l, d;
    cin >> n >> l >> d;
    double ans = 2.0 * (n - d) / (n * n) * (l - 1.0);
    if(d == 0) ans /= 2.0;
    printf("%.15f\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}


int main() {
  int n,m; cin >> n >> m;
  vector<pair<int,int>> x(m);
  rep(i,m) {
    cin >> x[i].second >> x[i].first;
    --x[i].first, --x[i].second;
  }

  vector<int> r2l(n, -1);
  for(auto [r,l] : x) {
    umax(r2l[r], l);
  }

  int d = -1;
  int ans = 0;
  rep(r,n) {
    if (r2l[r] != -1) {
      int l = r2l[r];
      if(l >= d) {
        ++ans;
        d = r;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4468
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
        int a, b;
        cin >> a >> b;
        if (a == b)
                cout << "Draw" << endl;
        else if (a == 1 || b == 1)
                cout << (a == 1 ? "Alice" : "Bob") << endl;
        else
                cout << (a > b ? "Alice" : "Bob") << endl;

        return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

result="*"*n

for _ in range(m):
    s,c=map(int,input().split())
    if result[s-1]=="*":
        result=result[:s-1]+str(c)+result[s:]
        #print(result)
    elif result[s-1]!=str(c):
        print(-1)
        exit()

if result[0]=="0" and len(result)==1:
    print(0)
    exit()

if result[0]=="0":
    print(-1)
    exit()
result2=result.replace("*","0")

result2=int(result2)
result2=str(result2)


if len(result2)==n:
    print(int(result2))
else:
    temp=10**(n-1)
    print(int(result2)+temp)
    


Measured memory_bytes: 38384
package main

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

func main() {
	n, m := readInt(), readInt()
	cnt := map[int]int{}
	for i := 0; i < m; i++ {
		cnt[i+1] = 0
	}

	for i := 0; i < n; i++ {
		k := readInt()
		for j := 0; j < k; j++ {
			cnt[readInt()]++
		}
	}

	ans := 0
	for _, v := range cnt {
		if v == n {
			ans++
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
N = int(input())
XL = [list(map(int,input().split())) for _ in range(N)]
r_l = []
for n in range(N):
  xl = XL[n]
  x = xl[0]
  l = xl[1]
  r_l.append([x-l,x+l])

r_l = sorted(r_l,key = lambda x:x[1])
ans = 1
l = r_l[0][1]
for a in r_l:
  if a[0]<l:
    continue
  else:
    ans += 1
    l = a[1]
    
print(ans)

Measured memory_bytes: 75480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = String.valueOf(a);
		
		for (int i=0; i<s.length(); i++){
			
			char c = s.charAt(i);
			if (c == '1'){
				System.out.print("9");
			}
			else {
				System.out.print("1");
				
			}
			
		}
		
		System.out.println("");
		
		
		
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
	for(int i=1;i<=4;i++)scanf("%1d",&a[i]);
	if(a[1]==a[2]||a[2]==a[3]||a[3]==a[4])puts("Bad");
	else puts("Good");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int N;
    string S;
    cin >> N >> S;
    bool ok = true;
    if(N % 2 == 1) ok = false;
    else{
        REP(i, N / 2){
            if(S[i] != S[N / 2 + i]) ok = false;
        }
    }
    if(ok) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
 
const int MAX = 100005;
 
LL a[MAX];
LL b[MAX];
 
LL s[MAX];
int main()
{
 //  freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
 
    int n;
    cin>>n;
    FOR(i,0,n)
    {
    	cin>>a[i]>>b[i];
    }
 
    FOR(i,0,n)
    {
    	s[i] = (b[i] - a[i]%b[i])%b[i];
    }
 
    LL ans = s[n-1];
 
    RFOR(i,n-1,0)
    {
    	a[i] += ans;
    	ans += (b[i]-a[i]%b[i])%b[i];
    }
 
    cout<<ans;
	return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int count=0;
  for(int i=1;i<=n;i++)
   { if(i%2!=0)
       count++;}
  float y=(float)count/n;
  float x=0.0000000000;
 x+=y;
  cout<<fixed<<setprecision(6)<<x;
  cout<<"0000"<<endl;
  return 0;
}

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

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> go(n+1);
    for(int i=0;i<n;i++){
        cin >> go.at(i+1);
    }

    int now=1;
    vector<int> flag(n+1);
    flag.at(1)=1;
    while(flag.at(go.at(now))!=1){
        now = go.at(now);
        flag.at(now) = 1;
    }
    int start=go.at(now);
    now = start;
    vector<int> roop;
    roop.push_back(now);
    while(go.at(now)!=start){
        now = go.at(now);
        roop.push_back(now);
    }

    now=1;
    int i=0;
    while(now!=roop.at(0)&&i<k){
        now = go.at(now);
        i++;
    }
    if(i==k){
        cout << now << endl;
    }else{
        int nokori=(k-i)%roop.size();
        cout << roop.at(nokori) << endl;
    }
}


Measured memory_bytes: 5680
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    string s;
    while (getline(cin, s)) {
        stringstream ss;
        ss << s;
        int a, l, x;
        ss >> a >> l >> x;
        auto r = l / 2.0 * sqrt(x * x + 2.0 * l * x) +
                 a / 4.0 * sqrt(4.0 * l * l - a * a);
        cout << setprecision(17) << r << endl;
    }
}

Measured memory_bytes: 3236
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b,j,v=0,f = 1;
    cin>>a;
    int A[a];
    for(int i=0;i<a;i++){
        cin>>A[i];
    }
    while(f){
        f=0;
        for(int j=a-1;j>0;j--){
            if(A[j]<A[j-1]){
              b=A[j];
              A[j]=A[j-1];
              A[j-1]=b;
              f=1;
              v++;
            }
        }
    }

    for(int i=0;i<a;i++){
        if(i==a-1){
            cout<<A[i]<<endl;
            cout<<v<<endl;
        }else{
            cout<<A[i]<<" ";
        }
    }

    /*for(int i=0;i<a;i++){
        if(i==a-1){
            cout<<A[i]<<endl;
        }else{
        cout<<A[i]<<" ";
        }
    }*/
    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>

using Int = long long int;
using std::vector;

struct Data {
    Int ans, sum, l, r;
    Data() : ans(0), sum(0), l(0), r(0) {}
};

struct SegmentTree {
    int len;
    vector<Data> dat;

    SegmentTree(int n) {
        len = 1;
        while (len < n) len <<= 1;
        dat.resize(len * 2 - 1);
    }

    Data update(int idx, Int x, int nidx, int nl, int nr) {
        if (nl <= idx && idx < nr) {
            if (nr - nl == 1) {
                dat[nidx].sum = x;
                dat[nidx].ans = dat[nidx].l = dat[nidx].r = std::max(0LL, x);
            } else {
                int nm = (nl + nr) / 2;
                Data l = update(idx, x, nidx * 2 + 1, nl, nm),
                     r = update(idx, x, nidx * 2 + 2, nm, nr);

                dat[nidx].sum = l.sum + r.sum;
                dat[nidx].ans = std::max({l.ans, r.ans, l.r + r.l});
                dat[nidx].l = std::max(l.l, l.sum + r.l);
                dat[nidx].r = std::max(r.r, r.sum + l.r);
            }
        }
        return dat[nidx];
    }

    Int update(int idx, Int x) {
        return update(idx, x, 0, 0, len).ans;
    }
};

int main() {
    int n, q;
    std::cin >> n >> q;

    SegmentTree seg(n);
    Int ans;
    for (int i = 0; i < n; ++i) {
        Int x;
        std::cin >> x;
        ans = seg.update(i, x);
    }
    std::cout << ans << std::endl;

    for (int i = 0; i < q; ++i) {
        int k;
        Int x;
        std::cin >> k >> x;
        --k;
        std::cout << seg.update(k, x) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 11040
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll>vec;
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        vec.push_back(a);
    }
    sort(vec.rbegin(),vec.rend());
    x=vec[0];
    a=1;
    b=0;
    for(i=3;i<=n;i++)
    {
        x+=vec[a];
        b++;
        if(b==2)
        {
            a++;
            b=0;
        }

    }
    cout<<x<<endl;
}


Measured memory_bytes: 5340
using System;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] input = Console.ReadLine().ToCharArray();

            for (int i = 0;i < input.Length; i++)
            {
                if (char.IsUpper(input[i]))
                {
                    input[i] = char.ToLower(input[i]);
                }
                else
                {
                    input[i] = char.ToUpper(input[i]);
                }
            }

            Console.WriteLine(input);
        }
    }
}

Measured memory_bytes: 9228
#
# abc179 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """apple"""
        output = """apples"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """bus"""
        output = """buses"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """box"""
        output = """boxs"""
        self.assertIO(input, output)


def resolve():
    S = input()
    if S[-1] == "s":
        print(S+"es")
    else:
        print(S+"s")


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define ff first
#define tcase int _; cin>> _; for( ; _; --_)
#define ss second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	for(;exp; exp>>=1){
		if(exp % 2 == 1) total = mod(((mod(total, m)) * (mod(base, m))), m);
		base= mod((mod(base, m) * mod(base, m)), m);
	}
	return total;
}

int n;

void solve(){
    string s, t;
    cin>> s >> t;
    
    int mx = 0;
    for(int i = 0; i <= s.size() - t.size(); ++i){
        int c = 0;
        for(int j = 0; j < t.size(); ++j) 
            if(s[i + j] == t[j]) ++c;

        mx = max(mx, c);
    }
    cout << t.size() - mx << endl;
}

int32_t main(){
	fastio;
	solve();
	return 0;
}



Measured memory_bytes: 3660
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sum(a)
for i in range(n-1,-1,-1):
  if a[i+1] < b[i]:  
    a[i] = max(0, a[i]-b[i]+a[i+1])
    a[i+1] = 0
  else:
    a[i+1] -= b[i]
print(s-sum(a))

Measured memory_bytes: 24152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) 1e9
#define tt ll testcase; cin>>testcase; while(testcase--)
 
int main(){
	fast;
	int n;
	cin>>n;
	int a[n], b[n], c[n];
	for(int i =0 ; i<n; i++){
		cin>> a[i] >> b[i] >> c[i];
	}
	int dp[n+1][3]={};
	for(int i = 1; i <= n; i++){
		dp[i][0] = a[i-1] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = b[i-1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = c[i-1] + max(dp[i-1][0], dp[i-1][1]);
	}
	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>

using namespace std;

int main(void){
	
	int A,B;
	
	cin>>A>>B;
	
	
	if(B%A==0)
		cout<<A+B<<endl;
	else
		cout<<B-A<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int h, w;
  cin >> h >> w;
  char c[h][w];
  rep(i, h) rep(j, w) cin >> c[i][j];

  vector<vector<int> > table(h, vector<int>(w));
  rep(i, h) rep(j, w) if (c[i][j] == '.') table[i][j] = 1;

  vector<vector<int> > table3(h, vector<int>(w));
  rep(k, 4) {
    vector<vector<int> > table2 = table;
    if (k == 0) {
      rep(i, h) rep3(j, 1, w) if (c[i][j] == '.') table2[i][j] += table2[i][j - 1];
    } else if (k == 1) {
      // cout << k << endl;
      rep(i, h) for (int j = w - 2; j >= 0; --j) if (c[i][j] == '.') table2[i][j] += table2[i][j + 1];
    } else if (k == 2) {
      rep3(i, 1, h) rep(j, w) if (c[i][j] == '.') table2[i][j] += table2[i - 1][j];
    } else {
      for (int i = h - 2; i >= 0; --i) rep(j, w) if (c[i][j] == '.') table2[i][j] += table2[i + 1][j];
    }
    rep(i, h) rep(j, w) table3[i][j] += table2[i][j];
    // cout << endl; rep(i, h) cout << table2[i] << endl;
  }
  // rep(i, h) cout << table3[i] << endl;
  int ans = 0;
  rep(i, h) rep(j, w) chmax(ans, table3[i][j]);
  cout << ans - 3 << endl;
}


Measured memory_bytes: 51328
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
using state=struct{P p;int num;};
int dy[4]={0,1,0,-1};
int dx[4]={1,0,-1,0};
 
int main(){
    int R,C;
    cin >> R >> C;
    int sy=1,sx=1;
    int gy=R,gx=C;
    queue<state> qu;
    char s[R][C];
    LL count=0;
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            cin >> s[i][j];
            if(s[i][j]=='#') count++;
        }
    }
    qu.push({make_pair(sx-1,sy-1),0});
    while(qu.size()){
        state y;
        y = qu.front();
        qu.pop();
        P e;
        e=y.p;
        if(e.first==gx-1&&e.second==gy-1){
            cout << R*C-(y.num+count+1) << endl;
            return 0;
        }
        s[e.second][e.first]='#';
        for(int i=0;i<4;i++){
            int nx,ny;
            nx=e.first+dx[i];
            ny=e.second+dy[i];
            if(0<=nx&&nx<C&&0<=ny&&ny<R&&s[ny][nx]=='.'){
                qu.push({make_pair(nx,ny),y.num+1});
                s[ny][nx]='#';
            }
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b){
    TSTART();
    string ans;
    if(a % 3 == 0|| b % 3 == 0|| (a+b) % 3 == 0)ans = "Possible";
    else ans = "Impossible";
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))

mine_s = [[0]*w for i in range(h)]

def prt_bomb(a, b):
    if(s[a][b] == '#'):
        mine_s[a][b] = '#'
    else:
        ret = 0
        for i in range(max(0, a-1), min(a+1, h-1)+1):
            for j in range(max(0, b-1), min(b+1, w-1)+1):
                if(s[i][j] == '#'):
                    ret += 1
        mine_s[a][b] = str(ret)

for i in range(h):
    for j in range(w):
        prt_bomb(i, j)

for i in range(h):
    print(''.join(mine_s[i]))


Measured memory_bytes: 3188
import java.time.LocalDate;
import java.time.Period;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		age_difference();
	}

	private static void age_difference() {
		Scanner sc = new Scanner(System.in);
		int[] d = new int[6];

			for (int i = 0; i < 6; i++) {
				d[i] = sc.nextInt();
			}


		LocalDate d1 = LocalDate.of(d[0], d[1], d[2]);
		LocalDate d2 = LocalDate.of(d[3], d[4], d[5]);

		int age_diff = Math.abs(Period.between(d1, d2).getYears());

		if (d[1] == d[4] && d[2] == d[5]) {
			System.out.println(age_diff);
		} else {
			System.out.println(age_diff + 1);
		}
		sc.close();

	}

}


Measured memory_bytes: 32584
N,M=map(int,input().split())
S=[list(input().split()) for i in range(M)]

C=[0]*(N+1)
L=[0]*(N+1)
W=0

for x,y in S:
    if y=="AC":
        L[int(x)]=1

for x,y in S:
    x=int(x)
    if L[x]==0:
        continue

    if y=="AC":
        C[x]=1

    if C[x]==0 and y=="WA":
        W+=1

print(sum(L),W)

Measured memory_bytes: 27456
N, K, Q = map(int,input().split())
A = [int(input()) for i in range(Q)]

point = []

for i in range(N):
    point.append(0)
    
for i in range(Q):
    point[A[i]-1] += 1
    
for i in range(N):
    if point[i]+(K-Q) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 8636
N = int(input())
(A, B) = list(map(int, input().split()))
P = list(map(int, input().split()))
COUNT = [0, 0, 0]
for i in sorted(P):
    if i <= A:
        COUNT[0] += 1
    elif i <= B:
        COUNT[1] += 1
    else:
        COUNT[2] += 1
print(min(COUNT))


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

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;


int main() {
	int a,b,c;
	char s[20];
	cin >> a;
	cout << (a - 2) * 180;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}

Measured memory_bytes: 256
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	let N = parseInt(input[0][0],10);
	let M = parseInt(input[0][1],10);
	let arr_xy = [];
	graph = Array.from({length: N}, () => []);
	for (let i = 0; i < M; i++){
		arr_xy.push(input[i + 1].map(e => parseInt(e, 10)));
		graph[arr_xy[i][0] - 1].push(arr_xy[i][1] - 1);
	}
	v = Array.from({length: N}, () => -1);
	let ans = 0;
	for (let i = 0; i < N; i++){
		ans = Math.max(ans, runRecursive(DP, i));
	}
	console.log(ans);
}

function* DP(x){
	if (v[x] !== -1) {
		return v[x];
	} else {
		let maxD = -1;
		for (let a of graph[x]){	
			maxD = Math.max(yield[a], maxD);
		}
		v[x] = maxD + 1;
		return v[x];
	}
}

function runRecursive(func, ...args) {
	// 最終結果を受け取るオブジェクトを用意
	const rootCaller = {
	  lastReturnValue: null
	};
	// 自前のコールスタックを用意
	const callStack = [];
	// 最初の関数呼び出しを追加
	callStack.push({
	  iterator: func(...args),
	  lastReturnValue: null,
	  caller: rootCaller
	});
	while (callStack.length > 0) {
	  const stackFrame = callStack[callStack.length - 1];
	  const { iterator, lastReturnValue, caller } = stackFrame;
	  // 関数の実行を再開
	  const { value, done } = iterator.next(lastReturnValue);
	  if (done) {
		// 関数がreturnしたので親に返り値を記録
		caller.lastReturnValue = value;
		callStack.pop();
	  } else {
		// 関数がyieldした（valueは再帰呼び出しの引数リスト）
		callStack.push({
		  iterator: func(...value),
		  lastReturnValue: null,
		  caller: stackFrame
		});
	  }
	}
	return rootCaller.lastReturnValue;
  }

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 123972
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	int s[n];
	for (int i = 0; i < sizeof(s) / sizeof(s[0]); i++) {
		cin >> s[i];
	}
	int q;
	cin >> q;
	int t[q];
	for (int i = 0; i < sizeof(t) / sizeof(t[0]); i++) {
		cin >> t[i];
	}
	vector<int> c;
	for (int i = 0; i < sizeof(t) / sizeof(t[0]); i++) {
		int high = sizeof(s) / sizeof(s[0]);
		int low = 0;
		int mid = (high + low) / 2;		
		bool isExist = false;
		for (int j = 0; j < c.size(); j++) {
			if (t[i] == c[j]) isExist = true;
		}
		if (!isExist) {
			while (high >= low) {
				if (t[i] > s[mid]) {
					low = mid + 1;
				}
				else if (t[i] < s[mid]) {
					high = mid - 1;
				}
				else {
					c.push_back(t[i]);
					break;
				}
				mid = (high + low) / 2;
			}
		}
	}
	cout << c.size()<< '\n';
}



Measured memory_bytes: 3596
#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() {
  string s;
  cin >> s;
  int m = stoi(s.substr(5, 2));
  if (m <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

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

int main() {
    int n;
    string a,b,c;
    cin >> n >> a >> b >> c;
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i]){
            count+=2;
        }
        else if(a[i]==b[i]&&b[i]!=c[i]){
            count++;
        }
        else if(a[i]!=b[i]&&b[i]==c[i]){
            count++;
        }
        else if(c[i]!=b[i]&&a[i]==c[i]){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


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

using namespace std;
using ll = long long;
using ull = unsigned long long;


int main() {
	ll n;
	vector<ll> a;

	cin >> n;
	a.resize(n);
	REP(i, n) {
		int t;
		cin >> t;
		a[i] = t - (i + 1);
	}

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

	ll b = a[a.size() / 2];

	ll ans = 0;
	REP(i, n) {
		ans += abs(a[i] - b);
	}

	cout << ans NL;

	return 0;

}

Measured memory_bytes: 1792
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]

cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    elif d1 != d2:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()

print("No")

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

using namespace std;

bool cmp(pair<int,int>x,pair<int,int>y){
	return x.first<y.first;
}
int b[200000][2];
int main(){
	int n,m,ans=0;
	scanf("%d%d",&n,&m);
	vector<pair<int,int> >a(m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&a[i].first,&a[i].second);
	}
	sort(a.begin(),a.end(),cmp);
	for(int i=0;i<m;i++){
		if(a[i].first>=b[ans][1]){
			ans++;
			b[ans][0]=a[i].first;
			b[ans][1]=a[i].second;
		}
		else{
			b[ans][0]=max(a[i].first,b[ans][0]);
			b[ans][1]=min(a[i].second,b[ans][1]);
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M;
  cin >> N >> M;
  vector<int>vvv(N,0);
  for(int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    a--;
    if((vvv[a] != 0 && vvv[a] != b) || (a == 0 && b == 0 && N !=1)){
      cout << -1 << endl;
      return 0;
    }
    vvv[a] = b;
  }
  if(vvv[0] == 0 && N != 1){
    vvv[0] = 1;
  }

  for(int i=0; i<N; i++){
    cout << vvv[i];
  }
  cout << endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
    int a,b,c,d;
    cin >>a >> b >> c >> d;

    if(a+b > c+d)
        cout << "Left" << endl;
    else if(a+b < c+d)
        cout << "Right" << endl;
    else    
        cout << "Balanced" << endl;


    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
An = []
for _ in range(N):
    An.append(int(input()))

ans_dict = {}
for A in An:
    if A in ans_dict:
        ans_dict[A] = abs(ans_dict[A] - 1)
    else:
        ans_dict[A] = 1

sum = 0
for i in ans_dict.values():
    sum += i

print(sum)


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

using namespace std;

long long n, k, h[100010], dp[100010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	cin >> n >> k;
	for(long long i = 1; i <= n; i++) {
		cin >> h[i];
	}
	dp[1] = 0;
	for(long long i = 2; i <= n; i++) {
		dp[i] = 1e9 + 9;
		for(long long j = 1; j <= k; j++) {
			if(i - j < 1) {
				break;
			}
			dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1792
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
Y = [list(map(int, input().split())) for _ in range(Q)]

p = [[0] * (N + 1) for _ in range(N + 1)]

for l, r in X:
    p[l][r] += 1
    
for i in range(1, N + 1):
    for j in range(1, N + 1):
        p[i][j] += p[i][j - 1]
        
for i in range(1, N + 1):
    for j in range(1, N + 1):
        p[i][j] += p[i - 1][j]
        
for l, r in Y:
    ans = p[r][r] + p[l - 1][l - 1] - p[l - 1][r] - p[r][l - 1]
    print(ans)


Measured memory_bytes: 109400
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] count = new int[26];
        while (sc.hasNext()) {
            String line = sc.nextLine();
            line = line.toLowerCase();
            char[] ch = line.toCharArray();
            for (int i = 0; i < ch.length; i++) {
                int n = ch[i] - 'a';
                if (0 <= n && n <= 25) {
                    count[n]++;
                }
            }
        }
        for (int i = 0; i < count.length; i++) {
            char c = (char)(i+'a');
            System.out.println(c + " : "+ count[i]);
        }
        sc.close();
        
    }

}

Measured memory_bytes: 17152
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	int N, M;
	vector<int> H;
	vector<bool> ok;

	int res = 0;

	std::cin >> N >> M;

	for(int i=0; i<N; i++){
		int tmp;
		cin >> tmp;
		H.push_back(tmp);
		ok.push_back(true);
	}

	for(int i=0; i<M; i++){
		int A, B;
		cin >> A >> B;
		if(H[A-1] <= H[B-1]){
			ok[A-1] = false;
		}
		if(H[A-1] >= H[B-1]){
			ok[B-1] = false;	
		}
	}

	for(int i=0; i<N; i++){
		if(ok[i]){
			res++;
		}
	}

	cout << res;

	return 0;
	
}

Measured memory_bytes: 3900
h,w=map(int,input().split())
s=[input() for i in range(h)]

#四つのうち#があればOK
def four_next(i,j):
    global s
    if i>0 :
        if s[i-1][j]=="#":
            return True
    if i<h-1 :
        if s[i+1][j]=="#":
            return True
    if j>0 :
        if s[i][j-1]=="#":
            return True
    if j<w-1 :
        if s[i][j+1]=="#":
            return True
    return False

f=0
for i in range(h):
    for j in range(w):
        if s[i][j]=="#" and (not four_next(i,j)):
            f=1
            break
    if f==1:
        break
if f==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064