akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <limits>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

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

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

  ll n,t;
  std::cin>>n>>t;

  std::vector<ll> imos(t+2,0);

  rep(i,0,n){
    ll l,r;
    std::cin>>l>>r;
    imos[l]++;imos[r]--;
  }

  ll ans=imos[0];

  rep(i,1,t+2){
    imos[i]+=imos[i-1];
    chmax(ans,imos[i]);
  }

  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t M;
  cin >> M;
  int64_t sum = 0;
  int64_t ans = 0;
  for(int i=0; i<M; i++){
    int64_t x, y;
    cin >> x >> y;
    ans += y;
    sum += x*y;
  }
  cout << (ans - 1) + (sum-1)/9 << endl;
} 

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main() {
	int ans[1111],n,an,ban[1111],ba;
	while (1) {
		cin >> n;
		if (n == 0) {
			goto x;
		}
		an = 0;
		ba = 0;
		for (int i = 1; i <= n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			for (int z = 1; z <= an; z++) {
				if (ban[z] == a) {
					ans[z] = ans[z] + b * c;
					goto a;
				}
			}
			an = an + 1;
			ans[an] = b * c;
			ban[an] = a;
		a:;
		}
		int kk;
		kk = 0;
		for (int i = 1; i <= an; i++) {
			if (ans[i] >= 1000000) {
				cout << ban[i] << endl;
				kk = 1;
			}
		}
		if (kk == 1) {
			kk = 0;
		}
		else {
			cout << "NA" << endl;
		}
	}
x:;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, int> DI;
typedef tuple<ll, ll, ll> T;

int N, K;
vector<P> A;
vector<ll> X, Y;

int main(void){
    
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; ++i){
        ll x, y; scanf("%lld %lld", &x, &y);
        A.push_back(make_pair(x, y));
        X.push_back(x), Y.push_back(y);
    }
    sort(X.begin(), X.end()), sort(Y.begin(), Y.end());
    
    ll ans = LLONG_MAX;
    for(int i = 0; i < N; ++i){ //左辺
        for(int j = i + 1; j < N; ++j){ //右辺
            for(int k = 0; k < N; ++k){ //下辺
                for(int l = k + 1; l < N; ++l){ //上辺
                    ll left = X[i], right = X[j], under = Y[k], upper = Y[l];
                    int cnt = 0;
                    for(int n = 0; n < N; ++n){
                        ll x = A[n].first, y = A[n].second;
                        if(left <= x && x <= right && under <= y && y <= upper) ++cnt;
                    }
                    if(cnt >= K) ans = min(ans, abs(left - right) * abs(under - upper));
                }
            }
        }
    }
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
def dump(n,k):
  for i in range(k-1):
    print(i+1)
  for i in range(n-1,k-1,-1):
    print(i)

n,l=map(int,input().split(' '))
a=input().split(' ')
a=[int(s) for s in a]

k=0
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    k=i+1
    break

if k==0:
  print("Impossible")
else:
  print("Possible")
  dump(n,k)


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

int main(){
    int N,A,B;
    cin>>N;
    if(N==1){
        cout<<"Hello World"<<endl;
    }else if(N==2){
        cin>>A>>B;
        cout<<A+B<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll n,x,d;
typedef pair<ll,ll> P;

int main(){
  cin>>n>>x>>d;
  if(d==0){
    if(x==0)cout<<1<<endl;
    else cout<<n+1<<endl;
    return 0;
  }

  map<int,vector<P>> mp;
  REP(i,n+1){
    ll s=x*i;
    ll l=(ll)i*(i-1)/2;
    ll r=l+(ll)i*(n-i);
    s+=l*d;
    r-=l;
    //sをdで割った正のあまり、s,rを入れている。
    mp[(s%d+d)%d].emplace_back(s,r);
  }

  ll ans=0;
  for(auto p:mp){
    auto a=p.second;
    int m=a.size();
    REP(i,m)a[i].first=(a[i].first-p.first)/d;
    vector<P> ev;
    REP(i,m){
      ev.emplace_back(a[i].first,1);
      ev.emplace_back(a[i].first+a[i].second+1,-1);
    }
    sort(ev.begin(),ev.end());
    ll cnt=0,pre=-INF;
    for(auto e :ev){
      ll len=e.first-pre;
      if(cnt)ans+=len;
      cnt+=e.second;
      pre=e.first;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k; cin >> n >> k;
	int cnt[105] = {};
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int x; cin >> x;
			cnt[x]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) ans += cnt[i] == 0;
	cout << ans;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<list>
#include<cstring>
#include<stack>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
const int maxn = 100100;
int depth[maxn], n, vis[maxn], para[maxn], tid[maxn], height[maxn],slib[maxn],deg[maxn];
vector<int> son[maxn], nodes;
int dfs(int s, int dis)
{
	vis[s] = 1;
	depth[s] = dis;
	height[s] = -1;
	int sz = son[s].size();
	if (sz == 0)
	{
		height[s] = 0;
	}
	for(int i=0; i<sz; i++)
	{
		int val = son[s][i];
		//cout << val << endl;
		if (vis[val] == 1)
			continue;
		height[s] = max(height[s], dfs(val, dis + 1)+1);
	}
	return height[s];
}

int main()
{
	
	int id, cn, tmp;
	for (int i = 0; i < maxn; i++)
		son[i].clear(), para[i]=-1;
	memset(vis, 0, sizeof vis);
	memset(tid, -1, sizeof id);
	memset(deg, 0, sizeof deg);
	memset(slib, -1, sizeof slib);
	scanf("%d", &n);
	int a, b;
	for(int _=1; _<=n; _++)
	{
		scanf("%d%d%d", &id, &a,&b);
		nodes.push_back(id);
		if (a != -1)
			son[id].push_back(a), para[a] = id, slib[a]=b, deg[id]++;
		if (b != -1)
			son[id].push_back(b), para[b]=id, slib[b]=a, deg[id]++;
	}

	int root = -1;
	sort(nodes.begin(), nodes.end());
	for (auto it=nodes.begin(); it!=nodes.end(); it++)
	{
		//cout << "para" << para[i] << endl;
		if(para[*it]==-1)
		{
			root = *it;
			break;
		}
	}
	//cout << root << endl;
	dfs(root,0);
	string str = "";
	for (auto it=nodes.begin(); it!=nodes.end(); it++)
	{
		int i = *it;
		printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d,",i,para[i],slib[i],deg[i],depth[i],height[i]);
		
		if (son[i].size() > 0)
		{
			if (para[i] == -1)
			{
				printf(" root\n");
			}
			else
				printf(" internal node\n");
			
		}
		else
		{
			if (para[i] != -1)
				printf(" leaf\n");
			else
				printf(" root\n");
		}
	}

	return 0;


}


Measured memory_bytes: 7260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <unordered_map>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<long>A(N+1, 1);
	for (int i = 0, a; i < M; i++) {
		cin >> a;
		A[a] = 0;
	}
	for (int i = 2; i < N+1; i++) {
		if (A[i] != 0) {
			A[i] = (A[i - 1] + A[i - 2])%1000000007;
		}
	}

	cout << A.back();
	return 0;
}



Measured memory_bytes: 1024
import java.util.*;
 
class Main {
    public static void main(String[] args) {
    	
    	Scanner sc = new Scanner(System.in);
    	
    	double a = sc.nextDouble(), b = sc.nextDouble();
    	int C = sc.nextInt();
    	
    	double S = 0.5 * a * b * Math.sin(Math.toRadians(C));
    	double L = a + b + Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(Math.toRadians(C)));
    	double h = b * Math.sin(Math.toRadians(C));

    	System.out.println(S);
    	System.out.println(L);
    	System.out.println(h);
    }
}

Measured memory_bytes: 27996
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for(int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for(int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007

using namespace std;
using ll = long long;

template <class T> void printVector(const vector<T> &vec) {
    for(auto value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size() - 1, ans;
    rep(i, 1 << n) {
        ans = s[0] - '0';
        vector<string> exqr(n);
        rep(j, n) {
            if(i >> j & 1) {
                ans += (s[j + 1] - '0');
                exqr[j] = '+';
            } else {
                ans -= (s[j + 1] - '0');
                exqr[j] = '-';
            }
        }
 
        if(ans == 7) {
            rep(j, n + 1) { cout << s[j] << exqr[j]; }
            cout << "=7" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 380
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

def dfs(num):
    temp = [num]
    visited = [0]*N
    
    while temp:
        p = temp.pop()
        for i in ab[p]:
            if visited[i] == 0:
                visited[i] = 1
                temp.append(i)
    if sum(visited)==N: jdg = False
    else: jdg = True
    return jdg

ans = 0 
for a,b in AB:
    ab = [[] for _ in range(N)]
    for a1, b1 in AB:
        if a1==a and b1==b:continue
        ab[a1-1].append(b1-1)
        ab[b1-1].append(a1-1)
        
    if dfs(a):ans += 1
print(ans)
    

Measured memory_bytes: 3064
def main():
    from collections import deque
    import sys

    input = sys.stdin.readline

    h, w = map(int, input().split())
    s = [input() for _ in range(h)]

    bk = 0
    for row in s:
        bk += row.count('#')

    def coods(r, c):
        if r > 0: yield r - 1, c
        if r < h - 1: yield r + 1, c
        if c > 0: yield r, c - 1
        if c < w - 1: yield r, c + 1

    q = deque()
    q.append((0, 0))
    count = [[-1] * w for _ in range(h)]
    count[0][0] = 1
    while q:
        r, c = q.popleft()
        k = count[r][c]
        for nr, nc in coods(r, c):
            nchar = s[nr][nc]
            if nchar == '#': continue
            if count[nr][nc] != -1: continue
            count[nr][nc] = k + 1
            if (nr, nc) == (h - 1, w - 1):
                print(h * w - (k + 1) - bk)
                return
            q.append((nr, nc))
    print(-1)


if __name__ == '__main__':
    main()


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif
}

#define debug(x)    cerr << #x << ": <" << (x) << ">\n"
#define dotc()      int tcs; if (cin >> tcs) for (int tc = 0; tc < tcs; tc++)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second
#define mod         1000000007

using ll = long long;
using vi = vector<int>;

int main() {
  ioThings();

  int n, k; cin >> n >> k;
  int cnt = 0;
  while (n) {
    n /= k;
    cnt++;
  }

  cout << cnt;

  return 0;
}


Measured memory_bytes: 256
K,N = map(int, input().split())
A=list(map(int, input().split()))
Adist=[]

for i in range(N-1):
	Adist.append(A[i+1]-A[i])
Adist.append(K-A[N-1]+A[0])

Adist.pop(Adist.index(max(Adist)))

print(sum(Adist))

Measured memory_bytes: 26444
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }

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

    string s; cin >> s;
    int size = s.size();
    vector<int> a(size+1, 0);
    int cnt = 0;
    for(int i = 1; i <= size; i++) {
        if(s[i - 1] == 'S') a[i] = a[i - 1] + 1;
        else {
            if(a[i - 1] > 0) {
                a[i] = a[i - 1] - 1;
                cnt++;
            }
        }
    }
    cout << size - (2 * cnt) << endl;
}


Measured memory_bytes: 1428
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

require 'bigdecimal'

N = get_int
T, A = get_ints
H = get_ints

min = 10 ** 5 + 1
ans = -1
H.each.with_index do |h, i|
  sa = (A - (T - BigDecimal(h) * 0.006)).abs
  if sa < min
    min = sa
    ans = i
  end
end

puts ans + 1


Measured memory_bytes: 14692
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <string>


using namespace std;


void a(){

    int A,B,T; cin >> A >> B >> T;

    int c = T/A;

    cout << c*B;

}

void b(){

    int N; cin >> N;

    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }
    int profit = 0;
    for(int i = 0; i < N; i++){
        if (V[i] - C[i] > 0){
            profit += V[i] - C[i];
        }
    }

    cout << profit;

}
int main(){

    b();
    return 0;
}

Measured memory_bytes: 888
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, x[202020], y[202020];
int seen[202020];

int d(int i, int j) {
    return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}

int f(int x) {
    int ret = x;
    int tmp = 0;
    for (int i = 0; i < N; i++) {
        if (chmax(tmp, d(i, x)))
            ret = i;
    }
    return ret;
}

void solve() {
    for (int i = 0; i < N; i++) {
        int a, b;
        a = x[i];
        b = y[i];
        x[i] = a + b;
        y[i] = a - b;
    }
    int MINX = x[0], MAXX = x[0], MINY = y[0], MAXY = y[0];
    for (int i = 0; i < N; i++) {
        chmin(MINX, x[i]);
        chmin(MINY, y[i]);
        chmax(MAXX, x[i]);
        chmax(MAXY, y[i]);
    }
    int ans = max(MAXX - MINX, MAXY - MINY);
    cout << ans << endl;
}

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    solve();
    return 0;
}


Measured memory_bytes: 6788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,M;
    cin>>N>>M;
    vi v(N+1,0);
    rep(i,M) {
        int l,r;
        cin>>l>>r;
        l--; 
        v[l]++;
        v[r]--;
    }
    int counter=0,ans=0;
    rep(i,N) {
        counter+=v[i];
        if(counter>=M) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
"use strict"
// inputに入力データ全体が入る
function Main(input){
    input = input.split("\n");
    const lineA = input[0].split(" ").map(e=>+e);
    let n = lineA[0], k = lineA[1];
    const x = input[1].split(" ").map(e=>+e);
    let ans = Number.MAX_SAFE_INTEGER;

    for(let i = 0;i < n - k + 1;i++){
        let l = i, r = i+k-1;
        ans = Math.min(ans, Math.abs(x[l]) + Math.abs(x[r] - x[l]), Math.abs(x[r]) + Math.abs(x[r] - x[l]));
    }
    console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  // start from 0
  int res1 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s[i] != '0')
      ++res1;
    else if (i % 2 == 1 && s[i] != '1')
      ++res1;
  }

  // start from 1
  int res2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2 == 0 && s[i] != '1')
      ++res2;
    else if (i % 2 == 1 && s[i] != '0')
      ++res2;
  }

  cout << min(res1, res2) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

typedef struct {
  int parent;
  vector<int> child;
  int counter;
  int add;
}node;

node tree[2*110000];
int  op[2*110000];

void update_counter(int root, int inc) {
  tree[root].counter += inc;
  tree[root].counter += tree[root].add;
  for(int i:tree[root].child) {
    update_counter(i, tree[root].counter);
  }
}

int main() {
  int N, Q; cin >> N >> Q;
  rep(i, N-1) {
    int a, b; cin >> a >> b;
    tree[a].child.push_back(b);
    tree[b].parent = a;
  }
  rep(i, Q) {
    int p, x; cin >> p >> x;
    tree[p].add += x;
  }
  update_counter(1, 0);
  for(int i=1; i<=N; ++i){
    cout << tree[i].counter;
    if(i == N) cout << endl;
    else cout << " ";
  }
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  ll n;  cin >> n;
  vector<ll> a(n);
  ll cnt[60]={0};
  rep(i,0,n){
    ll add; cin >> add;
    rep(j,0,60){
      if(add & (1LL<<j)){
        cnt[j]++;
      }
    }
  }
  ll ans = 0;
  rep(i,0,60){
    ans += (1LL<<i)%mod * cnt[i] % mod * (n-cnt[i]) % mod;
    ans %= mod;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int n,m,k[100005],L[100005],x,y,used[100005],cou=0,tmp=0;
long long int tmpx,tmpy;
//union find木(グループわけができる)
int par[120000];
int unifind(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
	return 0;
}
	//木の根を求める
int unifind_root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = unifind_root(par[x]);
	}
}
	//同じグループか判定
bool unifind_same(int x, int y) {
	return unifind_root(x) == unifind_root(y);
}
	//グループ併合
int unifind_unite(int x, int y) {
	x = unifind_root(x);
	y = unifind_root(y);
	if (x == y) {
		return 0;
	}
	par[x] = y;
    return 0;
}

int main() {
    const long long int mod = 1000000007,INF=99999999999999;
	map<long long int, long long int>mp;
    string str;
	cout << fixed << setprecision(10);
    unifind(100005);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>k[i];
        cin>>L[1];
        used[L[1]]=1;
        for(int j=2;j<=k[i];j++){
            cin>>L[j];
            used[L[j]]=1;
            unifind_unite(L[j],L[j-1]);
        }
    }
    long long int id;
    for(int i=1;i<=m;i++){
        if(used[i]==1){
            id=i;
        }
    }
    for(int i=1;i<=m;i++){
        if(used[i]==1){
            if(unifind_root(i)!=unifind_root(id)){
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
} 


Measured memory_bytes: 1280
n = gets.to_i
ary = []

n.times do |i|
  ary[i] = gets.split.map(&:to_i)
end
ary2 = {}
n.times do |i|
  ((i+1)..(n-1)).each do |j|
    p = ary[i][0] - ary[j][0]
    q = ary[i][1] - ary[j][1]
    if p < 0
      p *= -1
      q *= -1
    elsif p ==0
      q = q.abs
    end
    ary2[[p,q]] ||= 0
    ary2[[p,q]] +=1
  end
end

max = ary2.values.max || 0

puts n - max    

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef __int128_t i128;
typedef long long i64;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define FPEN2 freopen("out.txt", "w", stdout);
#else
#define FPEN
#define FPEN2
#endif
#define Sz(a) ((int)(a).size())
const int maxn = 200009;
const int MOD = 1e9 + 7;
int main(){
  FPEN;
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int t1=h1*60+m1,t2=h2*60+m2,t3;
  if(t1<t2)t3=t2-t1;
  else t3=23*60+59-t1+t2;
  if(t3<k){
    cout<<0<<'\n';
  }else{
    cout<<t3-k<<'\n';
  }
  
  return 0;
}
//2020.05.30 20:04:00


Measured memory_bytes: 3608
from bisect import*
class SqrtSet:
    def __init__(self,block_limit=201):
        self.key=[]
        self.child=[[]]
        self.block_limit=block_limit
    def le(self,key):
        ret=key
        i=bisect_left(self.key,key)
        if i:ret=self.key[i-1]
        block=self.child[i]
        i=bisect_left(block,key)
        if i:ret=block[i-1]
        return ret
    def ge(self,key):
        ret=key
        i=bisect(self.key,key)
        if i<len(self.key):ret=self.key[i]
        block=self.child[i]
        i=bisect(block,key)
        if i<len(block):ret=block[i]
        return ret
    def insert(self,key):
        i=bisect(self.key,key)
        block=self.child[i]
        insort(block,key)
        if len(block)==self.block_limit:
            sep=self.block_limit//2
            self.key.insert(i,block[sep])
            self.child.insert(i+1,block[sep+1:])
            self.child[i]=block[:sep]
def main():
    n,*p=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(p,1):l[v-1]=i
    t=SqrtSet()
    insert,le,ge=t.insert,t.le,t.ge
    insert(0),insert(n+1)
    a=0
    for i,v in list(enumerate(l,1))[::-1]:
        f,b=ge(v),le(v)
        g,c=ge(f),le(b)
        a+=i*((f-v)*(b-c)+(v-b)*(g-f))
        insert(v)
    print(a)
main()

Measured memory_bytes: 92472
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int dy[]={-1,0,1,0},dx[]={0,-1,0,1};
int w,h,tx,ty,kx,ky;
int f[50][50];
bool v[50][50][50][50];

int main()
{
	while(scanf("%d%d",&w,&h),w)
	{
		scanf("%d%d%d%d",&tx,&ty,&kx,&ky);
		tx--; ty--; kx--; ky--;
		rep(i,h)rep(j,w)scanf("%d",f[i]+j);
		rep(i,h)rep(j,w)rep(k,h)rep(l,w)v[i][j][k][l]=0;
		
		v[tx][ty][kx][ky]=1;
		queue<pair<pair<pi,pi>,int> >Q;
		Q.push(mp(mp(mp(tx,ty),mp(kx,ky)),0));
		while(!Q.empty())
		{
			tx=Q.front().first.first.first; ty=Q.front().first.first.second;
			kx=Q.front().first.second.first; ky=Q.front().first.second.second;
			int cc=Q.front().second; Q.pop();
			
			rep(d,4)
			{
				int ntx=tx+dx[d],nty=ty+dy[d];
				int nkx=kx-dx[d],nky=ky-dy[d];
				
				if(ntx<0||ntx>=w||nty<0||nty>=h||f[nty][ntx])ntx=tx,nty=ty;
				if(nkx<0||nkx>=w||nky<0||nky>=h||f[nky][nkx])nkx=kx,nky=ky;
				if(v[ntx][nty][nkx][nky]||cc>=99)continue;
				if(ntx==nkx&&nty==nky)
				{
					printf("%d\n",cc+1); goto END;
				}
				Q.push(mp(mp(mp(ntx,nty),mp(nkx,nky)),cc+1));
				v[ntx][nty][nkx][nky]=1;
			}
		}
		puts("NA"); END:;
	}
	return 0;
}

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

int binom_max = 10010;
vector<int> fact(binom_max), inv_fact(binom_max), inv(binom_max);

void modbinom_init() {
    fact[0] = fact[1] = 1;
    inv_fact[0] = inv_fact[1] = 1;
    inv[1] = 1;
    for(int i=2; i<binom_max; i++){
        fact[i] = fact[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        inv_fact[i] = inv_fact[i-1] * inv[i] % MOD;
    }
}

int comb(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fact[n] * (inv_fact[k] * inv_fact[n-k] % MOD) % MOD;
}

int perm(int n, int k){
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return (fact[n] * inv_fact[n-k]) % MOD;
}

signed main(){
    modbinom_init();
    int s; cin >> s;
    int ans = 0;
    reps(group,1,s){
        int remain = s - 3 * group;
        if(remain < 0) break;
        ans = mod(ans + comb(remain+group-1, remain));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3868
import sys
input=sys.stdin.readline
#N = int(input())
#S = input()[:-1]
N,K = map(int,input().split())
#S,T = map(str,input().split())
#A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
a = N % K
b = min(a,K-a)
print(b)

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

public class Program
{
    public static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var dict = new Dictionary<int, int>();
        for (int i = 0; i < nm[1]; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            if (!dict.ContainsKey(vals[0]))
            {
                dict.Add(vals[0], vals[1]);
            }
            else
            {
                if (dict[vals[0]] != vals[1])
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            if (dict.ContainsKey(1) && dict[1] == 0 && nm[0] > 1)
            {
                Console.WriteLine(-1);
                return;
            }
        }
        var result = new int[nm[0]];
        for (int i = 0; i < nm[0]; i++)
        {
            if (dict.ContainsKey(i + 1))
            {
                result[i] = dict[i + 1];
            }
            else
            {
                result[i] = 0;
            }
        }
        if (result[0] == 0 && nm[0] > 1)
        {
            result[0]++;
        }
        Console.WriteLine(string.Join("", result));
    }
}

Measured memory_bytes: 13280
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int n;
	int h[100];
	cin >> n;
	rep(i, n) cin >> h[i];
	
	int cnt = 1;
	
	for (int i = n-1; i > 0; i--) {
		bool flg = false;
		for (int j = 0; j < i; j++) {
			
			if (h[i] < h[j]) {
				flg = true;
				break;	
			}
		}
		if (!flg) cnt++;
	}
	cout << cnt<< endl;


	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
LL a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i < N; i++) a[i] = a[i - 1] + a[i - 2];
	int n;
	cin >> n;
	cout << a[n] << endl;
	return 0;
}


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

using i64 = int64_t;

int main(){
    int l, k;
    cin >> l >> k;
    vector<vector<i64>> dp(2, vector<i64>(l+1));
    dp[0][0] = 1;
    for(int i=0;i<l;++i){
        for(int j=0;j<2;++j){
            if(i+1 <= l)
                dp[j^1][i+1] += dp[j][i];
            if(j == 0 && i+k <= l)
                dp[j^1][i+k] += dp[j][i];
        }
    }

    i64 ans = 0;
    for(int i=0;i<=l;++i)ans += dp[1][i];
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3152
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	static int INF = (int)1e9 + 7;
	int N,M;
	int[] c;
	int[] dp;
	
	public void solve() {
		N = nextInt();
		M = nextInt();
		c = new int[M];
		dp = new int[N + 1];
		
		for(int i = 0;i < M;i++){
			c[i] = nextInt();
		}
		
		Arrays.fill(dp,INF);
		dp[0] = 0;
		for(int i = 0;i <= N;i++){
			for(int j = 0;j < M;j++){
				if(i + c[j] <= N){
					dp[i + c[j]] = Math.min(dp[i + c[j]],dp[i] + 1);
				}
			}
			
		}
		out.println(dp[N]);
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 25556
using System;

namespace B___Theater
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ans = 0;
            for (var i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                ans += int.Parse(input[1]) - int.Parse(input[0]) + 1;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll dp[100010];
int main(void){
	ll n;
	cin >> n;
	dp[0] = 0;
	for (ll i = 1;i <= n;i++) {
		dp[i] = i;
		for (int j = 1;;j *= 6) {
			if (i - j < 0)break;
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
		for (int j = 1;;j *= 9) {
			if (i - j < 0)break;
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long               ll;
typedef long double             ld;
 
 
#define racecar          ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time_start		 time_t start, end; time(&start); 
#define time_end		 time(&end);double time_taken=double(end-start);cout <<"\n"<< time_taken*1000<<" ms";
#define si(a)            scanf("%d", &a)
#define si2(a,b)         scanf("%d %d", &a,&b)
#define sll(a)           scanf("%I64d",&a)
#define sll2(a,b)        scanf("%I64d %I64d",&a,&b)
#define pb               push_back
#define pi(a)            printf("%d",int(a))
#define pll(a)           printf("%I64d",ll(a))
#define all(x)           (x).begin(),(x).end()
#define rall(x)          (x).rbegin(),(x).rend()
#define ps               printf(" ")
#define nln              printf("\n")
#define ff               first
#define ss               second
#define vi               vector<int>
#define vll              vector<ll>
#define vstr             vector<string>
#define vc               vector<char>
#define pii              pair<int,int>
#define PLL              pair<ll,ll>
#define PI               acos(-1)
#define sq(x)            x*x
#define forr(i,a,b)      for(ll i=ll(a);i<ll(b);i++)
#define forn(i,a,b)      for(ll i=ll(a);i>ll(b);i--)
#define max3(a,b,c)      max(a,max(b,c))
#define max4(a,b,c,d)    max(max3(a,b,c),d)
#define min3(a,b,c)      min(a,min(b,c))
#define mod              1000000007
#define inf              9223372036854775807

///knight moves:
///int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2}; 
///int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};

 
ll power(ll b,ll n)
{
    if(n==0) return 1;
    else if(n%2) return b*power(b,n/2)*power(b,n/2);
    else return power(b,n/2)*power(b,n/2);
}
 
ld root(ll n,ll r)
{
    ld dif=0.0001;
    ld guess=n/2.0;
    while(abs(pow(guess,r)-n)>=dif)
    {
        ld temp=pow(guess,r)-n;
        ld tmp=r*pow(guess,r-1);
        guess-=temp/tmp;
    }
    return guess;
}
 
void fileio()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}


int solve()
{
	int n,k;
	si2(n,k);

	int dif=k-n;
	dif++;
	
	forr(i,dif,k) pll(i),ps;
	
	forr(i,k,k+n) pll(i),ps;
				
	return 0;
}
	
 
int main()
{
//	time_start;
//    racecar;
//    cout<<fixed<<setprecision(9);
//    fileio();
    solve();
//    time_end;
}

 
 
///    Before submission=>
///    ***check for integer overflow,array bounds
///    ***check for n


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

string shuffle(string str,int h){
    string head = str.substr(0,h);
    string tail = str.substr(h,str.size()-h);
    return tail + head;
}

int main(){
    string card;
    int m,h;
    while(1){
        cin >> card;
        if(card=="-") break;
        cin >> m;
        for(int i=0;i<m;i++){
            cin >> h;
            card = shuffle(card,h);
        }
        cout << card << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double

#define pll pair<ll,ll>
#define ff first
#define ss second

#define pb push_back
#define all(x) x.begin(),x.end()

#define MOD  1000000007
const int N = 100005; 

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n,k;
    cin >> n >> k;
    ll a[n+1],b[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        cin >> b[i];
    }
    ll ans = -1e18;
    for(ll i=1;i<=n;i++)
    {
        ll sum = b[a[i]];
        ll j = a[i];
        ll cnt = 1;
        while(j!=i)
        {
            cnt++;
            sum += b[a[j]];
            j = a[j];
        }
        ll how = k/cnt;
        ll rem = k%cnt;
        ll here = 0,done = 0;
        if(sum>0 && how)   here = (how - 1)*sum,done = 1;
        ll baki = rem + cnt;
        baki = min(baki,k);
        sum = b[a[i]];
        ll maxi = sum;
        j = a[i];
        cnt = 1;
        while(cnt<baki)
        {
            cnt++;
            sum += b[a[j]];
            maxi = max(maxi,sum);
            j = a[j];
        }
        if(done && maxi<0)   maxi = 0;
        here += maxi;   
        ans = max(ans,here);
    }
    cout<<ans;
}

int main()
{
    FAST;
    int t = 1;
    //cin >> t;
    for(int i=1;i<=t;i++)
    {
        solve();
    }
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int n,x;
int a[105];
int main()
{
    while(~scanf("%d%d",&n,&x))
    {
        for(int i=1;i<=n;i++)
            cin>>a[i];
        sort(a+1,a+1+n);
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(x>=a[i])
            {
                if(i==n&&x>a[i])
                    continue;
                else{
                    cnt++;
                    x-=a[i];
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for _ in range(n):
    b, f, r, v = map(int,input().split())
    count[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {count[i][j][k]}',end='')
        print()
    if i < 3:
        print('#'*20)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;


struct BIT{
    private:
    int n,n_;
    vector<long long> bit;

    public:
    BIT(int n):n(n){
        bit.resize(n+1);
        n_ = 1;
        while(n_<=n) n_<<=1;
        n_ >>= 1;
    }
    //1-index
    long long sum(int i){
        long long res = 0;
        while(i > 0){
            res += bit[i];
            i -= i&-i;
        }
        return res;
    }
    //1-index
    void add(int i,long long val){
        while(i <= n){
            bit[i] += val;
            i += i&-i;
        }
    }
    //return 1-index
    int lowerbound(long long w){
        if(w <= 0) return 0;
        int x = 0;
        for(int k=n_;k>0;k>>=1){
            if(x+k<=n&&bit[x+k]<w){
                w -= bit[x+k];
                x += k;
            }
        }
        return x+1;
    }
};

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

    BIT bit(n);
    rep(i,n){
        int a;
        cin >> a;
        bit.add(i+1,a);
    }

    while(q--){
        int t;
        cin >> t;
        if(t==0){
            int p,x;
            cin >> p >> x;
            bit.add(p+1,x);
        }else{
            int l,r;
            cin >> l >> r;
            if(l==0) cout << bit.sum(r) << endl;
            else cout << bit.sum(r) - bit.sum(l) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007
#define ff first
#define ss second
#define pb push_back  
#define INF 10000000000
typedef long long C;
typedef complex<C> P; 
#define X real() 
#define Y imag()


									// nestedcode


 int main(){
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   ll d,n,a,ans = 0,i,j,h,x;
   cin>>n>>d>>a;
   vector<pair<ll,ll> > v,vv;
   for(i=0;i<n;i++){
   	cin>>x>>h;
   	ll k = (h+a-1)/a;
   	v.pb({x,k});
   	
   }
   sort(v.begin(),v.end());
   ll s = 0,str = 0;;
   
   for(i=0;i<n;i++){
       //cout<<i<<endl;
    //   cout<<s<<endl;
   	if(i == 0){
   	    vv.pb({v[i].first + 2*d , v[i].second});
   	    ans+=v[i].second;
   	    s+=v[i].second;
   	    continue;
	   }
	  
   while(1){
       if((str < vv.size()) && vv[str].first < v[i].first){
           s-=vv[str].second;
           str++;
       }else{
           break;
       }
   }
  
  
  
  
   	if(s < v[i].second){
   	
   			vv.pb({v[i].first + 2*d,v[i].second - s});
   				ans+=v[i].second -s;
   			s+=v[i].second - s;
   		
		   
	   }
   }
   
   cout<<ans;
   
}

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

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

  int vec[n][d];

  rep(i, n)
  {
    rep(j, d)
    {
      cin >> vec[i][j];
    }
  }

  int flag = 0;

  for (int i = 0; i < n; i++)
  {
    for (int j = i + 1; j < n; j++)
    {
      double dis = 0;

      for (int k = 0; k < d; k++)
      {
        double dif = vec[i][k] - vec[j][k];
        dis += dif * dif;
      }

      dis = sqrt(dis);
      if (floor(dis) == dis)
        flag++;
    }
  }

  cout << flag;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  printf("%d\n", n * n * n);
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;

	vector<int> kotae;
	for (int i = N; i > 0;) {
		int atta = 0;
		for (int j = max(0, i - M); j < i; j++) {
			if (S[j] == '0') {
				kotae.pb(i - j);
				i = j;
				atta = 1;
				break;
			}
		}
		if (atta == 0) {
			printf("-1\n");
			return 0;
		}
	}

	for (auto itr = kotae.rbegin(); itr != kotae.rend(); itr++) {
		cosp(*itr);
	}

	Would you please return 0;
}

Measured memory_bytes: 1144
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val aa = Array(n){readLine()!!}

    val wa = aa.groupBy { it }.mapValues { it.value.count() }
    val max = wa.values.max()

    val res = wa.filter { it.value == max }.keys.sorted().joinToString("\n")
    println(res)
}

Measured memory_bytes: 128788