akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

int INF=1000000001;

typedef struct edge{
  int to;
  int cost;
}edge;

int N,E;
vector <edge> G[100001];
int mincost[100000];

void dikstra(){
  //priority_queue?????£?¨?
  typedef pair<int, int> P;
  priority_queue<P, vector<P>, greater<P> > Q;

  //mincost??????????????????????????????
  for(int i=0;i<N;i++){
    mincost[i]=INF;
  }
  mincost[0]=0;//??????????????°????????????0

  Q.push(P(0,0));
  //????????????????????????????????¬???
  while(!Q.empty()){
    int pos=Q.top().second;//position
    int pos_cost=Q.top().first;
    Q.pop();
    
    if(mincost[pos] < pos_cost ){
      continue;
    }

    for(int i=0;i<(int)G[pos].size();i++){
      edge e=G[pos][i];
      if(mincost[e.to]>pos_cost+e.cost){
        mincost[e.to]=pos_cost+e.cost;
        Q.push(P(mincost[e.to], e.to));
      }
    }
      
  }
  for(int i=0;i<N;i++){
      cout<<i<<' '<<mincost[i]<<endl;
    }
}

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    int id, k;
    cin >> id >> k;
    for(int j=0;j<k;j++){
      edge e;
      cin >> e.to >> e.cost;
      G[id].push_back(e);
    }
  }
  dikstra();
  return 0;
}

Measured memory_bytes: 10196
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int main(void) {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		cout << C << endl;
	}
	else if (A == C) {
		cout << B << endl;
	}
	else {
		cout << A << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int N = nextInt();
        final int K = nextInt();

        int[] h = new int[N];

        for (int i = 0; i < N; i++) h[i] = nextInt();

        Arrays.sort(h);

        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;

        for (int i = 0; i < K; i++) {
            if (h[i] < min) min = h[i];
            if (max < h[i]) max = h[i];
        }

        int ans = max - min;

        for (int i = 1; i <= N - K; i++) {
            min = h[i];
            max = h[i + K - 1];
            if (max - min < ans) ans = max - min;
        }

        out.println(ans);

        out.flush();
    }

    // FastScanner start
    static final InputStream in = System.in;
    static final byte[] buffer = new byte[1024];
    static int ptr = 0;
    static int buflen = 0;
    static boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    static int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    static String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    static long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    static double nextDouble() {
        return Double.parseDouble(next());
    }
    // FastScanner end
}


Measured memory_bytes: 24828
/* https://atcoder.jp/contests/dp/tasks/dp_g */

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
	ll N, M;
	cin>>N>>M;
	map<int, vector<int>> v;
	vector<ll> ind(N+1);
	ll x, y;
	for (int i = 0;i < M;++i) {
		cin>>x>>y;
		v[x].push_back(y);
		ind[y] += 1;
	}

	vector<ll> d(N+1);
	vector<bool> vi(N+1);

	ll ans = LLONG_MIN;
	function<void(int)> dfs = [&] (int vertex) {
		vi[vertex] = true;
		for (auto& x : v[vertex]) {
			d[x] = max(d[x], d[vertex] + 1);
			ind[x] -= 1;
			if (!ind[x]) {
				dfs(x);
			}
		}
	};
	
	for (int i = 1;i <= N;++i) {
		if (!vi[i] && !ind[i]) {
			dfs(i);
		}
	}

	for (int i = 1;i <= N;++i) {
		ans = max(ans, d[i]);
	}

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


Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

const long INF = LLONG_MAX / 3;

