akhauriyash/Code-Regression huggingface dataset:
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        v: [(usize1, usize1); m]
    }
    let mut g = vec![vec![]; n];
    for &(a, b) in &v {
        g[a].push(b);
        g[b].push(a);
    }
    let mut p1 = vec![];
    let mut p2 = vec![];
    let mut done = vec![false; n];
    done[0] = true;
    for &i in &g[0] {
        if done[i] {
            continue;
        }
        done[i] = true;
        if p1.len() == 0 {
            dfs(i, &g, &mut p1, &mut done);
        } else {
            dfs(i, &g, &mut p2, &mut done);
            break;
        }
    }
    println!("{}", p1.len() + p2.len() + 1);
    if p2.len() > 0 {
        for &p in p2.iter().rev() {
            print!("{} ", p + 1);
        }
    }
    print!("1");
    for &p in &p1 {
        print!(" {}", p + 1);
    }
    println!("");
}

fn dfs(v: usize, g: &Vec<Vec<usize>>, path: &mut Vec<usize>, done: &mut Vec<bool>) {
    path.push(v);
    for &c in &g[v] {
        if done[c] {
            continue;
        }
        done[c] = true;
        dfs(c, g, path, done);
        return;
    }
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(X);
    scanInt(Y);
    scanInt(Z);
    scanInt(K);
    scanVecLLInt(A, X);
    scanVecLLInt(B, Y);
    scanVecLLInt(C, Z);
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    vector<ll> AB; AB.reserve(A.size() * B.size());
    for (auto& a : A){
        for (auto& b : B){
            AB.emplace_back(a + b);
        }
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    AB.resize(K);
    vector<ll> ABC; ABC.reserve(AB.size() * C.size());
    for (auto& ab : AB){
        for (auto& c : C){
            ABC.emplace_back(ab + c);
        }
    }
    sort(ABC.begin(), ABC.end(), greater<ll>());
    REP(k, K){
        cout << ABC[k] << endl;
    }
}


Measured memory_bytes: 31616
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD=1e9+7;

//実際にgrundy数を計算すると分かる

int main(void){
	ll X,Y;
	cin>>X>>Y;
	cout<<(abs(X-Y)<=1?"Brown":"Alice")<<endl;
	return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())

count = 0
divisors = make_divisors(N)
for i in divisors[1:]:
    tmp = i - 1 
    if N // tmp == N % tmp:
        count += tmp
        # print(tmp)
print(count)


Measured memory_bytes: 3296
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll A[N];
        ll i;
    for(i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    ll sum=0,sum1=0;

    if(N%2==0){
        for(i=0;i<N/2-1;i++){
            sum+=2*(A[N-1-i]-A[i]);
        }
        sum+=A[N/2]-A[N/2-1];
    }else {
        for(i=0;i<N/2;i++){
            sum-=2*A[i];
            sum1+=2*A[N-i-1];
        }
        for(i=0;i<N/2-1;i++){
            sum+=2*A[N-i-1];
            sum1-=2*A[i];
        }
        sum+=A[N/2]+A[N/2+1];
        sum1-=A[N/2]+A[N/2-1];
    }
    cout << max(sum,sum1) << endl;
    return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn main(){
    println!("{}", 48-read_one::<i32>())
}

fn read_one<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin.bytes().map(|c| c.expect("Error") as char) 
        .skip_while(|c| c.is_whitespace()).take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("Error")
}
fn read_line<T: FromStr>() -> T{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.parse().ok().expect("Error")
}
fn read_vec<T: FromStr>() -> Vec<T>{
    let mut buf = String::new();
    stdin().read_line(&mut buf);
    let vec : Vec<&str> = buf.split_whitespace().collect();
    let mut v : Vec<T> = vec!();
    for i in 0..vec.len(){
        v.push(vec[i].parse().ok().expect("Error"));
    }
    v
}

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

const int INF = INT_MAX / 2 - 10;

int main() {
  cout << fixed << setprecision(10);
  int D, E;
  while (cin >> D >> E && D) {
    double mindiff = INF;
    for (int x = 0; x < D; ++x) {
      int y = D - x;
      mindiff = min(mindiff, abs(E - sqrt(x * x + y * y)));
    }
    cout << mindiff << endl;
  }
}

Measured memory_bytes: 3204
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll mod = 1000000007;

vector<P> prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({ a, ex });
    }
    if (N != 1) res.push_back({ N, 1 });
    return res;
}

