akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	
	long ans;
	foreach (i; 1..N)
	{
		auto cnt = (N-1) / i;
		ans += cnt;
	}
	
	writeln(ans);
	stdout.flush;
	debug readln;
}


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



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

    vector<int> up(n);
    vector<int> down(n);


    for(int i=0;i<n;i++){
        cin>>up.at(i);
    }

    for(int i=0;i<n;i++){
        cin>>down.at(i);
    }


    long long sum;
    int test;
    long long max=0;


    for(int i=0;i<n;i++){
        sum = 0;
        test = 0;
        for(int j=0;j<n;j++){
            if(i==j){
                sum += (up.at(j)+down.at(j));
                test=1;
            }else{
                if(test==1){
                    sum += down.at(j);
                }else{
                    sum += up.at(j);
                }
            }
        }
        if(max<sum){
            max = sum;
        }
    }

    cout<<max<<endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    int tmp = S[0] - '0';
    deque<char> ans;
    ans.push_back(S[0]);

    for(int bit = 0;bit < (1<<4);bit++){
        rep(i,3){
            if(bit & 1 << i){
                tmp += (S[i+1]-'0');
                ans.push_back('+');
            }
            else{
                tmp -= (S[i+1]-'0');
                ans.push_back('-');                
            }
            ans.push_back(S[i+1]);
        }
        if(tmp == 7){
            ans.push_back('=');
            ans.push_back('7');
            while(!ans.empty()){
                cout << ans.front();
                ans.pop_front();
            }
            break;
        }
        else{
            ans.clear();
            ans.push_back(S[0]);
            tmp = S[0] - '0';
        } 
    }


}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
inputs = gets.split.map(&:to_i)

cnt = Hash.new
tar = inputs.min
left =  N
right = 0
inputs.each_with_index do |x,i|
  # cnt[x] = 0 unless cnt.has_key? x
  # cnt[x] += 1
  # tar = x if x <tar
  left = i if x == tar && left > i
  right = i if x == tar && right < i
end
# STDERR.puts [left, N - right - 1].join(" ")

ret = left / (K-1)
if left % (K-1) != 0
  ret += 1
  left += (K-1) - left % (K-1)
end
if right < left
  right = left
end
# STDERR.puts [left, N - right - 1].join(" ")
# right = N - right - 1
ret += (N - right - 1) / (K-1)
if (N - right - 1) % (K-1) != 0
  ret += 1
  right -= (K-1) - (N - right - 1) % (K-1)
end

flag = true
m = 0
for i in (left..right) do
  if inputs[i] != tar
    if flag
      flag = false
      m = 1
    else
      m += 1
    end
  else
    if !flag
      ret += n / (K-1) + (n % (K-1) == 0 ? 0 : 1)
      m = 0
      flag = true
    end
  end
end
# STDERR.puts [left, right].join(" ")
puts ret


Measured memory_bytes: 8076
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int [] h = new int [10000];
    int [] w = new int [10000];
    int m = 0;
    for(int i=0;;i++){
      int H = sc.nextInt();
      int W = sc.nextInt();
      h[i] = H;
      w[i] = W;
      if(H == 0 && W == 0) break;
      m++;
    }
    for(int l=0;l<m;l++){
      for(int j=0;j<h[l];j++){
        if(j == 0 || j == h[l] -1){
          for(int k=0;k<w[l];k++){
            System.out.printf("#");
          }
          System.out.printf("\n");
        }else{
          System.out.printf("#");
          for(int k=2;k<w[l];k++){
            System.out.printf(".");
          }
          System.out.printf("#\n");
        }
      }
      System.out.printf("\n");
    }
  }
}



Measured memory_bytes: 57752
n = int(input())
s = input()
t = input()
if s == t:
  print(n)
else:
  for i in range(-1, -n-1, -1):
    temp = s + t[i:]
    temp_s = temp[:n]
    temp_t = temp[-n:]
    if temp_s == s and temp_t == t:
      print(len(temp))
      break