int main(){
  int n, k;
  cin>>n>>k;
  vector<int> h(n);
  rep(i,n) cin>>h[i];

  vector<long> dp(n, INF);
  dp[0] = 0;
  rep(i,n){
    rep(j,1,k+1){
      if(i+j < n){
        dp[i+j] = min<long>(dp[i+j], dp[i] + abs<long>(h[i+j] - h[i]));
      }
    }
  }

  cout << dp[n-1] << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  if(N >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}





Measured memory_bytes: 3628
#include <iostream>
int main(int argc, char const *argv[]) {
  int A,B,C;
  long long K;
  std::cin >> A>>B>>C>>K;
  int X= A-B;
  int Y= B-A;
  if (K%2==0) std::cout << X << '\n';
  else std::cout << Y << '\n';
  return 0;
}


Measured memory_bytes: 256
/* Manish Pant - insider_pants, hello_my_friend */
    
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll x;

ll f(ll a, ll b)
{
    ll ans = (a * a * a * a) + (a * a * a * b) + (a * a * b * b) + (a * b * b * b) + (b * b * b * b);
    return ans;
}

void solve()
{
    set<ll> factors;
    for(ll i = 1; i * i <= x; i++)
    {
        if(x % i == 0)
        {
            factors.insert(i);
            factors.insert(x / i);
        }
    }

    ll sq = sqrt(x) + 5;
    for(auto &i: factors)
    {
        if(i > sq) break;
        ll prev = ll(1e16);
        for(ll j = 0; ; j++)
        {
            ll temp = f(j, j - i);
            if(temp * i > prev && temp * i > x) break;

            if(temp * i == x)
            {
                cout << j << ' ' << j - i << endl;
                return;
            }
            prev = temp * i;
        }
    }
}

int main()
{
    fast();
    cin >> x;
    solve();
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();
        double[] A=new double[N];
        
        double m=0;
        for (int i=0; i<N;i++) {
        	A[i]=gi();
        	m+=A[i];
        }
        m=Math.round(m/N);
        
        int s=0;
        for (int i=0; i<N;i++) {
        	s+=(m-A[i])*(m-A[i]);
        }

        System.out.print(s);

//        if (s>L[n-2]) {
//        	System.out.println("Yes");
//        }else {
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  double A[N];
  double max = 0.0,sum = 0.0;
  
  for(int i = 0; i < N; i++){
    double a;
    cin >> a;
    A[i] = ((1.0+a)*a/2.0)/a;
    sum += A[i];
    if(i >= K) sum -= A[i-K];
    if(sum >= max) max = sum;
  }
  printf("%f\n", max);
}

Measured memory_bytes: 1792
memo = Array.new(31,0)
memo[0] = 1
1.upto(30) do |i|
    memo[i] = memo[i-3] + memo[i-2] + memo[i-1]
end
loop do
    n = gets.to_i
    break if n == 0
    p (memo[n].to_f/3650).ceil
end

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

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

  int n, m;
  cin >> n >> m;
  vector<tuple<long long, int, int>> pref_year_city(m);
  rep(i, m) {
    int p, y;
    cin >> p >> y;
    pref_year_city[i] = make_tuple(p, y, i);
  }
  sort(pref_year_city.begin(), pref_year_city.end());
  unordered_map<int, long long> city_pref_cnt;
  vector<int> cnt(n + 1);
  for(auto & pyc : pref_year_city) {
    long long p;
    int c;
    tie(p, ignore, c)= pyc;
    ++cnt[p];
    city_pref_cnt[c] = p * 1000000 + cnt[p];
  }
  rep(i, m) {
    cout << setfill('0') << setw(12) << city_pref_cnt[i] << endl;
  }
}


Measured memory_bytes: 7588
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b=map(int,input().split())
print(max(a+b,a-b,a*b))

Measured memory_bytes: 72988
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    int t, a;
    cin >> t >> a;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin >> h.at(i);

    float min = 999999.0;
    int index = -1;
    for(int i=0;i<n;i++){
        float d = a - (t - h.at(i) * 0.006);
        if(abs(min) > abs(d)){
            min = d;
            index = i+1;
        }
    }

    cout << index << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;


int main(){

    string s;
    cin >> s;
    int K;
    cin >> K;

    map<string, int> candi;
    vector<string> ans;

    char c = 'a';
    while(  candi.size() < K  ){
        for(int i = 0; i < s.size(); i++){
            if(s[i] == c ){
                for(int j = 1; j <= K; j++){
                    int cnt = 0;
                    if(candi.find(s.substr(i, j)) == candi.end() && j + i <= s.size()){
                        if(cnt == K) continue;

                        candi[s.substr(i, j)] ;
                        ans.push_back(s.substr(i, j));
                        cnt ++;
                    }
                }
            }
        }
        c ++;
    }

    sort(all(ans));
    cout << ans[K-1] << endl;

}

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

