akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

struct UnionFind{

	std::vector<int> data;
	// dataの各要素について
	// 負の値:その集合のルートであること示す。また、その絶対値は集合の要素数となっている。
	// 正の値:親ノードの番号(dataのインデックス)。root()を呼び出すたびに集合のルートを指すように書きなおされるので木はそんなに深くならない

	//初期化 size:最大要素数
	UnionFind(int size): data(size, -1) {}
	
	// 集合を併合する
	// すでに同じ集合だった場合は、falseが返る
	bool unite(int x, int y){
		x=root(x);
		y=root(y);
		if( x != y ){
			// 要素数の大きな方へ合併するためのswap
			if( data[y] < data[x] ) std::swap(x, y);
			// 要素数を加算する
			data[x] += data[y];
			// yの属する集合のルートをxに変更
			data[y] = x;
		}
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		// 負の値を持つものがその集合のルート
		// 正の値は同じ集合に属するものを指す(辿ればいずれルートへ着く)
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}

	// 集合の要素数を返す
	int size(int x){
		return -data[ root(x) ];
	}
};

#define NUM_MAX  100050
int node_minus[NUM_MAX] = {0}; //引く数を規定

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<P> ab(m);
    vector<P> cd(k);

    rep(i, m) {cin >> ab[i].first >>ab[i].second;}
    rep(i, k) {cin >> cd[i].first >>cd[i].second;}

    UnionFind uf(n+1);

    rep(i, m){
        uf.unite(ab[i].first, ab[i].second);
        node_minus[ab[i].first]++;
        node_minus[ab[i].second]++;
    }

    rep(i, k){
        if (uf.root(cd[i].first) == uf.root(cd[i].second)){
            node_minus[cd[i].first]++;
            node_minus[cd[i].second]++;
        }
    }

    rep(i, n){
        int id = i+1;
        cout << uf.size(id) - node_minus[id] - 1 << " ";
    }

}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a)>abs(x-b))cout << "B" << endl;
    else cout << "A" << endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
#pragma GCC optimize("O3")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 300*1000+15;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tree_set;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int h,n;
    cin>>h>>n;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin>>x;
        h-=x;
    }
    cout<< ((h>0) ? "No" : "Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e9;

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

    vector<vector<char>> grid1(50,vector<char>(100,'#'));
    vector<vector<char>> grid2(50,vector<char>(100,'.'));
    
    int i1 = 1;
    int j1 = 1;
    while (a > 1) {
        grid1[i1][j1] = '.';
        a -= 1;
        j1 += 2;
        if (j1 == 101) {
            i1 += 2;
            j1 = 1;
        }
    }

    int i2 = 1;
    int j2 = 1;
    while (b > 1) {
        grid2[i2][j2] = '#';
        b -= 1;
        j2 += 2;
        if (j2 == 101) {
            i2 += 2;
            j2 = 1;
        }
    }
    
    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 50; i ++) {
        for (int j = 0; j < 100; j ++ ) {
            cout << grid1[i][j];
        }
        cout << '\n';
    }
    for (int i = 0; i < 50; i ++) {
        for (int j = 0; j < 100; j ++ ) {
            cout << grid2[i][j];
        }
        cout << '\n';
    }

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();//武器の数
        int H = cin.nextInt();//敵のHP

        int[] swingingPower = new int[N];
        int[] throwingSword = new int[N];
        int maxSwinging = 0;
        for (int i = 0; i < N; i++){
            swingingPower[i] = cin.nextInt();
            throwingSword[i] = cin.nextInt();

            if (swingingPower[i] > maxSwinging)
                maxSwinging = swingingPower[i];
        }

        Array.Sort(throwingSword);
        Array.Reverse(throwingSword);

        int result = 0;
        int leftHP = H;
        while(throwingSword[result] > maxSwinging){
            leftHP -= throwingSword[result];
            result++;
            if (result >= N || leftHP <= 0)
                break;
        }

        if (leftHP > 0)
        {
            int swingCount = leftHP / maxSwinging;
            if (leftHP % maxSwinging != 0)
                swingCount++;

            result += swingCount;
        }

        Console.WriteLine(result.ToString());
    }
}


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: 17324
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int n;
  int a[5];
  bool b[5], first;
  first = true;
  while (cin >> n) {
    for (int i=0; i<5; i++) {
      a[i] = n % 10;
      n /= 10;
    }
    reverse(a, a+5);
    for (int i=0; i<5; i++) {
      if (a[i] < 5) {
        b[i] = false;
      } else {
        a[i] -= 5;
        b[i] = true;
      }
    }
    if (!first) cout << endl;
    for (int i=0; i<5; i++) cout << (b[i] ? ' ' : '*');
    cout << endl;
    for (int i=0; i<5; i++) cout << (b[i] ? '*' : ' ');
    cout << endl;
    for (int i=0; i<5; i++) cout << '=';
    cout << endl;
    for (int i=0; i<5; i++) {
      for (int j=0; j<5; j++) {
        cout << ((i == a[j]) ? ' ' : '*');
      }
      cout << endl;
    }
    first = false;
  }
  return 0;
}

