akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int a[m];
    int count = 0;
    for (int i = 0; i < m; i++) {
      cin >> a[m];
      if(a[m]<x) count++;
    }
    m=min(count,(m-count));
    cout << m << "\n";
}

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

int main() {
    int a=0,b=0;
    int c=0,d=0;
    int k=1,l=1;

    vector<string> f(10);
    string g;

    cin >> a >> b;

    for(int i=0;i<b;i++){
        c = c + (k * a);
        k = k*10;
    }
    for(int i=0;i<a;i++){
        d = d + (l * b);
        l = l*10;
    }

    if(a<=b){
        string g = to_string(c);
        cout << g << endl;
    }else if(a > b){
        string g = to_string(d);
        cout << g << endl;
    }

}

Measured memory_bytes: 256
let rec lucas = function
  | 0 -> (2, 1)
  | n ->
      let (l_n_2, l_n_1) = lucas (n - 1) in
      (l_n_1, l_n_1 + l_n_2)

let () = Scanf.scanf "%d" (fun n ->
  Printf.printf "%d\n" @@ fst @@ lucas n)

Measured memory_bytes: 384
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, v = input_to_int_map()
    b, w = input_to_int_map()
    t = input_int()

    tidimu = v - w
    if tidimu <= 0:
        return "NO"

    ret = "NO"
    if abs(a - b) - (tidimu * t) <= 0:
        ret = "YES"

    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9200
Scanf.scanf "%d %d" (fun n m ->
    let par = Array.init n (fun n -> n) in
    let rec root x =
        if par.(x) = x then x else
            let r = root par.(x) in
            let () = par.(x) <- r in
            r
    in
    let merge a b =
        if root a <> root b then par.(par.(b)) <- par.(a)
    in
    let rel = Array.make n [] in
    let pos = Array.make n 0 in
    let visited = Array.make n false in

    for i = 1 to m do
        Scanf.scanf " %d %d %d" (fun l r d ->
            let l = l - 1 in
            let r = r - 1 in
            rel.(l) <- (r, -d) :: rel.(l);
            rel.(r) <- (l,  d) :: rel.(r);
            merge l r
        )
    done;

    let rec loop i =
        if i = n then "Yes" else (
            if root i <> i then loop (i + 1) else (
                let rec dfs k expectpos =
                    if visited.(k) then (
                        pos.(k) = expectpos 
                    ) else (
                        let () = pos.(k) <- expectpos in
                        let () = visited.(k) <- true in
                        let rec loop2 = function
                            | [] -> true
                            | (p, d) :: tl ->
                                    if dfs p (d + expectpos) then loop2 tl
                                    else false
                        in
                        loop2 rel.(k)
                    )
                in
                if dfs i 0 then loop (i + 1) else "No"
            )
        )
    in
    loop 0 |> print_endline
)

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c;
  cin >> a >> b >> c;

  cout << (a + b + c > 21 ? "bust" : "win") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;

    int a[45] = {0};
    a[0] = a[1] = 1;

    for (int i = 2; i <= n; i++)
        a[i] = a[i - 1] + a[i - 2];
    cout << a[n] << endl;

    return 0;
}


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

using namespace std;

const int kN = 1e2+7;

int n, m;
int a[kN][kN], sum[kN][kN], sort_a[kN], vis[kN], co[kN];
// sum[i][j] the number of group j in row i
// co[i] the group of row i
// vis[i] has group i been visited

inline void print()
{
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

bool check(int cur)
{
    for (int i = 1; i <= n; ++i) {
        if (!sum[cur][i] || vis[i]) continue;
        vis[i] = 1;
        if (!co[i] || check(co[i])) {
            co[i] = cur;
            return true;
        }
    }
    return false;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> a[i][j];
            int group = (a[i][j]-1)/m+1;
            ++sum[i][group];
        }
    }
    // phase 1
    for (int j = 1; j <= m; ++j) {
        memset(co, 0, sizeof co);
        for (int i = 1; i <= n; ++i) {
            memset(vis, 0, sizeof vis);
            check(i);
        }
        for (int g = 1; g <= n; ++g) {
            int i = co[g];
            --sum[i][g];
            for (int k = j; k <= m; ++k) {
                int group = (a[i][k]-1)/m+1;
                if (group == g) {
                    swap(a[i][j], a[i][k]);
                    break;
                }
            }
        }
    }
    print();
    // phase 2
    for (int j = 1; j <= m; ++j) {
        for (int i = 1; i <= n; ++i) {
            sort_a[i] = a[i][j];
        }
        sort(sort_a+1, sort_a+n+1);
        for (int i = 1; i <= n; ++i) {
            a[i][j] = sort_a[i];
        }
    }
    print();
    return 0;
}

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