class Main
{
  static void do_left(String s, int[] v, int idx){
	while(idx > 0 && s.charAt(idx) == '>'){
      v[idx - 1] = Math.max(v[idx] + 1, v[idx - 1]);
      idx -= 1;
    }
  }

  static void do_right(String s, int[] v, int idx){
    while(idx < s.length() - 2 && s.charAt(idx + 1) == '<'){
      v[idx + 1] = Math.max(v[idx] + 1, v[idx + 1]);
      idx += 1;
    }
  }
  
  public static void main(String... args){
	Scanner scanner = new Scanner(System.in);
	String s = ">" + scanner.next() + "<";
    int[] v = new int[s.length() - 1];

    for(int i = 0; i < s.length() - 1; i++){
      if(s.charAt(i) == '>' && s.charAt(i + 1) == '<'){
        do_left(s, v, i);
        do_right(s, v, i);
      }
    }

    //Arrays.stream(v).forEach(x -> System.out.print(x + ","));
    //System.out.println();
	long sum = 0;
    for(int i = 0; i < v.length; i++){
      sum += v[i];
    }
    System.out.println(sum);    
  }
}


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

#define MAX_N 100005
int par[MAX_N]; 
int ran[MAX_N]; 
void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    ran[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  else return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;
  if(ran[x] < ran[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ran[x] == ran[y]) ran[x]++;
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

int n,m,p[100003],ans,x,y;

int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++){cin>>p[i];p[i]--;}
  init(n);
  for(int i=0;i<m;i++){
    cin>>x>>y;x--;y--;unite(x,y);
  }
  for(int i=0;i<n;i++){
    if(same(i,p[i])==true)ans++;
  }    
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
       
public class Main
{
    public static void main (String[] args)
    {
        Scanner scanner = new Scanner(System.in);
       
        for(int i = 1; i<=10000; i++){
         int x = scanner.nextInt();
         if(0 < x && x <= 10000){
          System.out.println("Case " + i +": "+ x);
         }else{
         }
        }
   }
}

Measured memory_bytes: 42392
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
char s[10];
scanf("%s", s);
if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])printf("Yes\n");
 else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3])printf("Yes\n");
 else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2])printf("Yes\n");
 else printf("No\n");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        var n = sc.nextInt();
        var p = new int[n];

        for (int i = 0; i < n; i++)
        {
            p[i] = sc.nextInt();
        }


        int cnt = 0;
        for (int i = 1; i < n - 1; i++)
        {
            if ((p[i - 1] < p[i] && p[i] <= p[i + 1]) || (p[i - 1] >= p[i] && p[i] > p[i + 1])) cnt++;
        }

        Console.WriteLine(cnt);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