Measured memory_bytes: 1152
#a
n = int(input())
aa = []
bb = []

for i in range(n):
    a,b = [int(j) for j in input().split()]
    aa.append(a)
    bb.append(b)

cnt = 0
for i in range(n-1,-1,-1):
    a = aa[i] + cnt
    b = bb[i]
    
    r = a%b
    add = (b-r)%b
    cnt += add

print(cnt)
    

Measured memory_bytes: 11052
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int time = 0;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_6_A-in9.txt"));

		int k = scan.nextInt();
		HS hs = new HS();

		for (int i = 0; i < k; i++) {
			int r = scan.nextInt();
			int c = scan.nextInt();
			hs.add(i, r, c);
		}
		hs.solve();

		for (int r = 0; r < 8; r++) {
			for (int c = 0; c < 8; c++)
				if (hs.isQuenn(r, c))
					System.out.print("Q");
				else
					System.out.print(".");
			System.out.println();
		}

		scan.close();
		System.exit(0);
	}
}

class HS {

	int[] row;
	int[] col;

	public HS() {
		row = new int[8];
		col = new int[8];
		for (int i = 0; i < 8; i++) {
			row[i] = -1;
			col[i] = -1;
		}
	}

	public boolean isQuenn(int r, int c) {
		for (int k = 0; k < 8; k++)
			if (row[k] == r && col[k] == c)
				return true;
		return false;
	}

	public void solve() {
		int k = 0;
		for (; k < row.length; k++)
			if (row[k] == -1)
				break;
		sol(k);
	}

	private boolean sol(int k) {
		if (k == 8)
			return true;
		for (int r = 0; r < 8; r++)
			for (int c = 0; c < 8; c++)
				if (isAbl(r, c)) {
					row[k] = r;
					col[k] = c;
					if (sol(k + 1))
						return true;
					row[k] = -1;
					col[k] = -1;
				}
		return false;
	}

	private boolean isAbl(int r, int c) {
		for (int k = 0; k < 8; k++) {
			if (row[k] == -1)
				break;
			if (row[k] == r || col[k] == c || row[k] + col[k] == r + c || row[k] - col[k] == r - c)
				return false;
		}
		return true;
	}

	public void add(int i, int r, int c) {
		row[i] = r;
		col[i] = c;
	}
}

Measured memory_bytes: 27248
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

struct unionfind {
  vector<int> group;
  vector<int> rank;

  unionfind() {
    unionfind(0);
  }

  unionfind(int n) {
    group = vector<int>(n);
    rank = vector<int>(n);
    for (int i = 0; i < n; i++) group[i] = i;
  }

