akhauriyash/Code-Regression huggingface dataset:
<?php

    // 標準入力を配列化して取得する
    function get_input() {
        $input = [];
        while ($line = fgets(STDIN)) {
            $input[] = trim($line);
        }
        return $input;
    }

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $input = get_input();

    list($keta, $kazu) = explode(' ', $input[0]);

    $result = -1;
    $bound = [
        [], [0, 9], [10, 99], [100, 999]
    ];

    for ($i = $bound[$keta][0]; $i <= $bound[$keta][1]; $i++) {
        for ($j = 1; $j < count($input); $j++) {
            list($s, $c) = explode(' ', $input[$j]);
            $wk = str_split($i);
            if ($wk[$s - 1] != $c) {
                continue 2;
            }
        }
        $result = $i;
        break;
    }

    output($result);


Measured memory_bytes: 4728
package main

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

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

func main() {
	N := nextInt()
	A := nextInts(N)
	LeftGcd := make([]int, N)
	RightGcd := make([]int, N)
	LeftGcd[0] = A[0]
	RightGcd[N-1] = A[N-1]

	for i := 1; i < N; i++ {
		LeftGcd[i] = gcd(LeftGcd[i-1], A[i])
	}

	for i := N - 2; i >= 0; i-- {
		RightGcd[i] = gcd(RightGcd[i+1], A[i])
	}

	// log.Println(A)
	// log.Println(LeftGcd)
	// log.Println(RightGcd)

	ans := max(LeftGcd[N-2], RightGcd[1])

	for j := 0; j < N-2; j++ {
		ans = max(ans, gcd(LeftGcd[j], RightGcd[j+2]))
	}
	fmt.Println(ans)
}

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

var dx = []int{0, 1, 0, -1, 0}
var dy = []int{1, 0, -1, 0, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

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

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

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() []byte

func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}

func newScanner() func() []byte {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() []byte {
		r.Scan()
		return r.Bytes()
	}
}

func nextBytes() []byte {
	return nextReader()
}