Measured memory_bytes: 3060
X = int(input())
MAX = 10**5+3
num = 2
primes = [0 for _ in range(MAX+1)]


for num in range(2, int(MAX**0.5)):
  if primes[num] == 1:
    continue
  for i in range(num*2, MAX+1, num):
    primes[i] = 1
for num in range(X, MAX+1):
  if primes[num] == 0:
    print(num)
    exit()



  
  


Measured memory_bytes: 71812
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {


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

		while (true) {
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int[] dp = new int[n+1];
			dp[0] = 1;
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i = 1; i * i <= n; i++){
				list.add(i * i);
			}
			
			for(int coin : list){
				for(int i = 0; i < dp.length; i++){
					if(dp[i] > 0 && i + coin <= n){
						dp[i+coin] += dp[i];
					}
				}
			}
			
			System.out.println(dp[n]);
			
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] = 'a' + s[k - 1] - 'A';
    cout << s << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()

  p=a*x+b*y
  q=c*2*max(x,y)

  if x<=y:
    r=c*x*2
    r+=(y-x)*b
  else:
    r=c*y*2
    r+=(x-y)*a

  return min(p,q,r)

print(main())


Measured memory_bytes: 5536
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> ord(N+1);

  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    ord.at(a) = i;
  }
  for (int i = 1; i <= N; i++) {
    if (i > 1) cout << " ";
    cout << ord.at(i);
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <algorithm>
#define lowbit(x) ((x)&(-(x)))
#define re register
#define ll long long
#define ull unsigned long long
#define rep(i,a,b) for(re int i=a;i<=b;++i)
#define per(i,a,b) for(re int i=a;i>=b;--i)
template<typename T>
inline void read(T&x)
{
	x=0;
	char s=(char)getchar();
	bool f=false;
	while(!(s>='0'&&s<='9'))
	{
		if(s=='-')
			f=true;
		s=(char)getchar();
	}
	while(s>='0'&&s<='9')
	{
		x=(x<<1)+(x<<3)+s-'0';
		s=(char)getchar();
	}
	if(f)
		x=(~x)+1;
}
template<typename T>
inline void clear(T*a,int l,int r,int val)
{
	memset(&a[l],val,sizeof(T)*(r-l+1));
}
using namespace std;
const int N=1e6+5;
struct node
{
	int a , b;
	inline bool operator < (node const &x) const
	{
		if(a == x.a) return b < x.b;
		return a < x.a;
	}
} x[N];
pair<int , int>p[N];
#define fi first
#define se second
int n ;
signed main()
{
	read(n);
	rep(i , 1 , n)
	read(x[i].a),read(x[i].b);
	sort(x + 1 , x + 1 + n);
	int cnt = 0;
	rep(i , 1 , n)
	{
		p[++ cnt].fi = x[i].a;
		p[cnt].se = i;
		p[++ cnt].fi = x[i].b;
		p[cnt].se = -i;
	}
	sort(p + 1 , p + 1 + cnt);
	if(n & 1)
	{

		int one = 0 , two = 0;
		int l = 0 , r = 0;
		rep(i , 1 , cnt)
		{
			if(p[i].se > 0)
			{
				++ one ;
				if(one == n / 2 + 1) l = p[i].fi;
			}
			else
			{
				++ two ;
				if(two == n / 2 + 1) r = p[i].fi;
			}
		}
		printf("%d\n",r-l+1);
	}
	else
	{
		int one = 0 , two = 0;
		int l1 = -1 , r1 = -1 , l2 = -1 , r2 = -1;
		rep(i , 1 , cnt)
		{
			if(p[i].se > 0)
			{
				++one ;
				if(one == n / 2) l1 = p[i].fi;
				else if(one == n / 2 + 1) l2 = p[i].fi;
			}
			else
			{
				++two ;
				if(two == n / 2) r1 = p[i].fi;
				else if(two == n / 2 + 1) r2 = p[i].fi;
			}
		}
		printf("%d\n",r1 - l1 + 1 + r2 - l2 );
	}
	return 0;
}

Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    
    cin>>a;
    
    if(a=="SAT") cout<<"1";
    else {
	if(a=="SUN") cout<<"7";
	else {
	    if(a=="TUE") cout<<"5";
	    else {
		if(a=="WED") cout<<"4";
		else{
		    if(a=="THU") cout<<"3";
		    else {
			if(a=="FRI") cout<<"2";
			else cout<<"6";
		    }
		}
	    }
	}
    }
    cout<<"\n";
}

			    


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#include <numeric>
#include <deque>
#include <limits>
#include <set>
#include <map>

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) // cerr << __LINE__ << ":\t" #x " = " << x << endl