const int N=100005;
int a[N];
int main(){
  //  freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n;cin>>n;
    for (int i=1;i<=n;i++) scanf("%d",a+i);
    sort(a+1,a+n+1);
    if (a[n]==0) {puts("Yes");return 0;}
    else if (n%3) {puts("No");return 0;}

    int n1=n/3,n2=n/3*2;
    if (a[n1]==a[1]&&a[n1+1]==a[n2]&&a[n2+1]==a[n]&&((a[1]^a[n1+1]^a[n])==0)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;



int main() {
   

    ll h,a;
    cin >> h >> a;
    if(h%a == 0){
        cout << h/a << endl;
    }else{
        cout << h/a + 1 << endl;
    }

}

Measured memory_bytes: 256
n,k,s = map(int, input().split())

out = []

m = 1000000000

if s == m:
  for i in range(k):
    out.append(str(m))
  for i in range(n-k):
    out.append(str(m-1))
else:
  for i in range(k):
    out.append(str(s))
  for i in range(n-k):
    out.append(str(m))
print(' '.join(out))

Measured memory_bytes: 13464
N,K = map(int,input().split())
hlist = [int(input()) for _ in range(N)]
hlist.sort(reverse=True)
sa = []

for _ in range(N-K+1):
    num = hlist[_]-hlist[_+(K-1)]
    sa.append(num)
sa.sort()
print(sa[0])


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B;
    rep(i,N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    deque<ll> que,rue;
    rep(i,N){
        que.push_back(A[i]);
    }
    rue.push_back(que.front());
    que.pop_front();
    bool flag = true;
    while(!que.empty()){
        if(flag){
            rue.push_front(que.back());
            que.pop_back();
            if(que.empty())break;
            rue.push_back(que.back());
            que.pop_back();
            flag = !flag;
        }else{
            rue.push_front(que.front());
            que.pop_front();
            if(que.empty())break;
            rue.push_back(que.front());
            que.pop_front();
            flag = !flag;
        }

    }
    ll sum1 = 0;
    rep(i,N-1){
        sum1 += abs(rue[i+1]-rue[i]);
    }
    que = deque<ll>();
    rue = deque<ll>();
    
    rep(i,N){
        que.push_back(A[i]);
    }
    rue.push_back(que.back());
    que.pop_back();
    flag = false;
    while(!que.empty()){
        if(flag){
            rue.push_front(que.back());
            que.pop_back();
            if(que.empty())break;
            rue.push_back(que.back());
            que.pop_back();
            flag = !flag;
        }else{
            rue.push_front(que.front());
            que.pop_front();
            if(que.empty())break;
            rue.push_back(que.front());
            que.pop_front();
            flag = !flag;
        }

    }
    ll sum2 = 0;
    rep(i,N-1){
        sum2 += abs(rue[i+1]-rue[i]);
    }
    cout << max(sum1, sum2) << endl;
    /*
    B = vector<ll>();

    rep(i,N){
        que.push_back(A[i]);
    }
    rep(i,N){
        if(i%2 == 1){
            B.push_back(que.front());
            que.pop_front();
        }else{
            B.push_back(que.back());
            que.pop_back();
        }
    }
    ll sum2 = 0;
    rep(i,N-1){
        sum2 += abs(B[i+1]-B[i]);
    }
    cout << max(sum1, sum2) << endl;*/
}


Measured memory_bytes: 1920
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

int sum=0;

int main(){
	int t;
	for(int i=0;i<4;i++){
		cin>>t;
		sum+=t;
	}
	cout<<sum/60<<endl<<sum%60<<endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		A[i]--;
	}
	VI idx(N);
	set<int> s;
	int ans = 0;
	REP(i, N) idx[A[i]] = i;
	for (int x = N - 1; x >= 0; x--) {
		int i = idx[x];
		int c = 0;

		VI L(2,-1),R(2,N);
		s.insert(i);
		auto it = s.find(i);
		REP(j, 2) {
			if (it == s.begin())break;
			it--;
			L[j] = *it;
		}
		it = s.find(i);
		REP(j, 2) {
			it++;
			if (it == s.end())break;
			R[j] = *it;
		}
		VI Ls(2);
		Ls[0] = i - L[0];
		Ls[1] = L[0] - L[1];
		VI Rs(2);
		Rs[0] = R[0]-i;
		Rs[1] = R[1] - R[0];

		c = Ls[0] * Rs[1] + Ls[1] * Rs[0];

		ans += c * (x + 1);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6528
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		HashSet<Integer> set = new HashSet<Integer>();
		for (int i=0;i<N;i++) {
			int tmp=Integer.parseInt(sc.next());
			set.add(tmp);
		}
		System.out.println(set.size());
	}
}

Measured memory_bytes: 23380
/*
	Bakul Gaur (caesar1551)
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PrePro ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,n) for(ll i = 0; i < n; i++)
#define fre(i,a,b) for(ll i = a; i <= b; i++)
#define fb(i,n) for(ll i = n; i >= 0; i--)
#define fbe(i,a,b) for(ll i = a; i >= b; i--)
#define umap(x,y) unordered_map<x,y>
#define uset(x) unordered_set<x>
#define vv(x) vector<x>
#define pp(x,y) pair<x,y>
#define prar(a,n) fr(i,n){cout << a[i] << " ";}
#define inar(a,n) fr(i,n){cin >> a[i];}
#define mk make_pair
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define MAX 1000001
inline ll gcd(ll a, ll b){
	if(b == 0){
		return a;
	}
	return gcd(b,a%b);
}
inline ll pwr(ll a, ll b, ll modulo = mod){
	if(a == 0 && b == 0){
		return 0;
	}
	ll ans = 1;
	while(b > 0){
		if(b&1){
			ans = ((ans%modulo) * (a%modulo))%modulo;
		}
		b >>= 1;
		a = ((a%modulo) * (a%modulo))%modulo;
	}
	return (ans+modulo)%modulo;
}
inline ll modInverse(ll a, ll p){
	// Only if p is prime.
	return pwr(a,p-2,p);
}



/* #############
   START SOLVING 
   ############# */

void dfs(vv(vv(ll)) &graph, vv(bool) &vis, vv(ll) &dp, ll start){
	vis[start] = true;
	for(auto i:graph[start]){
		if(vis[i] == false){
			dfs(graph,vis,dp,i);
		}
		dp[start] = max(dp[start], 1 + dp[i]);
	}
	return;
}

void solve(){
	ll n, m;
	cin >> n >> m;
	vv(vv(ll)) graph(n+1);
	while(m--){
		ll a, b;
		cin >> a >> b;
		graph[a].pb(b);
	}
	vv(bool) vis(n+1,false);
	vv(ll) dp(n+1,0);
	fre(i,1,n){
		if(vis[i] == false){
			dfs(graph,vis,dp,i);
		}
	}
	ll ans = 0;
	fre(i,1,n){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}
int main(){
	PrePro
	/* #ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif */
    ll t = 1;
    // cin >> t;
    fr(i,t){
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    	// cout << endl;
    }
	return 0;
}

Measured memory_bytes: 12884
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let MOD = 100_000_000_0 + 7;
    let n :u64 = read();
    let a :Vec<u64> = (0..n).map(|_| read()).collect();
    let mut ans = 0;
    let mut it = a.iter().rev();
    let la = it.next().unwrap();
    let lb = it.next().unwrap();
    let mut sum = la + lb;
    sum %= MOD;
    ans += la * lb;
    ans %= MOD;
    loop {
        let next = it.next();
        let nextVal;
        match next {
            None => break,
            Some(s) => nextVal = *s,
        };
        ans += nextVal * sum;
        ans %= MOD;
        sum += nextVal;
        sum %= MOD;
    }

    print!("{}", ans);

}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <string>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <queue>

#define N 4009

using namespace std;

const long long int mod=998244353;

long long int fac[N],invfac[N],pws[N];
int ways[N];

long long int nCr(int n,int r){
    if(r>n){
        return 0;
    }
    long long int buf1=(fac[n]*invfac[n-r])%mod;
    buf1=(buf1*invfac[r])%mod;
    return buf1;
}

long long int mul(long long int base,long long int pows){
    long long int buf1,buf2,res=1;
    buf1=base%mod;
    while(pows>0){
        if(pows&1){
            res=(res*buf1)%mod;
        }
        pows>>=1ll;
        buf1=(buf1*buf1)%mod;
    }
    return res;
}

int main(){
    int i,j,t1,t2,t3,t4,n,k;
    long long int buf1,buf2,buf3,ans;
    scanf("%d %d",&k,&n);
    fac[0]=invfac[0]=pws[0]=1;
    for(i=1;i<=4000;i++){
        fac[i]=(fac[i-1]*i)%mod;
        invfac[i]=mul(fac[i],mod-2);
        pws[i]=(pws[i-1]*2)%mod;
    }
    for(i=2;i<=2*k;i++){
        for(j=1;j<=k;j++){
            t1=i-j;
            if(t1>=1 && t1<=k){
                ways[i]++;
            }
        }
    }
    for(i=2;i<=2*k;i++){
        ans=0;
        if(i%2){
            for(j=0;j<=ways[i]/2;j++){
                buf1=(nCr(ways[i]/2,j)*pws[j])%mod;
                t1=n-j;
                t2=j+k-2*(ways[i]/2);
                buf1=(buf1*nCr(t1+t2-1,t2-1))%mod;
                ans=(ans+buf1)%mod;
            }
        }
        else{
            // i/2 is zero
            for(j=0;j<=ways[i]/2;j++){
                buf1=(nCr(ways[i]/2,j)*pws[j])%mod;
                t1=n-j;
                t2=j+k-2*(ways[i]/2)-1;
                buf1=(buf1*nCr(t1+t2-1,t2-1))%mod;
                ans=(ans+buf1)%mod;
            }
            // i/2 is one
            for(j=0;j<=ways[i]/2;j++){
                buf1=(nCr(ways[i]/2,j)*pws[j])%mod;
                t1=n-1-j;
                t2=j+k-2*(ways[i]/2)-1;
                buf1=(buf1*nCr(t1+t2-1,t2-1))%mod;
                ans=(ans+buf1)%mod;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 384
//Keep calm and carry on..

/*  Problem :
    URL :

*/

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;


# define fast           ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
# define pb             push_back
# define pi             3.1415926535897932384626
# define mod            1000000007
# define endl          '\n'
# define DEBUG          false
# define F              first
# define S              second
# define loop1(i,a,b)   for(ll i = a; i<b; i++)
# define loop2(i,a,b)   for(ll i = b-1; i>=a; i--)
# pragma GCC optimize "trapv"


 int main(){
     fast;
     int d,t,s;
     cin>>d >>t >>s;
     
     float ans = (float)d /s;
        
     if (ans <= t) cout<< "Yes";
     else cout<<"No";

     return 0;
}


Measured memory_bytes: 3628
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int L[N];
int n,k;

bool judge(int d){
    ll cnt=0;
    rep(i,1,n){
        cnt+=(L[i]+d-1)/d-1;
        if(cnt>k)return false;
    }
    return true;
}

int main(){
    in>>n>>k;
    rep(i,1,n)
        in>>L[i];
    int l=1,r=1000000001;
    while(l<r){
        int mid=(l+r)>>1;
        if(judge(mid))
            r=mid;
        else l=mid+1;
    }
    out<<l;
    return 0;
}


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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n], b[n], c[n];

    for (int32_t i = 0; i < n; i++) { cin >> a[i]; }
    for (int32_t i = 0; i < n; i++) { cin >> b[i]; }
    for (int32_t i = 0; i < n; i++) { cin >> c[i]; }
    sort(a, a + n);
    sort(c, c + n);

    int64_t answer = 0;
    for (int32_t i = 0; i < n; i++) {
        answer += (lower_bound(a, a + n, b[i]) - a) * (n - (lower_bound(c, c + n, b[i] + 1) - c));
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>

using namespace std;
using ll = long long;

#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  IN(N); IN(K);

  if (K % 2 == 1) {
    ll k = (N / K);
    OUT(k * k * k);
  } else {
    ll k = N/K + (N%K >= K/2 ? 1 : 0);
    ll k2 = (N / K);
    OUT((ll)k * k * k +  k2 * k2 * k2);
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1001

char X[N], Y[N];
int c[N][N];

int LCSLength(){

  int i, j, m, n;

  m = strlen(X);
  n = strlen(Y);
  
  for(i = 1 ; i <= m ; i++){
    c[i][0] = 0;
  }
  for(j = 0 ; j <= n ; j++){
    c[0][j] = 0;
  }
  for(i = 1 ; i <= m ; i++){
    for(j = 1 ; j <= n ; j++){
      if(X[i-1] == Y[j-1]){
	c[i][j] = c[i-1][j-1]+1;
      }
      else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }
      else{
	c[i][j] = c[i][j-1];
      }
    }
  }
  return c[m][n];
  
}


int main(){

  int  a[150], i, q;

  scanf("%d", &q);
  for(i = 0 ; i < q ; i++){
    scanf("%s%s", X, Y);
    a[i] = LCSLength();
  }
  
 for(i = 0 ; i < q ; i++){
  printf("%d\n", a[i]);
 }

  return 0;
}

Measured memory_bytes: 4516
n,m,x,y = map(int,input().split())
X_want = list(map(int,input().split()))
Y_want = list(map(int,input().split()))
for i in range(max(X_want)+1,min(Y_want)+1):
  if x < i <= y:
    print("No War")
    break
else:
  print('War')

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

namespace ABC126
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            string S = Console.ReadLine();
            char[] c = S.ToCharArray();
            char[] clow = S.ToLower().ToCharArray();
            c[K - 1] = clow[K - 1];
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>

using namespace std;
const int MAX_N = 2000000;
int N;
int R[MAX_N];

void solve() {
	int min = 1000000000;
	int score = -1000000000;

	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", R + i);
	}
	min = R[0];
	for (int i = 1; i < N; i++) {
		if (score < R[i] - min) {
			score = R[i] - min;
		}
		if (R[i] < min) {
			min = R[i];
		}
	}

	printf("%d\n", score);
}

int main() {
	solve();
}

Measured memory_bytes: 3496
N = int(input())
a = list(map(int, input().split()))
mi = 0
ma = 0
border = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 4801]
num = [0 for i in range(9)]
for i in a:
    for j in range(len(border[0:-1])):
        if(border[j] <= i and i < border[j+1]):
            num[j] += 1

for i in num[0:-1]:
    if(i > 0):
        mi += 1
        ma += 1

mi = max(1, mi)
ma = ma+num[-1]
print(mi, ma)


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

ll ans;

void sum(int left, int right){
    if(left==right){
        ans+=left*left;
    }else if(left>right){
        REP(i,1,left+1){
            ans+=i;
        }
        REP(i,1,right){
            ans+=i;
        }
    }else{
        REP(i,1,right+1){
            ans+=i;
        }
        REP(i,1,left){
            ans+=i;
        }
    }
}

int main(){
    string S;
    cin >> S;
    ans=0;
    int left=0,right=0;
    char flag='<';
    REP(i,0,S.size()){
        if(S[i]=='<'){
            if(S[i]==flag){
                left++;
            }else{
                flag='<';
                sum(left,right);
                left=1; right=0;
            }
        }else{
            if(S[i]==flag){
                right++;
            }else{
                flag='>';
                right++;
            }
        }
    }
    sum(left, right);
    P(ans);
}

//最後の処理に気をつける

Measured memory_bytes: 900
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0; 
    cin>>n; 
    int a[n],d;
    for (int i=0;i<n;i++) {
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a,a+n);
    if(n&1) d=a[n/2];
    else d=(a[n/2]+a[(n+1)/2])/2;
    for (int &i: a) ans += abs(i-d);
    cout << ans << endl;
}

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

/*
7
1 1 1 1 2 3 4

answer: 6

*/


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

int main(void){
    int nums[3], cnt = 0;
    for (int i=0; i<3; i++) cin >> nums[i];
    sort(nums, nums+3, greater<int>());
    cnt += (nums[0] - nums[1]) / 2;
    cnt += (nums[0] - nums[2]) / 2;
    if ((nums[0]-nums[1])%2 == 1 && (nums[0]-nums[2])%2 == 1) cnt++;
    else if ((nums[0]-nums[1])%2 == 1 || (nums[0]-nums[2])%2 == 1) cnt+=2;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
using namespace std;
 
#define N 500000
#define INF 1000000007
typedef long long LLI;

int cmpCnt;

void merge(LLI a[], int l, int m, int r){
  int bufL[N+1], bufR[N+1];
  int n1, n2, idL, idR;
  n1 = m-l; n2 = r-m;
  for (int i=0; i<n1; i++) bufL[i] = a[l+i];
  for (int i=0; i<n2; i++) bufR[i] = a[m+i];
  bufL[n1] = bufR[n2] = INF;
  idL = idR = 0;
  for (int i=l; i<r; i++){
    cmpCnt++;
    if (bufL[idL]<=bufR[idR]){
      a[i] = bufL[idL++];
    } else {
      a[i] = bufR[idR++];
    }
  }
}

// a[l...r)をソート
void mrgSort(LLI a[], int l, int r){
  if (r-l <= 1) return;
  int m = (l+r)/2;
  mrgSort(a,l,m);
  mrgSort(a,m,r);
  merge(a,l,m,r);
}

int main(void){
  int n;
  LLI a[N];
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  mrgSort(a, 0, n);
  for (int i=0; i<n; i++){
    cout << a[i];
    cout << (i==n-1?"\n":" ");
  }
  cout << cmpCnt << endl;
  return 0;
}


Measured memory_bytes: 8892
#include<bits/stdc++.h>
using namespace std;
vector<long long >v;
int main()
{
    long long t,n,c,x,p;
    string s;
    cin>>t;
    x=t%500;
    p=x/5;
    t/=500;
    cout<<(t*1000)+(5*p);


}


Measured memory_bytes: 256
#include <stdio.h>

int main( int argc, char *argv[] )
{
	int A,B;
	char op[5];
	scanf("%d%s%d",&A,op,&B);
	if(op[0] == '+')printf("%d\n",A+B);
	else printf("%d\n",A-B);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p;
   cin>>n>>m>>p;
    int a[3];
    a[0]=n;
    a[1]=m;
    a[2]=p;
    sort(a,a+3);
    int sum=a[0]+a[1];
    cout<<sum<<endl;
}


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

int main(){
    int n,cnt=0; cin>>n;
    vector<int> a(n+1);
    for(int i=1; i<=n; i++) cin>>a[i];

    for(int i=1; i<=n; i++){
        if(a[i] == i){
            cnt++;
            if(i != n) swap(a[i],a[i+1]);
            }
        }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define maxn 100010
#define LL long long 
using namespace std;
struct Edge{
	int u,v,w;
}e[maxn*5];
int n,cnt=0,f[maxn];
LL ans=0;
struct Node{
	int x,y,pos;
}seg[maxn]; 
bool cmp1(Node a,Node b){
	if(a.x==b.x) return a.y<b.y;
	else return a.x<b.x;
}
bool cmp2(Node a,Node b){
	if(a.y==b.y) return a.x<b.x;
	else return a.y<b.y;
}
bool cmp(Edge a,Edge b){
	return a.w<b.w;
}
int find(int x){
	return x==f[x]?x:f[x]=find(f[x]);
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&seg[i].x,&seg[i].y);
		seg[i].pos=i;
		f[i]=i;
	}
	sort(seg+1,seg+1+n,cmp1);
	for(int i=2;i<=n;i++){
		e[++cnt].u=seg[i-1].pos;
		e[cnt].v=seg[i].pos;
		e[cnt].w=seg[i].x-seg[i-1].x; 
		e[++cnt].u=seg[i].pos;
		e[cnt].v=seg[i-1].pos;
		e[cnt].w=seg[i].x-seg[i-1].x;
	}
	sort(seg+1,seg+1+n,cmp2);
	for(int i=2;i<=n;i++){
		e[++cnt].u=seg[i-1].pos;
		e[cnt].v=seg[i].pos;
		e[cnt].w=seg[i].y-seg[i-1].y; 
		e[++cnt].u=seg[i].pos;
		e[cnt].v=seg[i-1].pos;
		e[cnt].w=seg[i].y-seg[i-1].y; 
	}
	sort(e+1,e+1+cnt,cmp);
	for(int i=1;i<=cnt;i++){
		int nx=find(e[i].u),ny=find(e[i].v);
		if(nx==ny) continue;
		ans+=e[i].w;
		f[nx]=ny;	
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 6528
class UnionFindVerSize():
    def __init__(self, N):
        self._parent = [n for n in range(0, N)]
        self._size = [1] * N

    def find_root(self, x):
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x])
        return self._parent[x]

    def unite(self, x, y):
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

import sys

input=sys.stdin.readline


N,M=map(int,input().split())
uf=UnionFindVerSize(N)
for _ in range(M):
    a,b=map(int,input().split())
    uf.unite(a-1,b-1)

ans=-1
for i in range(N):
    ans=max(ans,uf.get_size(i))

print(ans)

Measured memory_bytes: 82168
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  ll a,b; cin >> a >> b;
  cout << (a<=8&&b<=8 ? "Yay!" : ":(");
  return 0;
}


Measured memory_bytes: 3620