func nextString() string {
	return string(nextReader())
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(string(nextReader()), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(string(nextReader()))
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(string(nextReader()), 64)
	return f
}


Measured memory_bytes: 4736
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF = 10000000;

int main(){
    string s;
    cin >> s;
    int ans = 0, tmp = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i]=='A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C'){
            tmp++;
        }else{
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

flag = 1
for i in 0..(n-1)
  if a[i] == 0
    flag = 0
    puts 0
    break
  end
end
exit if flag == 0

ans = 1
for i in 0..(n-1)
  ans *= a[i]
  flag = 0 if ans > 10**18
  break if flag == 0
end

flag == 1 ? (puts ans):(puts -1)

Measured memory_bytes: 21756
program children_and_candies
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: n, c, a(400) = 0, b(400) = 0, i, j, k
  integer(8) :: p(0:400,0:400) = 0_8, m, dp(400,0:400) = 0_8
  read(*,*) n, c
  read(*,*) a(1:n)
  read(*,*) b(1:n)
  do i = 0, 400
    m = 0_8
    do j = 0, 400
      m = mod(m+pow(int(j,8),i),md)
      p(i,j) = m
    end do
  end do
  do i = 0, c
    dp(1,i) = mod(md+p(i,b(1))-p(i,a(1)-1),md)
  end do
  do i = 2, n
    do j = 0, c
      do k = 0, j
        dp(i,j) = mod(dp(i,j)+mod(dp(i-1,j-k)*(md+p(k,b(i))-p(k,a(i)-1)),md),md)
      end do
    end do
  end do
  write(*,'(i0)') dp(n,c)
  stop
contains
  recursive function pow(a,b) result(r)
    implicit none
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer(8) :: r
    r = 1_8
    if (b.eq.0) return
    if (mod(b,2).eq.0) then
      r = pow(a,b/2)
      r = mod(r*r,md)
      return
    end if
    r = mod(a*pow(a,b-1),md)
    return
  end function pow
end program children_and_candies

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

int main(){
      int N,ans=0,flag=0;
      int A[220];

      cin >> N;
      for(int i=0;i<N;i++)cin >> A[i];
      while(1){
            for(int j = 0;j < N; j++){
                  if(A[j] % 2 != 0)flag=1;
            }
            if(flag == 1)break;
            for(int k=0;k < N; k++){
                  A[k]/=2;
            }
            
            ans++;
      }
                  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n;
vector<int> g[1001000];
int d[1001000];
bool used[1001000];

int getIndex(int a, int b)
{
    if (a > b)
        swap(a, b);

    return a + b * n;
}

int dfs(int p)
{
    if (d[p] != -1)
        return d[p];

    if (used[p])
        return -1;

    used[p] = true;

    int res = 1;

    for (int i : g[p])
    {
        if (d[i] != -1)
        {
            res = max(res, d[i] + 1);
            continue;
        }
        if (used[i])
            return -1;

        int r = dfs(i);

        if (r == -1)
            return -1;

        res = max(res, r + 1);
    }

    d[p] = res;

    return res;
}

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

    cin >> n;

    memset(d, -1, sizeof(d));

    REP(i, n)
    {
        int a[1000];
        REP(j, n - 1)
        {
            cin >> a[j];

            if (j == 0)
                continue;

            g[getIndex(i + 1, a[j - 1])].push_back(getIndex(i + 1, a[j]));
        }
    }

    int first = 1 + 2 * n;
    int last = (n - 1) + n * n;

    int res = 0;

    memset(used, 0, sizeof(used));

    for (int i = first; i <= last; i++)
    {
        if (d[i] != -1)
            continue;
        int r = dfs(i);

        if (r == -1)
        {
            cout << -1 << endl;
            return 0;
        }

        res = max(res, r);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 44288
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define all(v) v.begin(),v.end()
#define PB push_back
#define T(val) while(val--)
#define FIN for(i=0;i<n;i++)
#define FIS for(i=0;i<s.length();i++)
#define AIN for(i=0;i<n;i++){cin>>a[i];}
#define F(i,k,n) for(i=k;i<n;i++)
#define FG(i,k,n,x) for(i=k;i<n;i+=x)
#define YES cout<<"YES\n"; 
#define NO cout<<"NO\n"; 
#define ll long long
#define MOD 1000000007
#define deb(x) cout << #x << "=" << x << endl;
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//sort(arr, arr+n, greater<int>()); For sorting in reverse order 
double prob[3005];
double dp[3005][3005];
//  dp[index][heads];
int solve(){
  int n;
  cin>>n;
  int i,j;
  for(i=0;i<n;i++){
    cin>>prob[i];
  }
  int m=ceil((n+1)/2);
  for(i=1;i<=n;i++){
    for(j=0;j<=n;j++){
      dp[i][j]=1;
      if(i==1&&j==0){
        dp[1][0]=1-prob[0];
        continue;
      }
      if(i==1&&j==1){
        dp[1][1]=prob[0];
        continue;
      }
      if(j>i){
        dp[i][j]=0;
        continue;
      }
      if(j==0){
        dp[i][j]=dp[i-1][j]*(1-prob[i-1]);
        continue;
      }
      dp[i][j]=dp[i-1][j-1]*prob[i-1]+dp[i-1][j]*(1-prob[i-1]);
      
    }
  }
  double ans=0;
  while(m){
    ans+=dp[n][n-m+1];
    m--;
  }
  cout<<setprecision(10);
  cout<<fixed;
  cout<<ans<<"\n";
  return 0;
}
int main(){
fast
  int t=1;
  // cin>>t; 
  T(t){
    solve();
  }
  return 0;
}

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

using i64 = int64_t;

int main(){
    i64 s;
    cin >> s;
    i64 x = (1000000000 - s%1000000000)%1000000000;
    i64 y = (s+x) / 1000000000;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{	
	auto S = RD!string;

	long ans1;
	foreach (i, c; S)
	{
		if ([c].to!long == i % 2) ++ans1;
	}
	long ans2;
	foreach (i, c; S)
	{
		if ([c].to!long != i % 2) ++ans2;
	}

	writeln(min(ans1, ans2));
	stdout.flush();
	debug readln();
}

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

using namespace std;

string getString() {
	string x;
	cin >> x;
	if (x.size() < 3 || x.size() > 99) {
		return getString();
	}
	if (x.size() % 2 == 0) {
		return getString();
	}
	int tama = static_cast<int>(x.size());
	for (int i = 0; i < tama; i++) {
		if (x[i] < 96 || x[i]>122) {
			return getString();
		}
	}

	return x;
}

bool check_palindrome(string caso) {
	int tama = static_cast<int>(caso.size());
	int ptr1=0;
	int ptr2 = tama - 1;
	for (int i = 0; i < tama / 2; i++) {
		if (ptr1 == ptr2) {
			return true;
		}
		if (caso[ptr1] != caso[ptr2]) {
			return false;
		}
		ptr1++;
		ptr2--;
	}
	

	return true;
}

int main() {
	string caso{ getString() };
	int tama = static_cast<int>(caso.size());
	if (check_palindrome(caso)) {
		int first_case{ ((tama - 1) / 2) };
		string caso1{ caso[0] };
		for (int i = 1; i < first_case; i++)
		{
			caso1 += caso[i];
		}
		if (check_palindrome(caso1)) {
			int second_case{ (tama + 3) / 2 };
			string caso2{ caso[second_case - 1] };
			for (int j = second_case; j < caso.size(); j++)
			{
				caso2 += caso[j];
			}
			if (check_palindrome(caso2)) {
				cout << "Yes";
				return 0;
			}
			cout << "No";
			return 0;
		}
		cout << "No";
		return 0;
	}
	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 3088
#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);
  }
  
  int s = 1, cnt = 1;
  for(int i = 0; i < N; i++) {
    s = a.at(s-1);
    if(s == 2) {
      cout << cnt << endl;
      break;
    }
    cnt++;
  }
  
  if(s != 2) {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3772
#include<stdio.h>
  
main()
{
    int r,c;
    scanf("%d %d",&r,&c);
      
    int calc[r+1][c+1];
    calc[r][c]=0;
      
    int i,j;
      
    for(i=0;i<r;i++){
        calc[i][c]=0;
        for(j=0;j<c;j++){
            if(i==0){
                calc[r][j]=0;
            }
            scanf(" %d",&calc[i][j]);
        }
    }
      
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            if(j!=0){
                printf(" ");
            }
              
            printf("%d",calc[i][j]);
              
            if(j==c){
                printf("\n");
            }
            if(j>=0 && j<=c-1){
                calc[i][c] += calc[i][j];
                if(i!=r){
                    calc[r][j] += calc[i][j];
                }
            }
        }
          
    }
    return 0;
}


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

template <typename _tp> inline void read(_tp&x){
	char ch=getchar(),ob=0;x=0;
	while(ch!='-'&&!isdigit(ch))ch=getchar();if(ch=='-')ob=1,ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();if(ob)x=-x;
}

#define lson l,mid,x<<1
#define rson mid+1,r,x<<1|1

const ll INF = 1e18;
const int N = 601000;
ll mi0[N], mi1[N], sg[N], tag[N];
int n, Q;

void build(int l, int r, int x) {
	sg[x] = mi0[x] = mi1[x] = INF;
	if(l == r) return ;
	int mid = l + r >> 1;
	build(lson), build(rson);
}

inline void down(int x) {
	const int l = x << 1, r = l | 1;
	ll&v = tag[x];
	sg[l] += v, sg[r] += v,
	mi0[l] += v, mi1[l] += v,
	mi0[r] += v, mi1[r] += v,
	tag[l] += v, tag[r] += v;
	v = 0;
}

void upd(int l, int r, int x, int ps, ll vl) {
	if(l == r) {
		if(sg[x] > vl) {
			sg[x] = vl;
			mi0[x] = vl - l;
			mi1[x] = vl + l;
		}
		return ;
	}
	if(tag[x]) down(x);
	int mid = l + r >> 1;
	if(ps <= mid) upd(lson, ps, vl);
	else upd(rson, ps, vl);
	mi0[x] = min(mi0[x<<1], mi0[x<<1|1]);
	mi1[x] = min(mi1[x<<1], mi1[x<<1|1]);
}

ll get0(int l, int r, int x, int R) {
	if(r <= R) return mi0[x];
	if(tag[x]) down(x);
	int mid = l + r >> 1;
	if(R <= mid) return get0(lson, R);
	return min(get0(lson, R), get0(rson, R));
}

ll get1(int l, int r, int x, int L) {
	if(L <= l) return mi1[x];
	if(tag[x]) down(x);
	int mid = l + r >> 1;
	if(mid < L) return get1(rson, L);
	return min(get1(lson, L), get1(rson, L));
}

ll get(int l, int r, int x) {
	if(l == r) return sg[x];
	if(tag[x]) down(x);
	int mid = l + r >> 1;
	return min(get(lson), get(rson));
}

int main() {
	read(n), read(Q);
	build(1, n, 1);
	int x, y, z;
	read(x), read(y), read(z);
	upd(1, n, 1, x, abs(y - z));
	upd(1, n, 1, y, abs(x - z));
	while(--Q) {
		read(x), y = abs(x - z);
		ll vl = min(get0(1, n, 1, x) + x, get1(1, n, 1, x) - x);
		mi0[1] += y, mi1[1] += y, tag[1] += y;
		upd(1, n, 1, z, vl), z = x;
	}
	printf("%lld\n", get(1, n, 1));
	return 0;
}

Measured memory_bytes: 18688
#include <stdio.h>
int main(void){
    double r,m,e;
    scanf("%lf",&r);
    m = r * r * 3.141592653589;
    e = 2 * r * 3.141592653589;
    printf("%.5lf %.5lf\n",m,e);
    return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

void solve()
{
	double a, b, n;
	cin >> a >> b >> n;

	double x = min(n, b - 1);

	cout << floor(a * x / b) << endl;

}

int main()
{
	solve();

	return 0;
}

Measured memory_bytes: 3712
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE MultiWayIf #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main = do
    n <- readLn :: IO Int
    print $ solve n



solve n = solveAux n (potFacs 2 n) 0

solveAux n [] ac = ac
solveAux n (x:xs) ac =
    -- traceShow (n,x,ac)$ 
    solveAux (n `div` x) (potFacs (x+1) (n `div` x)) (ac + 1)


fac :: Int -> Int -> [Int]
fac st n = filter ((==0) . (n `rem`)) [st..floor(sqrt $ fromIntegral n)]

fac2 st n = (fac st n) ++ dropWhile (<st) (reverse (map (n`div`) (fac 1 n)))

potFacs st n = filter isPrimePot (fac2 st n)


isPrimePot n = length (fac 2 n) == 0  ||  length (pfacTup n) == 1

pfacTup = fAux primes where
    fAux    _     1 = []
    fAux q@(p:ps) n = if n`rem`p==0
        then let e = head (dropWhile (\x-> n`rem`(p^x) == 0) [1..])-1
            in (p,e):(fAux q (n`quot`(p^e)))
        else fAux ps n

primes = f [2..] where f (p:ps) = p:(filter ((/=0).(`rem`p)) ps)



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

int main(){
  int X,Y,Z,K;
  cin >> X >> Y >> Z >> K;
  vector<long long> A(X),B(Y),C(Z);
  for(int i=0;i<X;i++) cin >> A[i];
  for(int i=0;i<Y;i++) cin >> B[i];
  for(int i=0;i<Z;i++) cin >> C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
  
  vector<long long> AB(0);
  for(int i=0;i<X;i++){
    for(int j=0;j<Y;j++){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.begin(),AB.end());
  reverse(AB.begin(),AB.end());
  
  vector<long long> ABC(0);
  for(int i=0;i<Z;i++){
    for(int j=0;j<min(K,X*Y);j++){
      ABC.push_back(C[i]+AB[j]);
    }
  }
  sort(ABC.begin(),ABC.end());
  reverse(ABC.begin(),ABC.end());
  
  for(int i=0;i<K;i++) cout << ABC[i] << endl;
  return 0;
}


Measured memory_bytes: 43112
def solve():
    N = int(input())
    Xs = [(X, i+1) for i, X in enumerate(map(int, input().split()))]

    N2 = N**2
    Xs.sort()

    As = [0] * (2*N2+1)
    for X, no in Xs:
        As[X] = no

    iA = 1
    for X, no in Xs:
        num = no-1
        while num:
            if As[iA] == 0:
                As[iA] = no
                num -= 1
            iA += 1
        if iA > X:
            return []

    for X, no in Xs:
        while As[iA] != 0:
            iA += 1
        if iA <= X:
            return []
        num = N-no
        while num:
            if As[iA] == 0:
                As[iA] = no
                num -= 1
            iA += 1

    if iA != N2+1:
        return []

    return As[1:iA]


anss = solve()
if anss:
    print('Yes')
    print(' '.join(map(str, anss)))
else:
    print('No')


Measured memory_bytes: 22192
N = int(input())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]),
                    dp[i - 1] + abs(H[i] - H[i - 1]))
print(dp[N - 1])


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, X, Y; cin >> N >> X >> Y; X--, Y--;
  vector<int> cnt(N);
  rep(i, N) REP(j, i + 1, N) {
    auto min_dist = min({j - i, abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(X - j)});
    cnt[min_dist]++;
  }
  REP(i, 1, N) {
    cout << cnt[i] << "\n";
  }
}


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

int log2(int);
  
int main(void){
  int N;
  cin >> N;
  int A[N];
  int R[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    R[i] = log2(A[i]);
  }

  int ans = R[0];
  for(int i = 1; i < N; ++i){
    if(ans > R[i]){
      ans = R[i];
    } else {
      
    }
  }
  cout << ans << endl;

  return 0;
}

int log2(int n){
  int ln = 0;

  while(n % 2  == 0){
    ln++;
    n = n/2;
  }

  return ln;
}
//あかん

// #include <iostream>
// using namespace std;

// int main(void){
//   int N;
//   cin >> N;

//   int A[N];
//   int R[N] = {0};
//   for(int i = 0; i < N; ++i){
//     cin >> A[i];
//   }
//   for(int i = 0; i < N; ++i){
//     while(A[i] % 2 == 0){
//       ++R[i];
//       A[i] = A[i]/2;
//     }
//   }

//   int ans = 0;
//   for(int i = 0; i < N; ++i){

//     if(ans < R[i]){
//       ans = R[i];
//     } else {
      
//     }
//   }

//   cout << ans << endl;
//   return 0;
// }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

int main(void){
    int N; cin >> N;
    
    map<ll,ll> mp;
    for(ll i = 1; i <= N; i++){
        ll num = i;
        for(ll j = 2; j * j <= num; j++){
            if (num % j == 0){
                ll cnt = 0;
                while(num % j == 0){
                    num /= j;
                    cnt++;
                }
                mp[j] += cnt;
            }
        }
        if (num != 1) mp[num]++;
    }
    ll ans = 1;
    for(auto p: mp){
        // cout << p.first << ' ' << p.second << endl;
        ans *= (p.second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main (){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  char n;
  cin >> n;
  if (n >= 'A' && n <= 'Z') 
    cout << 'A';
  else
    cout << 'a';

}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

// BWBWBW
// BWWBBW
// BWWBWB
// BWWWBB

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

	int b = 0, ans = 0;
	for(auto i : s){
		if(i == 'B') b++;
		else{
			ans += b;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
int main() {
  int hp_a, str_a, hp_b, str_b;
  std::cin >> hp_a >> str_a >> hp_b >> str_b;
  while(1) {
    hp_b -= str_a;
    if (hp_b <= 0) {
      std::cout << "Yes\n";
      break;
    }
    hp_a -= str_b;
    if (hp_a <= 0) {
      std::cout << "No\n";
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
typedef long long ll;
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

int main(){
    int N;
    char S[30101];
    scanf("%d%s", &N, S);

    int ans = 0;
    rep(i,0,10){
        int idxi = 0;
        while(idxi < N && S[idxi] != ('0'+i)) idxi++;
        if(idxi >= N-2) continue;
        rep(j,0,10){
            int idxj = idxi+1;
            while(idxj < N && S[idxj] != ('0'+j)) idxj++;
            if(idxj >= N-1) continue;
            int cnt[10] = {0};
            rep(idxk,idxj+1,N) cnt[S[idxk]-'0']++;
            rep(k,0,10) if(cnt[k] > 0) ans++;
        }
    }

    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2);
  return x*POW(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,ans,l[30];
  ans=1;
  char c[120000];
  cin >> n;
  rep(i,n)cin >> c[i];
  sort(c,c+n);
  rep(i,29)l[i]=0;
  rep(i,n)l[c[i]-'a']++;
  rep(i,29)ans=ans*(l[i]+1)%MOD;
  printf("%lld",((ans-1)%MOD+2*MOD)%MOD);
}

Measured memory_bytes: 384
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/
//---------------------------------------------------
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)
//---------------------------------------------------
LL max(LL a, LL b){
  if (a > b) {
    return a;
  }else return b;
}

int main(void)
{
  int n;
  int k;
  int d;
  int a;
  int ans = 0;
  int A[200] = {0};
  scanf("%d %d", &n, &k);

  for (size_t i = 0; i < k; i++) {
    scanf("%d", &d);
    for (size_t j = 0; j < d; j++) {
      scanf("%d", &a);
      A[a-1]++;
    }
  }

  for (size_t i = 0; i < n; i++) {
    if (A[i] == 0) {
      ans++;
    }
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1732
def divide_a_cuboid():
	a,b,c = map(int, raw_input().split(" "))
	if a%2==0 or b%2==0 or c%2==0:
		print 0
	else:
		l = sorted([a,b,c])
		print l[0]*l[1]


if __name__ == "__main__":
	divide_a_cuboid()

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

int main(){
 	
	int n;
	cin >>n;
	
	int m = n, cnt = 0;
	if(n == 2){
		cnt = 1;
		m = 1;
	}
	while(m != 1){
		cnt++;
		if(m % 3 == 0){
			m = m / 3;
		} else{
			m = m / 3 + 1;
		}
	}
	cout <<cnt <<endl;
	return 0;
}

Measured memory_bytes: 0
module Main where

import Control.Monad
import Control.Applicative
import Data.List
import Text.Printf

getIntList = (map read . words) <$> getLine :: IO[Int]

showingList :: [Int] -> String
showingList (x:[]) = show x
showingList (x:xs) = (show x) ++ " " ++ (showingList xs)

func :: String -> String
func ('.':b) = b
func (c:b) = [c] ++ func(b)

func2 :: String -> String
func2 (x:y:[]) = ""
func2 (x:[]) = "0"
func2 (x:xs) = [x] ++ func2(xs)

main :: IO ()
main = do
    [a, b] <- words <$> getLine
    let c = read a :: Int
    let d = read (func b) :: Int
    putStrLn $ func2 $ show $ c * d

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

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


Measured memory_bytes: 2988
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
ll m=1000000007;
int main()
{
	fast;
	string s;cin>>s;
	int sum=0;
	for(int i=0;i<s.length();i++)
	{
		sum+=s[i]-'0';
		sum=sum%9;
	}
	if(!sum)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
string s[110],ans[110];
bool hang[110],lie[110];
int main()
{
	memset(hang,1,sizeof(hang));
    memset(lie,1,sizeof(lie));
    int h,w,i,j;
    cin >> h >> w;
    for (i = 0;i < h;i++) 
		cin >> s[i];

    for (i = 0;i < h;i++)
    {
        bool all = 1;
        for (j = 0;j < w;j++)
        {
            if (s[i][j] == '#') 
			{
				all = 0;
				break;
			}
		}
        if (all) 
			hang[i] = 0;
    }
    for (i = 0;i < w;i++)
    {
        bool all = 1;
        for (j = 0;j < h;j++)
    	{
            if (s[j][i] == '#') 
			{
				all = 0;
				break;
			}
    	}
		if (all) 
			lie[i]=0;
    }
    for (i = 0;i < h;i++)
    {
        bool out = 0;
        for (j = 0;j < w;j++)
    	{
            if ((hang[i]) && (lie[j])) 
			{
				cout << s[i][j];
				out = 1;
			}
    	}
		if (out) 
			puts("");
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;

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

    // 小さいものを中央にする
    deque<int> deq_s;
    int si = 0, bi = n;
    deq_s.push_back(a[0]);
    int t = 1;
    ll ans_s = 0;
    while (bi - si > 1) {
        if (t) {
            ans_s += abs(deq_s.front() - a[bi-1]) + abs(deq_s.back() - a[bi-2]);
            deq_s.push_front(a[bi-1]);
            deq_s.push_back(a[bi-2]);
            bi -= 2;
            t = 0;
        } else {
            ans_s += abs(deq_s.front() - a[si+1]) + abs(deq_s.back() - a[si+2]);
            deq_s.push_front(a[si+1]);
            deq_s.push_back(a[si+2]);
            si += 2;
            t = 1;
        }
    }
    if (bi - si > 1) {
        ans_s += max(abs(deq_s.front() - a[si+1]), abs(deq_s.back() - a[si+1]));
    }
    ans = max(ans_s, ans);

    // 大きいものを中央にする
    deque<int> deq_b;
    si = -1, bi = n-1;
    deq_b.push_back(a[n-1]);
    t = 0;
    ll ans_b = 0;
    while (bi - si > 1) {
        if (t) {
            ans_b += abs(deq_b.front() - a[bi-1]) + abs(deq_b.back() - a[bi-2]);
            deq_b.push_front(a[bi-1]);
            deq_b.push_back(a[bi-2]);
            bi -= 2;
            t = 0;
        } else {
            ans_b += abs(deq_b.front() - a[si+1]) + abs(deq_b.back() - a[si+2]);
            deq_b.push_front(a[si+1]);
            deq_b.push_back(a[si+2]);
            si += 2;
            t = 1;
        }
    }
    if (bi - si > 1) {
        ans_b += max(abs(deq_b.front() - a[si+1]), abs(deq_b.back() - a[si+1]));
    }
    ans = max(ans_b, ans);

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

Measured memory_bytes: 1408
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
lst=[a,b]
print(*lst)

Measured memory_bytes: 66236
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{
  string a,b;
  cin>>a>>b;
  int n=a.length(),m=b.length();
  vector<vi> dp(n+1,vi(m+1));

  loop(i,0,n)
  {
    loop(j,0,m)
    {
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(a[i-1]==b[j-1])
      {
        dp[i][j]=1+dp[i-1][j-1];
      }
      else
      {
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }

  string ans="";
  int i=n,j=m;

  while(i>0 && j>0)
  {
    if(a[i-1]==b[j-1])
    {
      ans+=a[i-1];
      i--,j--;
    }
    else if(dp[i][j-1]>dp[i-1][j])
    {
      j--;
    }
    else
      i--;

  }

  reverse(all(ans));
  cout<<ans<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

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

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 38476
N = int(input())
A, B = map(int, input().split())

a, b, c = 0, 0, 0

for i in input().split():
    item = int(i)
    if item <= A:
        a += 1
    elif A + 1 <= item <= B:
        b += 1
    elif B < item:
        c += 1

print(min(a, b, c))


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

int main()
{
    int a;
    string s;
    
    cin >> a;
    cin >> s;
    
    if(a >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#define llint long long

using namespace std;

llint T;
llint a[10];
llint memo[35][65];

llint get(char c)
{
  if(c <= '9') return c-'0';
  else return c-'a'+10;
}

llint parse(string s)
{
  //cout << s << " ";
  reverse(s.begin(),s.end());
  llint ret = 0, mul = 1;
  for(int i = 0; i < s.size(); i++) ret += mul*get(s[i]), mul *= 16;
  //cout << ret << endl;
  return ret;
}

llint dfs(int p, int c)
{
  //cout << p << " " << c << endl;
  if(p >= 32) return 0;
  if(memo[p][c] != -1) return memo[p][c];
  llint cnt[2] = {0, 0};
  for(int i = 1; i <= 8; i++){
    if(a[i] & (1<<p)) cnt[1]++;
    else cnt[0]++;
  }
  for(llint b = 0; b < 2; b++){
    if((c+cnt[1-b]) % 2 == (((a[9]>>p)&1)+b)%2){
      llint res = dfs(p+1, (c+cnt[1-b])/2);
      if(res != -1){
        return memo[p][c] = res | (b << p);
      }
    }
  }
  return memo[p][c] = -1;
}

int main(void)
{
  cin >> T;
  for(int t = 0; t < T; t++){
    string s;
    for(int i = 1; i <= 9; i++){
      cin >> s;
      a[i] = parse(s);
    }
    //for(int i = 1; i <= 9; i++) cout << a[i] << " "; cout << endl;
    for(int i = 0; i <= 32; i++){
      for(int j = 0; j < 65; j++){
        memo[i][j] = -1;
      }
    }
    printf("%llx\n", dfs(0, 0));
  }
  return 0;
}



Measured memory_bytes: 3208
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a[4];
int final;
int main()
{
	int i;
	for(i=1;i<=3;i++)
	  scanf("%d",&a[i]);
	sort(a+1,a+4);
	for(i=2;i<=3;i++)
	  final+=abs(a[i]-a[i-1]);
	printf("%d\n",final);
	return 0;
}

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

dlist=[]

for i in range(1,N):
    d=A[i]-A[i-1]
    dlist.append(d)

dlist.append(A[0]+K-A[N-1])

print(K-max(dlist))

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A, B, K;

ll i, j, k;
int main(){
    scanf("%lld%lld%lld", &K, &A, &B);
    fornum(i,A,B+1){
        if(i%K==0)
            break;
    }
    if(B<i){
        printf("NG\n");
    }else{
        printf("OK\n");
    }
    return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector< vector<int> > Graph;
vector< int > value;




void dfs(int now, int parent, int score) {
    value[now] += score;
    rep (i, Graph[now].size()) {
        //Don't search parent nood.
        if (Graph[now][i] == parent) continue;
        //Graph[now][i] is a nood which conect with now nood.
        dfs(Graph[now][i], now, value[now]);
    }
}





int main(int argc, const char * argv[]) {
    
   
    
    
    
    
  
    int n, q;
    cin >> n >> q;
    Graph.resize(n);
    value.resize(n);
    
    rep (i, n - 1) {
    int u, v;
    cin >> u >> v;
        u--; v--;
        Graph[u].push_back(v);
        Graph[v].push_back(u);
    }
    rep (i, q) {
        int u, x;
        cin >> u >> x;
        u--;
        value[u] += x;
    }
    
    
    dfs(0, -1, 0);
    
    rep (i, n) cout << value[i] << " "; cout << endl;

    
    
    

    
    

    
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  int ans = 0;
  while(1){
    bool update = true;
    for(int i=0; i<n; i++){
      if(a[i] % 2){
        update = false;
        break;
      }
    }
    if(update){
      ans++;
      for(int i=0; i<n; i++) a[i] /= 2;
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())
choices = []
for i in range(2 ** n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp.append(j)
    choices.append(tmp)
#choices.sort()
#del choices[0]
books = [ list(map(int,input().split())) for _ in range(n)]
anscost = float('inf')
for choice in choices:#[0, 1]
    cost = 0
    learn = [ 0 for _ in range(m)]
    for i in choice:
        book = books[i]
        cost += book[0]
        for j in range(1,m+1):
            learn[j-1] += book[j]
    #print("-----")
    #print(choice)
    #print(learn)
    if min(learn) >= x:
        anscost = min(anscost,cost)
if anscost ==  float('inf'):
    print(-1)
else:
    print(anscost)

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  
  cin >> N ;
   
  int L,R;
  
  int d=0;
 
  
  for(int i=0;i<N;i++){
    
 	cin >> L;
    
    cin >> R; 
    
    d+=(R-L+1);
    
  }
 
  cout << d << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    long m, a, r, c, h;
    m = a = r = c = h = 0;
    Set<Character> set = new HashSet<>();
    for(int i = 0; i < N; i++){
      String str = sc.nextLine();
      if(str.charAt(0) == 'M'){
        set.add('M');
        m++;
      }else if(str.charAt(0) == 'A'){
        set.add('A');
        a++;
      }else if(str.charAt(0) == 'R'){
        set.add('R');
        r++;
      }else if(str.charAt(0) == 'C'){
        set.add('C');
        c++;
      }else if(str.charAt(0) == 'H'){
        set.add('H');
        h++;
      }
    }
    
    long ans = 0;
    if(set.size() > 2){
      ans += m * a * r;
      ans += m * a * c;
      ans += m * a * h;
      ans += m * r * c;
      ans += m * r * h;
      ans += m * c * h;
      ans += a * r * c;
      ans += a * r * h;
      ans += a * c * h;
      ans += r * c * h;
    }
    System.out.println(ans);
  }
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0,cnt;
  string s,t;
  cin >> s;
  rep(i,n){
    cin >> t;
    rep(j,t.size()){
      if(t[j] == s[0]){
        rep(k,t.size()){
          cnt = 0;
          rep(l,s.size()){
            if(j+k*l < t.size() && t[j+k*l] == s[l]){
              ++cnt;
            }
          }
          if(cnt == s.size()){
            ++ans;
            break;
          }
        }
        if(cnt == s.size()){
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct PAIR{
public:
    int x,y;
};

int main(void){
    // Your code here!
    int h,w;
    cin >> h>> w;
    string maze[h+2];
    int distance[h+2][w+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            maze[i][j]='#';
            distance[i][j]=0;
        }
    }
    for(int i=1;i<=h;i++){
        string tmp;
        cin >> tmp;
        maze[i]='#'+tmp+'#';
    }
    
    int black=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(maze[i][j]=='#')
            black++;
        }
    }
    
    std::vector<PAIR> que;
    que.push_back(PAIR{1,1});
    int cnt=0;
    bool flag=false;
    while(que.size()!=0){
        PAIR id = que.front();
        que.erase(que.begin());
        int x=id.x,y=id.y;
        if(x==h and y==w){
            flag=true;
            break;
        }else{
            int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
            for(int i=0;i<4;i++){
                if (maze[x+dx[i]][y+dy[i]]=='.'){
                    maze[x+dx[i]][y+dy[i]]='o';
                    que.push_back(PAIR{x+dx[i],y+dy[i]});
                    distance[x+dx[i]][y+dy[i]]=distance[x][y]+1;
                }
            }
        }
        // for(int i=0;i<h+2;i++){
        //     for(int j=0;j<w+2;j++){
        //         cout << maze[i][j];
        //     }
        //     cout << endl;
        // }
    }
    if(flag == false){
        cout << -1;
    }else{
        cout << (h*w)-black-distance[h][w]-1;        
    }
    // cout << h << ' '<< w << ' '<<black<<' '<<distance[h][w]<<endl;


}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
unsigned long long int a = 0, b = 0, c = 0,d=0,e=0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
unsigned long long int iremono[100001], koware[100001];
unsigned long long int iremono2[100001], check[100001],xpo[10000001],ypo[10000001],hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;
vector<pair<long long int, long long int>>pairs;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char re;
int starta, startb, enda, endb,ab;


unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい
bool qw = false, er = false, ty = false,ui=false;
int main() {
	cin >> a>>b;
	rep(i, a) {
		cin >> c;
	}
	x = 1;
	while (a>x) {
		counter++;
		x += b - 1;
	}
	cout << counter << endl;
}


Measured memory_bytes: 256