int main() {
	ll n;
	cin >> n;
    vector<P> p;
    p = prime_factorize(n);
    ll count = 0;
    for (auto id: p) {
        ll index = 1;
        while (id.second > 0) {
            if (id.second - index < 0) {
                break;
            }
            id.second -= index;
            index++;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;


int main()
{
  string S;
  cin >> S;
  int sz[3] = {};
  sz[0] = count(begin(S), end(S), 'a');
  sz[1] = count(begin(S), end(S), 'b');
  sz[2] = count(begin(S), end(S), 'c');
//  cout << sz[0] << " " << sz[1] << " " << sz[2] << endl;

  if(max({sz[0], sz[1], sz[2]}) - min({sz[0], sz[1], sz[2]}) <= 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;
// main() is where program execution begins.


int main() {
int H, W;
cin >> H >> W;
char arry[H][W];
int dp[H][W];
for (int i = 0; i < H; ++i)
{
	for (int j = 0; j < W; ++j)
	{
	   cin >> arry[i][j];
	}
}
for (int i = 0; i < H; ++i)
{
	for (int j = 0; j < W; ++j)
	{
	   dp[i][j] = 0;
	}
}
for (int i = 0; i < H; ++i)
{	
	if(arry[i][0] == '#') {break;}
	dp[i][0] = 1;
}

for (int i = 0; i < W; ++i)
{	
	if(arry[0][i] == '#') {break;}
	dp[0][i] = 1;
}

for (int i = 1; i < H; ++i)
{
	for (int j = 1; j < W; ++j)
	{
	   
	   if(arry[i][j] == '.'){
	   		dp[i][j] = (dp[i-1][j] + dp[i][j-1])%1000000007;
	   }
	}
}

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

return 0;
}

Measured memory_bytes: 5120
#include<iostream>

using namespace std;

int main(void)
{
    int N, K, C, i, j, a, b, c;
    string S;
    cin >> N >> K >> C;
    cin >> S;
    int arr[N];
    j = 0;
    for(i = 0; i < N; i++)
    {
        if(S[i]=='o')
        {     
            arr[j++] = i+1;
        }
    }
    int L[K], R[K];
    a = j-1;
    b = K-1;
    c = arr[a];
    L[b] = c;
    while(a >= 0)
    {
        if(c - C > arr[a])
        {
            b--;
            c = arr[a];
            L[b] = c;
            if(b == 0)
            {
                break;
            }
        }
        a--;
    }
    
    a = 0;
    b = 0;
    c = arr[a];
    R[b] = c;
    while(a < j)
    {
        if(c + C < arr[a])
        {
            b++;
            c = arr[a];
            R[b] = c;
            if(b == K-1)
            {
                break;
            }
        }
        a++;
    }

    /*
    cerr << N <<" "<< K <<" "<< C <<endl;
    cerr << S << endl;
    for(i = 0; i < j; i++)
    {
        cerr << arr[i] << " ";
    }
    cerr << endl;
    for(i = 0; i < K; i++)
    {
        cerr << L[i] << " ";
    }
    cerr << endl;
    for(i = 0; i < K; i++)
    {
        cerr << R[i] << " ";
    }
    cerr << endl;
    */
    for(i = 0; i < K; i++)
    {
        if(L[i] == R[i])
        {
            cout<<L[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4228
#include <vector>
#include <cassert>

using size_t = std::size_t;

template<class id_type>
class Graph{
public:
  using vertex_type = size_t;
  struct Edge{
    vertex_type to;
    id_type id;
  };

  struct Edge_Pair{
    vertex_type from;
    vertex_type to;
    id_type id;
  };
private:
  std::vector<vertex_type> ver;
  std::vector<Edge_Pair> edges;
  std::vector<std::vector<Edge>> G;
  std::vector<std::vector<Edge>> rG;
public:
  Graph(size_t sz) : ver(sz) , G(sz) , rG(sz){
    for(size_t i = 0;i < ver.size();i++) ver[i] = i;
  }

  const std::vector<vertex_type>& V() const{
    return ver;
  }

  const std::vector<Edge_Pair>& E() const{
    return edges;
  }

  void add_edge(const Edge_Pair& e){
    edges.push_back(e);
    G[e.from].push_back({e.to,e.id});
    rG[e.to].push_back({e.from,e.id});
  }

  void add_edge(vertex_type from,vertex_type to,id_type id){
    add_edge({from,to,id});
  }

  Graph operator+=(const Edge_Pair& e){
    add_edge(e);
    return *this;
  }


  const std::vector<Edge>& delta_p(vertex_type v) const{
    return G[v];
  }

  const std::vector<Edge>& delta_m(vertex_type v) const{
    return rG[v];
  }

  const std::vector<Edge>& operator[](vertex_type v) const{
    return this->delta_p(v);
  }
};

#include <set>
#include <queue>
#include <functional>

template<class dist_type,class id_type>
std::vector<dist_type> dijkstra(const Graph<id_type>& g,std::function<dist_type(id_type)> cost,size_t s,dist_type init,dist_type INF){
    using vt = typename Graph<id_type>::vertex_type;
    using P = std::pair<dist_type,vt>;
    std::vector<dist_type> dist(g.V().size(),INF);
    dist[s] = init;

    std::priority_queue<P,std::vector<P>,std::greater<P>> que;

    que.push({dist[s],s});

    while(!que.empty()){
      vt v = que.top().second;
      dist_type d = que.top().first;
      que.pop();
      if(dist[v] < d) continue;
      for(const auto & e : g.delta_p(v)){
        if(dist[e.to] > dist[v] + cost(e.id)){
          dist[e.to] = dist[v] + cost(e.id);
          que.push({dist[e.to],e.to});
        }
      }
    }

    return dist;
}

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int n;
  cin >> n;
  Graph<size_t> g(n);
  vector<i64> cost;
  for(int i = 0;i < n;i++){
    size_t u,t;
    cin >> u >> t;
    for(int j = 0;j < t;j++){
      size_t v;
      i64 c;
      cin >> v >> c;
      g.add_edge(u,v,cost.size());
      cost.push_back(c);
    }
  }

  auto res = dijkstra<i64,size_t>(g,[&](size_t id)->i64{return cost[id];},0UL,0LL,(i64)1e9);
  for(int i = 0;i < n;i++){
    cout << i << " " << res[i] << endl;
  }
}



Measured memory_bytes: 3344
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] input = sc.nextLine().split("[\\s]+");
    int N = Integer.parseInt(input[0]);
    int i = Integer.parseInt(input[1]);
    System.out.println(N-i+1);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w;
	cin>>h>>w;
	vvi f(h,vi(w,0));
	vs s(h);
	cin>>s;
	ll cnt,bck;

	rep(i,h){
		cnt=0, bck=INF;
		rep(j,w){
			if(s[i][j]=='.'){
				cnt++;
				chmin(bck,j);
			}else if(bck!=INF){
				range(k,bck,bck+cnt){
					f[i][k]+=cnt;
				}
				cnt=0, bck=INF;
			}
		}
		if(bck!=INF){
			range(k,bck,bck+cnt){
				f[i][k]+=cnt;
			}
			cnt=0, bck=INF;
		}
	}
	rep(j,w){
		cnt=0, bck=INF;
		rep(i,h){
			if(s[i][j]=='.'){
				cnt++;
				chmin(bck,i);
			}else if(bck!=INF){
				range(k,bck,bck+cnt){
					f[k][j]+=cnt;
				}
				cnt=0, bck=INF;
			}
		}
		if(bck!=INF){
			range(k,bck,bck+cnt){
				f[k][j]+=cnt;
			}
			cnt=0, bck=INF;
		}
	}
	int ans=0;
	for(auto l:f)chmax(ans,max(l));
	puta(ans-1);

	return 0;
}

Measured memory_bytes: 20224
# coding: utf-8
# user: herp_sy

def quicksort(seq):
  if len(seq) < 1:
      return seq
  pivot = seq[0]
  left = []
  right = []
  for x in range(1, len(seq)):
    if seq[x] <= pivot:
        left.append(seq[x])
    else:
        right.append(seq[x])
  left = quicksort(left)
  right = quicksort(right)
  foo = [pivot]
  return (left + foo + right)

# , = map(int, input.split())
#  = int(input())

n = int(input())
while n >= 4:
  if n % 4 == 0 or n % 7 == 0:
    print('Yes')
    exit(0)
  elif n > 4:
    n = n - 4
  elif n > 7:
    n = n - 7
print('No') 

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

int main(){
    vector<int>P={2,3,5,7,11,13,17,19,23};
    
    int crtr=1;
    vector<int>A(9);
    for(int i=0;i<9;i++)
    {cin>>A[i];}
    int N;
    cin>>N;
    vector<int>B(N);
    for(int i=0;i<N;i++)
    {cin>>B[i];}
    for(int i=0;i<9;i++)
    {for(int j=0;j<N;j++)
    {if(A[i]==B[j]){crtr*=P[i];}}
        }
    
    if(crtr%30!=0&&
       crtr%1001!=0&&
       crtr%7429!=0&&
       crtr%506!=0&&
       crtr%1495!=0&&
       crtr%627!=0&&
       crtr%238!=0&&
       crtr%935!=0){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}
    


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>


int main()
{
    long long N, K;
    std::cin >> N >> K;
    long long ans = N % K;
    std::cout << std::min(ans, std::abs(ans - K)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
Amax = A[-1]
dp = [1]*(Amax+1)
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:
    for q in range(Amax//p+1):
      dp[p*q] = 0
    if A[i] != A[i+1]: 
      ans += 1
if dp[Amax] == 1:
  ans += 1
print(ans)

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}



signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int min = 1;
  for (int i = 0; N > i; i++){
    if (min * 2 < min + K){
      min *= 2;
    }
    else{
      min += K;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char[] a = in.next().toCharArray();
		Arrays.sort(a);
		System.out.println((a[0] == 'a' && a[1] == 'b' && a[2] == 'c') ? "Yes" : "No");
	}

	static class Query {
		int i, l, x;

		public Query(int ii, int ll, int xx) {
			i = ii;
			l = ll;
			x = xx;
		}
	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (st.hasMoreTokens())
				return st.nextToken();
			else
				st = new StringTokenizer(br.readLine());
			return next();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
	}
}

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

int main() {
    string s;
    cin >> s;
    string ans = "No";
    if (s[0] == s[1] and s[1] == s[2] and s[2] == s[3]);
    else if (s[0] == s[1] and s[2] == s[3]) ans = "Yes";
    else if (s[0] == s[3] and s[1] == s[2]) ans = "Yes";
    else if (s[0] == s[2] and s[1] == s[3]) ans = "Yes";
    cout << ans << endl;
}

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

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    int ans = 0;
    int b[M];
    for(int j = 0; j < M; j++){
        cin >> b[j]; 
    }
    for(int i = 0; i < N; i++){
        int a[M];
        for(int j = 0; j < M; j++){
            cin >> a[j]; 
        }
        int sum = 0;
        for(int j = 0; j < M; j++){
             sum += a[j] * b[j];
        }
        if( sum + C > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
  h,w=map(int,input().split())
  cy,cx=map(int,input().split())
  dy,dx=map(int,input().split())

  M=["##"+input()+"##" for x in range(h)]
  for i in range(2):
    M.insert(0,"#"*(w+4))
    M.append("#"*(w+4))

  C=[[-1 if M[j][i]=="." else -2 for i in range(w+4)] for j in range(h+4)]
  C[-~cy][-~cx]=0
  QA,QB=deque(),deque()
  QA.append((-~cy,-~cx,0))
  W=[[i,j] for i in range(-2,3) for j in range(-2,3) if abs(i)+abs(j)>1]

  while QA:
    h,w,c=QA.popleft()
    QB.append((h,w,c))

    for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
      dh,dw=h+i,w+j
      if C[dh][dw]==-1:
        C[dh][dw]=c
        QA.appendleft((dh,dw,c))

    if QA:
      continue

    while QB:
      h,w,c=QB.popleft()
      for i,j in W:
        dh,dw=h+i,w+j
        if C[dh][dw]==-1:
          C[dh][dw]=-~c
          QA.append((dh,dw,-~c))

  print(C[-~dy][-~dx])

if __name__ == "__main__":
  main()


Measured memory_bytes: 24544
#include<iostream>
#include<iostream>
using namespace std;
int main(){
int a;
int b;
cin>>a>>b;
int k=0;
int j=0;
int arr[9]={0};
for(int i=0;i<b;i++){
    arr[i]=a;
}
int brr[9]={0};
for(int i=0;i<a;i++){
    brr[i]=b;
}
int flage=0;
for(int i=0;i<min(a,b);i++){
    if(arr[i]<=brr[i]){
        continue;
    }
    else{
        flage=1;
        break;
    }
}
if(flage==0){
    for(int i=0;i<b;i++){
        cout<<arr[i];
    }
}
else{
    for(int i=0;i<a;i++){
        cout<<brr[i];
    }
}

return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	long long int a,b;
	cin>>a>>b;
	if(a==1&&b==1){
		cout<<1<<endl;
	}
	else if(a==1){
		cout<<b-2<<endl;
	}
	else if(b==1){
		cout<<a-2<<endl;
	}
	else{
		cout<<(a-2)*(b-2)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
    // INPUT
    ll N = 0;
    cin >> N;

    // SOURCE
    ll ans = 0;
    for (ll i = 1; i < N + 1; ++i) {
        ll Y = N / i;
        ans += (Y*(Y+1)*i)/2;
    }

    // OUTPUT
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  bool Y = false;
  for (int i = 0; i < N; ++i){
	string S;
    cin >> S;
    if ("Y" == S){
      Y = true;
      break;
    }
  }
  if (Y){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define sqr(x) (x)*(x)
using namespace std;

ll lcm(ll a, ll b){
	return a*b/__gcd(a,b);
}

int main(){
#ifdef LOCAL
    freopen("inp.txt", "r", stdin );
    freopen("ans.txt", "w", stdout);
#endif
    ll n, m;
    cin >> n >> m;
    vector<int>a(n);
    for(int i=0; i<n; i++){
    	cin >> a[i];
    	a[i] /= 2;
    }
    ll l = a[0];
    for(int i=1; i<n; i++){
    	l = lcm(l, a[i]);
    }
    for(int i=0; i<n; i++){
    	if((l / a[i]) % 2 == 0){
    		cout << 0 << '\n';
    		return 0;
    	}
    }
    cout << m/(l*2) + (m/l)%2 << '\n';
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define fin for(int i=0;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define endl '\n'
#define fi first
#define se second

void solve(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x = max(a*d,a*c);
  int y = max(b*c,b*d);
  cout<<max(x,y)<<endl;
 
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while(t--) solve();
}


Measured memory_bytes: 3632
#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 MOD 1000000007
#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,k;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    m--;
    double v[100][100];
    rep(i,n)rep(j,n)cin>>v[i][j];
    double dp[105][105];
    rep(i,n) dp[0][i]=1;
    loop(i,1,m+1)rep(j,n){
      dp[i][j]=0;
      rep(k,n)
	dp[i][j]=max(dp[i][j],dp[i-1][k]*v[k][j]);
 
    }
    double ans=0;
    rep(i,n)ans=max(ans,dp[m][i]);
    cout<<shosu(2)<<ans<<endl;
  }
}

Measured memory_bytes: 3384
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:57 2020

@author: liang
"""

N = int(input())
S = input()

tmp = 0

for i in range(1,N):
    if S[i] == "E":
        tmp += 1

ans = 10**6
for i in range(N):
    if ans > tmp:
        ans = tmp
    if i == N-1:
        break
    if S[i] == "W":
        tmp += 1
    if S[i+1] == "E":
        tmp -= 1
    #print(tmp)
        
print(ans)

Measured memory_bytes: 9756
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ctoi(x) x-'0'
#define fr(i,n) for(ll i=0;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define WUBBAxxLUBAxxDUBxxDUB int main
#define salamo3lekooooom ios::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
#define pb(a,x) ll x; cin>>x; a.push_back(x);
#define test() ll q; cin>>q; while(q--)
using namespace std;
const string alph="abcdefghijklmnopqrstuvwxyz";
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
   {
       return (a.second < b.second);
   }

                #define LIMIT 1000000
                long long i, j;
                long long prime_flag[LIMIT];
                void calculate_prime_flag()
                {
                    prime_flag[0] = prime_flag[1] = 1;
                    for(i=2; i<LIMIT; i++)
                    {
                        if (prime_flag[i]==0)
                        {
                            for(j=i*i; j<LIMIT; j+=i)
                            {
                                prime_flag[j] = 1;
                            }
                        }
                    }
                }





                int LPS(char *str)
                {
                    int n=strlen(str);
                    int i,j,cl;
                    int l[n][n];
                    for(i=0; i<n; i++)
                        l[i][i]=1;
                    for(cl=2; cl<=n; cl++)
                    {
                        for(i=0; i<n-cl+1; i++)
                        {
                            j=i+cl-1;
                            if(str[i]==str[j]&&cl==2)
                                l[i][j]=2;
                            else if (str[i]==str[j])
                                l[i][j]=l[i+1][j-1]+2;
                            else
                                l[i][j]=max(l[i][j-1],l[i+1][j]);


                        }
                    }
                    return l[0][n-1];


                }


bool prime(ll x)
{
    for(int i=2;i*i<=x;i++)
    {
        if(x%i==0)
            return false;

    }
    return true;
}

/////3aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
// Get SHWIFTY

ll LCM ( ll x,ll y)
{
    return (x*y)/__gcd(x,y);
}

int setBitNumber(int n)
{
    if (n == 0)
        return 0;

    int msb = 0;
    while (n != 0) {
        n = n / 2;
        msb++;
    }

    return msb-1;
}


const ll mod = 1e9+7;
long long fastpower(long long a,long long b)
{
    if(b==0)
        return 1;
    if(b==1)
        return a;
    long long res = fastpower(a,b/2);
    res = (res* res);
    res%= mod;
    if(b%2!=0)
        res*=a;
    return res%mod;
}


WUBBAxxLUBAxxDUBxxDUB(){
salamo3lekooooom;


  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll sum=0;
    if(k>=a)
    {
        sum+=a;
        k-=a;
        if(k>0)
        {
            ll temp=min(k,b);
            k-=temp;
            if(k>0)
            {
                ll temp2=min(k,c);
                sum-=temp2;

            }
        }
        cout<<sum<<endl;

    }
    else
        cout<<k<<endl;


}


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

def main():
    AtoE = [int(input()) for _ in range(5)]
    k = int(input())

    for i in AtoE:
        for j in AtoE:
            if abs(i - j) > k:
                print(':(')
                exit()
    else:
        print('Yay!')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

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

char S[10];
int main(){
    scanf("%s",&S);
    int Sn=0;
    for(Sn=0;S[Sn]!='\0';Sn++);
    if(Sn==3){
        char s=S[0];
        S[0]=S[2];
        S[2]=s;
    }
    printf("%s",S);
    
    return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]

b = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if a[i][j] == '.':
            cnt += 1
            
    if cnt != w:
        b.append(a[i])

c = ['']*len(b) 
for i in range(len(b[0])):
    cnt = 0
    for j in range(len(b)):
        if b[j][i] == '.':
            cnt += 1
    
    if cnt != len(b):
        for j in range(len(b)):
            c[j] += b[j][i]

for i in range(len(c)):
    print(c[i])

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int n,ans;
  int a[100010];
  
  cin >> n;
  for (int i=1; i<=n; i++) cin >> a[i];
  ans=0;
  for (int i=1; i<=n; i++){
    if (a[a[i]]==i) ans++;
  }
  cout << (ans/2) << endl;
  
  return 0;
}


Measured memory_bytes: 640
N = int(input())
S = input().split()
series = []
left = 0
mid = 0
right = 0
counter = 0
for i in range(N):
    series.append(int(S[i]))
for i in range(N-1):
    if i == 0:
        left = series[i]
        continue
    left = series[i-1]
    mid = series[i]
    right = series[i+1]
    if (left > mid and right < mid) or (left < mid and right > mid):
        counter += 1
print(counter)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int ac = 0, wa = 0, tle = 0, re = 0;
  int n;
  cin >> n;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "AC") {
      ac++;
    } else if (s == "WA") wa++;
    else if (s == "TLE") tle++;
    else if (s == "RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

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

int main()
{
  string s; cin>>s;
  int q; cin>>q;
  while(q--)
  {
    string d; cin>>d;
    int a, b; cin>>a>>b;
    if(d=="replace") 
    {
      string r; cin>>r;
      s = s.substr(0,a) + r + s.substr(b+1, s.size()-b-1);
    }
    if(d=="reverse")
    {
      string r; r = s.substr(a, b-a+1);
      reverse(r.begin(), r.end());
      s = s.substr(0,a) + r + s.substr(b+1, s.size()-b-1);
    }
    if(d=="print")
    {
      cout << s.substr(a, b-a+1) << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3204
#include "bits/stdc++.h"
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int X;
	cin >> X;
	long long ans = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if (i * 500 + j * 100 + k * 50 == X)ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N,K;
	ll result=0;
	string S;
	cin>>N>>K;
	VI A(N);
	REP(i, N) cin >> A[i];
	ll maxi=MAX(A);
	ll G=GCD(A);
	if(K%G==0&&K<=maxi)
		S="POSSIBLE";
	else
		S="IMPOSSIBLE";
	cout << S << "\n";
	return;
}

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


Measured memory_bytes: 1792
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()

h, w, k = [int(x) for x in input().split()]
g = [input() for _ in range(h)]
ans = 0
for r in range(1 << h):
    for c in range(1 << w):
        if sum(1 for i in range(h) for j in range(w) if (r & (1 << i)) == 0 and (c & (1 << j)) and g[i][j] == '#') == k:
            ans += 1
print(ans)

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  ll cnt[200001] = {0};
  for(int i(0);i<N;i++){
    cnt[A[i]]++;
  }
  ll tmp(0);
  for(int i(1);i<=N;i++){
    if(cnt[i] != 0){
      tmp += (cnt[i]*(cnt[i]-1)/2);
    }
  }
  //cout << tmp << endl;
  for(int i(0);i<N;i++){
    cout << tmp - cnt[A[i]] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 5760
import Foundation
// 第一引数に二分探索したい配列を渡す
// 第二引数に検索したい要素を渡す
func binarySearch(list:[Int],item:Int)->Int{
    // 解の存在範囲を初期化
    var low = -1
    var high = list.count 
    // 解の存在範囲が1より大きい間、繰り返す
    while (high - low > 1) {
        let mid = Int(floor(Double(low + high) / 2))
        if list[mid] >= item {
            // midが条件を満たせば、解の存在範囲は(low,mid]
            high = mid
        } else {
            // midが条件を満たさなければ、解の存在範囲は(mid,high]
            low = mid
        }
    }
    // この時点で、low + 1 = highとなっている
    return high
}

// 標準入力の受け取り
let n = Int(readLine()!)!
var a = readLine()!.split(separator:" ").map{Int($0)!}
var b = readLine()!.split(separator:" ").map{Int($0)!}
var c = readLine()!.split(separator:" ").map{Int($0)!}

// とりあえず各配列をソートする
a.sort { $0 < $1 }
b.sort { $0 < $1 }
c.sort { $0 < $1 }

// 答えを入れる変数を用意
var ans = 0;

// 中部のパーツの配列に対して全探索
for i in b{
    // 各配列に対して二分探索
    let ai = binarySearch(list:a,item:i)
    let ci = binarySearch(list:c,item:i+1)
    
    // ansに考えられるパーツの組み合わせの個数を加える
    ans += (ai)*(n-ci)
}

// 答えを出力
print(ans)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string s,t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t), greater<char>());
    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	int sum = 0;
	REP(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	vvi dp(n + 1, vi(sum+1,0));
	dp[0][0] = 1;
	REP(i, n) {
		REP(j, sum + 1) {
			if (j < v[i])dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = dp[i][j] | dp[i][j - v[i]];
		}
	}
	RREP(i, sum + 1) {
		if (dp[n][i] && i % 10 != 0) {
			cout << i << endl;
			return 0;
		}
	
	}
	cout << 0 << endl;
	return 0;
}


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

int main(void){
    int e;
    while(cin >> e && e){
        int x,y,z;
        int m=e;
        for(z=0;z*z*z<=e;z++){
            for(y=0;y*y<=e;y++){
                x=e-z*z*z-y*y;
                if(x>=0)
                    m=min(m,x+y+z);
            }
        }
        cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define all(n) n.begin(),n.end()
using namespace std;

int main()
{
  int n;
  map<int,int> tes;
  vector<int> vec;
  for(int i=0;i<=1000;i++)
    for(int j=0;j<=1000;j++)
      vec.push_back(i+j),tes[i+j]++;
  sort(all(vec));

  while(cin >> n)
    {
      unsigned long long sum = 0;
      for(int i=0;i<=1000 && i <= n;i++)
	for(int j=0;j<=1000 && j+i <= n;j++)
	  sum += upper_bound(all(vec),n-(i+j))-lower_bound(all(vec),n-(i+j));
	     
      cout << sum << endl;
    }
  return 0;
}

Measured memory_bytes: 7220
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	
	cin >>n;
	int bef;
	//vector<int> ans(100200, 0);
	map<int,int>ans;
	int an=0;
	rep(i,n){
		cin>>bef;
		ans[bef-1]++;
		ans[bef+1]++;
		ans[bef]++;
	}
	for(auto itr=ans.begin();itr!=ans.end();itr++){
		chmax(an,itr->S);
	}
	//sort(all(ans),greater<int>());
	cout<<an<<endl;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,k,tmp=0,ans=0,t=0;
    cin>>a>>b>>c>>k;
    tmp=min(a,k);
    //cout<<tmp<<endl;
    k-=tmp;
    if(k>0){
        t=min(k,b);
        k-=t;
    }
   // cout<<t<<endl;
    if(k>0){
        ans=min(k,c)*(-1);
    }
    ans=ans+(t*0)+tmp;




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





Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
namespace fdata
{
inline char nextchar()
{
    static const int BS = 1 << 21;
    static char buf[BS], *st, *ed;
    if (st == ed)
        ed = buf + fread(st = buf, 1, BS, stdin);
    return st == ed ? -1 : *st++;
}
#ifdef lky233
#define nextchar getchar
#endif
template <typename Y>
inline void poread(Y &ret)
{
    ret = 0;
    char ch;
    while (!isdigit(ch = nextchar()))
        ;
    do
        ret = ret * 10 + ch - '0';
    while (isdigit(ch = nextchar()));
}
#undef nextcar
} // namespace fdata
using fdata::poread;
#define int long long
const int MAXN =  5e5 + 10;
const int MOD = 1e9 + 7;
inline int qpow(int a, int b)
{
	register int res = 1;
	for(; b; b >>= 1)
	{
		if(b & 1)
			res = (long long)res * a % MOD;
		a =  (long long)a * a % MOD;	
	}	
	return res;
}
int n;
int a[MAXN];
bool vis[MAXN];
int fac[MAXN], inv_fac[MAXN];
int s[MAXN], ans[MAXN];

inline int C(int n, int m)
{
	if(n < m)
		return 0;
	return (long long) fac[n] * inv_fac[n - m] % MOD * inv_fac[m] % MOD;
}

int tree[MAXN];
inline void add(int x, int d)
{
	for(; x <= n; x += (x & -x))
		tree[x] = (tree[x] + d) % MOD;
}
inline int ask(int x)
{
	register int res = 0;
	for(; x; x -= (x & -x))
		res = (res + tree[x]) % MOD;
	return res;
}

signed main()
{
#ifdef lky233
	freopen("testdata.in",  "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
	poread(n);
	for(register int i = 1; i <= n; ++i)
		poread(a[i]);
	fac[0] = fac[1] = 1;
	for(register int i = 2; i <= n; ++i)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	inv_fac[n] = qpow(fac[n], MOD - 2);
	for(register int i = n - 1; i >= 0; --i)
		inv_fac[i] = (long long)inv_fac[i + 1] * (i + 1) % MOD;
	register int k = 0, sum = 0;
	for(register int i = 1; i <= n; ++i)
		a[i] ? vis[a[i]] = 1 : ++k;
	for(register int i = n; i >= 1; --i)
	{
		s[i] += s[i + 1];
		if(!vis[i])
		{
			++s[i];
			sum = (sum + i - 1) % MOD;
		}
	}
	register int pre = 0, rem = 0;
	for(register int i = 1; i <= n; ++i)
	{
		if(!a[i])
		{
			ans[i] = (ans[i] + MOD - pre) % MOD;
			if(k >= 2)
				ans[i] = (ans[i] + MOD - (long long)rem * C(k,2) % MOD * fac[k - 2] % MOD) % MOD;
			ans[i] = (ans[i] + sum * fac[k - 1] % MOD) % MOD;
			++rem;
		}
		else
		{
			ans[i] = (ans[i] + (long long)(a[i] - 1) * fac[k] % MOD) % MOD;
			ans[i] = (ans[i] + MOD - (long long)ask(a[i] - 1) * fac[k] % MOD) % MOD;
			if(k) ans[i] = (ans[i] + MOD - (long long)rem * (s[1] - s[a[i]]) % MOD * fac[k - 1] % MOD) % MOD;
			if(k) pre = (pre + (long long)s[a[i] + 1] * fac[k - 1] % MOD) % MOD;
			add(a[i], 1);
		}
	}
	register int res = fac[k];
	for(register int i = 1; i <= n; ++i)
		res = (res + fac[n - i] * ans[i] % MOD) % MOD;
	cerr << res << endl;
	printf("%lld\n", res);
	return 0;
	
}


Measured memory_bytes: 26368
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int N,K;
vector<int> A;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;
  cout << ceil((double)(N-1)/(double)(K-1));
  return 0;
}


Measured memory_bytes: 256