akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l;
int h[1000000];

int get(int x) {
    int ret = 0;
    while (x > 0) {
        ret = max(ret, h[x]);
        x &= (x - 1);
    }
    return ret;
}

void add(int x, int y) {
    while (x <= n) {
        h[x] = max(h[x], y);
        x = (x|(x-1)) + 1;
    }
}

int main() {
    // freopen("x.in", "r", stdin);

    int X1, Y1, X2, Y2;
    cin >> X1 >> Y1 >> X2 >> Y2;
    if (X1 > X2) {
        swap(X1, X2);
        swap(Y1, Y2);
    }
    int MINY = min(Y1, Y2);
    int MAXY = max(Y1, Y2);
    cin >> n;
    vector<pii> v;
    F0(i, n) {
        int x, y;
        scanf("%d%d", &x, &y);
        if (x < X1 || x > X2 || y < MINY || y > MAXY) continue;
        
        v.push_back(pii(x - X1 + 1, y - MINY + 1));
    }
    
    n = SZ(v);
    sort(v.begin(), v.end());
    F0(i, n) v[i].first = i+1;
    F0(i, n) swap(v[i].first, v[i].second);
    sort(v.begin(), v.end());
    if (Y1 > Y2) {
        F0(i, n) v[i].second=n+1-v[i].second;
    }
    
    int cnt = 0;   
    
    F0(i, n) {
        int x = get(v[i].second - 1) + 1;
        cnt = max(cnt, x); 
        add(v[i].second, x); 
    }
 
    double ans = 100.0*(X2-X1+MAXY-MINY) + cnt * (pi * 5 - 20);
    if (cnt == X2-X1+1 || cnt == MAXY-MINY+1) {
        ans += pi * 5;
    }
    printf("%.10lf\n", ans);
    
    return 0;
}

Measured memory_bytes: 2672
using System;

class main
{
    static void Main(string[] args)
    {
        string s1, s2, a4;
        int c = int.Parse(Console.ReadLine());
        for (int m = 0; m < c; m++)
        {
            s1 = Console.ReadLine();
            s2 = Console.ReadLine();
            a4 = string.Empty;
            string[] s3 = new string[5];
            string[] s4 = new string[5];
            string[] s5 = new string[5];
            ulong[] a3 = new ulong[5];
            if (s1.Length > 80 || s2.Length > 80)
            {
                Console.WriteLine("overflow");
                goto end;
            }
            s1 = s1.PadLeft(80, '0');
            s2 = s2.PadLeft(80, '0');
            for (int i = 0; i < 5; i++)
            {
                s3[i] = s1.Substring(16 * i, 16);
                s4[i] = s2.Substring(16 * i, 16);
            }
            for (int j = 4; j >= 0; j--)
            {
                a3[j] += ulong.Parse(s3[j]) + ulong.Parse(s4[j]);
                if (a3[j].ToString().Length == 17)
                {
                    if (j == 0)
                    {
                        Console.WriteLine("overflow");
                        goto end;
                    }
                    a3[j] -= 10000000000000000;
                    a3[j - 1] += 1;
                }
                s5[j] = a3[j].ToString().PadLeft(16, '0');
            }
            a4 = string.Join("", s5);
            while (a4.StartsWith("0"))
            {
                a4 = a4.TrimStart('0');
                if (a4 == "")
                {
                    Console.WriteLine(0);
                    goto end;
                }
            }
            Console.WriteLine(a4);
        end: ;
        }
    }
}

Measured memory_bytes: 6352
#include <iostream>

using namespace std;

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

int main(void){
  int A, B;
  cin >> A >> B;

  int x = max(A+B, A-B);

  x = max(x, A*B);

  cout << x << endl;
  
  return 0;
}


Measured memory_bytes: 256
(*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*)

open System;

let s = Console.ReadLine()
let k = int(Console.ReadLine()) - 1
let len = s.Length

let mutable substSet : string Set = Set.empty

for i = 0 to len - 1 do
    for j = i to (min (i + k) (len - 1)) do
        substSet <- Set.add s.[i..j] substSet

