akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N, K = map(int, readline().split())
  H = list(map(int, readline().split()))
  ans = N
  for i in range(N):
    if H[i]<K:
      ans -= 1
  print(ans)
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 10364
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import Data.Bits

modN = 1000000007


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

pow :: Int -> Int -> Int -> Int
pow base 1 modNum = base `mod` modNum
pow base time modNum
    | odd time = let 
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a * base `mod` modNum
    | otherwise = let
        a = pow base (time `div` 2) modNum `mod` modNum
        in
        a * a `mod` modNum

solve :: Int -> [Int] -> Int
solve n hs = let
    hMap = IM.fromList $ zip [1..] hs
    getI 1 = 0
    getI 2 = abs $ hMap IM.! 1 - hMap IM.! 2
    getI i = let
        hTwo = hMap IM.! (i - 2)
        hOne = hMap IM.! (i - 1)
        cTwo = dp IML.! (i - 2)
        cOne = dp IML.! (i - 1)
        h = hMap IM.! i
        in
        min ((+cTwo) . abs $ hTwo - h) ((+cOne) . abs $ hOne - h)
        
    dp = IML.fromList [(i, getI i)| i <- [1..n]]
    in 
    dp IML.! n


main = do
    n <- readInt
    hs <- readInts
    print $ solve n hs







Measured memory_bytes: 27004
MAX_N = 200
N = int(input())
a = [3, 5]
i = 7
while 3 * 5 * i < MAX_N:
  a.append(i)
  i += 2
len_a = len(a)
dot = []
for j in range(len_a-2):
  for k in range(j+1, len_a-1):
    for l in range(k+1, len_a):
      d = a[j] * a[k] * a[l]
      if d < MAX_N:
        dot.append(a[j] * a[k] * a[l])
dot = sorted(dot)
r = 0
for x in dot:
  if x <= N:
    r += 1
  else:
    break
print(r)

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

using namespace std;

const int mod = 1e9+7;

int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}
const int N = 10004;
const int M = 1000006;

int n;
int a[N];

int cnt[M];

int main() {
	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		scanf("%d", a + i);
	}

	for(int i = 0; i < n; i++) {
		int val = a[i];
		for(int j = 2; j * j <= val; j++) if(val % j == 0) {
			int tmp = 0;
			while(val % j == 0) {
				tmp++;
				val /= j;
			}
			cnt[j] = max(cnt[j], tmp);
		}
		if(val > 1) cnt[val] = max(cnt[val], 1);
	}

	int lc = 1;

	for(int i = 2; i < M; i++) if(cnt[i]) {
		lc = mul(lc, fexp(i, cnt[i]));
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans = add(ans, mul(lc, fexp(a[i])));
	}
	printf("%d\n", ans);

}