  int root(int x) {
    if (group[x] == x) return x;
    return group[x] = root(group[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rank[rx] > rank[ry]) group[ry] = rx;
    else if (rank[ry] > rank[rx]) group[rx] = ry;
    else if (rx != ry) {
      group[ry] = rx;
      rank[rx]++;
    }
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

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

  int n;
  cin >> n;
  vector<Pii> xy(n);
  for (auto &x: xy) cin >> x.first >> x.second;

  vector<int> y(n);
  for (auto &x: xy) y[x.first-1] = x.second;
  unionfind uf(n);

  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  pque.emplace(y[0], 0);
  for (int i = 1; i < n; i++) {
    auto top = pque.top();
    if (top.first < y[i]) {
      while (!pque.empty()) {
        auto next = pque.top();
        if (next.first > y[i]) break;
        pque.pop();
        uf.unite(i, next.second);
      }
      pque.push(top);
    }
    else {
      pque.emplace(y[i], i);
    }
  }

  unordered_map<int, int> root_count;
  for (int i = 0; i < n; i++) root_count[uf.root(i)]++;

  vector<int> ans(n);
  for (int i = 0; i < n; i++) ans[i] = root_count[uf.root(xy[i].first-1)];

  for (auto &x: ans) cout << x << endl;

  return 0;
}


Measured memory_bytes: 8216
a = list(input())
if a.count('R')==0:
  print(0)
elif a.count('R') ==1:
  print(1)
elif a.count('R')==2 and a[1]=='S':
  print(1)
elif a.count('R')==2:
  print(2)
else:
  print(3)

Measured memory_bytes: 61808
def operator?(s)
	s =~ /\+|-|\*/
end

def number?(s)
	return true if s.is_a? Integer
	s =~ /\A-?\d+\Z/
end

def operate(x, y, o)
x = x.to_i unless x.is_a? Integer
	y = y.to_i unless y.is_a? Integer
	case o
	when "+"
		x + y
	when "-"
		x - y
	when "*"
		x * y
	else
		raise "Illegal statement. #{x} #{y} #{o}"
	end
end

inputs = STDIN.gets.split
stack = []
inputs.each do |e|
	if number?(e)
		stack.push(e)
	elsif operator?(e)
		x, y = stack.pop(2)
		stack.push(operate x, y, e)
	end
end

puts stack.pop

Measured memory_bytes: 6100
#include <iostream>
#include <vector>
typedef long long ll;
const ll MAX_H = 1000000000;
using namespace std;

ll A, B;

bool isEnough(const vector<ll>& h, ll num) {
    ll res = 0;
    for (int i = 0; i < h.size(); i++) {
        ll t = h[i] - num*B;
        if (t > 0) {
            res += t/(A-B) + (t%(A-B) != 0 ? 1 : 0);
        }
    }
    // cout << "# res = " << res << endl;
    // cout << "# num = " << num << endl;
    return (res<=num ? true : false);
}

int main(void) {

    int N; cin >> N >> A >> B;
    vector<ll> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    ll left, mid, right;
    left = 0; right = MAX_H;
    while (right - left > 1) {
        mid = (left + right) / 2;
        if (isEnough(h, mid)) {
            right = mid;
        } else {
            left = mid;
        }
    }

    cout << right << endl;

    return 0;
}

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

int n;

int main() {
  scanf("%d",&n);

  if ((n%10 == (n/10)%10 && n%10 == (n/100)%10) ||
      ((n/10)%10 == (n/100)%10 && (n/10)%10 == (n/1000)%10)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

}

Measured memory_bytes: 128
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,M; R(N,M);
    VI d(M+1);
    REP(i,N){
        int K; R(K);
        while(K--){
            int x; R(x);
            d[x]++;
        }
    }
    W(count(ALL(d),N));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<string>
#define ll long long

using namespace std;

int main()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll sum=0;
  ll a1=k-a;
  ll b1=k-a-b;
  if(a1<=0)
   {
       cout<<k<<endl;
       return 0 ;
   }
   if(a1>0 && b1<=0)
     {
         cout<<a<<endl;
         return 0;
     }
     else
     cout<<-1*(k-a-b)+a<<endl;
     
    
   
    return 0;
   
   
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	FOR(i,0,N)cin>>a[i];
	FOR(i,0,N){
		ll k;
		cin >> k;
		a[i] -= k;
	}
	SORT(a);
	REV(a);
	ll ans = 0;
	FOR(i,0,N){
		if(a[i]>0)ans+=a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {
    ll n;
    cin >> n;
    if (n % 2 == 1){
        cout << 0 << endl;
        return 0;
    }

    ll i = 10;
    ll ans = 0;
    while(i <= n){
        ans += n / i;
        i *= 5;
    }
    cout << ans << endl;

    return 0;
}

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

#define MAX 1000100

int main(){
  int n, k, cs;
  
  cin >> cs;
  while(cs--){
    cin >> n >> k;
    
    int val[MAX], dis[MAX];
    
    for(int i = 0 ; i < n ; i++) cin >> val[i];
    for(int i = 0 ; i < n-1 ; i++) dis[i] = val[i+1]-val[i];
    
    int total = val[n-1] - val[0];
    
    sort(dis, dis+n-1);
    reverse(dis, dis+n-1);
    
    if(n <= k) cout << 0 << endl;
    else{
      for(int i = 0 ; i < k-1 ; i++) total -= dis[i];
      cout << total << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3620
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#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 h,w,k,ans=0; 
    cin>>h>>w>>k; 
    string s[h];
    for (int i=0;i<h;i++) cin>>s[i]; 

    for (int r=0;r<(1<<h);r++){
    	for (int c=0;c<(1<<w);c++){
    		int cnt=0;
    		for (int i=0;i<h;i++){
    			for (int j=0;j<w;j++){
    				if ((((r>>i)&1)==0) and (((c>>j)&1)==0) and (s[i][j]=='#')) cnt++;
    			}
    		}
    		if (cnt==k) ans++;
    	}
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3624
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s, t = input().split()
    a, b = LI()
    u = input()
    if u == s:
        print("{} {}".format(a - 1, b))
    elif u == t:
        print("{} {}".format(a, b - 1))
    return


# B
def B():
    s = input()
    print('x' * len(s))
    return


# C
def C():
    n = I()
    a = LI()
    s = set()
    for i in a:
        s.add(i)
    if len(s) == n:
        print('YES')
    else:
        print('NO')
    return


# D
def D():
    N, K = LI()
    p = LI()
    map_p = list(map(lambda x: (1 + x), p))
    cumsum_p = [0] * N
    ans_p = [0] * N
    cumsum_p[0] = map_p[0]
    ans_p[0] = map_p[0]
    for i in range(1, N):
        cumsum_p[i] = cumsum_p[i - 1] + map_p[i]
        ans_p[i] = ans_p[i - 1] + map_p[i]
    for i in range(K, N):
        ans_p[i] -= cumsum_p[i - K]
    print(max(ans_p[K - 1:]) / 2.0)
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 75272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5 + 5)

ll par[N] , sz[N];

ll gr(ll x)
{
    if(x == par[x])
        return x;
    return par[x] = gr(par[x]);
}

void merg(ll x,ll y)
{
    ll xr = gr(x);
    ll yr = gr(y);

    if(xr == yr)
        return;
    if(sz[xr] < sz[yr])
        swap(xr,yr);

    sz[xr] += sz[yr];
    par[yr] = xr;

}

void solve()
{
    ll n,m,x,y;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
        par[i] = i , sz[i] = 1;

    while(m--)
    {
        cin>>x>>y;
        merg(x,y);
    }

    ll ans = 0;
    for(int i=1;i<=n;i++)
        ans = max(ans , sz[gr(i)]);

    cout<<ans;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f;
const int MAX = 1e6;

int n, m;
vector<int> G[MAX];
vector<int> ts;
int degree[MAX];
bool cor[MAX];


void dfs(int v)
{
	cor[v] = true;
	for(int &u : G[v])
		if(!cor[u])
			dfs(u);
	ts.push_back(v);
}

int longestPath()
{
	vector<int> dist(n + 1, -1);
	for(int i = 0; i < n; i++)
		if(!degree[i])
			dist[i] = 0;			
	for(int &w : ts)
		for(int &u : G[w])
			if(dist[u] < dist[w] + 1)
				dist[u] = dist[w] + 1;
	return *max_element(dist.begin(), dist.end());
}

int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v);
		degree[v]++;
	}
	for(int i = 0; i < n; i++)
		if(!cor[i])
			dfs(i);
	reverse(ts.begin(), ts.end());
	cout << longestPath() << '\n';	

	return 0;
}

Measured memory_bytes: 31096
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def is_palindrome(s)
  (s.size / 2).times do |i|
    return false unless s[i] == s[(s.size - 1) - i]
  end
  return true
end

def main(argv)
  s = InputLine.to_s
  t = s[0...(s.size / 2)]
  u = s[((s.size / 2) + 1)...s.size]

  flag = [s, t, u].map{|s| is_palindrome(s)}.reduce(true){|f, g| f && g}

  puts (flag ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
n = int(input())
a_inputs = [int(i) for i in input().split()]

a_only = list(set(a_inputs))

ans=0
count=0
for i in range(len(a_inputs)):
    if a_inputs[i]==(count+1):
        count+=1
        continue
    else:
        ans+=1

if a_inputs==a_only:
    print(0)
elif 1 not in a_inputs:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 26012
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    string str;
    int n;
    cin >> n;
    cin >> str;
    int num = str.size();
    if(num%2!=0)    cout << "No";
    else{
        num/=2;
        for(int i=0;i<num;i++){
            if(str[i]!=str[i+num]){
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
    }
}   

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $k);
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));
sort($P);

$sum = 0;
for ($i = 0; $i < $k; ++$i) {
    $sum += $P[$i];
}
echo $sum, PHP_EOL;


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

int main(){
  int N,M;
  cin>>N>>M;
  int ans=1;
  for(int i=1;i*i<=M;i++){
    if(M%i==0){
      if(M/i>=N)ans=max(ans,i);
      if(i>=N)ans=max(ans,M/i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll A, B, C;

int main()
{
	cin >> A >> B >> C;

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(B*C,min(A*B,A*C))<< endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(input())
X = [int(x) for x in X]
X.reverse()

def popcnt0(n):
    c = 0
    for i in range(64):
        c += (n >> i) & 1
    return c
  
#最初にNまでの表を作る
D = [0 for _ in range(N+1)]
D[1] = 1
for i in range(2, N+1):
  D[i] = D[i % popcnt0(i)] + 1
  
#次に、Xの１のカウントを求める
ct_1 = 0
for x in X:
  if x == 1:
    ct_1 += 1

#ct_1-1による2^n mod
if ct_1 > 1:
  B = [0 for _ in range(N)]
  j = 1
  for i in range(N):
    B[i] = j
    j *= 2
    j %= ct_1 - 1 


#ct_1+1による2^n mod
C = [0 for _ in range(N)]
j = 1
for i in range(N):
  C[i] = j
  j *= 2
  j %= ct_1 + 1 

#X mod ct_1-1 と、X mod ct_1+1 を求める
s = 0
t = 0
for i in range(N):
  if ct_1 > 1:
    s += X[i] * B[i]
    s %= ct_1-1
  t += X[i] * C[i] 
  t %= ct_1+1

X.reverse()
#print(X)
#print(D,B,C)
i = N-1
#各場合の1回目の操作後の数を計算して、Dをつかって答えを出す
for x in X:
  if x == 1:
    if ct_1 > 1:
      k = (s - B[i]) % (ct_1-1)
    else:
      print(0)
  else:
    k = (t + C[i]) % (ct_1+1)        
  i -= 1
  if ct_1 > 1 or x == 0:
    print(D[k]+1)
 

  
  
  

Measured memory_bytes: 109892
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int dp[100010];

int main() {
	int n; cin >> n;
	for (int i = 0; i <= n; i++)dp[i] = 10000000;

	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + 1);
		int sixn = 1, ninen = 1;
		for (int j = 0; j < 50; j++) {
			sixn *= 6;
			if (i+sixn > 100000)break;
			dp[i + sixn] = min(dp[i + sixn], dp[i] + 1);
		}
		for (int j = 0; j < 25; j++) {
			ninen *= 9;
			if (i+ninen > 100000)break;
			dp[i + ninen] = min(dp[i + ninen], dp[i] + 1);
		}
	}

	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        1000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
    int n;
    cin >> n;
    if(n%10 == 7){cout << "Yes";return 0;}
    n /= 10;
    if(n%10 == 7){cout << "Yes";return 0;}
    n /= 10;
    if(n%10 == 7){cout << "Yes";return 0;}
    cout << "No";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 3604
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    s = S()
    for i in range(len(s)):
        if i%2:
            if s[i] not in ["L","U","D"]:
                print("No")
                return
        else:
            if s[i] not in ["R","U","D"]:
                print("No")
                return
    print("Yes")
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    B()


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

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

constexpr int INF = (1 << 29);

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

	int N, E, T;
	cin >> N >> E >> T;

	vector<int> dp(N, INF);

	for(int i = 0; i < N; ++i) {
		int w;
		cin >> w;
		if(w == 1) dp[i] = 1;
	}

	vector<vector<vector<int>>> G(N);

	for(int i = 0; i < E; ++i) {
		int g, c;
		cin >> g >> c;

		vector<int> material(c);
		for(auto &e : material) {
			cin >> e;
			--e;
		}

		G[g - 1].emplace_back(move(material));
	}

	while(true) {
		bool update = false;

		for(int v = 0; v < N; ++v) {
			for(const auto &nodes : G[v]) {
				vector<int> need;
				need.reserve(nodes.size());

				for(const auto &c : nodes) {
					need.emplace_back(dp[c]);
				}

				sort(need.rbegin(), need.rend());

				int tmp = 0;
				for(int i = 0; i < static_cast<int>(need.size()); ++i) {
					chmax(tmp, need[i] + i);
				}

				if(dp[v] > tmp) {
					dp[v] = tmp;
					update = true;
				}
			}
		}

		if(!update) break;
	}

	cout << (dp[T - 1] == INF ? -1 : dp[T - 1]) << endl;


	return EXIT_SUCCESS;
}

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

int main(){
    string s;
    int q;

    cin>>s;
    cin>>q;
    bool R=true;
    deque<char> ans;
    int count=0;

    for(int i=0;i<s.size();i++){
        ans.push_back(s[i]);
    }


    int t;
    int f;
    char c;
    for(int g=0;g<q;g++){
        cin>>t;
        if(t==1){
            if(R) R=false;
            else R=true;
            count+=1;
        }else{
            cin>>f>>c;
            if((f==1 && R) || (f==2 && !R)) ans.push_front(c);
            else if((f==1 && !R) || (f==2 && R)) ans.push_back(c);
        }
    }

    if (count%2==0){
        for(int l=0;l<ans.size();l++){
            cout<<ans[l];
        }
    }else{
        for(int l=ans.size()-1;l>=0;l--){
            cout<<ans[l];
        }
    }
    printf("\n");
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型
using namespace std;

// const long long INF = 1LL << 60; //無限大の値
int INF = 1000000;
int dp[100010];
int main()
{
        dp[0] = 0;
        FOR(n, 1, 100000+1)
        {
                dp[n] = INF;
                int power = 1;
                while (power <= n)
                {
                        dp[n] = min(dp[n], dp[n - power] + 1);
                        power *= 6;
                }
                power = 1;
                while (power <= n)
                {
                        dp[n] = min(dp[n], dp[n - power] + 1);
                        power *= 9;
                }
        }
        int N;
        cin >> N;
        cout << dp[N] << endl;

        return 0;
}

Measured memory_bytes: 640
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# a,b = map(int, input().split())
n = int(input())
p = list(map(int,input().split()))

min = p[0]
count = 0
for i in range(n):
    if p[i] <= min:
        min = p[i]
        count += 1

print(count)

Measured memory_bytes: 24872