akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

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

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [n] <- readInt
  put $ n `div` 3


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5+9;

struct graph {
    vector<int> from;
    int cost = -1; // この頂点に来る最大コスト
};
int n, m;
graph g[SIZE];

int dfs(int i) {
    if(g[i].cost != -1) return g[i].cost;
    if(g[i].from.empty()) return 0;

    int cost_max = -1;
    for(auto fi : g[i].from)
        cost_max = max(cost_max, dfs(fi));

    return g[i].cost = cost_max + 1;
}


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

    for(int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[y].from.push_back(x);
    }

    int ans = -1;
    for(int i = 1; i <= n; i++) {
        if(g[i].cost == -1)
            g[i].cost = dfs(i);
        ans = max(ans, g[i].cost);
    }
    cout << ans << endl;
}

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

int main()
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	int err=0;

	for(int i=1; i<=n; i++)
	{
		int pi;
		cin>>pi;

		if(i!=pi) err++;
	}

	if(err>2) cout << "NO" << endl;
	else cout << "YES" << endl;
}

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

using namespace std;

int oo = 0x3f3f3f3f;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)

int dist[400][400];
int pre[400][400];

void floyd(int n) {
    FOR(i,0,n) FOR(j,0,n)
        pre[i][j] = i;
    FOR(k,0,n) FOR(i,0,n) FOR(j,0,n)
        if (dist[i][k] < oo && dist[k][j] < oo && dist[i][k]+dist[k][j] < dist[i][j]) {
            dist[i][j] = max(dist[i][k]+dist[k][j], -oo);
            pre[i][j] = (pre[k][j] != j ? pre[k][j] : pre[i][k]);
        }
}