let substList = Set.toList substSet
Console.WriteLine(substList.[k])

Measured memory_bytes: 22352
def c():
   
    K = int(input())
    ans = ""
    if K == 0:
        print(0)
        return 0
    while True:
        amari = -1*(K%-2) 
        # print(amari,end = "")
        ans += str(amari)
        K = (K-amari) / (-2)
        K = int(K)
        # print("K=",K)
        if K == 0 or K == 1:
            break
    ans += str(K)
    print(ans[::-1])
if __name__ == '__main__':
    c()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 2222;
int dp[N][N], sum[N][N];
int a[N], b[N];
int n, m;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    rep(i, 1, n) {
        cin >> a[i];
    }
    rep(j, 1, m) {
        cin >> b[j];
    }
    dp[0][0] = 1;
    sum[0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, m) {
            if(i && j) {
                if(a[i] == b[j]) {
                    dp[i][j] = sum[i - 1][j - 1];
                }
                sum[i][j] = dp[i][j] + sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
            } else if(j > 0) {
                sum[0][j] = sum[0][j - 1];
            } else if(i > 0) {
                sum[i][0] = sum[i - 1][0];
            }
            sum[i][j] = (sum[i][j] % MOD + MOD) % MOD;
        }
    }
    cout << sum[n][m] << endl;
    return 0;
}


Measured memory_bytes: 72064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        int n = Integer.parseInt(reader.readLine());
        String[] s = reader.readLine().split(" ");
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = n - 1; j >= i + 1; j--) {
                if (a[j] < a[j - 1]) {
                    sum++;
                    int temp = a[j];
                    a[j] = a[j - 1];
                    a[j - 1] = temp;
                }
            }
        }
        StringBuilder builder = new StringBuilder();
        for (int k = 0; k < n; k++) {
            if (k > 0)
                builder.append(" ");
            builder.append(a[k]);
        }
        builder.append("\n").append(sum);
        System.out.println(builder);
 
    }
}


Measured memory_bytes: 24464
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;


int main(){

    int n,k;
    cin >> n >> k;
    double f = 0.0;
    double c = log2(k);

    for(int i = 1; i <= n; i++){
        //ダブルアップしないといけない回数
        double tmpc = c - log2(i);
        if(ceil(tmpc) > 0){
            f = f + pow(0.5, ceil(tmpc)) / n;
        }else{
            f = f + 1.0 / n;
        }
    }

    cout << setprecision(12) << f << endl;
 
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,l;
  cin>>n>>l;
  int sum=0;
  for (int i=1;i<=n;i++) {
    sum+=(l+i-1);
  }
  if (l>=0) {
    cout<<sum-l<<endl;
  }
  else if(l+n-1<=0) {
    cout<<sum-(l+n-1)<<endl;
  }
  else {
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int r; cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 

void solve();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;++i){
		if(i%k==0){
			printf("OK");
			return 0;
		}
	}
	printf("NG");
	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    long long int l,rm,r,lm;
    lm=0;
    rm=s.length() -1;
    r=(s.length()-1)/2 -1;
    l=(s.length()+3)/2 -1;
    
    bool flag=false;
    while(lm<r)
    {
        if(s[lm]!=s[r])
        {
            flag=true;
            break;
        }
        lm++;
        r--;
    }
    if(flag)
    {
        cout<<"No";
        return 0;
    }
    
    while(rm>l)
    {
        if(s[rm]!=s[l])
        {
            flag=true;
            break;
        }
        rm--;
        l++;
    }
    
    if(flag)
    {
        cout<<"No";
        return 0;
    }
    
    l=0;
    r=s.length()-1;
    while(l<r)
    {
        if(s[l]!=s[r])
        {
            flag=true;
            break;
        }
        l++;
        r--;
    }
    if(flag)
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 256
#! -*- coding: utf-8 -*-
import numpy as np

n = int(raw_input())
a = np.zeros([n],int)
for i in range(n):
    a[i] = int(raw_input())

count = 0

i = n-1
if not a[0] == 0:
    count = -1
else:
    while i > 0:
        if a[i-1] >= a[i]:
            count += a[i]
        elif a[i-1] == a[i]-1:
            count += 1
        else:
            count = -1
            break
        i -= 1

print count


Measured memory_bytes: 26956
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc138_c
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            string[] vn = Console.ReadLine().Split(' ');

            List<int> vnList = new List<int>();

            foreach (string vk in vn)
            {
                vnList.Add(int.Parse(vk));

            }

            //sort by asc
            vnList.Sort();

            double result = 0.0;

            //query by desc
            for (int index = 0; index < n; index++)
            {
                double addValue = 0.0;

                if (index == 0)
                {
                    addValue = vnList[index] / Math.Pow(2, n - 1);
                }
                else {
                    addValue = vnList[index] / Math.Pow(2, n - index);
                }

                result += addValue;
            }



            Console.WriteLine(result);



        }
    }
}