int n, m;
vector<int> x;
map<int, int> cnt;

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

    while (cin >> n >> m) {
        cnt.clear();
        x.resize(n);
        for (int i = 0; i < n; i++) {
            int a;
            cin >> a;
            x[i] = a;
            ++cnt[a];
        }
        vector<vector<int>> v(m);
        for (auto &p : cnt) {
            v[p.first % m].push_back(p.second);
        }

        int ans = 0;

        for (int i = 0; i <= m / 2; i++) {
            dump(i);
            if (i == 0 || i == m - i) {
                int add = accumulate(v[i].begin(), v[i].end(), 0) / 2;
                dump(add);
                ans += add;
            } else {
                auto &p = v[i], &q = v[m - i];
                int sp = accumulate(all(p), 0);
                int sq = accumulate(all(q), 0);
                auto &many = sp > sq ? p : q;
                int diff = abs(sp - sq);
                for (auto &x : many) {
                    while (diff >= 1 && x >= 2) {
                        int add = 1;
                        diff -= 2;
                        x -= 2;
                        dump(add);
                        ans += add;
                    }
                }

                int rem_p = 0, rem_q = 0;
                for (auto &x : p) {
                    rem_p += x;
                }
                for (auto &x : q) {
                    rem_q += x;
                }
                int add = min(rem_p, rem_q);
                dump(add);
                ans += add;
            }
        }

        //for (auto &sz : v) {
        //    for (int x : sz) {
        //        ans += x / 2;
        //    }
        //}
            cout << ans << endl;
    }
}

Measured memory_bytes: 10752
n=int(input())
s1=input()
s2=input()
p=1000000007

if s1[0]==s2[0]:
	flag=0
	i=1
	ans=3
else:
	flag=1
	i=2
	ans=6	
while i<n:
	if s1[i]==s2[i]:
		if flag==0:
			ans=((ans%p)*2)%p
		else:
			ans = ans%p
		flag=0
		i+=1	
	else:	
		if flag==0:
			ans=((ans%p)*2)%p
		else:
			ans=((ans%p)*3)%p
		flag=1
		i+=2	
print(ans)		

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int m=s.size();
  int n=t.size();
  vector<vector<int>> lcs(m+1,vector<int>(n+1));
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(s[i]==t[j]){
        lcs[i+1][j+1]=lcs[i][j]+1;
      }
      else{
        lcs[i+1][j+1]=max(lcs[i+1][j],lcs[i][j+1]);
      }
    }
  }
  string u="";
  while(m&&n){
    if(lcs[m][n]==lcs[m-1][n]){
      m--;
    }
    else if(lcs[m][n]==lcs[m][n-1]){
      n--;
    }
    else{
      u=s[m-1]+u;
      m--,n--;
    }
  }
  cout << u << endl;
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

vector<int> kmp_table(string t){
  vector<int> res = vector<int>(t.size(), 0);
  int j = 0;
  for(int i = 1; i < t.size(); i++){
    if(t[i] == t[j]){
      j++;
    }else{
      j = 0;
    }
    res[i] = j;
  }
  return res;
}

// s: text, t: pattern
vector<int> kmp_search(string s, string t){
  vector<int> res;
  vector<int> shift = kmp_table(t);

  // i: text index, p: pattern index
  int i = 0, p = 0;
  while(i < s.size() && p < t.size()){
    if(s[i] == t[p]){
      i++;
      p++;
    }else if(p == 0){
      i++;
    }else{
      p = shift[p - 1];
    }
    if(p == t.size()){
      res.push_back(i - p);
      p = shift[p - 1];
    }
  }

  return res;
}

