akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
S = (stdin.readline().rstrip())
K = int(stdin.readline().rstrip())
ans = 0
N=len(S)
cnt = 1
G = S+"@"
for i in range(0,N):
    if G[i] == G[i+1]:
        cnt += 1
    else:
        if cnt != 1:
            #print(cnt)
            ans += (cnt//2)
            cnt = 1
for_eq = 1
rev_eq = 1
revS = S[::-1]
for j in range(0,N-1):
    if S[j] == S[j+1]:
        for_eq += 1
    else:
        break
for k in range(0,N-1):
    if revS[k] == revS[k+1]:
        rev_eq += 1
    else:
        break
#print(ans)
ans = ans*K
#print(rev_eq,for_eq)
if S[0] == S[-1]:
    ans+=((K-1)*((rev_eq+for_eq)//2))
    ans-=((rev_eq//2)*(K-1))
    ans-=((for_eq//2)*(K-1))
    """
    if (rev_eq % 2 != 0) and (for_eq % 2 != 0):
        ans += ((K+1)//2)
    """
if len(set(S))==1:
    ans = (len(S)*K)//2
print(ans)

Measured memory_bytes: 3064
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


inline int64_t func(int64_t a, int64_t b)
{
	if (a > b) {
		std::swap(a, b);
	}
	if (a == 0) {
		return -b;
	}
	return (int64_t)(b / a) * 2 * (int64_t)(a)+func(a, b%a);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	int64_t N, X;
	in >> N >> X;
	out << func(N - X, X)+N << endl;

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll x,y; cin>>x>>y;
	ll arr1[7] = {1,3,5,7,8,10,12};
	ll arr2[4] = {4,6,9,11};
	ll arr3 = 2;
	ll t1=-1,t2=-1;
	if(x == y) cout << "Yes" << endl;
	else if(x == arr3 && y == arr3) cout << "Yes" << endl; 
	else
	{
		for(ll i = 0; i < 7; i++)
		{
			if(x == arr1[i])
			{
				t1 = 1;
			}
			if(y == arr1[i])
			{
				t2 = 1;
			}
		}
		if(t1 == 1 && t2 == 1)
		{
			cout << "Yes" << endl;
			return 0; 
		}
		for(ll i = 0; i < 4; i++)
		{
			if(x == arr2[i])
			{
				t1 = 2;
			}
			if(y == arr2[i])
			{
				t2 = 2;
			}
		}
		if(t1 == 2 && t2 == 2)
		{
			cout << "Yes" << endl;
			return 0; 
		}
		cout << "No" << endl;
	}
 	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  vector<ll>b(3);
  rep(i,0,n)b[a[i]-1]++;
  auto dp=make_v(n+1,n+1,n+1,ld(0));
  rep(o,0,b[2]+1)rep(j,0,b[1]+b[2]+1)rep(i,0,n+1){
  //rep(o,0,b[2]+1)rrep(i,b[0]+1,0)rrep(j,b[1]+1,0){
    if(i+j+o>n)continue;
    if(i>=1)dp[i][j][o]+=dp[i-1][j][o]*i;
    if(j>=1&&i<n)dp[i][j][o]+=dp[i+1][j-1][o]*j;
    if(o>=1&&j<b[1]+b[2])dp[i][j][o]+=dp[i][j+1][o-1]*o;
    if(i!=0||j!=0||o!=0)dp[i][j][o]/=i+j+o;
    if(i!=0||j!=0||o!=0)dp[i][j][o]+=ld(n)/(i+j+o);
    //cout<<dp[i][j][o] spa i spa j spa o<<endl;
  }
  cout lfs dp[b[0]][b[1]][b[2]]<<endl;
  return 0;
}

Measured memory_bytes: 431360
#include <stdio.h>
int main() {
    int N,i,v,j,k;
    scanf("%d",&N);
    int A[N]; 
    for(i=0; i<N; i++){
        scanf("%d",&A[i]);
    }
    for(i=0; i<N; i++){
        v = A[i];
        j = i-1;
        while( j>= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        for(k=0; k<N; k++){
            printf("%d",A[k]);
            if(k<N-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 604
import heapq
t = 1
# t = input()
# t = int(t)
def max(a,b):
	if a > b:
		return a
	return b
while t > 0:
	t -= 1
	# s = input()
	# ans = ""
	# if s == "Sunny":
	# 	ans = "Cloudy"
	# elif s == "Cloudy":
	# 	ans = "Rainy"
	# else:
	# 	ans = "Sunny"
	# print(ans)
	n,m = map(int,input().split())	
	v = list(map(int,input().strip().split()))[0:n]
	for i in range(n):
		v[i] = -v[i]
	heapq.heapify(v)
	for i in range(m):
		x = heapq.heappop(v)
		x = -x
		x = x//2
		heapq.heappush(v,-x)
	ans = 0
	for i in range(n):
		ans += (-heapq.heappop(v))
	print(ans)
	# # m = {}
	# l = []
	# for i in range(n):
	# 	l.append(0)
	# # ans = 0
	# j = 1
	# for i in v:
	# 	l[i-1] = j
	# 	j += 1
	# # print(ans)
	# for i in l:
	# 	print(i,end=" ")


Measured memory_bytes: 86476
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ms(x,a) memset(x,a,sizeof x)
#define se second
#define fi first
#define lowbit(x) (x&-x)
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define coint const int
typedef long long ll;
using namespace std;
template<class T>inline T rd(){
	static char ch;static bool neg;static T x;
	for(neg=0,ch=0; ch>'9'||ch<'0'; neg|=(ch=='-'),ch=getchar());
	for(x=0; ch<='9'&&ch>='0'; x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar());
	return neg?-x:x;
}
template<class T>inline T Max(const T &x, const T &y){
	return x>y?x:y;
}
template<class T>inline T Min(const T &x, const T &y){
	return x<y?x:y;
}
coint N=1e5+5;


int main(){
	ll n=rd<ll>();
	printf("%lld\n",n*(n-1)/2);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct Data {
    int w, s, v;
    Data() {}
    Data(int w, int s, int v) : w(w), s(s), v(v) {}
};

ll dp[1010][20010];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<Data> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i].w >> a[i].s >> a[i].v;
    }
    sort(ALL(a),
         [](const Data &x, const Data &y) { return (x.s + x.w < y.s + y.w); });
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 20010; j++) {
            if(j <= a[i].s) {
                chmax(dp[i + 1][j + a[i].w], dp[i][j] + a[i].v);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    for(int j = 0; j < 20010; j++) {
        chmax(ans, dp[N][j]);
    }
    cout << ans << endl;
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	while (t--) {
		int n;
		cin >> n;
		int a = 0;
		int flag = -1;
		for (int i = 1; i <= 10000000; i++) {
			a = a * 10 + 7;
			a = a % n;
			if (a == 0) {
				flag = i; break;
			}
		}
		cout << flag;
	}
	return 0;
}

Measured memory_bytes: 3628
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  ll h,n;cin>>h>>n;
  ll sum=0;
  int a;
  REP(i,n) {
    cin>>a;
    sum+=a;
  }
  if(sum>=h) {
    p("Yes");
  } else {
    p("No");
  }
  return 0;
}



Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))+[0]
import copy
L1=copy.deepcopy(A)

for i in range(K):
    a=[0 for i in range(N+1)]
    for j in range(N):
        a[max(0,j-L1[j])]+=1
        a[min(N,j+L1[j]+1)]-=1
        #print(a[:N])
    L2=[a[0]]
    for j in range(1,N):
        L2.append(L2[-1]+a[j])
    #print(L2)
    if L2==L1[:N]:
        print(*L2)
        exit()
    else:
        L1=L2+[0]
print(*L2)
    


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

int main() {
  int m,f,r;
  while(cin>>m&&cin>>f&&cin>>r&&(m!=-1||f!=-1||r!=-1)){
    if(m==-1||f==-1){cout<<'F'<<endl;}
    else if(m+f>=80){cout<<'A'<<endl;}
    else if(m+f>=65&&m+f<80){cout<<'B'<<endl;}
    else if(m+f>=50&&m+f<65){cout<<'C'<<endl;}
    else if(m+f>=30&&m+f<50&&r>=50){cout<<'C'<<endl;}
    else if(m+f>=30&&m+f<50){cout<<'D'<<endl;}
    else if(m+f<30){cout<<'F'<<endl;}
  }
  return 0;
}


Measured memory_bytes: 3092
<?php
//$N = (int)trim(fgets(STDIN));
list($x,$y) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$S = trim(fgets(STDIN));
//$x = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($x * 2 > $y) {
  printf("No\n");
  exit;
}

for($i=0;$i<=100;$i++) {
  for($j=0;$j<=100;$j++) {
    if ($j+$i>$x) break;
    if (($i*2 + $j*4)==$y) {
      printf("Yes\n");
      exit;
    }
  }
}
printf("No\n");


Measured memory_bytes: 16204
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N, M = Scanner.map_int()
    ans = 0
    X = Scanner.int_list_list(N)
    for k in range(8):
        D = [0] * 3
        for d in range(3):
            if (k >> d) & 1:
                D[d] = 1
            else:
                D[d] = -1
        X.sort(key=lambda c: D[0] * c[0] + D[1] * c[1] + D[2] * c[2])
        x, y, z = 0, 0, 0
        for i in range(M):
            x += X[i][0]
            y += X[i][1]
            z += X[i][2]
        ans = max(ans, abs(x)+abs(y)+abs(z))
    print(ans)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 40044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();

            var i = 0;
            Console.WriteLine(new string(s.Where(c => {
                i++;
                if (i % 2 != 0) return true;
                else return false;
            }) .ToArray()));
        }
    }

    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 int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            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 long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            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;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11380
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int w = sc.nextInt();
        int[] weight = new int[n];
        long[] value = new long[n];
        for(int i = 0;i < n;i++) {
            weight[i] = sc.nextInt();
            value[i] = sc.nextLong();
        }
        long[][] memo = new long[n][w + 1];
        for(int i = 0;i < n;i++) {
            for(int j = 0;j < w + 1;j++) memo[i][j] = -1;
        }
        System.out.println(dp(n, w, weight, value, 0, 0, memo));
    }

    private static long dp(int n, int w, int[] weight, long[] value, int i, int u, long[][] memo) {
        if(u > w) return Long.MIN_VALUE;
        else if(memo[i][u] != -1) return memo[i][u];
        else if(i == n - 1) {
            if(u + weight[i] <= w) {
                memo[i][u] = value[i];
                return value[i];
            }
            else {
                memo[i][u] = 0;
                return 0;
            }
        }
        else {
            int nextIdx = i + 1;
            long maxValue = Long.MIN_VALUE;
            long tmpValue1 = Long.MIN_VALUE;
            long tmpValue2 = Long.MIN_VALUE;
            
            tmpValue1 = dp(n, w, weight, value, nextIdx, u, memo);
            tmpValue2 = dp(n, w, weight, value, nextIdx, u + weight[i], memo) + value[i];
            maxValue = Long.max(tmpValue1, tmpValue2);
            memo[i][u] = maxValue;
            
            return maxValue;
        }
    }
}


Measured memory_bytes: 125524
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


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

	int n;
	ll d;
	cin >> n >> d;
	int res = 0;
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		ll sqr_distance = x * x + y * y;
		if (sqr_distance <= d * d)
			res++;
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

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

vector<int> input(int N) {
  vector<int> res(N);
  for (int i = 0; i < N; i++)scanf("%d", &res[i]);
  return res;
}

int main(){
    int N, K;
    scanf("%d%d", &N, &K);
    vector<int> h(N);
    h = input(N);
    vector<int> dp(N, 0);
    for(int i = 0; i < min(N, K); i++)dp[i] = abs(h[i] - h[0]);
    for(int i = K; i < N; i++){
        dp[i] = dp[i - K] + abs(h[i] - h[i - K]);
        for(int j = K; j > 0; j--)dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
    printf("%d\n", dp[N - 1]);
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>
#include<iomanip>

using namespace std;

int main() {
    int N;
    cin >> N;
    set<string> S;
    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        S.insert(str);
    }
    cout << S.size() << endl;



}

Measured memory_bytes: 19220
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    double n;
    cin >> n; 
    ld ans=n*6.2831;
    out(ans);
}

Measured memory_bytes: 3828
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1, 0);
    rep(i, m) {
        int num;
        cin >> num;

        a[num] = 1;
    }
    vector<mint> dp(n + 2, 0);
    dp[n] = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] == 1) continue;
        dp[i] = dp[i + 1] + dp[i + 2];
    }

    cout << dp[0] << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 4536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    const int kNumSample = 10;
    const int kNumPrint = 3;

    vector<int> list;
    list.resize(kNumSample, 0);

    for(int i = 0; i < kNumSample; i++)
    {
        cin >> list[i];
    }

    sort(list.begin(), list.end(), [](const int &a, const int &b){ return a > b; } );
    for(int i = 0; i < kNumPrint; i++)
    {
        cout << list[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3108
import java.util.*;

public class Main {

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

        String x = sc.next();

        if(x.equals(x.toUpperCase())){
            System.out.println("A");
        } else {
            System.out.println("a");
        }

    }

}

Measured memory_bytes: 35748
def ceil(a,b):
    return -((-a)//b)
def floor(a,b):
    return a//b
K=int(input())
A=[int(i) for i in input().split()]
L=[0 for i in range(K+1)]
R=[0 for i in range(K+1)]
L[K]=2
R[K]=2
for i in range(1,K+1)[::-1]:
    L[i-1]=ceil(L[i],A[i-1])*A[i-1]
    R[i-1]=floor(R[i],A[i-1])*A[i-1]+A[i-1]-1
if L[0]<=R[0]:
    print(L[0],R[0])
else:
    print(-1)


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<vector<int> > mat(n + 5, vector<int>(n + 5, 0));
  for (int i = 0; i < n; ++i) {
    int v = -1, k = -1, u = -1;
    fscanf(stdin, "%d %d", &v, &k);
    for (int j = 0; j < k; ++j) {
      fscanf(stdin, "%d", &u);
      mat[v][u] = 1;
    }
  }
  vector<int> visited(n + 5, 0), cost(n + 5, INF);
  queue<int> que;
  cost[1] = 0;
  que.push(1);
  while (!que.empty()) {
    int v = que.front(); que.pop();
    if (visited[v]) { continue; }
    visited[v] = 1;
    for (int u = 1; u <= n; ++u) {
      if (mat[v][u] && !visited[u]) {
        cost[u] = min(cost[u], cost[v] + 1);
        que.push(u);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    fprintf(stdout, "%d %d\n", i, visited[i] ? cost[i] : -1);
  }
  return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    int L[N];
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L, L + N);
    int num = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            for (int k = j + 1; k < N; k++) {
                if (L[j] < L[i] + L[k]) {
                    if (L[k] < L[j] + L[i]) {
                        num++;
                    }
                }
            }
        }
    }
    cout << num << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int N;
    double sum=0;
    

    //入力
    cin >> N;
    vector<double> div(N);
    rep(i, N) {
        int A;
        cin >> A;
        sum += 1.0/A;
    }
    


    cout << fixed << setprecision(20) << 1/sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
template<class T> inline void YES(T condition) { 
    if(condition) cout << "YES" << endl;
    else cout << "NO" << endl;
}
template<class T> inline void Yes(T condition) {
    if(condition) cout << "Yes" << endl;
    else cout << "No" << endl;
}
template<class T> T gcd(T a, T b) {
    if(a && b) { return gcd(min(a, b), max(a, b) % min(a, b)); }
    else { return a; }
}
template<class T> T lcm(T a, T b){
    return a / gcd(a, b) * b;
}
const int MOD = 2019;
long long qpow(long long a, long long b) {
    if (b == 0) return 1;
    long long res = 1;
    while (b) {
        if (b & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

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

    int n, k;
    cin >> n >> k;
    if (k > (n - 1) * (n - 2) / 2) {
        cout << "-1" << '\n';
        return 0;
    } 
    vector<vector<int>> edges(n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = n; j > i; j--) {
            edges[i].push_back(j);
        }
    }
    int cur = 1;
    int cnt = n * (n - 1) / 2;
    while (k) {
        while (k && (int)(edges[cur].size()) > 1) {
            edges[cur].pop_back();
            k--;
            cnt--;
        }
        if (k) cur++;
    }
    cout << cnt << '\n';
    for (int i = 1; i <= n; i++) {
        for (auto& j: edges[i]) {
            cout << i << " " << j << '\n';
        }
    }

    return 0;
}


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

int main() {
  string str;
  cin >> str;

  if (str.size() % 2 == 0) {
    for (int i = 0; i < str.size() - 1; i = i + 2) {
      if (str[i] != 'h' || str[i + 1] != 'i') {
        cout << "No" << endl;
        return 0;
      }
    }
  } else {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 


#x,y = [int(i) for i in readline().split()]

n = int(input())
xy = [[int(i) for i in readline().split()] for i in range(n)]

from math import hypot

d = [[0]*n for i in range(n)]

for i in range(n):
    for j in range(n):
        d[i][j] = hypot(xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]) 


#print(d)

from itertools import permutations

L = list(range(n))
ans = 0.0
for p in permutations(L,n):
    for i in range(n-1):
        ans += d[p[i]][p[i+1]]

from math import factorial
print(ans/factorial(n))        



    







Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1];
	return 0;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
x = list(int(i) for i in input().split())
x = sorted(x)
if m>1:
    res = x[-1]-x[0]
    dif = []
    for i in range(m-1):
        dif.append(abs(x[i+1]-x[i]))
        
    dif = sorted(dif,reverse = True)
    if n<m:
        for i in range(n-1):
            res -= dif[i]
    else:
        res = 0
else:
    res = 0
print(res)


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

fn uneven_numbers(n: u32) -> u32 {
    let mut cnt = 0;
    for mut i in 1..(n+1) {
        let mut digit = 0;
        while i != 0 {
            i = i / 10;
            digit = digit + 1;
        }
        if digit % 2 == 1 {
            cnt = cnt + 1;
        }
    }
    cnt
}

#[test]
fn test() {
    assert_eq!(uneven_numbers(11), 9);
    assert_eq!(uneven_numbers(136), 46);
//    assert_eq!(uneven_numbers(100000), 90909);
}

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

fn main() {
    let n: u32 = read();


    let ans = uneven_numbers(n);
    println!("{}", ans);
}



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

int main() {
  int n,k,q;
  cin>>n>>k>>q;
  vector<int> a(n);
  rep(i, q) {
    int x;
    cin>>x;
    x--;
    a[x]++;
  }
  rep(i, n) {
    ll tmp = k - q + a[i];
    if (tmp > 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 1024
#include<stdio.h>
main()
{
	int x,y,c;
	
	while( scanf("%d %d",&x,&y) != EOF )
	{
		if(x == 0 && y == 0) break;

		if(x > y){
			c=x;
			x=y;
			y=c;
		}

		printf("%d %d\n",x,y);

	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>

using namespace std;

typedef pair<int,int> P;
const int SIZE = 16;
char field[SIZE][SIZE];
int ans;
vector<P> v(4);

bool isInside(int h, int w){return 0<=h&&h<4&&0<=w&&w<4;}

bool input(){
  for(int i = 0; i < 4; i++)
    if(!(cin >> v[i].first >> v[i].second)) return false;
  return true;
}

void rec(char c,int pos){

  int h = pos/4;
  int w = pos%4;
  if(pos == 16){
    ans++;
    return;
  }

  if(field[h][w] != '.'){
    rec(c,pos+1);
    return;
  }
 
  for(int i = 0; i < 4; i++)
    for(int sign = 0; sign < 2; sign++){
      int s = (sign==0?1:-1);
      
      int nh = h+s*v[i].first;
      int nw = w+s*v[i].second;
      if(!isInside(nh,nw)) continue;
      if(field[h][w] != '.' || field[nh][nw] != '.') continue;
      
      field[h][w] = field[nh][nw] = c;
      rec(c+1,pos+1);
      field[h][w] = field[nh][nw] = '.';
    }
}

int main(){

  while(input()){
    memset(field,'.',sizeof(field));
    ans = 0;
    rec('A',0);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
const lines=readlines()
input()=shift!(lines)
int(x)=parse(Int,x)
intLine()=map(int,split(input()))
function inE(e)
    u,v=intLine()
    push!(e[u],v)
end
function bfs(e,f,s,t)
    q=Array{Tuple{Int,Int}}([(s,1)])
    while !isempty(q)
        v,m=shift!(q)
        u=m>2?1:m+1
        for w=e[v]
            if f[w,u]<0
                f[w,u]=f[v,m]+1
                push!(q,(w,u))
            end
        end
    end
end
function main()
    n,m=intLine()
    e=Array{Int,1}[[]for i=1:n]
    for i=1:m;inE(e);end
    s,t=intLine()
    f=ones(Int,(n,3))*-3
    f[s,1]=0
    bfs(e,f,s,t)
    show(f[t,1]÷3)
end
main()

Measured memory_bytes: 165068
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
string s;
map<char,int> mp;

int main(){
	mp['R']=0;
	mp['G']=1;
	mp['B']=2;
	cin>>n>>s;
	ll res=0;
	for(int i=1;i<n-1;i++){
		int a[3]={0,0,0},b[3]={0,0,0};
		for(int j=0;j<i;j++) a[mp[s[j]]]++;
		for(int j=i+1;j<n;j++) b[mp[s[j]]]++;
		for(int j=0;j<3;j++) for(int k=0;k<3;k++){
			if(j!=k&&j!=mp[s[i]]&&k!=mp[s[i]]) res+=a[j]*b[k];
		}
		for(int j=1;i-j>=0&&i+j<n;j++){
			char A=s[i-j],B=s[i],C=s[i+j];
			if(A!=B&&B!=C&&C!=A) res--;
		}
	}
	cout<<res<<endl;
}

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

int main() {
	// your code goes here
	int a[4];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int clock=0;
	for(int i=0;i<3;i++){
		if(a[0]==a[i]) clock++;
	}
	if(clock==2)
	cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int topNum = sc.nextInt();
        int pointNum = sc.nextInt();
        List<Integer> pointList = scanIntList(sc,pointNum);

        System.out.println(execute(topNum,pointNum,pointList));

    }

    public static long execute(int topNum, int pointNum, List<Integer> pointList) {
        pointList = pointList.stream().sorted((x, y) -> y - x).collect(Collectors.toList());

        if(topNum >= pointNum){
            return 0;
        }
        List<Integer> distanceList = new ArrayList<>();
        Long allDistance = 0L;
        for(int i = 1; i < pointList.size() ; i++){
            Integer distance = Math.abs(pointList.get(i-1) - pointList.get(i));
            distanceList.add(distance);
            allDistance += distance;
        }
        distanceList = distanceList.stream().sorted((x, y) -> y - x).collect(Collectors.toList());

        Long notMove = 0L;

        for(int i=0; i< topNum -1;i++){
            notMove += distanceList.get(i);
        }

        return allDistance - notMove;
    }

    public static List<Integer> scanIntList(Scanner sc,int num){
        List<Integer> scanList = new ArrayList<>();
        for(int i = 0; i < num; i++){
            scanList.add(sc.nextInt());
        }
        return scanList;
    }

}


Measured memory_bytes: 60760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC165
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            long x = long.Parse(Console.ReadLine());
            long sum = 100;
            long ans = 0;
            bool flg = true;
            while(flg)
            {
                sum += sum / 100;
                if (sum >= x)
                    flg = false;
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27536
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int dishNum = sc.nextInt();
		
		ArrayList<Integer> eatOrder = new ArrayList<>();
		for(int i = 0; i < dishNum; i++) {
			eatOrder.add(sc.nextInt());
		}
		
		ArrayList<Integer> firstSatisfaction = new ArrayList<>();
		for(int i = 0; i < dishNum; i++) {
			firstSatisfaction.add(sc.nextInt());
		}
		
		ArrayList<Integer> secondSatisfaction = new ArrayList<>();
		for(int i = 0; i < dishNum-1; i++) {
			secondSatisfaction.add(sc.nextInt());
		}

		int result = 0;
		for(int i = 0; i < dishNum; i++) {
			int eatNum = eatOrder.get(i);
			result += firstSatisfaction.get(eatNum-1);
			
			if(i != dishNum-1) {
				int eatNumNext = eatOrder.get(i+1);
				if(eatNum+1 == eatNumNext) {
					result += secondSatisfaction.get(eatNum-1);
				}	
			}
		}
		
		System.out.println(result);
		sc.close();
	}
}


Measured memory_bytes: 23764
t = list(input())
l = len(t)

for i in range(l):
    if t[i] == "?":
        t[i] = "D"

# s = 0

# for i in range(l):
#     if i < l-1:
#         if t[i] == "P" and t[i+1] == "D":
#             s += 1
    
#     if t[i] == "D":
#         s += 1

print("".join(t))

Measured memory_bytes: 10884
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std ;

const int N = 800 + 5;
const int inf = 1e9 + 20;
int n, m, k;
char a[N][N];

int sx, sy;
int ans = inf;
int d[N][N];
queue < pair<int, int> > q;

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

void bfs(int sx, int sy)
{
	d[sx][sy] = 0;
	q.push({sx, sy});
	while (q.size())
	{
		int vx = q.front().first;
		int vy = q.front().second;
		q.pop();
		if (vx == 0 || vx == n - 1 || vy == 0 || vy == m - 1)
		{
			cout << 1;
			exit(0);
		}
		int res = min({vx, n - 1 - vx, vy, m - 1 - vy});
		ans = min(ans, 1 + (res + k - 1) / k);
		if (d[vx][vy] == k) 
		{
			continue;
		}
		for (int i = 0; i < 4; i++)
		{
			int ux = vx + dx[i];
			int uy = vy + dy[i];
			if (a[ux][uy] != '#' && d[vx][vy] + 1 < d[ux][uy])
			{
				d[ux][uy] = d[vx][vy] + 1;
				q.push({ux, uy});
			}
		}
	}
}

int main()
{
	cin >> n >> m >> k;	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			d[i][j] = 1000000000;
			cin >> a[i][j];
			if (a[i][j] == 'S')
			{
				sx = i;
				sy = j;
			}
		}
	}
	bfs(sx, sy);
	cout << ans << endl;
}


 

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

bool is_prime(int _Num){
    if(_Num < 2)return false;
    if(_Num % 2 == 0){
        if(_Num == 2)return true;
        else return false;
    }
    bool _prime = true;
    for(int i = 3; i <= sqrt(_Num); i += 2){
        if(_Num % i == 0){
            _prime = false;
            break;
        }
    }
    return _prime;
}

int main(){
    int N;
    cin >> N;
    vector<int> ans;
    for(int i = 2; i <= 55555; i++){
        if(is_prime(i) && i % 5 == 1){
            ans.push_back(i);
        }
    }
    
    for(int i = 0; i < N; i++){
        cout << ans[i] << " ";
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0)
		puts("Alice");
	else
		puts("Borys");
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
# = int(input())
# = input()
x = list(map(int, input().split()))

if n >= m:
	print(0)
else:
	x.sort()
	dif = []
	for i in range(1, m):
		dif.append(x[i] - x[i-1])
	dif.sort()
	print(sum(dif[:len(dif)-(n-1)]))


Measured memory_bytes: 13960
#include <stdio.h>

int main()
{
	int a, b, c, i, tmp_num;
	scanf("%d%d%d", &a, &b, &c);
	if (c < b)
	{
		tmp_num = c;
		c = b;
		b = tmp_num;
		tmp_num = 0;
	}
	if (b < a)
	{
		tmp_num = a;
		a = b;
		b = tmp_num;
		tmp_num = 0;
	}
	if (c < b)
	{
		tmp_num = c;
		c = b;
		b = tmp_num;
	}
	
	printf("%d %d %d\n", a, b, c);

	return 0;
}

Measured memory_bytes: 596
fun main(args:Array<String>):Unit {
    while(true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        Array(n){
            val arg = readLine()!!.trim().split(' ').map(String::toInt)
            val bowringScore = BowringScore()
            arg.drop(1).forEach { bowringScore.throwBall(it) }
            Pair(arg.first(), bowringScore.currentScore)
        }.sortedByDescending { it.second * 100000 - it.first }.forEach {
            println("${it.first} ${it.second}")
        }

    }
}
class BowringScore{
    private var mIsNextSpare = 0
    private var mIsNextStrike = 0
    var currentScore:Int = 0
        private set
    private var mFirst = true
    private var flame = 0
    private var mRest:Int = 10
    fun throwBall(num:Int):Unit {
        if (mFirst) ++flame
        if (flame <= 10) {
            currentScore += num * (1 + mIsNextSpare + mIsNextStrike)
            mIsNextSpare = mIsNextStrike
            mIsNextStrike = 0
            if (mFirst) {
                if (num == 10) {
                    mIsNextStrike = 1
                } else {
                    mRest -= num
                    mFirst = false
                }
            } else {
                if (num == mRest) {
                    mIsNextSpare += 1
                }
                mRest = 10
                mFirst = true
            }
        }else{
            currentScore += num * (mIsNextSpare + mIsNextStrike)
            mIsNextSpare = mIsNextStrike
            mIsNextStrike = 0
        }
    }
}


Measured memory_bytes: 32332