Measured memory_bytes: 13268
while True:
    cnt = 0
    n,x = map(int,input().split())
    if n == x == 0:break
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+ j+ k == x:
                    cnt += 1
    print(cnt)



Measured memory_bytes: 5596
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double C = scan.nextDouble();
		scan.close();
		double S = a * b * Math.sin(C/180*Math.PI) / 2;
		double c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(C/180*Math.PI));
		double l = a + b + c;
		double h = 2 * S / a;
		System.out.println(S);
		System.out.println(l);
		System.out.println(h);
	}
}


Measured memory_bytes: 27948
K = int(input())
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(L[K-1])

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    };
    let mut c = 0;
    for v in s{
        if v == '1'{
            c += 1;
        }
    }
    println!("{}", c);
}


Measured memory_bytes: 4352
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let (n, k): (String, usize) = stdin.lock().gets().split(' ').values();
    let dislike = stdin.lock().gets().split(' ').take(k)
        .map(|x| x.as_bytes()[0] - b'0').collect::<Vec<_>>();
    let mut n = n.as_bytes().iter().map(|x| x - b'0').collect::<Vec<_>>();
    n.reverse();
    n.push(0);
    let mut lastinc = 0;
    for i in 0..(n.len() - 1) {
        while n[i] <= 9 && dislike.contains(&n[i]) {
            n[i] += 1;
            lastinc = i;
        }
        if n[i] > 9 {
            n[i + 1] += 1;
            lastinc = i + 1;
        }
    }
    let minlike = (0..10).find(|x| !dislike.contains(x)).unwrap();
    for i in 0..lastinc {
        n[i] = minlike;
    }
    let idx = n.len() - 1;
    if n[idx] == 0 {
        n.pop();
    } else {
        n[idx] = (1..10).find(|x| !dislike.contains(x)).unwrap();
    }
    println!("{}", n.into_iter().rev().map(|x| (x + b'0') as char)
             .collect::<String>());
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}


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

const int mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    bool isVisible = true;
    int ans = 0;
    rep(i, n) cin >> h[i];
    rep(i,n){
        for (int j = 0; j < i; j++){
            if(h[j]>h[i]){
                isVisible = false;
            }
        }
        if(isVisible){
            ans++;
            //cout << ans << endl;
        }
        isVisible = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
c=[[0]*10 for i in range(10)]
for i in range(1,n+1):
  c[int(str(i)[0])][int(str(i)[len(str(i))-1])]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3064
def main():
	a,b,c = map(int,input().split())
	k = int(input())
	judge = True
	counter = 0
	while judge:
		if a < b < c:
			print("Yes")
			break
		else:
			counter += 1
		if counter <= k:
			if a >= b:
				b *= 2
			elif b >= c:
				c *= 2
		else:
			print("No")
			break

			

if __name__ == '__main__':
	main()

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	ll a,b;
	cin>>a>>b>>t;
	i=a;
	while(i<=t) ans+=b,i+=a;
	ret(ans)	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";

}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

ll cnt[53], pat[53];