int main(void)
{
    int x,y;
    cin >> x >> y;

    if(y%2==1){
        cout << "No" << endl;
    }else if(x*2>y){
        cout << "No" << endl;
    }else if(x*4<y){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------
int n, m;

int dfs(int x, int y, vector<vector<int>> &grid, int cnt)
{
    //行けない場所に行ったら戻る
    if (x < 0 || x >= m || y < 0 || y >= n)
    {
        return cnt;
    }
    // 薄氷がなければ戻る
    if (grid[y][x] == 0)
    {
        return cnt;
    }
    cnt++;
    grid[y][x] = 0;
    int res = 0;
    for (int i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];
        chmax(res, dfs(nx, ny, grid, cnt));
    }
    grid[y][x] = 1;
    return res;
}

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

    while (true)
    {
        cin >> m >> n;
        if (n == 0 && m == 0)
        {
            return 0;
        }
        vector<vector<int>> grid(n, vector<int>(m));
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                cin >> grid[i][j];
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                chmax(ans, dfs(j, i, grid, 0));
            }
        }
        cout << ans << endl;
    }
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    st t ;
    st s ;
    cin >> t >> s ;

    cout << s + t ;



    return 0 ;
}


Measured memory_bytes: 256
import math
n = int(input())

coord_list = [list(map(int, input().split())) for _ in range(n)]
all_distances = 0

# 順列計算
for i in range(n-1):
    for j in range(i+1, n):
        distance = math.sqrt((coord_list[i][0] - coord_list[j][0]) ** 2 + (coord_list[i][1] - coord_list[j][1]) ** 2)      
        all_distances += distance
        # print("i:{}, j:{} distance:{}".format(i, j, distance))

print(all_distances * 2 / n)


Measured memory_bytes: 3060
digit :: Int -> Int
digit n = length $ takeWhile (<= n) ( iterate (*10) 1 )

-- 各桁ペアごとのルンルン性リストを返す
checkDigits :: Int -> [Bool]
checkDigits n = reverse [ abs (a - b) <= 1 | (a,b) <- zip ms (tail ms) ]
    where
        ms = take (digit n) . map (`mod` 10) $ iterate (`div` 10) n


-- ダメな桁ペアの一番最初のもの
-- 例：97123 -> 1,2番目の要素について、 (|9-7| <= 1) を満たさないから
--     この場合 2番目の要素を +1, つまり +10^3 = 10^(digit - 2(=badIndex)) 
--     したい。よって戻り値 2。
badIndex :: [Bool] -> Int
badIndex ns = (2+) . length $ takeWhile (== True) ns

isLun :: Int -> Bool
isLun n = and $ checkDigits n

bitLun :: Int -> Int
bitLun n 
    | isLun n   = 1 
    | otherwise = 0

floorNum :: Int -> Int -> Int
floorNum n i  = n - mod n (10^i)

searchK :: Int -> Int
searchK n = f' (n+1) 0
    where
    f' 0 count = count - 1
    f' k count = f' (k - bitLun count) next
        where
        next
            | isLun count = count + 1
            | otherwise   = floorNum (count + (10 ^ pow)) pow
        pow = digit count - badIndex (checkDigits count)

dbg :: Int -> IO()
dbg k = do
     print $ "k           " ++ show k
     print $ "checkDigits " ++ show (checkDigits k)
     print $ "isLun       " ++ show (isLun k)
     print $ "badIndex    " ++ (show $ badIndex (checkDigits k))
     print $ "step    10^ " ++ show ((digit k - badIndex (checkDigits k)))
     print " "

main :: IO ()
main = do
    --[n,k] <- map read . words <$> getLine :: IO [Int]
    {--
    dbg 1
    dbg 12
    dbg 13
    dbg 14
    dbg 19
    dbg 20
    dbg 22
    dbg 40
    dbg 112
    dbg 113
    dbg 120
    dbg 121
    --}
    
    --
    k <- read <$> getLine :: IO Int
    print $ searchK k
    --}


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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
int n,l[MAXN],r[MAXN];
ll ls,rs,res=0;
priority_queue<ll> L;
priority_queue<ll,vector<ll>,greater<ll> > R;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&l[i],&r[i]);
    L.push(l[1]);R.push(l[1]);
    for(int i=2;i<=n;i++)
    {
        ls-=r[i]-l[i];rs+=r[i-1]-l[i-1];
        ll lb=L.top()+ls,rb=R.top()+rs;
        if(l[i]<lb)
        {
            res+=lb-l[i];R.push(lb-rs);
            L.push(l[i]-ls);L.push(l[i]-ls);L.pop();
        }
        else if(l[i]>rb)
        {
            res+=l[i]-rb;L.push(rb-ls);
            R.push(l[i]-rs);R.push(l[i]-rs);R.pop();
        }
        else
        {
            L.push(l[i]-ls);
            R.push(l[i]-rs);
        }
    }
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 2804
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    li=[]
    for i in range(N):
        ab=list(map(int,readline().split()))
        li.append(ab)
    
    li.sort(key=lambda x:x[1])
    t=0
    for i in range(N):
        task=li[i]
        t+=task[0]
        if t>task[1]:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