int main() {
    vector<vector<int>> dirs = {{1,0}, {-1,0}, {0,1}, {0,-1}};

    int h, w;
    cin >> h >> w;

    for (int i = 0; i < 400; i++) {
        for (int j = 0; j < 400; j++) {
            if (i == j) dist[i][j] = 0;
            else dist[i][j] = oo;
        }
    }

    vector<vector<bool>> s = vector<vector<bool>>(h, vector<bool>(w, false));
    string si;
    vector<vector<int>> node_num = vector<vector<int>>(h, vector<int>(w, -1));
    int node_count = 0;
    for (int i = 0; i < h; i++) {
        cin >> si;
        for (int j = 0; j < w; j++) {
            if (si[j] == '.') {
                node_num[i][j] = node_count;
                node_count++;
                s[i][j] = true;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (!s[i][j]) continue;
            for (int k = 0; k < 4; k++) {
                vector<int> dir = dirs[k];
                if (i+dir[0] >= 0 && i+dir[0] < h && j+dir[1] >= 0 && j+dir[1] < w) {
                    if (s[i+dir[0]][j+dir[1]]) {
                        dist[node_num[i][j]][node_num[i+dir[0]][j+dir[1]]] = 1;
                    }
                }
            }
        }
    }

    floyd(node_count);

    int max_dist = 0;
    FOR(i,0,400) FOR(j,0,400) {
        if (dist[i][j] != oo) max_dist = max(max_dist, dist[i][j]);
    }

    cout << max_dist << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int a,b,x;
int main()
{
    cin>>a>>b>>x;
    if (x<a||x>(a+b))
    {
        cout<<"NO";
        return 0;
    }
    if (a==x||x<=(a+b))
    {
        cout<<"YES";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(x1);CIN(y1);
    CIN(x2);CIN(y2);
    cout<<x2 + y1-y2 <<" "<<y2 + x2-x1<<" "<<x1 - y2 + y1 <<" "<<y1 + x2 - x1<<std::endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
#define MOD 1000000007
 
ll gcd(ll a, ll b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void){
    int N,M; cin >> N >> M;
    if(N < M) rep(i,M) cout << N;
    else rep(i,N) cout << M;
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll h, w, n;
    cin>>h>>w>>n;
    map<LP, ll> mp;
    rep(i, n) {
        ll x, y;
        cin>>x>>y; x--; y--;

        rep(j, 3) rep(k, 3) {
            ll nx = x + j - 2;
            ll ny = y + k - 2;
            if (nx >= 0 && nx < h - 2 && ny >= 0 && ny < w - 2) mp[LP(nx, ny)]++;
        }
    }
    vl ans(10);
    ll z = (h - 2) * (w - 2);
    for (auto v : mp) {
        ans[v.second]++;
        z--;
    }
    ans[0] = z;
    rep(i, 10) cout<<ans[i]<<endl;
}

Measured memory_bytes: 56576
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main()
{
	vector<string> c(3);
	std::cin >>c[0] >>c[1] >> c[2];

	
	std::cout << c[0][0] << c[1][1] << c[2][2];
	
	return 0;
}


Measured memory_bytes: 256
def factorization(n: int) -> list:
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    n = int(input())
    if n == 1:
        print(0)
        return
    factors = factorization(n)
    ans = 0

    for _, e in factors:
        ei = 1
        ans += 1
        while ei < e:
            e -= ei
            ei += 1
            if ei <= e:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63448
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n, m, k = read()
	arr1 = [0]+read(); arr2 = [0]+read()
	for i in range(1, n+1):arr1[i] += arr1[i-1]
	for i in range(1, m+1):arr2[i] += arr2[i-1]

	i = 0; ans = 0
	while i < n+1 and arr1[i] <= k:
		tem = i + bisect(arr2, k-arr1[i])-1
		# print(tem, i, arr1[i], bisect(arr2, k-arr1[i]))
		ans = max(ans, tem)
		i += 1
	print(ans)

	





		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 42380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
  int a,b;cin >> a >> b;
  int ans = a+ b;
  if(ans<10){
    cout << ans << endl;
  }else {
    cout << "error" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int n;
  long double x;
  string u;
  cin >> n;
  long double sum = 0;
  for(int i = 0;i < n;i++){
    cin >> x >> u;
    if(u == "JPY"){
      sum += x;
    }else{
      sum += (x * 380000.0);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
import bisect

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

A.sort()
C.sort()

res = 0
for b in B:
    res += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
    
print(res)

Measured memory_bytes: 23232
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	g := make([][]int, n)
	for i := 0; i < m; i++ {
		a, b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
	}

	var dfs func(a int, arr []int) bool
	t := 0
	ts := make([]int, n)
	var ans []int
	dfs = func(a int, arr []int) bool {
		if len(arr) != 1 && a == arr[0] {
			ans = arr
			return true
		}
		for _, b := range g[a] {
			if ts[b] == t {
				continue
			}
			ts[b] = t
			if dfs(b, append(arr, b)) {
				return true
			}
		}
		return false
	}

	for i := 0; i < n; i++ {
		t++
		if dfs(i, []int{i}) {
			break
		}
	}

	if len(ans) == 0 {
		fmt.Fprintln(wr, -1)
	} else {
		for {
			f := make([]bool, n)
			idx := map[int]int{}
			for i := 0; i < len(ans)-1; i++ {
				f[ans[i]] = true
				idx[ans[i]] = i
			}
			a, b := -1, -1
			for i := 0; i < len(ans)-1; i++ {
				for _, v := range g[ans[i]] {
					if f[v] && v != ans[i+1] {
						a, b = i, idx[v]
						break
					}
				}
				if b != -1 {
					break
				}
			}
			// debug(ans, a, b)
			if b == -1 {
				fmt.Fprintln(wr, len(ans)-1)
				for i := 0; i < len(ans)-1; i++ {
					fmt.Fprintln(wr, ans[i]+1)
				}
				return
			}
			if a > b {
				ans = append(ans[b:a+1], ans[b])
			} else {
				ans = append(ans[:a+1], ans[b:]...)
			}
		}
	}
}


Measured memory_bytes: 1280
def getTheNumberOfCoin(n, m, c):
    INF = 1 << 29
    t = [INF] * (n + 1)
    t[0] = 0
    for i in range(m):
        for j in range(c[i], n + 1):
            t[j] = min(t[j], t[j - c[i]] + 1)

    return t[n]

if __name__ == '__main__':
    n, m = [int(v) for v in input().split()]
    c = [int(v) for v in input().split()]
    print(getTheNumberOfCoin(n, m, c))


Measured memory_bytes: 7520
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 20;

int main() {
  int T; cin >>T;
  REP(t, T){
    int G[MAX_N][MAX_N][MAX_N][MAX_N];
    REP(i, MAX_N) REP(j, MAX_N) REP(k, MAX_N) REP(l, MAX_N) G[i][j][k][l] = 1;
    int gx, gy; cin >>gx >>gy;
    int P; cin >>P;
    REP(p, P){
      int fx, fy, tx, ty; cin >>fx >>fy >>tx >>ty;
      G[fx][fy][tx][ty] = G[tx][ty][fx][fy] = 0;
    }
    int cnt[MAX_N][MAX_N];
    REP(i, MAX_N) REP(j, MAX_N) cnt[i][j] = 0;
    cnt[0][0] = 1;
    REP(nx, gx + 1){
      REP(ny, gy + 1){
        if(nx - 1 >= 0 && G[nx][ny][nx - 1][ny]) cnt[nx][ny] += cnt[nx - 1][ny];
        if(ny - 1 >= 0 && G[nx][ny][nx][ny - 1]) cnt[nx][ny] += cnt[nx][ny - 1];
      }
    }
    if(cnt[gx][gy]) cout <<cnt[gx][gy] <<endl;
    else cout << "Miserable Hokusai!" <<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0, s.size()))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int main(){
    ll a, b, k; cin >> a >> b >> k;
    repr(i, a, min(b+1, a+k)) cout << i << endl;
    repr(i, max(b-k+1, a+k), b+1) cout << i << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200
#define INF 0x3f3f3f3f
int main(){
	int n=read(),k=read();
	if(k>(n-1)*(n-2)/2){
		puts("-1");
		return 0;
	}
	if(!k){
		printf("%d\n",n*(n-1)/2);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				printf("%d %d\n",i,j);
		return 0;
	}
	printf("%d\n",(n-1)*(n-2)/2-k+n-1);
	for(int i=1;i<n;i++)
		printf("%d %d\n",i,n);
	int cnt=(n-1)*(n-2)/2-k;
	for(int i=1;i<n&&cnt;i++)
		for(int j=i+1;j<n&&cnt;j++){
			cnt--;
			printf("%d %d\n",i,j);
		}
	
	return 0;
}

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

using namespace std;
#define ll long long
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;

int main (){
    int n;
    cin >>n;
    ll a[120000];
    cinf(n,a)
    ll total =0;
  	ll total2 = 0;
    ll count1 = 0;
    ll count2 = 0;
    REP(i,n){
        	if(i % 2 == 0){
      		total += a[i];//偶数かい
      		total2 += a[i];
            if(total >= 0){ //偶数かいがマイナスになるもの
                count1 += (abs(total) + 1);
                total = -1;
            }
            if(total2 <= 0){ //偶数かいがプラスになるもの
                count2 += (abs(total2) + 1);
                total2 = 1;
            }
            }
            
            if(i % 2 != 0){
            total += a[i]; //奇数かい
      		total2 += a[i];
            if(total <= 0){ //プラスなるやつ
                count1 += (abs(total) + 1);
                total = 1;
            }
            if(total2 >= 0){ //マイナスなるやつ
                count2 += (abs(total2) + 1);
                total2 = -1;
            }
            }
        
    }

	cout << min(count1,count2) << endl;



    return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	int t = -1;
	int f = vec.size();
	while (f - t > 1) {
		int m = (t + f) / 2;
		if (vec[m] < xx) {
			t = m;
		}
		else {
			f = m;
		}
	}
	return f;
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) { 
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx == 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}




signed main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3596
package main

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

func insertionSort(elems []int, step int) int {
	n := len(elems)
	var count int
	for i := 0; i < step; i++ {
		for j := i; j < n; j += step {
			target := elems[j]
			targetInd := j
			for k := j-step; k >= 0; k -= step {
				if elems[k] > target {
					elems[k+step] = elems[k]
					targetInd = k
					count++
				} else {
					break
				}
			}
			elems[targetInd] = target
		}
	}
	return count
}

func max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func shellSort(elems []int) ([]int, int) {
	n := len(elems)
	var count int
	var steps []int
	for i := max(n/2, 1); i >= 1; i /= 2 {
		steps = append(steps, i)
		count += insertionSort(elems, i)
	}
	return steps, count
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	elems := make([]int, n)
	for i := 0; i < n; i++ {
		x, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		elems[i] = x
	}

	steps, count := shellSort(elems)
	fmt.Println(len(steps))
	fmt.Println(formatIs(steps, " "))
	fmt.Println(count)
	fmt.Println(formatIs(elems, "\n"))
}

func formatIs(elems []int, sep string) string {
	n := len(elems)
	as := make([]string, n)
	for i := 0; i < n; i++ {
		as[i] = strconv.Itoa(elems[i])
	}
	return strings.Join(as, sep)
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 71020
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
int a[MAXN];
unordered_map<int, int>cnt;
int main(){
    int n; scanf("%d", &n);
    long long ans = 0;
    for (int i = 1; i <= n; i++){
        scanf("%d", a + i);
        ans += cnt[a[i] - i];
        cnt[-i - a[i]]++;
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;
const int N = 2e5 + 10;
int q[N];
double qq[N] , sum[N];
int main(){
	
	int n , k;
	cin >> n >> k;
	
	for(int i = 0; i < n; i ++) scanf("%d" , &q[i]) , qq[i] = (1 + q[i]) * 1.0 / 2;
	
	double ans = 0;
	sum[0] = 0;
	for(int i = 1; i <= n; i ++){
		
		sum[i] += sum[i - 1] + qq[i - 1];
	}
	
	for(int i = 1 , j = k; i <= n && j <= n; i ++ , j ++){
		
		ans = max(ans , sum[j] - sum[i - 1]);
	}
	
	printf("%.12lf" , ans);
	
	
}

Measured memory_bytes: 4096
import sys
from collections import deque
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        u, v = map(int, input().split())
        G[u-1].append(v-1)
    S, T = map(int, input().split())
    S, T = S-1, T-1

    q = deque()
    q.append(S)
    cnt = 0
    cnt_k = 0
    visited = [False] * N
    visited[S] = True
    while len(q) > 0:
        cnt += 1
        if cnt % 3 == 0:
            cnt_k += 1

        next_ = set()
        while len(q) > 0:
            n0 = q.pop()
            for n1 in G[n0]:
                if cnt % 3 == 0:
                    if n1 == T:
                        return cnt_k

                    if visited[n1]:
                        continue

                    visited[n1] = True

                next_.add(n1)

        q = deque()
        q.extend(list(next_))

    return -1


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


Measured memory_bytes: 19160
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e5+1;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n,m,k,mx=0;
    cin>>n>>m>>k;
    ll a[n],b[m];
    lp(i,0,n)
        cin>>a[i];
    lp(i,0,m){
        cin>>b[i];
        if(i)
            b[i]+=b[i-1];
        if(b[i]<=k)
            mx=i+1;
    }
    ll sum=0;
    lp(i,0,n){
        sum+=a[i];
        if(sum<=k){
            int l=0,r=m-1,mid,val=k-sum;
            while(l<=r){
                mid=(l+r)/2;
                if(b[mid]<=val)
                    l=mid+1;
                else
                    r=mid-1;
            }
            mx=max(mx,l+i+1);
        } else
            break;
    }
    cout<<mx;
}

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

using namespace std;

vector<bool> valid;

void kmp_pre(string& s, string& p){
    //int b[P]; b[0]=-1;// kmp backup table
    int l = p.size();
    vector<int> b(l+1);
    b[0] = -1;
    int j = -1;

    for (int i=0; i < l;){
        while (j >= 0 && p[i] != p[j])
            j = b[j];
        i++; j++;
        b[i] = j;
    }

    int n = s.size();
    int len = 0;
    for (int i=0; i<n+l; i++){
        char x = s[i%n];
        int j = len;
        while (j >= 0 && x != p[j])
            j = b[j];
        len = ++j;
        if (len == l) {
            valid[i-l+1] = true;
        }
    }
}

void solve() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    valid.assign(n, false);
    kmp_pre(s, t);
   // for (bool x: valid) {
   //     cout << (x?'T':'F');
   // }
    
    vector<vector<int>> g(n);
    vector<int> indeg(n, -1);
    vector<int> d(n, 0);
    for (int i = 0; i < n; i++) {
        if (valid[i]) {
            indeg[i] = 0;
            d[i] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        int j = (i+m)%n;
        if (valid[i] && valid[j]) {
            if (i == j) {
                cout << -1; return; //self-loop
            }
            g[i].emplace_back(j);
            indeg[j]++;
        }
    }
    vector<int> trk(n, false);
    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (indeg[i] == 0) {
            q.push(i);
            trk[i] = true;
        }
    }
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto& v: g[u]) {
            d[v] = 1 + d[u];
            trk[v] = true;
            q.push(v);
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (valid[i] && !trk[i]) {
            cout << -1; return; // cycle
        }
        res = max(res, d[i]);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 34552
//#pragma GCC optimization ("O3")
//#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define ok puts("ok")
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define pl pair < ll, ll >
#define pi pair < int, int >
#define pii pair < ll, pi >
#define next next123
#define left left123

const int N = 1e5 + 7;
const ll INF = 1e15 + 7;

string s;

vector < pi > g;

main(){
    cin >> s;
    int n = s.length();
    s = ' ' + s;
    if (s[1] != '1' || s[n] == '1'){
        puts("-1");
        return 0;
    }
    int last = 1;
    for (int i = 1; i <= n / 2; i++){
        if (s[i] != s[n - i]){
            puts("-1");
            return 0;
        }
        g.pb(mk(last, i + 1));
        if (s[i] == '1')
            last = i + 1;
    }
    for (int i = n / 2 + 2; i <= n; i++)
        g.pb(mk(last, i));
    for (pi it : g)
        printf("%d %d\n", it.fr, it.sc);
}


Measured memory_bytes: 2416
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(int argc, char const *argv[]) {
    int n , k;
    cin >> n >> k;
    if(n%k==0)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


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

int main() { 
  long double a,b,h,m;
  long double res ;
  
  cin >> a >> b >> h >> m;
  
  long double ba,ca;
  
  ba = (h/12)*2*M_PI + (2*M_PI/12)*(m/60);
  ca = (m/60)*2*M_PI;
  
  res = sqrt(b*b + a*a - 2*b*a*cos(ba-ca));
  
  //cout << ba << " " << ca << " " << M_PI << " " << a << " " <<b  << endl;
  cout << fixed << setprecision(10) ;
  cout << res;
}

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

class Stack {
  private:
    int size_;
    int top_;
    int *stack_;

  public:
    Stack(int size = 100);
    ~Stack();

    void push(int num);
    int pop();
    int top();
    bool IsFull();
    bool IsEmpty();
    void trace();
};


Stack::Stack(int size) : size_{size}, top_{0} {
    stack_ = new int[size];
}

Stack::~Stack() {
    delete stack_;
}

void Stack::push(int num) {
    if (!IsFull()) {
        stack_[top_++] = num;
    } else {
        cout << "StackOverflow !" << endl;
    }
}

int Stack::pop() {
    if (!IsEmpty()) {
        int poped = stack_[--top_];
        return poped;
    } else {
        cout << "StackUnderFlow !" << endl;
        return -1;
    }
}

int Stack::top() { return top_; }

bool Stack::IsFull() { return top_ >= size_; }

bool Stack::IsEmpty() { return top_ <= 0; }

void Stack::trace() {
    cout << "*** trace ***" << endl;
    for (int i = 0; i < top_; i++) {
        cout << "[" << stack_[i] << "]";
    }
    cout << endl;
}

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

    Stack stack = Stack();
    string ope;
    while (cin >> ope) {
        if (ope == "+") {
            int right = stack.pop();
            int left = stack.pop();
            stack.push(left + right);
        } else if (ope == "-") {
            int right = stack.pop();
            int left = stack.pop();
            stack.push(left - right);
        } else if (ope == "*") {
            int right = stack.pop();
            int left = stack.pop();
            stack.push(left * right);
        } else {
            stack.push(stoi(ope));
        }
    }
    cout << stack.pop() << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    string S, T; cin >> S >> T;
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}



Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main ()
{
  
 int a, b, c, d; 
 d=0;
 cin >> a >> b>> c;
 
 
 while (a<=b) {
     if (c%a==0) {
         
         d++;
     }
     a++;
 }
 cout <<d << endl;


}


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

using namespace std;
typedef long long LL;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S, T;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    S.push_back(a);
  }
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    T.push_back(a);
  }
  const LL MOD = 1000000007;
  vector<vector<LL>> dp(N + 1, vector<LL>(M + 1, 0));
  vector<vector<LL>> ruiseki(N + 1, vector<LL>(M + 1, 0));

  dp[0][0] = 1;
  ruiseki[0][0] = 1;
  for (int i = 0; i <= N; i++) ruiseki[i][0] = 1;
  for (int j = 0; j <= M; j++) ruiseki[0][j] = 1;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) {
      if (S[i] == T[j]) {
        dp[i + 1][j + 1] = ruiseki[i][j];
      }
      ruiseki[i + 1][j + 1] = dp[i + 1][j + 1] + ruiseki[i + 1][j] +
                              ruiseki[i][j + 1] - ruiseki[i][j];
      ruiseki[i + 1][j + 1] %= MOD;
    }

  cout << (ruiseki[N][M] + MOD) % MOD << endl;

  return 0;
}

Measured memory_bytes: 62976
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	ll n, k, s;
	cin >> n >> k >> s;
	vector<ll> res(n);
	ll t = 1e9;
	if (s == t) {
		REP(i, k) {
			res[i] = s;
		}
		FOR(i, k, n) {
			res[i] = 1;
		}
	} else {
		REP(i, k) {
			res[i] = s;
		}
		FOR(i, k, n) {
			res[i] = s + 1;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 2176
S = input()
N = len(S)
for i in range(N-1):
    if S[i] == S[i+1]:
        print(i+1, i+2)
        exit()
for i in range(N-2):
    if S[i] == S[i+2]:
        print(i+1, i+3)
        exit()
print(-1, -1)


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

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fore(i,a,b) for(int i = a; i < b; i++)
#define rfor(i, a, b) for(int i = a - 1; i >= b; i--)

ll n,W,dp[2][1000100],wt[110],val[110];

int knapSack(ll V,ll n) { 
    fore(i,0,n+1) { 
        fore(v,0,V+1) {
            if (v==0)
                dp[i%2][v] = 0; 
            else if (i==0) 
                dp[i%2][v] = 100000000000; 
            else if (val[i-1] <= v) 
                dp[i%2][v] = min(wt[i-1] + dp[(i-1)%2][v-val[i-1]],dp[(i-1)%2][v]);
            else
                    dp[i%2][v] = dp[(i-1)%2][v]; 
        } 
    } 
    int ma = 0;
    fore(i,0,V+1)if(dp[1][i] != 100000000000 && dp[1][i] <=W)ma = i;
    fore(i,0,V+1)if(dp[0][i] != 100000000000 && dp[0][i] <=W)ma = max(ma,i);
    return ma; 
} 

int main(){
    ll ma = 0;
    cin>>n>>W;
    fore(i,0,n){
        cin>>wt[i]>>val[i];
        ma = max(ma,val[i]);
    }

    cout<<knapSack(ma*n,n)<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;
template<typename T> void test(vector<T> v){for(int i=0;i<v.size();i++){if(i)cout<<" ";cout<<v[i];}cout<<endl;}

int main(){
    int n,k;
    cin>>n>>k;
    rep(i,0,n){
        int x; cin>>x;
    }
    int x=1;
    int i;
    for(i=0;x<n;i++){
        x+=k-1;
    }
    cout<<i<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diverta
{
    class B
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int R = a[0], G = a[1], B = a[2], N = a[3];

            int count = 0;
            for(int i = 0; i <= N; i++)
            {
                for(int j = 0; j <= N; j++)
                {
                    if (R * i + G * j > N) continue;
                    int c = N - (R * i + G * j);
                    if (c % B == 0) count++;
                }
            }
            Console.WriteLine(count);

        }

    }
}


Measured memory_bytes: 13268
n=int(input())
K=list(map(int,input().split()))

dp=[float('inf') for _ in range(n)]
dp[0]=0
for i in range(len(K)-1):
  dp[i+1]=min(dp[i+1],dp[i]+abs(K[i]-K[i+1]))
  if i+2<len(K):
    dp[i+2]=min(dp[i+2],dp[i]+abs(K[i]-K[i+2]))
print(dp[-1])

Measured memory_bytes: 13928
while True :
  H,W = map(int,input().split())
  if W == 0 and H == 0 :
    break
  for i in range(H) : 
      if i == 0 or i == H-1 :       
        print('#'*W)
      else  :
        print('#' + '.'*(W-2) + '#')
  print('')


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

using namespace std;

typedef long long  ll;

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

    string s, t;

    cin >> s;
    for (auto c : s) {
        if (c == 'B' && 0 < t.size())
            t.pop_back();
        else if (c == '1' || c == '0')
            t += c;
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  int p[N];

  rep(i,N){
    int aa;
    cin>>aa;
    p[i]=aa-1;
  }

  int ans=0;
  rep(i,N){
    if(p[i]==i){
      ++ans;
      ++i;
    }
  }

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 640
h, w = gets.chomp.split(" ").map(&:to_i)
s = h.times.map do
    gets.chomp.split("")
end

dx = [1, -1, 1, 0, -1, 1, 0, -1]
dy = [0, 0, -1, -1, -1, 1, 1, 1]

class ConvZero
    @@character = "."

    def conv(data)
        data = data.map do |i|
            i.map do |x|
                if(x == @@character)
                    x = 0
                else
                    x = x
                end
            end
        end
        return data
    end
end

dotconv = ConvZero.new
s = dotconv.conv(s)

s.each_with_index do |si, idxi|
    si.each_with_index do |sj, idxj|
        if(sj == "#")
            for i in 0..7 do
                height = idxi + dy[i]
                width = idxj + dx[i]
                if(height < h && width < w && 0 <= height && 0 <= width)
                    if(s[height][width] != "#")
                        s[height][width] += 1
                    end
                end
            end
        end
    end
end

# print(h, " ", w)
# print(s, "\n")
s.each do |i|
    i.each do |j|
        print(j)
    end
    print("\n")
end

Measured memory_bytes: 2172
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d[] = new int[n];
        for (int i = 0; i < n; i++) {
            d[i] = in.nextInt();
        }

        Arrays.sort(d);
        System.out.println(d[n / 2] - d[n / 2 - 1]);
    }
}


Measured memory_bytes: 51436
#include<iostream>
using namespace std;
using ll=long long;
#define MOD 1000000007;

int main(){
    ll N;
    ll A[200002];
    cin>>N;
    ll sum=0;
    ll res=0;
    for(ll i=1;i<=N;i++){
        cin>>A[i];
        sum+=A[i];
        sum%=MOD;
    }
    for(ll i=1;i<N;i++){
        sum-=A[i];
        if(sum<0){
            sum+=MOD;
        }
        res+=(A[i]*sum)%MOD;
        res%=MOD;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5152
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A =new int[N+10];
		A[0] =0;
		for(int i =1;i<=N;i++){
			A[i]=sc.nextInt();
		}
		int cost=0;
		int[] inf = new int[N+10];
		for(int i =0;i<=N;i++){
			int div = A[i+1]-A[i];
			inf[i] =div;
			cost+=Math.abs(div);
		}
		
		for(int i =0;i<N;i++){
			int p = Math.abs(inf[i]);
			int q = Math.abs(inf[i+1]);
			if(inf[i]*inf[i+1]>=0){
				System.out.println(cost);
			}else{
				System.out.println(cost-((p+q)-Math.abs(p-q)));
			}
		}
 		sc.close();
	}
}


Measured memory_bytes: 68348
N=int(input())
L=[]
for i in range(N):
    a,b=map(int,input().split())
    L.append([b,a])

L.sort()
#print(L)

T=0
for i in range(N):
    T+=L[i][1]
    if T>L[i][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 77400
#include<stdio.h>

int main(void)
{
  int y, m, d;
  char c1, c2;
  
  scanf("%d%c%d%c%d", &y, &c1, &m, &c2, &d);

  if(m <= 4)
    printf("Heisei");
  else
    printf("TBD");
  
  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading;

class Program
{

    static int Max_N = 200000 + 1;
    static void Main(string[] args)
    {
        int[] arr1 = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        int n = arr1[0];
        int k = arr1[1];
        double[] arr = Console.ReadLine().Split(' ').Select(v => double.Parse(v)).ToArray();
        double[] eRui = new double[Max_N];
        double sum = 0;
        for(int i = 1; i <= n; i++)
        {
            sum += (arr[i - 1] + 1) / 2;
            eRui[i] = sum;
        }
        int start = 0;
        double max = 0;
        while (true)
        {
            max = Math.Max(max , eRui[start+k] - eRui[start]);
            if (start + k == n) break;
            start++;
        }
        Console.WriteLine(max);


    }




}

Measured memory_bytes: 43608
from fractions import gcd
import random
n = int(input())
a = list(map(int, input().split( )))
random.shuffle(a)
#最小公倍数でよいか？
#全てのjについてAiBiはAjで割り切れる
#計算時間は？

mod =10**9+7
def lcd(x,y):
    g = gcd(x,y)
    return x*y//g

ag1 = 1
for i in range(n//2):
    ag1 = lcd(ag1,a[i])
ag2 = 1
for i in range(n//2,n):
    ag2 = lcd(ag2,a[i])

ag3 = lcd(ag1,ag2)

ans = 0

for i in range(n//2):
    ans += ag1//a[i]
ans*=ag3//ag1
ans %=mod
ans2 = 0
for i in range(n//2,n):
    ans2 += ag2//a[i]
ans2*= ag3//ag2
ans2%=mod 
ans += ans2
ans %=mod
print(ans)


Measured memory_bytes: 71640
/// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	//input = input.split("\n");
	c=input.trim().split("\n");
    var al='abcdefghijklmnopqrstuvwxyz';
    var result = al.indexOf( c );
    var nxt = al.substr( result+1, 1 );
    console.log(nxt);
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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



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

    if ((min(a,b) < c) && (max(a,b) > c)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>

int main()
{
    char S[128];
    char T[128];
    scanf("%s %s", S, T);

    int A, B;
    scanf("%d %d", &A, &B);

    char U[128];
    scanf("%s", U);

    if (strcmp(S, U) == 0)
    {
        --A;
    }
    else {
        --B;
    }

    printf("%d %d\n", A, B);
}


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

int n;
int h[105] = {0};
stack<int> st;

int solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> h[i];
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  st.push(0);
  for(int i = 0; i <= n; ++i) {
    int now = st.top();
    while(now > h[i]) {
      st.pop();
      ans += now - max(st.top(), h[i]);
      now = st.top();
    }
    if(now < h[i]) st.push(h[i]);
  }
  return ans;
}

Measured memory_bytes: 256