ll func(int lev, ll res) {
	if (lev <= 0) return 1;
	if (res <= 1) return 0;
	res--;
	ll ret = 0;
	if (res <= cnt[lev - 1]) {
		ret += func(lev - 1, res);
	}
	else if (res == cnt[lev - 1] + 1) {
		ret += pat[lev - 1] + 1;
	}
	else if (res > cnt[lev - 1] + 1) {
		ret += pat[lev - 1] + 1 + func(lev - 1, res - cnt[lev - 1] - 1);
	}
	return ret;
}

int main() {
	ll n, x; cin >> n >> x;
	for (int i = 0; i <= n; i++) cnt[i] = (i == 0 ? 1 : 2 * cnt[i - 1] + 3);
	for (int i = 0; i <= n; i++) pat[i] = (i == 0 ? 1 : 2*pat[i - 1] + 1);
	pat[0] = 1;
	cout << func(n, x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

ll dp[101][101];

void COMinit() {
    rep(i, 101) {
        dp[i][0] = 1;
        repd(j, 1, i + 1) {
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
        }
    }
}
int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    map<ll, ll> cnt;

    rep(i, N) {
        cin >> v[i];
        cnt[v[i]]++;
    }

    sort(all(v));
    reverse(all(v));

    COMinit();
    long double ct;
    ll ans = 0;
    for (ll j = A; j <= B; j++) {
        map<ll, ll> l;
        ll res = 1;
        long double ave = 0;
        rep(i, j) {
            l[v[i]]++;
            ave += v[i];
        }
        ave /= j;
        if (j == A) ct = ave;
        else if (ave != ct) break;
        for (auto itr = l.begin(); itr != l.end(); itr++) {
            res *= dp[cnt[itr->first]][itr->second];
        }
        ans += res;
    }

    cout << fixed << setprecision(7) << ct << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() - 1 }
    val b = readLine()!!.split(" ").map { it.toInt() }
    val c = readLine()!!.split(" ").map { it.toInt() }
    val ans = a.map { b[it] }.sum() + (1 until a.size).filter { a[it-1] + 1 == a[it] }.map { c[a[it-1]] }.sum()
    println(ans)
}



Measured memory_bytes: 36656
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    map<string,int> m;

    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        if(m.count(S)){
            m[S]++;
        }else{
            m[S]=1;
        }
    }

    vector<string> S={"AC","WA","TLE","RE"};
    for(auto &s:S){
        cout << s << " x " << m[s] << endl;
    }
}

Measured memory_bytes: 3636
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
import std.range;
 
void main() {
	auto data = readln().split();
	auto A = data[0].to!int(), B = data[1].to!int(), K = data[2].to!int();
	iota(min(A, B), 0, -1).filter!(x => A%x == 0 && B%x == 0).array[K-1].writeln();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int t,n;
  int y[5]={0,6000,4000,3000,2000};
  rep(i,4){
    cin>>t>>n;
    cout<<n*y[t]<<endl;
  }
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int n,a[N],f[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int mx=0;
	for(int i=1;i<=n;i++) f[a[i]]=f[a[i]-1]+1,mx=max(mx,f[a[i]]);
	printf("%d",n-mx);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
char s[N][N];
int dp[N][N];

int main()
{
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i <= h; i++) {
		for (int j = 0; j <= w; j++) {
			dp[i][j] = 1e9;
			s[i][j] = '.';
		}
	}
	for (int i = 1; i <= h; i++) {
		scanf("%s", s[i] + 1);
	}
	dp[0][1] = dp[1][0] = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			dp[i][j] = min(dp[i-1][j] + (s[i][j] == '#' && s[i-1][j] == '.'), 
						   dp[i][j-1] + (s[i][j] == '#' && s[i][j-1] == '.'));
		}
	}
	printf("%d\n", dp[h][w]);
	return 0;
}

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

using namespace std;

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
ll mod=1000000007;

int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--)
        {
            ll n,i,j,k=0;
            cin>>n;
           vector<ll>v(n);
           for(i=0;i<n;i++)
           cin>>v[i];
          j=0;
          k=abs(v[1]-v[0]);
          for(i=2;i<n;i++)
          {
              ll temp=k;
              k=min(k+abs(v[i]-v[i-1]),j+abs(v[i]-v[i-2]));
              j=temp;
          }
          cout<<k;
          
            
        }
        
    }

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