Measured memory_bytes: 53656
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
const int maxn=1000;
ll lcm(ll a,ll b)
{
    return a*b/__gcd(a,b);
}
void dfs() {}
int dp[maxn][maxn];
signed main()
{
    IOS
    int num;
    cin>>num;
    memset(dp,0, sizeof(dp));
    for (int k = 0; k <=9 ; ++k)
    {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i)
    {
        for (int j = 0; j <=9 ; ++j)
        {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j)
    {
        for (int i = 1; i <=9 ; ++i)
        {
            if(num<=dp[j][i])
            {
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)
            break;
    }
    l--;
    ans.push(r);
    while(l!=0)
    {
        if(num<=dp[l][r-1])
        {
            r--;
            ans.push(r);
        }
        else
        {
            num-=dp[l][r-1];
            if(num<=dp[l][r])
            {
                ans.push(r);
            }
            else
            {
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty())
    {
        int now=ans.front();
        cout<<now;
        ans.pop();
    }
    return 0 ;
}


Measured memory_bytes: 4224
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let n: usize = read_line()[0];
    let a: Vec<usize> = read_line();

    let mut res_vec: Vec<usize> = vec![0; n];
    
    for a_i in a {
        res_vec[a_i - 1] += 1;
    }

    for res_i in res_vec {
        println!("{}", res_i);
    }
}


Measured memory_bytes: 5116
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

P = 10**9+7
D = {}
N = int(input())
A = [int(a) for a in input().split()]
t = 0
for a in A:
    t += pow(a, P-2, P)
    pf = primeFactor(a)
    for p in pf:
        if p in D:
            D[p] = max(D[p], pf[p])
        else:
            D[p] = pf[p]
s = 1
for f in D:
    s = (s * pow(f, D[f], P)) % P
print(s * t % P)

Measured memory_bytes: 48988
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<char> p(n); for (auto&& e : p) cin >> e;
  auto M = [](char x, char y) -> char {
    return x == 'F' or y == 'T' ? 'T' : 'F';
  };
  char res = M(p[0], p[1]);
  for (int i = 2; i < n; ++i) {
    res = M(res, p[i]);
  }
  cout << res << '\n';
}


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

int F(long A, long B)
{
    long target = max(A, B);
    return log10(target) + 1;
}

int main()
{
    long N;
    cin >> N;
    int result = log10(N)+1;
    for (long i=1; i<N; i++)
    {
        if (N%i==0)
        {
            int tmp = F(i, N/i);
            result = min(result, tmp);
        }
        if (i>pow(10, 5))
        {
            break;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  vector<ll> red(A);
  vector<ll> green(B);
  vector<ll> white(C);
  rep(i,A)cin>>red.at(i);
  rep(i,B)cin>>green.at(i);
  rep(i,C)cin>>white.at(i);
  sort(red.begin(),red.end(),greater<ll>());
  sort(green.begin(),green.end(),greater<ll>());
  vector<ll> ans(X+Y+C);
  rep(i,X)ans.at(i)=red.at(i);
  rep(i,Y)ans.at(i+X)=green.at(i);
  rep(i,C)ans.at(i+X+Y)=white.at(i);
  sort(ans.begin(),ans.end(),greater<ll>());
  ll sum=0;
  rep(i,X+Y)sum+=ans.at(i);
  cout<<sum<<endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[100005][13];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   string s;
   cin >> s;
   int n = s.size();

   dp[0][0] = 1;
   rep(i, 0, n) {
      if (s[i] == '?') {
         rep(d, 0, 10) rep(j, 0, 13) {
            (dp[i + 1][(j * 10 + d) % 13] += dp[i][j]) %= MOD;
         }
      } else {
         int d = s[i] - '0';
         rep(j, 0, 13) { (dp[i + 1][(j * 10 + d) % 13] += dp[i][j]) %= MOD; }
      }
   }

   ll ans = dp[n][5];
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 13900
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  string ans = "";
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != 'B') {
      ans += s[i];
    } else {
      if (ans.length() != 0) {
	ans.erase(ans.length()-1, 1);
      }
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }
  int ans=a[0];
  rep(i,n){
    if(ans==1){
      cout<<i+1<<endl;
      return 0;
    }
    ans=a[ans];
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3784
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	input := scanIntNum()
	fmt.Println(float64(input) * 2 * math.Pi)

}

func scanIntNum() (num int) {
	sc.Scan()

	num, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return num
}


Measured memory_bytes: 1756
from collections import defaultdict
def main():
    n,m = map(int,input().split())
    p = list(map(int,input().split()))
    xy = sorted([tuple(map(int,input().split())) for _ in range(m)])
    d = defaultdict(list)
    for i in xy:
        d[i[0]].append(i[1])
        d[i[1]].append(i[0])
    searched = [False]*n
    c = 0
    graph = []
    allset = set(range(1,n+1))
    while allset:
        xxx = allset.pop()
        pool = set([xxx])
        searched[xxx-1] = True
        g = [xxx]
        gap = g.append
        pad = pool.add
        while pool:
            s = pool.pop()
            tmp = set(d[s])
            dif = tmp&allset
            dad = dif.add
            for i in dif:
                if searched[i-1] is False:
                    dad(i)
                    searched[i-1] = True
                    c += 1
                    gap(i)
                    allset.discard(i)
                    pad(i)
        graph.append(tuple(g))
    ans = 0
    for i in graph:
        ppp = set([p[j-1] for j in i])
        ans += len(ppp&set(i))
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 119224
from collections import defaultdict, deque
import sys

INF = float('inf')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


h1, w1 = LI()
h, w = LI()
ans = max(0, (h1 - h) * (w1 - w))
print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main()
{
   //cout << "Hello World" << endl; 
   int n;
   cin>>n;
   int a[n][3];
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<3;j++)
       cin>>a[i][j];
   }
   int dp[n][3];
   for(int i=0;i<3;i++)
   dp[0][i]=a[0][i];
   for(int i=1;i<n;i++)
   {
       dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
       dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
       dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
   }
   cout<<max(dp[n-1][1],max(dp[n-1][2],dp[n-1][0]));
   return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll min(int x,int y){
	if(x<y) return x;
	else return y;
}
int main(){
	ll n,sum=0;
	scanf("%lld",&n);
	ll monster[n+1],hero;
	for(ll i=0;i<=n;i++)
		scanf("%lld",&monster[i]);
	for(ll i=0;i<n;i++){
		scanf("%lld",&hero);
		if(hero>monster[i]){
			sum+=monster[i];
			sum+=min(hero-monster[i],monster[i+1]);
			if(hero-monster[i]<monster[i+1])
				monster[i+1]-=hero-monster[i];
			else monster[i+1]=0;
		}
		else sum+=hero;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
		s=sc.nextLine();
		String S[]=s.split("");
		int ans=0;
		for(int i=0;i<S.length-1;i++) {
			int sum=0;String used="";
			for(int j=0;j<i;j++) {
				if( used.indexOf(S[j])==-1&&s.indexOf(S[j],i)>0)sum++;
				used+=S[j];
			}
			ans=Math.max(sum,ans);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25300
#include <iostream> 
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	sort(l.begin(), l.end());
	int shorthen = 0;
	for (int j = 0; j < n - 1; j++) shorthen = shorthen + l[j];
	if (l[n - 1] - shorthen < 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	if(a<b&&b<c){

		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}


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

void f(int x, int &a, int &b) {
  a = x % 10;
  b = 0;
    while (x > 0) {
      b = x;
      x /= 10;
    }
  return;
}

int main() {
  int n;
  cin >> n;
  
  vector<vector<int>> c(10, vector<int>(10, 0));
  for (int i = 1; i <= n; i++) {
    int a, b;
    f(i, a, b);
    c.at(a).at(b) += 1;
  }
  
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += c.at(i).at(j) * c.at(j).at(i);
    }
  }
  
  cout << ans << endl;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int n;
    cin>>n;

    vector<long long> b(n);

    rep(i,n)cin>>b[i];

    vector<int>ans;

    while(b.size()>0){
        bool find=false;

        for(int i=b.size()-1;i>-1;i--){
            if(b[i]==i+1){
            ans.insert(ans.begin(),b[i]);
            find=true;
            b.erase(b.begin()+i);
            break;
            }
        }

        if(!find){
            cout<<"-1"<<endl;
            return 0;
        }
    }
    rep(i,n)cout<<ans[i]<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

template <typename T,typename U>
struct compressor{
	vector<pair<T,U>> v;
	void add(T x,U y){
		v.emplace_back(x,y);
	}
	
	void compress(){
		stable_sort(v.begin(),v.end(),[&] (pair<T,U> a,pair<T,U> b){
			return a.first < b.first;
		}
		);
		
		vector<pair<T,U>> t;
		rep(i,v.size()){
			if(t.size()!=0 && t.back().first == v[i].first){
				t.back().second = func(t.back().second,v[i].second);
			}
			else{
				t.push_back(v[i]);
			}
		}
		swap(v,t);
		
	}

	U func(U a,U b){
		return a+b;
	}

	U e(){
		return 0;
	}

	int size(){
		return v.size();
	}
	
	U get(int p){
		return v[p].second;
	}
	
	U operator[] (T &x){
		auto it = lower_bound(v.begin(),v.end(),make_pair(x,0));
		if(it==v.end() || it->first!=x){
			if(it!=v.begin()){
				it--;
			}
		}
		if(it==v.end() || it->first!=x){
			return e();
		}
		else return it->second;
	}
};

bool f = false;
compressor<pair<string,string>,int> get(string S){
	int N = S.size();
	compressor<pair<string,string>,int> C;
	for(int i=0;i<(1<<N);i++){
		string s="",t="";
		for(int j=0;j<N;j++){
			if((i>>j)&1)s+=S[j];
			else t+=S[j];
		}
		reverse(t.begin(),t.end());
		if(f)swap(s,t);
		C.add(make_pair(s,t),1);
	}
	f=true;
	C.compress();
	return C;
}
 
int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	compressor<pair<string,string>,int> C0 = get(S.substr(0,N)),C1 = get(S.substr(N));
	
	long long ans = 0;
 
	for(auto a:C0.v){
		ans += (long long)a.second * C1[a.first];
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;

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

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


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
 
 
//---------------------------------------------
 
 
int main(void)
{
    float r;
    cin>>r;
 
    cout<<2*r*PI<<endl;
 
}

Measured memory_bytes: 3788
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
hand = {"r" : p, "s" : r, "p" : s}
ans = 0
for i in range(n):
  temp= i-k
  if temp >=0 and t[i]==t[temp]:
    t[i]=" "
  else:
    ans+=hand[t[i]]
print(ans)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());
  int n,l;
  string str;
  cin >> n >> l;
  vector<int> apples(n+1);
  apples[0] = -10000;
  int sum = 0;
  for(int i=1;i<=n;i++){
    apples[i] = l+i-1;
    sum += apples[i];
    //cout << apples[i];
  }
  //cout << sum << endl;
  int sa_min = 99999999;
  int k;
  for(int i=1;i<=n;i++){
    int sa = abs(apples[i]);
    if (sa <= sa_min) {
      sa_min = sa;
      k = apples[i];
    }
  }
  //sort(apples.begin(),apples.end());
  //int ans = 0;
  //for(int i=2;i<=n;i++){
//    ans += apples[i];
  //}
  cout << sum - k << endl;

  return 0;
}


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

static const int MAX = 1e5;
static const int INF = 1e9;

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<int> G[MAX], dt(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs1(int s) {
  queue<int> q;
  q.push(s);
  dt[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(dt[G[u][v]] == INF){
        dt[G[u][v]] = dt[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

// 隣接リストを用いた幅優先探索 O(|V|+|E|)
vector<int> da(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること

void bfs2(int s) {
  queue<int> q;
  q.push(s);
  da[s] = 0;
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v = 0; v < G[u].size(); v++){
      if(da[G[u][v]] == INF){
        da[G[u][v]] = da[u] + 1;
        q.push(G[u][v]);
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 無向(有向)グラフの隣接リスト
  int u, v, t, a;
  cin >> n >> t >> a;
  
  //vector<int> G[n]; // 頂点数がnのグラフを表す隣接リスト
  
  for(int i = 0; i < n - 1; i++){
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u); // 有向グラフではこの行をコメントアウト
  }
  
  bfs1(t - 1);
  bfs2(a - 1);
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(dt[i] < da[i]) ans = max(ans, da[i]);
  }
  
  cout << ans - 1 << "\n";
}

Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[101],ans[2];
bool cmp(const int &ai,const int &bi)
{
    return ai>bi;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++)
        ans[i&1]+=a[i];
    cout<<abs(ans[0]-ans[1])<<endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 27 02:05:32 2020

@author: liang
"""

N, M = map(int, input().split())
first = list()
second = set()

for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        first.append(b)
    if b == N:
        second.add(a)
        
for a in first:
    if a in second:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 20684
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	int H,W;cin>>H>>W;
	vector<vector<char>> VVI;
	VVI = vector<vector<char>>(H,vector<char>(W,0));
	rep(aa,H)rep(bb,W)cin>>VVI[aa][bb];

	int cnt = 0;
	for(int i = 0; i < H; i++){
		for(int t = 0; t < W; t++){
			cnt = 0;
			if(VVI[i][t] == '.'){
				cnt = 0;
				for(int x = -1; x <= 1; x++){
					for(int y = -1; y <= 1; y++){
						if(i + y >= 0 && t + x >= 0 && i + y < H && t + x < W){
							if(VVI[i + y][t + x] == '#'){
								cnt++;
							}
						}
					}
				}
				VVI[i][t] = to_string(cnt)[0];
			}
		}
	}
	//出力
	rep(j , H){
		rep(q , W){
			cout<<VVI[j][q];
		}
		cout<<endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    cin >> h >> w;
    vector<P> p(h);
    rep(i, h) {
        cin >> p[i].first >> p[i].second;
        p[i].first--; p[i].second--;
    }
    map<int, int> mp;
    multiset<int> se;
    rep(i, w) {
        mp[i] = i;
        se.insert(0);
    }
    

    rep(i, h) {
        int l = p[i].first;
        int r = p[i].second;
        int mr = -1;
        auto it = mp.lower_bound(l);
        while (it!=mp.end() && it->first<=r+1) {
            chmax(mr, it->second);
            int x = it->first - it->second;
            se.erase(se.find(x));
            auto pit = it;
            it++;
            mp.erase(pit);
        }
        if (mr!=-1 && r<w-1) {
            mp[r+1] = mr;
            se.insert(r+1-mr);
        }
        int ans = -1;
        if (se.size()>0) {
            ans = *se.begin();
            ans += (i+1);
        }
        pr(ans);
    }
    
    return 0;
}


Measured memory_bytes: 23516
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N; cin >> N;
	string S; cin >> S;
	int A[300005];
	int B[300005];
	for (int i = 0; i < N; ++i) {
		A[i] = 0;
	}
	if (S[0] == 'W') {
		A[0]++;
	}
	for (int i = 1; i < N; ++i) {
		if (S[i] == 'W') {
			A[i] = A[i - 1] + 1;
		}
		else {
			A[i] = A[i - 1];
		}
	}
	for (int i = 0; i < N; ++i) {
		B[i] = i + 1 - A[i];
	}
	int ans = INF;
	for (int i = 0; i < N; ++i) {
		int sum = 0;
		if (i == 0) {
			sum = B[N - 1] - B[0];
		}
		else {
			sum += A[i - 1] + B[N - 1] - B[i];
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3076
import math
N = int(input())
 
def Nsinpou(x, base):
    #配列を返す Nsin[0]が上位桁
    if x == 0: return [0]
    Nsin = []
    for i in range((round(math.log(x,base))+1)):
        ithdigit = x%(base**(i+1)) // (base ** i)
        Nsin.append(ithdigit)
    Nsin.reverse()
    return Nsin
 
ans = N
for i in range(N+1):
    coins = sum(Nsinpou(i,6)) + sum(Nsinpou(N-i,9))
    if coins < ans:
        ans = coins
    
print(ans)

Measured memory_bytes: 3064
def main5():
    N = int(input())
    S = list(input())

    r = g = b = 0
    for c in S:
        if c == "R":
            r += 1
        if c == "G":
            g += 1
        if c == "B":
            b += 1

    tmp = 0
    for i in range(len(S)):
        for j in range(len(S)):
            if i < j:
                k = 2*j - i
                if  k < len(S) and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                    tmp += 1
    
    ans = r*g*b - tmp

    print(ans)

if __name__ == "__main__":
    main5()

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 100000;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	int u, v;
	ll cost;
};

int main() {
	int n;
	vector<int> a;
	cin >> n;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		a.pb(tmp);
	}
	sort(a.begin(), a.end(), greater<int>());
	int suma, sumb;
	suma = sumb = 0;
	REP(i, n) {
		if (i % 2 == 0) suma += a[i];
		else sumb += a[i];
	}
	cout << suma - sumb << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i64 *sum = (i64 *) calloc (n + 1, sizeof (i64));
  for (i32 i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  i64 ans = 0;
  for (i32 bit = 40; bit >= 0;bit--) {
    i32 cnt = 0;
    for (i32 l = 0; l < n; ++l) {
      for (i32 r = l + 1; r <= n; ++r) {
	i64 v = sum[r] - sum[l];
	if ((v & ans) != ans) continue;
	cnt += (v >> bit) & 1;
      }
    }
    if (cnt >= k) {
      ans += (i64) 1 << bit;
    }
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


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

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

int main() {
    ll a;
    string b;
    cin >> a >> b;

    ll b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');

    cout << a * b100 / 100 << endl;

    return 0;
}



Measured memory_bytes: 3560
#include<stdio.h>
#include<stdlib.h>
#define max1 200000
int main()
{
    int n,i,a[max1]={0},b[max1]={0};
    scanf("%d",&n);

    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;(2*i)<n-1;i++)
{
    b[i]=a[n-2*i-1];
    b[n-i-1]=a[n-2*i-2];
}
    if(n%2)
        b[i]=a[0];
    for(i=0;i<n;i++)
    printf("%d ",b[i]);
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll M;
    cin >> M;
    ll d[M], c[M];
    rep(i, M) cin >> d[i] >> c[i];
    ll sum = 0, dig = 0;
    rep(i, M){
        sum += d[i]*c[i];
        dig += c[i];
    }
    ll ans = 0;
    ans += dig-1;
    if(sum %9 == 0) ans += sum/9-1;
    else ans += sum/9;
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<stdio.h>
#define N 2000000
int A[N];
int B[N];
int C[N];
main(){
  int i,j,k=0,l;
  scanf("%d",&l);
  for(i=0;i<l;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  for(i=0;i<=k;i++)
    C[i]=0;
  for(i=0; i<l; i++)
    C[A[i]]++;
  for(i=1; i<=k; i++)
    C[i]=C[i]+C[i-1];
  for(j=l; j>=0; j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  } 
  for(i=0;i<l;i++){
    printf("%d",B[i]);
    if(i !=l-1)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
   
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    if(n%10==3){
        cout << "bon" << "\n";
    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
        cout << "pon" << "\n";
    }else{
        cout << "hon" << "\n";
    }
    
}   
/*
183
*/

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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  vector<int> V = {A, B, C};
  int k = max_element(V.begin(), V.end()) - V.begin();
  V[k] *= (1 << K);
  int sum = 0;
  for(int i = 0; i < 3; i++) {
  	sum += V[i];
  }
  cout << sum << endl;
  return 0;
}

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

const int MOD = 1e+9 + 7;

int main() {
    int n,m;cin>>n>>m;
    int a[m];rep(i,m)cin>>a[i];
    rep(i,m-1)if(a[i+1]-a[i]==1){
        cout<<0<<endl;
        return 0;
    }

  ll b[n+1],c[n+1];
    memset(b,0,sizeof(b));

    rep(i,n+1)c[i]=1;
    rep(i,m)c[a[i]]=0;
    if(c[1]==1)b[1]=1;
    if(c[2]==1)b[2]=b[1]+1;
    for(int i = 3;i <= n;++i){
        b[i]=b[i-1]*c[i-1]+b[i-2]*c[i-2];
        b[i]%=MOD;
    }
    
    cout<<b[n]<<endl;
	return 0;
}

Measured memory_bytes: 5328
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean ans = true;
        int[][] array = new int[h + 2][w + 2];
        for (int i = 1; i < h + 1; i++) {
            String s = sc.next();
            for (int j = 1; j < w + 1; j++) {
                if (s.charAt(j - 1) == '.') {
                    array[i][j] = 0;
                } else {
                    array[i][j] = 1;
                }
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (array[i][j] == 1) {
                    if (array[i + 1][j] == 0 && array[i][j+ 1] == 0 && array[i - 1][j] == 0 && array[i][j - 1] == 0) {
                        ans = false;
                    }
                }
            }
        }
        if (ans) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23636
import Data.List

main = do
    s<-getLine
    let n = length s
    print $ minimum $ (n:) $ map (\i->max i (n-i)) $ f 1 s (tail s)
--
f _ _ [] = []
f i (a:ar) (b:br)
    | a /= b = i : f (i+1) ar br
    | otherwise = f (i+1) ar br

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

int main(){
  int n;
  vector<int> t,h;
  int tmp;
  int p,m;
  int i;

  while(1){
    cin >> n;
    if(!n)break;

    t.clear();
    for(i=0;i<n;i++){
      cin >> tmp;
      t.push_back(tmp);
    }
    sort(t.begin(),t.end());
    h.clear();
    int j = 0;
    for(i=1;i<=2*n;i++){
      if(t[j]!=i)h.push_back(i);
      else j++;
    }
    sort(h.begin(),h.end());

    p = 0;
    m = 0;
    while(1){
      if(!m){
	i = 0;
	while(i<t.size() && p>t[i])i++;
	if(i==t.size()){
	  p = 0;
	  m = 1;
	}else{
	  p = t[i];
	  t.erase(t.begin()+i);
	  if(!t.size())break;
	  m = 1;
	}
      }else{
	i = 0;
	while(i<h.size() && p>h[i])i++;
	if(i==h.size()){
	  p = 0;
	  m = 0;
	}else{
	  p = h[i];
	  h.erase(h.begin()+i);
	  if(!h.size())break;
	  m = 0;
	}
      }
    }
    cout << h.size() << endl << t.size() << endl;
  }
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    long double N;
    ll P;
    cin>>N>>P;
    ll gmax = pow(P, 1/N);
    for(ll g = gmax; g > 0; --g){
        ll gn = pow(g,N);
        if(P%gn==0){
            cout<<g<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <math.h>
#include <ctime>
#include <cstring>
#include <climits>
#include <sstream>
#include <array>
#include <tuple>
#include <set>
#include <iterator>
#include <cstdio>
#include <string>
#include <stack>
#include <valarray>
#include <utility>
#include <iomanip>
#include <list>
#include <numeric>
#include <regex>
#include <map>
#include <queue>
#include <deque>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define PI          3.1415926535
#define pb          push_back
#define ins         insert
#define INF         LLONG_MAX
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define uset        unordered_set
#define umap        unordered_map
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define double      long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007 //1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, b) for(ll i = (a); i<= (b); ++i)
#define trav(a, x) 	 for(auto &a : x)
#define re(i,n)      for(ll i = 0; i < n; ++i) 
const ll N = 4e5 + 7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template<typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template<typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;}
// always use 1ll*ans to avoid signed integer overflow; 
void prec(){

}

void solve(){
	int n;cin>>n;
	int h[n+1],dp[n+1];
	rep(i,1,n) cin>>h[i];
	dp[0]=0,dp[1]=0,dp[2]=abs(h[1]-h[2]),dp[3]=min(abs(h[1]-h[3]),abs(h[1]-h[2])+abs(h[2]-h[3]));
	rep(i,4,n){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]));
	}
	cout<<dp[n]<<endl;
}

int main()
{
    ios;
    int tc=1;
    //cin>>tc;
    prec();
    while(tc--)
    	solve();
    return 0; 
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define long long long
const int MOD=1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> num(N);
  for(int i=2; i<=N; i++){
    int tmp = i;
    while(tmp%2==0){
      tmp/=2;
      num[1]++;
    }
    for(int j=3; j<=sqrt(N); j+=2){
      while(tmp%j==0){
        tmp/=j;
        num[j-1]++;
      }
    }
    num[tmp-1]++;
  }
  long ans=1;
  for(int i=1; i<N; i++){
    if(N!=0){
      ans = ans*(num[i]+1)%MOD;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#define BIG 1000000000
using namespace std;
int a,b,c,ans;
int main() {
	scanf("%d%d%d",&a,&b,&c);
	ans=BIG;
	ans=min(ans,abs(c-b)+abs(b-a));
	ans=min(ans,abs(b-c)+abs(c-a));
	ans=min(ans,abs(c-a)+abs(a-b));
	ans=min(ans,abs(a-c)+abs(c-b));
	ans=min(ans,abs(b-a)+abs(a-c));
	ans=min(ans,abs(a-b)+abs(b-c));
	printf("%d\n",ans);
} 

Measured memory_bytes: 256
#include<stdio.h>
int rectangle(int tate,int yoko);
int main(void){
	int H[1000],W[1000],a,j;
	j=0;
	while(1){
		scanf("%d %d",&H[j] ,&W[j]);
			if((H[j]==0)&&(W[j]==0)){
			break;
	}
		j++;
	}
	for(a=0;a<j;a++){
		rectangle(H[a],W[a]);
		printf("\n");
	}
	return 0;
}
	
	int rectangle(int tate,int yoko){
		int h,i;
		for(h=0;h<tate;h++){
			for(i=0;i<yoko;i++){
				if((h>0)&&(h<tate-1)&&(i>0)&&(i<yoko-1)){
					printf(".");
				}
				else{
					printf("#");
				}
			}
			printf("\n");
		}
		return 0;
	}
	


Measured memory_bytes: 2032