// s: text, t: pattern
vector<int> bm_search(string s, string t){
  vector<int> res;
  unordered_map<char, int> mp;
  for(int i = 0; i < t.size(); i++){
    mp[t[i]] = t.size() - 1 - i;
  }
  // i: text index, p: pattern index
  int i = t.size() - 1, p = t.size() - 1;
  while(i < s.size() && p < t.size()){
    if(s[i] == t[p]){
      i--;
      p--;
    }else{
      if(mp.find(s[i]) == mp.end()){
        i += t.size();
      }else{
        if(p >= t.size() - 1 - mp[s[i]])i += mp[s[i]];
        else i += t.size() - p + 1;
      }
      p = t.size() - 1;
    }
    if(p < 0){
      res.push_back(i + 1);
      i += t.size() + 1;
      p = t.size() - 1;
    }
  }

  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string t, p;
  cin >> t >> p;
  auto res = bm_search(t, p);
  rep(i, sz(res))cout << res[i] << endl;
	return 0;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long
#define fi first
#define se second
#define ii  pair<int, int>
#define vi  vector <int>
#define vii vector <pair <int, int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 0.0000000001
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")


double a, b, x;
double temp;
double pi_2;



int main(){

   // freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();

    cin >> a >> b >> x;
    double to_v = a * a * b;
    pi_2 = 3.1415926535 / 2;
    if(x >= to_v / 2) {
        to_v = to_v - x;
        to_v *= 2;  
        to_v /= (a * a);
        cout << setprecision(10) << atan(to_v / a) * 90 / pi_2 << endl;
    }
    else {
        to_v = x;
        to_v *= 2;
        to_v /= (a * b);
        cout << setprecision(10) << (pi_2 - atan(to_v / b)) * 90/ pi_2 << endl;   
    }

    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int h, a; cin >> h >> a;
  cout << (h - 1) / a + 1;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	int rem = n % 1000;
	if (rem) {
		if (rem > 500)
			cout << (n / 1000) * 1000 + 1000 - n;
		else
			cout << 1000 - rem;
	} else {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 3596
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, m = map(int, input().split())
    ball, can = [1]*n, [False]*n
    can[0] = True
    for _ in range(m):
        x, y = map(int, input().split())
        if can[x-1] == True:
            can[y-1] = True
        ball[x-1] -= 1
        ball[y-1] += 1
        if ball[x-1] == 0:
            can[x-1] = False
    print(can.count(True))
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 11548
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define LL long long
#define mod 1000000007
#define G() Cr=getchar()
int Xr;char Cr;
inline int rd(){   //读入优化
    Xr=0,G();
    while(Cr<'0'||Cr>'9')G();
    while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0',G();
    return Xr;
}
int n;
int ans;
int main(){
    n=rd();
    ans+=n/500*1000;
    n%=500;
    ans+=n/5*5;
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    double n,m;

    cin >> n >> m;

    cout << ceil((n + m) / 2) << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N,M; cin>>N>>M;
    vector<pair<long long int,long long int>> A(N);
    long long int a=0,b=0;
    for(long long int i=0;i<N;i++){
        cin>>a>>b;
        A[i]=pair<long long int,long long int>(a,b);
    }
    sort(A.begin(),A.end());
    long long int ans=0;
    for(long long int i=0;i<N;i++){
        ans=ans+A[i].first*min(M,A[i].second);
        M=M-A[i].second;
        if(M<=0)break;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, cnt[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    FOR(i,1,k) {
        int x, p;
        cin >> x;
        while (x--) {
            cin >> p;
            cnt[p]++;
        }
    }
    int res = 0;
    FOR(i,1,n) res += cnt[i] == 0;
    cout << res;
    return 0;
}


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

int INF = 1e9;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> grid(h, vector<bool>(w, true));
    char x;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> x;
            if (x == '#') grid[i][j] = false;
        }
    }
    vector<vector<int>> dp(h, vector<int>(w, INF));
    if (grid[0][0]) dp[0][0] = 0;
    else dp[0][0] = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i != h - 1)
            {
                if (grid[i][j] && !grid[i + 1][j]) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + 1);
                else dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            }
            if (j != w - 1)
            {
                if (grid[i][j] && !grid[i][j + 1]) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + 1);
                else dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
struct Edge{
    int x,y;
    int c;
    Edge(){}
    Edge(int x,int y,int c):x(x),y(y),c(c){}
};
int a[305][305];
int d[305][305];
Edge e[90005];
int p[305];

int min(int a,int b){ return a>b?b:a; }

int find(int u){
    if(p[u]==u) return u;
    else return p[u] = find(p[u]);
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){ 
            scanf("%d",&a[i][j]);
            d[i][j] = a[i][j];
        }
    }
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ok = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(a[i][j]!=d[i][j]) ok = 0;
        }
    }
    if(!ok) printf("-1\n");
    else{
        int size = 0;
        for(int i = 1; i <= n; i++){
            p[i] = i;
            for(int j = i+1; j <= n; j++) e[++size] = Edge(i,j,a[i][j]);
        }
        std::sort(e+1,e+1+size,[&](Edge u,Edge v){ return u.c<v.c; });
        long long sum = 0;
        for(int i = 1; i <= size; i++){
            int x = e[i].x, y = e[i].y, w = e[i].c;
            int find = 0;
            for(int j = 1; j <= n; j++){
                if(j!=x && j!=y && d[x][j]+d[j][y]==w) find = 1;
            }
            if(!find){ 
                //printf("x = %d, y = %d: %d\n",x,y,w);
                sum += (long long)w;
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf=1e9+7;

int main(){
    int n,k;cin>>n>>k;
    vin h(n);
    rep(i,n)cin>>h[i];
    sort(all(h));
    int min=inf;
    rep(i,n-k+1){
        if(h[i+k-1]-h[i]<min)min=h[i+k-1]-h[i];
    }
    cout<<min<<endl;
}

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

int min8(int x) {
  return ((x * 25) / 2) + (x % 2 != 0 ? 1 : 0);
}

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

  int minA = min8(A);
  int maxA = min8(A+1); // [minA, maxA)
  int minB = 10 * B;
  int maxB = 10 * (B + 1);

  if (minA < minB) {
    cout << (minB < maxA ? minB : -1) << endl;
  }
  else {
    cout << (minA < maxB ? minA : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N; cin >> N;
    if (N[0] == '9' || N[1] == '9') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int n;
int main() {
  //  freopen("test.txt","r",stdin);
    int n,k;
    int a[maxn];
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    sort(a,a+n);
    ll ans=0;
    for(int i=0;i<n-k;i++) {
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
fn read_string() -> String {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);
    input.trim().to_string()
}

fn main () {
    let s = read_string();
    let t = read_string();
    let mut map1: Vec<usize> = vec![0; 26];
    let mut map2: Vec<usize> = vec![0; 26];
    for (i, j) in s.chars().zip(t.chars()) {
        let idx1 = (i as usize) - ('a' as usize);
        let idx2 = (j as usize) - ('a' as usize);
        if map1[idx1] == 0 && map2[idx2] == 0 {
            map1[idx1] = j as usize;
            map2[idx2] = i as usize;
        } else if map1[idx1] != j as usize || map2[idx2] != i as usize {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

int main(){
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  int H,W;
  int sump=0;
  cin>>H>>W;
  H--;W--;
  string S;
  char maze[W+1][H+1];
  int D[W+1][H+1];
  for(int i=0;i<=H;i++){
    for(int j=0;j<=W;j++){
      D[j][i]=3000;
    }
  }

  for(int i=0;i<=H;i++){
    cin>>S;
    for(int j=0;j<=W;j++){
      maze[j][i]=S.at(j);
      if(maze[j][i]=='.') sump++;
    }
  }
  
  D[0][0]=0;
  queue<P>que;
  que.push(P(0,0));
  while(que.size()){
    P p=que.front();que.pop();
    if(p.first==W && p.second==H) break;
    //cout<<p.first<<" "<<p.second<<endl;
    for(int i=0;i<4;i++){
      int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx && nx<=W && 0<=ny && ny<=H && maze[nx][ny]=='.' && D[nx][ny]==3000){
        que.push(P(nx,ny));
        D[nx][ny]=D[p.first][p.second]+1;
      }
    }
  }
  if(D[W][H]==3000){
    cout<<-1<<endl;
    return 0;
  }
  cout<<sump-D[W][H]-1<<endl;
  
  return 0;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll a, b, x, ans;
	cin >> a >> b >> x;
	if(a == 0) ans = b/x + 1;
	else ans = b/x -(a-1)/x;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
using namespace std;
int a,b,c,d,e;
int main()
{
	cin>>a>>b>>c>>d>>e;
	long long ans,tmp;
	ans=0ll+b+a/2*2+d/2*2+e/2*2;
	if(a&&d&&e){
		a--;d--;e--;tmp=3;
		tmp+=0ll+b+a/2*2+d/2*2+e/2*2;
		if(ans<tmp) ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,temp;
    cin>>a;
    temp=a+a*a+a*a*a;
    cout<<temp<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
using namespace std;

#define MAX 10000

int main() {
    int N;

    cin >> N;

    string state0;

    int curr_pos = 0;
    cout << curr_pos << endl;
    cout << flush;
    cin >> state0;

    if (state0 == "Vacant") {
        return 0;
    }

    int left = 0;
    int right = N - 1;

    while (left <= right) {
        int mid = (left + right) / 2;

        cout << mid << endl;
        cout << flush;

        string state;
        cin >> state;

        if (state == "Vacant") {
            return 0;
        }

        if (mid % 2 == 0) {
            if (state == state0) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        } else {
            if (state != state0) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
    }
}


Measured memory_bytes: 852
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim a As Integer = NextInt()
        Dim b As Integer = NextInt()
        Dim c As Integer = NextInt()
        Dim ans As Integer
        Dim dic As New List(Of Integer())
        Dim flg As Boolean

        Do
            Dim abc As Integer() = New Integer() {a, b, c}
            Array.Sort(abc)
            If Contains(dic, abc) Then ans = -1
            For Each v As Integer In abc
                If v Mod 2 <> 0 Then flg = True
            Next
            If flg OrElse ans < 0 Then Exit Do
            ans += 1
            dic.Add(abc)
            Dim x As Integer = b \ 2 + c \ 2
            Dim y As Integer = c \ 2 + a \ 2
            Dim z As Integer = a \ 2 + b \ 2
            a = x
            b = y
            c = z
        Loop
        WriteLine(ans)
    End Sub

    Function Contains(dic As IList(Of Integer()), abc As Integer()) As Boolean
        For Each dic_i As Integer() In dic
            Dim flg As Boolean = False
            Dim j As Integer = 0
            For Each dic_ij As Integer In dic_i
                If dic_ij <> abc(j) Then
                    flg = True
                End If
                j += 1
            Next
            If Not flg Then Return True
        Next
        Return False
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


Measured memory_bytes: 20432
#include <iostream>
using namespace std;
string s;
bool isSs (int len) {
  int l = len / 2;
  for (int i = 0; i < l; i++) {
    if(s[i] != s[i + l]) {
      return false;
    }
  }
  return true;
}
int main(void) {
  cin >> s;
  for (int i = 2; i < s.length(); i += 2) {
    if (isSs(s.length() - i)) {
      cout << (s.length() - i) << endl;
      return 0;
    }
  }
  return 0;
}

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

int main(){
  string s,t;
  cin >>s>>t;
  int l=s.size();
  s += s;
  for(int z=0;z<l;z++){
    for(int i=0;i<l;i++){
      if(s[z+i] != t[i]){
        break;
      }
      if(i == l-1){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector <int> digits;
  int d = N;
  if (d == 0) {
    cout << 0 << endl;
    exit(0);
  }
  while(d != 1) {
    if(abs(d) % 2 == 1) {
      d -= 1;
      digits.push_back(1);
    } else {
      digits.push_back(0);
    }
    d /= -2;
  }
  digits.push_back(1);
  reverse(digits.begin(), digits.end());
  for(int di: digits) {
    cout << di; 
  }
  cout << endl;
  return 0;
}

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

int mx[2] = {1,0};
int my[4] = {0,1};
char mas[8][8];
bool used[8][8] = {0};
int H,W;

int dfs(int y,int x)
{
  int rec = 0;
  int ny,nx;
  if(y == H - 1 && x == W - 1){
    Rep(i,H){
      Rep(j,W){
	if(mas[i][j] == '#' && used[i][j] == false)return 0;
      }
    } 
    return 1;
  }
  Rep(i,2){
    ny = y + my[i];
    nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && nx < W && ny < H && mas[ny][nx] == '#'){
      used[ny][nx] = true;
      rec += dfs(ny,nx);
      used[ny][nx] = false;
    }
  }
  return rec;
}

int main()
{

  cin >> H >> W;
  Rep(i,H){
    Rep(j,W){
      cin >> mas[i][j];
    }
  }
  used[0][0] = true;
  int sum = dfs(0,0);
  if(sum)cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int bx=y1-y2;
    int by=x2-x1;
    int x3=x2+bx;
    int y3=y2+by;
    int x4=x1+bx;
    int y4=y1+by;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}


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

int main(void){
  char a,b;
  cin>>a>>b;
  if(a=='H'&&b=='H')
    cout<<'H'<<endl;
  else if(a=='D'&&b=='D')
    cout<<'H'<<endl;
  else
    cout<<'D'<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ANovember30 {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a,b,c,d;
        in >> a >> b >> c >> d;
        if(a!=c){
            out << 1 << endl;
        }else{
            out << 0 << endl;
        }
	}
};


int main() {
	ANovember30 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 200010
int a[Maxn];
int b[Maxn],l,r;
int main(){
	int ans=1;
	scanf("%d",&n);
	l=r=n;
	scanf("%d",&a[1]);
	b[n]=a[1];
	for(register int i=2;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]<=b[l]){
			l--;
			b[l]=a[i];
			ans++;
			continue;
		}
		int L=l,R=r;
		while(L<R){
			int mid=(L+R)>>1;
			if(b[mid+1]<a[i])L=mid+1;
			else R=mid;
		}
		b[L]=a[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, m = map(int, input().split())
x = list(map(int, input().split()))
if n >= m:
    print(0)
    sys.exit()

x2 = sorted(x)
y = []
for i in range(1, m):
    heapq.heappush(y, (-(abs(x2[i] - x2[i - 1]))))
for i in range(n - 1):
    heapq.heappop(y)
print(-(sum(y)))


Measured memory_bytes: 16320
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        scanner.nextLine();

        WeightedUnionFindTree uft = new WeightedUnionFindTree(N);
        for (int i = 0; i < Q; i++) {
            int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            if (q[0] == 0) {
                uft.merge(q[1], q[2]);
            } else {
                System.out.println(uft.same(q[1], q[2]) ? 1: 0);
            }
        }
    }

}

class WeightedUnionFindTree {
    int size;
    int[] par;
    int[] rank;
    int[] weight;

    public WeightedUnionFindTree(int size) {
        this.size = size;
        par = new int[size];
        for (int i = 0; i < size; i++) {
            par[i] = i;
        }
        rank = new int[size];
        Arrays.fill(rank, 1);
        weight= new int[size];
    }

    private int root(int x) {
        if (x == par[x]) {
            return x;
        }
        int root = root(par[x]);
        par[x] = root;
        // cSum
        weight[x] += weight[par[x]];
        return root;
    }

    private int weight(int x) {
        root(x);
        return weight[x];
    }

    public int diff(int x, int y) {
        return weight(y) - weight(x);
    }

    public boolean same(int x, int y) {
        return root(x) == root(y);
    }

    public void merge(int x, int y) {
        merge(x, y, 1);
    }

    public void merge(int x, int y, int w) {
        w += weight[x];
        w -= weight[y];

        int xr = root(x);
        int yr = root(y);

        if (xr == yr) {
            return;
        }

        if (rank[xr] < rank[yr]) {
            par[xr] = yr;
            weight[y] = -w;
        } else {
            par[yr] = xr;
            if (rank[xr] == rank[yr]) {
                rank[xr]++;
            }
            weight[x] = w;
        }
    }

}



Measured memory_bytes: 166732
#include<bits/stdc++.h>
#define int long long
using namespace std;
int Size = 1e14;

int check(int a,int b,int c){

      if(a+b>c) return 1;
      else return 0;
}

int32_t main()
{

    int x,k,d;
    cin>>x>>k>>d;

    x = abs(x);

    int can  = x/d;

    //cout<<can<<endl;

    int left = 0;
    int update = 0;

    if(can<=k){

    left=k-can;
    update = x%d;

    if(left%2!=0 and left!=0){
        int a = abs(update-d);
        int b = abs(update+d);

        int c = min(a,b);

        update=c;
    }


    }
    else{
        update = x - (d*k);
    }

    cout<<update<<endl;


	return 0;
}


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

int main(){
 	int N,K;
  	cin >> N >> K;
  	string S;
  	cin >> S;
  	
  	//「1の個数」と「0の個数」を交互に記録していく
  	vector<int> nums;
  	if(S[0]=='0')nums.push_back(0);//先頭が0だったら
  	for(int i = 0; i < S.size();){
    	int j = i;
      	while(j < S.size()&&S[j]==S[i])++j;
      	nums.push_back(j-i);
      	i = j;
    } 
  	if(S.back()=='0')nums.push_back(0);
  
  	//累積和
  	vector<int> sums((int)nums.size()+1,0);
  	for(int i = 0; i < nums.size(); ++i) sums[i+1]=sums[i]+nums[i];
  	
  	int res = 0;
  	for(int left = 0; left<sums.size();left +=2){
    	int right = left + K*2+1;
      	if(right >= sums.size())right=(int)sums.size()-1;
      	res = max(res,sums[right]-sums[left]);
    }
  	cout << res << endl;
  
}

Measured memory_bytes: 1272
#21 C - Dice and Coin
import math
N,K = map(int,input().split())

ans = 0
for i in range(1,N+1):
    if K//i != 0:
        a = math.log2(K/i)
        if a.is_integer():
            x = int(a)
        else:
            x = int(a) + 1
        ans += (1/N)*(1/2)**x
    else:
        ans += (1/N)
print(ans)

Measured memory_bytes: 9448
#include <iostream>
#include <string>
#include <vector>

using namespace std;

    int main(){

        string s ;

		getline(cin,s);
		
		long long sum {0};
		
		for(auto e : s){
			sum += e - '0';
		}
		
		if(sum%9 == 0) cout<<"Yes";
		else cout<<"No";
		
		return 0 ;
    }

Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

const int MAX_N = 1e5 + 10;
int N;
int128_t A[MAX_N], B[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;
    rep (i, 1, N + 1) {
        std::cin >> A[i];
    }
    rep (i, 1, N) {
        std::cin >> B[i];
    }

    int128_t ret = 0;
    rep (i, 1, N) {
        if (B[i] <= A[i]) {
            A[i] -= B[i];
            ret += B[i];
            B[i] = 0;
        } else {
            ret += A[i];
            B[i] -= A[i];
            A[i] = 0;

            if (B[i] <= A[i+1]) {
                A[i+1] -= B[i];
                ret += B[i];
                B[i] = 0;
            } else {
                ret += A[i+1];
                B[i] -= A[i+1];
                A[i+1] = 0;
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var Lmax = 0L;
            var Rmin = N + 1L;
            for(var i=0;i<M;++i)
            {
                var LR = Sarray();
                Lmax = Max(Lmax, LR[0]);
                Rmin = Min(Rmin, LR[1]);
            }
            WriteLine(Max(0, Rmin - Lmax + 1));
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 17456