int main()
{
	queue<int> a;  // 開口部
	int n;
	int ball = 10;
	cin>>n;
	while( n-- > 0){
		int b=0, c=0;
		int k;
		for(int i=0;i<ball;i++){
			cin>>k;
			a.push( k );
		}
		
		// 最初の一つをbに入れておく
		b = a.front();
		a.pop();
		
		for(int i=0;i<ball-1;i++){
			if( a.front() > b && a.front() > c){
				if( a.front() - b > a.front() - c){
					c = a.front();
				}else{
					b = a.front();
				}
			}else if( a.front() > b){
				b = a.front();
			}else if( a.front() > c){
				c = a.front();
			}else{  // ゲームオーバー
				cout<<"NO"<<endl;
				while(1){
					if( a.empty()){
						break;
					}else{
						a.pop();
					}
				}
				break;
			}
			
			a.pop();
			if( a.empty()){
				cout<<"YES"<<endl;
				while(1){
					if( a.empty()){
						break;
					}else{
						a.pop();
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    mod = 998244353
    N, K = iim()
    it = map(int, sys.stdin.read().split())
    B = list(zip(it, it))

    N1 = N+1 if N&1 else N
    N2 = 1<<(N.bit_length())
    NN2 = N1 + N2
    A = [0] * NN2

    def add(a, i, j, x):
        i += N2; j += N2
        while i < j:
            if i & 1:
                A[i] = (A[i] + x) % mod
                i += 1
            if not j & 1:
                A[j] = (A[j] + x) % mod
                j -= 1
            i >>= 1; j >>= 1
        if i == j:
            A[i] = (A[i] + x) % mod

    def get(a, i):
        i += N2
        ans = 0
        while i > 0:
            ans = (ans + A[i]) % mod
            i >>= 1
        return ans

    A[N2] = 1

    B.sort()
    for i in range(N-1):
        x = get(A, i)
        for a, b in B:
            a += i; b += i
            if a > N-1: continue
            b = min(b, N-1)
            add(A, a, b, x)

    print(get(A, N-1))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 78444
#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 <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;
typedef tuple<ll, ll ,string> Tlls;
#define PI 3.141592

int main()
{

  long double R;
  cin >> R;
  double a = PI;
  //小数点以下を指定したい場合　https://marycore.jp/prog/cpp/stream-format-float/
  cout << fixed;
  cout << setprecision(12) << 2 * R * a << endl;

  return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    int a[N];
    int b[N];
    rep(i,N) {
        cin >> a[i];
        b[i]=0;
        while(a[i]%2==0){
            a[i]/=2;
            b[i]++;
            if(b[i]==2) break;
        }
    }
    string ans="Yes";
    int c[3]={};
    rep(i,N){
        c[b[i]]++;
    }
    if(c[0]>c[2] && c[1]>0) ans="No";
    else if(c[0]>c[2]+1 && c[1]==0) ans="No";
    cout << ans << endl;





}


Measured memory_bytes: 1024
def equals(s, t):
    for i in range(len(s)):
        rotated = s[-i:] + s[0:-i]
        if rotated == t:
            return True
    return False


if __name__ == '__main__':
    s = input()
    t = input()
    print('Yes') if equals(s, t) else print('No')

Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            double sum = 0;
            for (int i = 0; i < N; i++) {
                double x = in.nextInt();
                sum += 1 / x;
            }
            out.println(1 / sum);
        }

    }
}



Measured memory_bytes: 23124
#include <cstdio>

#define MAX 1000000
#define MIN 0
#define SIZE 200

int main() {
 int i;
 int a,b;
 int cnt = 0;
 int buf = 0;
 int sets[SIZE];

 while(scanf("%d %d",&a,&b) != EOF) {
  if((a < MIN) || (b > MAX)) continue;
  
  sets[cnt] = a + b;
  ++cnt;
 }

 for(i = 0;i < cnt;++i) {
  while(sets[i] != 0) {
   ++buf;
   sets[i] /= 10;
  }

  sets[i] = buf;
  buf = 0;
 }

 for(i = 0;i < cnt;i++) {
  printf("%d\n",sets[i]);
 }

 return 0;
}

Measured memory_bytes: 2760
#include "bits/stdc++.h" // {{{
using namespace std;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#define FAST()      ios::sync_with_stdio(false), cin.tie(nullptr)
#ifndef DEBUG
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
typedef long long ll;
typedef pair<int,int> pii;
namespace ydk{
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
{ return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f3f3f3f3fLL;
// }}}

constexpr int MX = ten(5) + 10;


void Xx_main_xX()
{
    FAST();
    int N, Q;
    static ll a[MX];

    cin >> N >> Q;
    rep(i, N) { cin >> a[i]; }

    while(Q--)
    {
        ll x; cin >> x;

        int r;
        ll sum, ans;
        r = sum = ans = 0;

        rep(l, N) {
            while(r < N && sum+a[r] <= x) sum += a[r++];
            ans += (r - l);
            (r == l)? ++r : sum -= a[l];
        }

        outl(ans);
    }

    return;
}

} // {{{
signed main(){cout << fixed << setprecision(9); ydk::Xx_main_xX(); return 0;} // }}}




Measured memory_bytes: 3968
import java.util.*

fun main(args:Array<String>?): Unit {
    val (w, h) = readLine()!!.trim().split(' ').map(String::toInt)
    val state = Array(h){readLine()!!.trim().toCharArray()}
    val goal = (0 until w).mapNotNull { x -> (0 until h).find{y -> state[y][x] == 't'}?.let{y -> Point(x, y)} }.first()
    val isReach = Array(h){BooleanArray(w){false}}
    val queue: Queue<Point> = ArrayDeque<Point>()
    repeat(readLine()!!.trim().toInt() + 1) {
        if (it == 0) {
            isReach[0][0] = true
            queue.add(Point(0, 0))
        }else {
            val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
            state[y][x] = '.'
            if (Point(x, y).neighbors.any{p -> (p.x in 0 until w) && (p.y in 0 until h) && isReach[p.y][p.x]}) {
                isReach[y][x] = true
                queue.add(Point(x, y))
            }
        }
        while(queue.isNotEmpty()){
            for ((x, y) in queue.poll().neighbors)
                if (x in 0 until w && y in 0 until h && state[y][x] != '#' && !isReach[y][x]) {
                    isReach[y][x] = true
                    queue.add(Point(x, y))
                }
        }
        //println(isReach.joinToString("\n", postfix = "\n"){it.joinToString(","){if (it) "o" else "x"}})
        if (isReach[goal.y][goal.x]) {
            println(it)
            return
        }
    }
    println(-1)
}
data class Point(val x: Int, val y: Int) {
    operator fun plus(that: Point): Point = Point(x + that.x, y + that.y)
}
val Point.neighbors: Iterable<Point>
    get() = listOf(Point(1, 0), Point(-1, 0), Point(0, 1), Point(0, -1)).map{it + this}


Measured memory_bytes: 170724
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s = "";
  long long k = 0;
  cin >> s >> k;
  int n = (int)s.size();
  for (int i=0; i<n; i++) {
    if (i == n-1) {
      k %= 26;
      s.at(i) = k > 'z' - s.at(i) ? 'a' + k - ('z' - s.at(i) + 1) : s.at(i) + k;
    } else if (s.at(i) != 'a') {
      long long dif = 'z' - s.at(i) + 1;
      if (dif <= k) {
        k -= dif;
        s.at(i) = 'a';
      }
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	char ch = next<char>();
	if ('a' <= ch && ch <= 'z') cout<<'a'<<endl;
	else cout<<'A'<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vp vector<pair<int, int>>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

ll gcd(ll a, ll b)
{
    if(b == 0)
    {
        return a;
    }
    return gcd(b, a%b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a/g * b;
}

int main()
{
    int n;
    cin >> n;
    vll data;
    while(n--)
    {
        ll t;
        cin >> t;
        data.pb(t);
    }
    ll ans = 1;
    for(int i = 0; i < data.size(); ++i)
    {
        ans = lcm(ans, data[i]);
    }

    cout << ans << endl;
}


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

int N, M;
int main() {
  cin >> N >> M;
  cout << (N == M ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	int sum = 0;
	rep (i, m) {
	  int a;
	  cin >> a;
	  sum += a;
	}
	cout << max(-1, n - sum) << endl;
    
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,ans;
    cin >> A >> B;
    if(A >= 13) ans = B;
    if(6 <= A && A<= 12) ans = B/2;
    if(A <6) ans = 0;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    
    if(a < b && b < c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2080
#include<stdio.h>
int main(void)
{
	int a,b,s,i,max,f,flg;
	flg=0;
	while(1){
		max=-1;
	for(i=0;i<5;i++){
		scanf("%d %d",&a,&b);
		s=a+b;
		if(a==0 && b==0){
			flg=1;
			break;
		}
		if(max<s){
			max=s;
			f=i;
		}
	}
		if(flg==1){
			break;
		}
	if(f==0){
		printf("A %d\n",max);
	}
	if(f==1){
		printf("B %d\n",max);
	}
	if(f==2){
		printf("C %d\n",max);
	}
	if(f==3){
		printf("D %d\n",max);
	}
	if(f==4){
		printf("E %d\n",max);
	}
	}
	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, C[101000], res, P[101000], U[101000];
int main() {
	int i, j, a;
	scanf("%d%d", &n,&m);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		C[a]++;
		P[a%m]++;
	}
	for (i = 1; i <= 100000; i++) {
		U[i%m] += C[i] / 2;
	}
	for (i = 0; i <= m/2; i++) {
		int t = (m - i) % m;
		if (i == t) {
			res += P[i] / 2;
			continue;
		}
		if (P[i] <= P[t] - U[t] * 2) {
			res += U[t] + P[i];
		}
		else if (P[i] - U[i] * 2 >= P[t]) {
			res += U[i] + P[t];
		}
		else {
			res += (P[i] + P[t]) / 2;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 1280
from collections import defaultdict
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

cards = defaultdict(int)
for i in s:
    cards[i] += 1
for j in t:
    cards[j] -= 1

print(max(max(cards.values()),0))


Measured memory_bytes: 3436
N = int(input())
D = ["a", "b", "c", "d", "e", "f", "g",
     "h", "i", "j", "k", "l", "m", "n", "o",
     "p", "q", "r", "s", "t", "u", "v", "w",
     "x", "y", "z"]
A = []
while True:
    T = (N-1) % 26
    N = (N-1) // 26
    A.append(D[T])
    if N == 0:
        break
A = reversed(A)
print("".join(A))

Measured memory_bytes: 9200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int gcd(int a, int b)
{
  if(b < a){
    int c = a;
    a = b;
    b = c;
  }
  int r;
  while((r = b%a) > 0){
    b = a;
    a = r;
  }
  return a;
}

int main(void)
{
  int N, X;
  scanf("%d%d", &N, &X);
  int g;
  scanf("%d", &g);
  g = abs(g-X);
  for(int i = 1; i < N; i++){
    int x;
    scanf("%d", &x);
    x = abs(x-X);
    g = gcd(g, x);
  }
  printf("%d\n", g);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << endl
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rrep(i,n) for(int i=(n); (i)>=0; --(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
#define maxemt(v) *max_element(v.begin(), v.end())
#define minemt(v) *min_element(v.begin(), v.end())
#define lb(v,x) v[lower_bound(v.begin(), v.end(), x) - v.begin()]
#define ub(v,x) v[upper_bound(v.begin(), v.end(), x) - v.begin()]
template<class T> inline bool print(T& x){ cout << x << endl; return true; }
template<class T> inline bool print_(T& x){ cout << x << " "; return true; }
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 gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
const int INF = 1e9;
const ll llINF = 1LL<<60;
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int ans=0;
    if(min(n-1-mini(a), mini(a)) <= k-1){
      ans++;
      if(mini(a)<n/2){
         a[k-1]=0;
         ans += (n-1-mini(a)+(k-2))/(k-1);
      }
      else{
         a[n-k]=0;
         ans += (mini(a)+(k-2))/(k-1);
      }
      cout << ans;
      return 0;
    }
    int tmp = mini(a);
    a[mini(a) - (mini(a) % (k-1))] = 0;
    ans = (mini(a)+(k-2))/(k-1) + (n-1-tmp+(k-2))/(k-1);
    cout << ans;
    return 0;
}




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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max() / 2;
const ll mod = 1e9+7;

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

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

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}

ll dp[1000][1000];
void solve(){
  int H, W;
  cin >> H >> W;
  char map[1000][1000];
  rep(y, H) rep(x, W) cin >> map[x][y];
  const ll mod = 1E9 + 7;

  dp[0][0] = 1;
  rep(y, H) rep(x, W){
    if(y == 0 && x == 0) continue;
    if(y == 0 && map[x][y] == '.') dp[x][y] = dp[x-1][y];
    else if(x == 0 && map[x][y] == '.') dp[x][y] = dp[x][y-1];
    else if(map[x][y] == '.') dp[x][y] = (dp[x][y-1] + dp[x-1][y]) % mod;
  }

  cout << dp[W-1][H-1] << endl;
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

Measured memory_bytes: 9088
using namespace std;

#include <bits/stdc++.h>

int main(){
    string S;
    cin >> S;
    bool fail = false;
    for ( int i = 0; i < S.size(); i ++ ){
        char c = S[i];
        if ( i % 2 == 1 && c == 'R' ) fail = true;
        else if ( i % 2 == 0 && c == 'L' ) fail = true;
    }
    if ( !fail ) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
int N,i,a,b,c,d;
scanf("%d\n",&N);
for(i=0;i<N;i++){
scanf("%d %d %d\n",&a,&b,&c);
if(a>b) d=a,a=b,b=d;
if(b>c) d=b,b=c,c=d;
if(c*c==a*a+b*b) printf("YES\n");
else printf("NO\n");
}
    return 0;
}

Measured memory_bytes: 584
# ABC136c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
h = list(map(int, input().split()))

mak = h[0]
for i in h:
    if (mak > i):
        if (mak - i > 1):
            print("No")
            exit()
    else:
        mak = i
print("Yes")

Measured memory_bytes: 14188
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++) cin >> p[i];
    int cnt = 0;
    for(int i = 1; i < n-1; i++) {
        // cout << p[i-1] << " : " << p[i] << " : " << p[i+1] << endl;
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

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

using namespace std;

int main(){
    long long k, x;
    cin >> k;
    queue <long long> q;
    for (int i = 1; i <= 9; i++){
        q.push(i);
    }
    while (k--){
        x = q.front();
        if (x%10 != 0){
            q.push(10*x + (x%10) -1);
        }
        q.push(10*x + x%10);
        if (x%10 != 9) q.push(10*x + (x%10) + 1);
        q.pop();
    }
    cout << x;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,l;
  scanf("%d%d",&n,&l);
  int *a=(int *)malloc(sizeof(int)*(n+1));
  int i;
  for(i=1;i<=n;i++) scanf("%d",a+i);
  for(i=1;i+1<=n;i++) if(a[i]+a[i+1]>=l) break;
  if(i+1<=n){
    printf("Possible\n");
    int j;
    for(j=1;j<i;j++) printf("%d\n",j);
    for(j=n-1;j>=i+1;j--) printf("%d\n",j);
    printf("%d\n",i);
  } else {
    printf("Impossible\n");
  }
  return;
}

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


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

 int main() {
  
     int N, M;
     cin >> N >> M;
  
     vector<int> s(M), c(M);
     rep(i, M) cin >> s[i] >> c[i], s[i]--;
  
     for (int i = 0; i <= 2000; i++) {
         string t = to_string(i);
         if (t.size() == N) {
             bool good = true;
             for (int j = 0; j < M; j++) {
                 if (t[s[j]] - '0' != c[j]) {
                     good = false;
                 }
             }
             if(good){
                 cout << i << endl;
                 return 0;
             }
         }
     }
  
     cout << -1 << endl;
  
 }

Measured memory_bytes: 256