Measured memory_bytes: 2816
s=input()
n=len(s)
x=s[:((n-1)//2)]
y=s[((n+3)//2)-1:]
if s==s[::-1]:
        
    if x==x[::-1] and y==y[::-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
#!/usr/bin/env run-cargo-script

#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, StdinLock, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn solve(a: usize, b: usize, s: String) -> bool {
    let s = s.as_bytes();
    s.len() == a + b + 1
        && s.iter()
            .enumerate()
            .all(|(i, &c)| i == a && c == b'-' || i != a && b'0' <= c && c <= b'9')
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!(
        "{}",
        if solve(sc.next(), sc.next(), sc.next()) {
            "Yes"
        } else {
            "No"
        }
    );
}

struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}

trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3944823
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

map<pair<LL, LL>, LL> ma;

bool cmp(pair<pair<LL, LL>, LL> a, pair<pair<LL, LL>, LL> b){
    if(a.first.first != b.first.first)   return (a.first.first < b.first.first);
    if(a.first.second != b.first.second) return (a.first.second > b.first.second);
    return (a.second < b.second);
}

class LazySegmentTree{
private:
    int size_;
    vector<LL> v, lazy;
    void update(int a, int b, LL x, int k, int l, int r){
        push(k, l, r);
        if(r <= a || b <= l) return;
        if(a <= l && r <= b){
            lazy[k] = x;
            push(k, l, r);
        }else{
            update(a, b, x, k * 2,                l, (l + r) >> 1);
            update(a, b, x, k * 2 + 1, (l + r) >> 1,            r);
            v[k] = merge(v[k * 2], v[k * 2 + 1]);
        }
    }
    LL query(int a, int b, int k, int l, int r){
        push(k, l, r);
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return v[k];
        LL lc = query(a, b, k * 2,                l, (l + r) >> 1);
        LL rc = query(a, b, k * 2 + 1, (l + r) >> 1,            r);
        return merge(lc, rc);
    }

public:
    LazySegmentTree() : v(vector<LL>()), lazy(vector<LL>()) {};
    LazySegmentTree(int n){
        for(size_ = 1; size_ < n;) size_ <<= 1;
        v.resize(size_ * 4,0);
        lazy.resize(size_ * 4,0);
    }
    inline void push(int k, int l, int r){
        if(lazy[k] != 0){
            v[k] += lazy[k];
            if(r - l > 1){
                lazy[k * 2]     += lazy[k];
                lazy[k * 2 + 1] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    inline LL merge(LL x, LL y){
        return min(x, y);
    }
    inline void update(int l, int r, LL x){
        update(l, r, x, 1, 0, size_);
    }
    inline LL query(int l, int r){
        return query(l, r, 1, 0, size_);
    }
};

vector<pair<LL, LL>> V[222222];
LL dp[222222];

int main(){
    
    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);
    LL sum = 0;
    for(int i = 0; i < M; i++){
        int l, r;
        LL w;
        scanf("%d %d %lld", &l, &r, &w);
        ma[{l, r}] += w;
        sum += w;
    }
    
    // 2. dp更新.
    vector<pair<pair<LL, LL>, LL>> vec;
    for(auto X : ma) vec.push_back(X);
    sort(vec.begin(), vec.end(), cmp);
    for(auto X : vec) V[X.first.second].push_back({X.first.first, X.second});
    LazySegmentTree st(N + 5);
    for(int i = 1; i <= N + 1; i++){
        dp[i] = st.query(0, i);
        for(pair<LL, LL> v : V[i]) st.update(0, v.first, v.second);
        st.update(i, i + 1, dp[i]);
    }
    
    // 3. 出力.
    printf("%lld\n", sum - dp[N + 1]);
    return 0;
    
}

Measured memory_bytes: 48108
## coding: UTF-8

#ダブリングを利用した実装

N, K = map(int,input().split())
A = list(map(int,input().split()))

#2**59 < 10**18< 2**60より2**60まで格納する
l = [0] * (N*61)

for j in range(N):
    l[j] = A[j]


for i in range(1,61):
#for i in range(1, 4):
    for j in range(N):
        p = l[(i-1)*N+j] #一段上を参照(2**(i-1)回移動した時の移動先)
        q = l[(i-1)*N+(p-1)] #pから2**(i-1)回移動した時の移動先を参照　＝　2**i 回移動した時の移動先
        l[i*N+(j)] = q
    #print(l)
#print(l)

bin_str = format(K, 'b')
#print(bin_str)
s = bin_str[::-1]
#print(s)
now = 1 #start地点
for i in range(len(s)):
    if(s[i] == '1'):
        now = l[(i)*N + (now-1)]
        #print(now)

        '''
        next_index = i*N + l[i*N + (now-1)]-1
        nex = l[next_index]
        now = nex
        print(now)
        '''
print(now)

Measured memory_bytes: 166216
n = gets.to_i
h = gets.split.map &:to_i
(n-1).downto(0) do |i|
  if i == 0
    puts "Yes"
    exit
  end
  if h[i-1] - h[i] > 1
    puts "No"
    exit
  elsif h[i-1] - h[i] == 1
    h[i-1] -= 1
  end
end


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

using namespace std;
const long long INF = 1LL <<60;

int count(int c[6][6]){
  long res=0;
  long long i,j;
  
  for(i=0;i<6;i++){
    for(j=0;j<6;j++){
      res+=c[i][j];
    }
  }
  
  return res;
}


int main(void){
  long long h,w,k;
  long long i,j,l,m;
  string tmp;
  long long res=0;
  int tmp2;
  
  cin>>h>>w>>k;
  int c[6][6];
  int c_tmp[6][6]={};
  int c_tmp2[6][6]={};
  for(i=0;i<6;i++){
    for(j=0;j<6;j++){
      c[i][j]=0;
    }
  }
  for(i=0;i<h;i++){
    cin>>tmp;
    for(j=0;j<w;j++){
      c[i][j]=(tmp[j]=='#');
      //cout<<i<<" "<<j<<" "<<c[i][j]<<endl;
    }
  }
  
  for(i=0;i<pow(2,h);i++){
    for(l=0;l<6;l++){
      for(m=0;m<6;m++){
        c_tmp[l][m]=c[l][m];
      }
    }
    if((i&1)==1){
      for(l=0;l<6;l++){
        c_tmp[0][l]=0;
      }
    }
    if((i&2)==2){
      for(l=0;l<6;l++){
        c_tmp[1][l]=0;
      }
    }
    if((i&4)==4){
      for(l=0;l<6;l++){
        c_tmp[2][l]=0;
      }
    }
    if((i&8)==8){
      for(l=0;l<6;l++){
        c_tmp[3][l]=0;
      }
    }
    if((i&16)==16){
      for(l=0;l<6;l++){
        c_tmp[4][l]=0;
      }
    }
    if((i&32)==32){
      for(l=0;l<6;l++){
        c_tmp[5][l]=0;
      }
    }
    for(j=0;j<pow(2,w);j++){
      for(l=0;l<6;l++){
        for(m=0;m<6;m++){
          c_tmp2[l][m]=c_tmp[l][m];
        }
      }

      if((j&1)==1){
        for(l=0;l<6;l++){
          c_tmp2[l][0]=0;
        }
      }
      if((j&2)==2){
        for(l=0;l<6;l++){
          c_tmp2[l][1]=0;
        }
      }
      if((j&4)==4){
        for(l=0;l<6;l++){
          c_tmp2[l][2]=0;
        }
      }
      if((j&8)==8){
        for(l=0;l<6;l++){            
          c_tmp2[l][3]=0;
        }
      }
      if((j&16)==16){
        for(l=0;l<6;l++){
          c_tmp2[l][4]=0;
        }
      }
      if((j&32)==32){
        for(l=0;l<6;l++){
          c_tmp2[l][5]=0;
        }
      }
      tmp2=count(c_tmp2);
      //cout<<i<<j<<tmp2<<endl;
      if(k==tmp2){
        res++;
      }
    }
    //cout<<i<<" "<<tmp2<<endl;
  }
  //res=res/pow(2,12-h-w);
  cout<<res<<endl;
  return 0;
  
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

using namespace std;

vector<int> smallest_prime_factors(int n) {
  vector<int> spf(n + 1);
  for (int i = 0; i <= n; i++) spf[i] = i;
  for (int i = 2; i * i <= n; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j <= n; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  return spf;
}

vector<int> factolization(int x, vector<int> &spf) {
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    x /= spf[x];
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> A(n); rep(i,n) std::cin >> A[i];

  bool setwise = false;
  ll sw = A[0];
  rep(i,n) sw = gcd(sw,A[i]);
  if ( sw == 1 ) setwise = true;

  std::unordered_map<int,int> mp;
  auto spf = smallest_prime_factors(1000000);
  rep(i,n) {
    auto result = factolization(A[i], spf);
    std::set<int> s;
    for(auto&& a : result) s.insert(a);
    for(auto&& a : s) mp[a]++;
  }

  bool pairwise = true;
  for(auto&& k : mp) {
    //std::cout << k.first << " " << k.second << std::endl;
    if ( k.second >= 2 ) pairwise = false;
  }

  if ( pairwise ) std::cout << "pairwise coprime" << std::endl;
  else if ( setwise ) std::cout << "setwise coprime" << std::endl;
  else std::cout << "not coprime" << std::endl;
  return 0;
}



Measured memory_bytes: 14424
#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;
//const int INF = 1e8;
using namespace std;

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

	vector<vector<int>> a(n, vector<int>(n,0));
	rep(i,n){
		int from;
		int m;
		cin >> from >> m;
		from--;
		rep(j,m){
			int to;
			cin >> to;
			to--;
			a[from][to] = 1;
		}
	}

	rep(i,n){
		rep(j,n){
			if(j) cout << ' ';
			cout << a[i][j];
		}
		cout << endl;
	}
}



Measured memory_bytes: 3148
function Main(input) {
    input = input.split(" ").map(Number);

    var A = input[0];
    var B = input[1];
    var C = input[2];

    var ans = C - (A - B);

    if (ans < 0) ans = 0;

  	//出力
	console.log(ans);
}

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

Measured memory_bytes: 21064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    enum Color { white, gray, black }

    class Node
    {
        internal int d, f;
        internal Color color;
        internal Queue<int> adj;

        public Node() { adj = new Queue<int>(); }
    }

    class Program
    {
        static int cnt;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Node[] nodes = new Node[n + 1];

            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                nodes[input[0]] = new Node();

                for (int j = 0; j < input[1]; j++)
                {
                    nodes[input[0]].adj.Enqueue(input[2 + j]);
                }
            }

            cnt = 0;

            for (int i = 1; i <= n; i++)
            {
                if (nodes[i].color == Color.white) DFS(nodes, nodes[i]);
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= n; i++)
            {
                sb.AppendLine(i + " " + nodes[i].d + " " + nodes[i].f);
            }
            Console.Write(sb);
        }

        static void DFS(Node[] nodes, Node node)
        {
            Stack<Node> stk = new Stack<Node>();

            node.color = Color.gray;
            node.d = ++cnt;
            stk.Push(node);

            while (stk.Count > 0)
            {
                Node u = stk.Peek();

                int v = -1;
                while (u.adj.Count > 0 && v == -1)
                {
                    if (nodes[u.adj.Peek()].color == Color.white) v = u.adj.Dequeue();
                    else u.adj.Dequeue();
                }

                if (v != -1)
                {
                    nodes[v].color = Color.gray;
                    nodes[v].d = ++cnt;
                    stk.Push(nodes[v]);
                }
                else
                {
                    u.color = Color.black;
                    u.f = ++cnt;
                    stk.Pop();
                }
            }
        }
    }
}

Measured memory_bytes: 10140
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

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

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
//約数を全て列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  auto po = divisor(N);
  ll ans = llINF;
  REP(i, po.size()) { ans = min(ans, po[i] + (N / po[i]) - 2); }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

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

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


int main() {

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = (k % 2 == 1) ? b - a : a - b;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

void intAryScan(int b[], int size)
{
  int i;
  for(i = 0; i < size; i++){
    scanf("%d", &b[i]);
  }
  return;
}

int main()
{
  int s[10000], t[500], n, q;
  int c, i, j;

  scanf("%d", &n);
  intAryScan(s, n);
  scanf("%d", &q);
  intAryScan(t, q);

  c = 0;
  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(t[i] == s[j]){
        c++;
		break;
      }
    }
  }
  printf("%d\n", c);

  return(0);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll x,a,b;
	cin>>x>>a>>b;
	if(x+a<b)
		cout<<"dangerous"<<endl;
	else if(b<=a)
		cout<<"delicious"<<endl;
	else
		cout<<"safe"<<endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var n = parseInt(input[0], 10);
    var v = input[1].split(' ');
    v = v.map(str => parseInt(str, 10));
    v.sort(function(a,b){return (a-b)});
    var worth = 0;
    for(var i=0;i<n;i++){
        worth += (i==0) ? v[i]/Math.pow(2,n-1) : v[i]/Math.pow(2,n-i);
    }

	console.log(worth);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    
    ll n,i;
    cin>>n;
    ll a[n],b[n],c[n];
    for(i=0;i<n;i++)
    {
      cin>>a[i]>>b[i]>>c[i];
    }
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(i=1;i<n;i++)
    {
      dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
      dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
      dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
 //     cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
}

Measured memory_bytes: 4864
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N, K;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  int last = 0, num = 0;
  while (last < N-1) {
    last += K-1;
    num++;
  }
  cout << num << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

import(
    "fmt"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := "ACGT"
    ans := 0
    for i:=0; i<len(s); i++{
        for j:=i; j<len(s); j++{
            b := false
            for k:=0; k<4; k++{
                if s[j]==a[k]{
                    b = true
                }
            }
            if !b{
                break
            }
            ans = max32(ans,j-i+1)
        }
    }
    fmt.Println(ans)
}





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

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 2;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<int> a(N);
    bool one = false;
    {
        string S;
        cin >> S;
        for (int i = 0; i < N; i++) {
            a[i] = S[i] - '1';
            if (a[i] == 1) one = true;
        }
    }
    if (!one) for (int i = 0; i < N; i++) a[i] /= 2;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (((N - 1)&i) != i) continue;
        ans += a[i];
        ans %= 2;
    }
    if (!one) ans *= 2;
    cout << ans << endl;
}


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

int main() {
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    for(int i=0;i<b;i++){
        for(int j=0;j<a;j++){
            cout << '0';
        }
        for(int j=0;j<w-a;j++){
            cout << '1';
        }
        cout << endl;
    }
    for(int i=0;i<h-b;i++){
        for(int j=0;j<a;j++){
            cout << '1';
        }
        for(int j=0;j<w-a;j++){
            cout << '0';
        }
        cout << endl;
    }
}

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

int main()
{
    ll N, M;
    cin >> N >> M;

    ll L[100100], R[100100];

    for (int i = 0; i < M; i++)
        cin >> L[i] >> R[i];

    ll *lmax = max_element(L, L + M);
    ll *rmin = min_element(R, R + M);

    ll res = 0;
    if (*rmin - *lmax >= 0)
    {
        res = *rmin - *lmax + 1;
    }

    cout << res << "\n";
}

Measured memory_bytes: 1792
def priority_push(array:, num:)
  index = array.bsearch_index { |i| i <= num}
  if index.nil?
    array.push(num)
  else
    array.insert(index, num)
  end
end

def priority_update(array:, index:, num:)
  array.delete_at(index)
  priority_push(array: array, num: num)
end

N = gets.to_i
arr = N.times.map{ gets.to_i }
stacks = [arr.shift]

arr.each do |i|
  overwrite_index = stacks.bsearch_index { |target| target < i }
  if overwrite_index.nil?
    stacks.push(i)
  else
    priority_update(array: stacks, index: overwrite_index, num: i)
  end
end
puts stacks.count


Measured memory_bytes: 4020
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define Pp push
#define LSTAGE 1
int arr[200010];
ll bfs(vector<int> a[])
{
    queue<int>v;
    v.push(1);
    int t;
    arr[1] = 0;
    int x;
    while(v.size())
    {
        t = v.front();
        v.pop();
        if(arr[t]==2)
            return 1;
        for(int i= 0; i < a[t].size(); i++)
        {
            x = a[t][i];
            if(arr[x]==-1)
            {
                v.push(x);
                arr[x] = arr[t]+1;

            }
        }

    }
    return 0;

}


int main()
{
 map<ll, ll> v;
 v.clear();
 ll n;
 cin >> n;
 ll r;
 while(n--)
 {
     cin >> r;
     if(v.count(r)==0)
     {
         v[r]==0;
     }
     if(v.count(r+1)==0) v[r+1] = 0;
     if(r>0 && v.count(r-1)==0) v[r-1] = 0;

     v[r]++;
     v[r-1]++;
     v[r+1]++;
 }
 map<ll, ll> :: iterator it;
 it = v.begin();
 ll mx  =0;
  while(it!= v.end())
  {
      mx = max(mx, it->S);
      it++;
  }
  cout << mx << endl;


    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
  	cin >> s;
  	if (s[s.size() - 1] == 's')
    	s += "es";
  	else
    	s += "s";
  	cout << s;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
using namespace std;
int main()
{
    long long n,ans=1,a=1000000007;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        ans=ans*i;
        if (ans>a)
            ans=ans%a;
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}                



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

int main() {
  int a;
  cin >> a;
  int res =a+pow(a,2)+pow(a,3);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4096
fun main(args: Array<String>) {
    val X = readInt()
    val list = mutableListOf<Int>()
    x@for (x in 2..100003) {
        for(l in list) if(x%l == 0) continue@x
        if (x >= X){
            println(x)
            return
        }
        list.add(x)
    }
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun Int.pow(n: Int) = Math.pow(this.toDouble(), n.toDouble())

Measured memory_bytes: 33736
import java.util.Scanner;

// 4
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		double ans = Math.ceil(N / 1.08);
		if((int)((int)ans * 1.08) == N)
			System.out.println((int)ans);
		else
			System.out.println(":(");
	}

}


Measured memory_bytes: 35672
#include <iostream>
#include <string>
#include <set>
using namespace std;

int main(){
 int N;
  cin >> N;
  set<string> dic;
 for(int i=0; i<N;i++){
   string str;
   cin >> str;
   dic.insert(str);
   
 }
  cout << dic.size()<<endl;
  return 0;
}


Measured memory_bytes: 19180
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1 << (x))
using namespace std;

int func(int x){
	int res = 0;
	while(x){
		res += x%10;
		x/=10;
	}
	return res;
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	int ans = 0;
	REPA(i, N+1){
		if(A <= func(i) && func(i) <= B)ans+=i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

int n=8;

void run(){
    vi ij(n,-1);
    int k;
    cin>>k;
    rep(i,k){
        int r,c;
        cin>>r>>c;
        ij[r]=c;
    }
    vi a(n);
    iota(all(a),0);
    do{
        bool f=true;
        rep(i,n){
            if(ij[i]!=-1&&ij[i]!=a[i])f=false;
        }
        rep(i,n){
            Rep(j,i+1,n){
                if(j-i==abs(a[i]-a[j]))f=false;
            }
        }
        if(f){
            rep(i,n){
                rep(j,n){
                    cout<<(a[i]==j?'Q':'.');
                }
                cout<<endl;
            }
        }
    }while(next_permutation(all(a)));
}


Measured memory_bytes: 3232
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

fn main() {
    input! {
        n:usize,
        mut a:[i64;n],
    }
    let n = n as i64;
    a.sort();
    let mut mp = HashMap::new();
    for &x in a.iter() {
        *mp.entry(x).or_insert(0) += 1;
    }
    if mp.len() == 1 {
        if let Some(x) = mp.get(&0) {
            yn(true);
            return;
        } else {
            yn(false);
            return;
        }
    } else if mp.len() == 2 {
        if n % 3 == 0 && mp.get(&0) == Some(&(n / 3)) {
            yn(true);
        } else {
            yn(false);
        }
    } else if mp.len() == 3 {
        let k = mp.keys().collect::<Vec<_>>();
        if n % 3 == 0 && mp.values().all(|&c| c == n / 3) && k[0] ^ k[1] ^ k[2] == 0 {
            yn(true);
        } else {
            yn(false);
        }
    } else {
        yn(false);
    }
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

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

int main() {
  ll n, ans = 0, mn = INF, p = 1;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll dp[n + 1][2];
  dp[0][0] = 0;
  dp[0][1] = -INF;
  for (int i = 1; i <= n; ++i) {
    dp[i][0] = max(dp[i - 1][0] + a[i - 1], dp[i - 1][1] - a[i - 1]);
    dp[i][1] = max(dp[i - 1][0] - a[i - 1], dp[i - 1][1] + a[i - 1]);
  }

  cout << dp[n][0] << endl;
  return 0;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i = 0; i < (int) s.length();++i)
    {
        if(i%2 == 0)
        {
            if(s[i] == 'L')
            {
                cout << "No";
                return 0;
            }
        }
        else
        {
            if(s[i] == 'R')
            {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
N = int(input())
dia = []
for _ in range(N-1):
    c,s,f = map(int,input().split())
    dia.append((c,s,f))
for i in range(N-1):
    time = 0
    for j in range(i,N-1):
        c,s,f = dia[j]
        while time > s:
            s += f

        time = s + c
    print(time)
print(0)










Measured memory_bytes: 42620
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int X, Y;

int main()
{
	scanf("%d %d", &X, &Y);

	if (X%Y == 0) printf("-1");
	else
	{
		printf("%lld", (ll)X*(Y + 1));
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

const int mod = 1e9 + 7;

ll pot(ll a, ll b) {
	if (!b) return 1;
	if (b % 2) return a * pot(a, b - 1) % mod;
	return pot(a * a % mod, b / 2);
}

int n, k;
int dp[100005];

int main() {		
	scanf ("%d%d", &n, &k);
	ll res= 0 ;
	per(i, 1, k) {
		dp[i] = pot(k / i, n);
		for (int j = i + i; j <= k; j += i)
			dp[i] = (dp[i] - dp[j] + mod) % mod;
		res = (res + (ll) dp[i] * i) % mod;
	}
	printf ("%lld\n", res);
	return 0;
}


Measured memory_bytes: 4112
#include<stdio.h>
 #include<stdlib.h>
 int main()
 {
     int a,b,j=0;
     scanf("%d%d",&a,&b);
     for(int i=0;i<=b||i<=a;i++)
     {
         if(abs(a-i)==abs(b-i)) {printf("%d",i); j=1;  break;}
     }
        if(j==0) printf("IMPOSSIBLE");
 }


Measured memory_bytes: 1728
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

killed = 0
for i in range(n):
    now_kill = min(a[i], b[i])
    killed += now_kill
    a[i] -= now_kill
    b[i] -= now_kill 
    if b[i] == 0:continue
    now_kill = min(a[i+1], b[i])
    killed += now_kill
    a[i+1] -= now_kill
    b[i] -= now_kill 

print(killed)


Measured memory_bytes: 19244
#!python3

# import numpy as np


# input
H, W = list(map(int, input().split()))


def main():
    if H == 1 or W == 1:
        print(1)
        return
    a = b = H // 2
    if H % 2 == 1:
        a += 1
    ans = (a + b) * (W // 2)
    if W % 2 == 1:
        ans += a
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <algorithm>

void a(std::istream& in)
{
    int N;
    in >> N;

    int change = N % 1000;
    change = change == 0 ? 0 : 1000 - change;

    std::cout << change;
}

int main(int, char* [])
{
    a(std::cin);
    return 0;
}



Measured memory_bytes: 3228
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    s = list(input())
    t = list(input())

    slen = len(s)
    tlen = len(t)
    dp = [[0 for _ in range(tlen + 1)] for _ in range(slen + 1)]

    for i in range(slen):
        for j in range(tlen):
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j], dp[i][j+1])

    ans = ''
    while slen > 0 and tlen > 0:
        if dp[slen][tlen] == dp[slen - 1][tlen]:
            slen -= 1
        elif dp[slen][tlen] == dp[slen][tlen - 1]:
            tlen -= 1
        else:
            slen -= 1
            tlen -= 1
            ans += s[slen]
    print(ans[::-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 120796
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,M=map(int, input().split())

if N==1 and M==1:
    print(1)
    sys.exit()

if N==1:
    print(M-2)
    sys.exit()

if M==1:
    print(N-2)
    sys.exit()

print((N-2)*(M-2))


Measured memory_bytes: 77472
use std::io;

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn main() {

    let s = read_one::<String>();
    let ars = s.chars().filter(|s| *s == 'o')
        .collect::<String>().len();
    println!("{}", 700 + 100 * ars);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> k;
    int a = 0, b = 0;
    erep(i, 1, k) {
        if (i%2) a++;
        else b++;
    }
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] input = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        bool flag = false;

        for (int i = 0; i < n; i++)
        {
            if (input[i] % 2 == 0)
            {
                if (input[i] % 3 != 0 && input[i] % 5 != 0)
                {
                    flag = true;
                }
            }
        }

        if (!flag)
        {
            Console.WriteLine("APPROVED");
        }
        else
        {
            Console.WriteLine("DENIED");
        }
    }
}


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

int main() {
  string s; cin >> s;
  int sum = 0;
  for(char c : s) {
    sum += (c - '0');
  }
  cout << (sum % 9 == 0 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3716
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long h  = sc.nextLong();
		long ans = func(h);
		System.out.println(ans);

	}

	public static long func(long h) {
		if(h==1) {
			return 1;
		}
		else {
			return 2*func(h/2)+1;
		}
	}
}

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

using namespace std;

#define M_DEBUG if (1)

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using lint = long long;
typedef unsigned long long int ullint;


/******************************************************************************
	Main
******************************************************************************/
#define L_N_MAX 101
#define L_W_MAX 100001

int main()
{
	int n = 0, w = 0;
	cin >> n >> w;
	assert(n >= 1 && n <= 100);
	assert(w >= 1 && w <= pow(10, 5));

	int ws[L_N_MAX] = {0};
	ullint vs[L_N_MAX] = {0};
	rep(i, n){
		cin >> ws[i] >> vs[i];
		assert(ws[i] >= 1 && ws[i] <= w);
		assert(vs[i] >= 1 && vs[i] <= pow(10, 9));
	}

	// ullint sum_list[L_N_MAX][L_W_MAX] = {0}; // [-] RE: return code 139
	ullint **sum_list = new ullint*[L_N_MAX]; // 品物 i までを w を超えないように選んだ(w, v)合計の最大値
	rep(i,L_N_MAX) {
		sum_list[i] = new ullint[L_W_MAX];
	}
	rep(i, n){
		rep(sum_w, w+1) {
			// i 番目の品物を取る場合の価値
			if (sum_w >= ws[i]) {
				chmax(sum_list[i+1][sum_w], sum_list[i][sum_w - ws[i]] + vs[i]); // 今追加しようとしている品物の重さ ws[i] を除いた重さ sum_w - ws[i] での最大価値 + 品物の町 v[i]
			}
			// 取らない
			chmax(sum_list[i+1][sum_w], sum_list[i][sum_w]);
		}
	}
	cout << sum_list[n][w] << endl;

	rep(i,L_N_MAX) {
		delete[] sum_list[i];
	}
	delete[] sum_list;

	return 0;
}


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

int main(void) {
  //変数宣言
  int n = 0;
  char vote[102][5] = {};
  int person[26] = {};
  int max = 0;
  int max2 = 0;
  char maxperson[2] = {};
  int i = 0;
  int j = 0;
  int temp = 0;


  while (true) {
    //初期化
    for (i = 0; i <= 101; i++) {
      vote[i][0] = 0;
    }
    for (i = 0; i <= 25; i++) {
      person[i] = 0;
    }
    max = 0;
    max2 = 0;
    maxperson[0] = 0;

    //読み込み
    scanf("%d", &n);

    //n==0ならwhile無限ループを抜ける
    if (n == 0) {
      break;
    }

    //読み込み
    for (i = 0; i <= n - 1; i++) {
      scanf("%s", vote[i]);
    }
    

    for (i = 0; i <= n - 1; i++) {
      //tempはi+1票目の得票者がだれかを表す数字
      temp = vote[i][0] - 'A'; 

      //person[temp]はアルファベットtemp+1番目の人の投票数
      person[temp]++;

      //i+1票目時点での最多得票の値とそれが誰か、二番目の得票数の値を記録
      if (max < person[temp]) {
        max = person[temp];
        maxperson[0] = vote[i][0];
      } else if (max2 < person[temp]) {
        max2 = person[temp];
      }

      //残りの票数＋二番目の得票数＜最多得票数なら勝ち目がない
      if (max > max2 + n - 1 - i) {
        printf("%s %d\n", maxperson, i + 1);
        break;
      }

      //breakしなけりゃTIE
      if (i == n - 1) {
        printf("TIE\n");
      }
    }
  }
  return 0;
}




Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int l,r,d; cin >> l >> r >> d;
    int ans=0;
    for(int i=l; i<=r; i++){
        if(i%d==0) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n, k;cin>>n>>k;
    int num;
    if (n % 2 == 0){
        num = n / 2;
    } else {
        num = (n+1)/2;
    }
    if (num >= k){
        cout << "YES" <<endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256