akhauriyash/Code-Regression huggingface dataset:
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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 (b < a) { a = b; return 1; } return 0; }




// ***************************************


int main(){

    ll X;
    cin >> X;

    double a = 100;
    ll cnt = 0;
    while(true){
        a = floor(a * 1.01);
        cnt++;
        if (a >= X) break;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int X, Y, A, B, C, painted, R ;
  cin >> X >> Y >> A >> B >> C ;
  long long int red[A], green[B], nocol[C], ans = 0, minringo ;
  for(int i=0;i<A;i++){
    cin >> red[i] ;
  }
  for(int i=0;i<B;i++){
    cin >> green[i] ;
  }
  for(int i=0;i<C;i++){
    cin >> nocol[i] ;
  }
  sort(red,red+A) ;
  sort(green,green+B) ;
  sort(nocol,nocol+C) ;
  painted = min(X+Y, C) ;
  long long int redtot[X+1], greentot[Y+1], nocoltot[painted+1] ;
  redtot[0] = 0 ;
  greentot[0] = 0 ;
  nocoltot[0] = 0 ;
  for(int i=1;i<(X+1);i++){
    redtot[i]=redtot[i-1]+red[A-i];
  }
  for(int i=1;i<(Y+1);i++){
    greentot[i]=greentot[i-1]+green[B-i];
  }
  for(int i=1;i<(painted+1);i++){
    nocoltot[i]=nocoltot[i-1]+nocol[C-i];
  }
  long long int DP[painted+1], DPsub1[painted+1], DPsub2[painted+1] ;
  DP[0] = redtot[X] + greentot[Y] ;
  DPsub1[0] = X ;
  DPsub2[0] = Y ;
  for(int i=1;i<(painted+1);i++){
    DP[i] = DP[i-1] ;
    if((DPsub1[i-1] !=0) && (red[A-DPsub1[i-1]] <= green[B-DPsub2[i-1]])){
      minringo = red[A-DPsub1[i-1]] ;
      if(minringo <= nocol[C-i]){
        DP[i] += ( nocol[C-i] - minringo ) ;
        DPsub1[i] = DPsub1[i-1] - 1 ;
        DPsub2[i] = DPsub2[i-1] ;
      }
      else{
        cout << DP[i] << endl ;
        return 0 ;
      }
    }
    else if((DPsub2[i-1] !=0) && (red[A-DPsub1[i-1]] > green[B-DPsub2[i-1]]) ){
      minringo = green[B-DPsub2[i-1]] ;
      if(minringo <= nocol[C-i]){
        DP[i] += ( nocol[C-i] - minringo ) ;
        DPsub1[i] = DPsub1[i-1] ;
        DPsub2[i] = DPsub2[i-1] - 1 ;
      }
      else{
        cout << DP[i] << endl ;
        return 0 ;
      }
    }
    else if((DPsub1[i-1] ==0) && (DPsub2[i-1] != 0)){
      minringo = green[B-DPsub2[i-1]] ;
      if(minringo <= nocol[C-i]){
        DP[i] += ( nocol[C-i] - minringo ) ;
        DPsub1[i] = DPsub1[i-1]  ;
        DPsub2[i] = DPsub2[i-1] - 1;
      }
      else{
        cout << DP[i] << endl ;
        return 0 ;
      }
    }
    else if(DPsub2[i-1] ==0){
      minringo = red[A-DPsub1[i-1]] ;
      if(minringo <= nocol[C-i]){
        DP[i] += ( nocol[C-i] - minringo ) ;
        DPsub1[i] = DPsub1[i-1] - 1 ;
        DPsub2[i] = DPsub2[i-1] ;
      }
      else{
        cout << DP[i] << endl ;
        return 0 ;
      }
    }
  }
  cout << DP[painted] << endl ;
  return 0 ;
}  

Measured memory_bytes: 7168
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll k,n,p,q=0,i,l,r=0,s=0;
    cin>>k>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    l=a[1]-a[0];
    for(i=1;i<n;i++)
    {
        
        if(i<n-1&&l<a[i+1]-a[i])
        {
            l=a[i+1]-a[i];
        }
        else if(i==n-1)
        {
            if(l<k-a[n-1]+a[0])
            {
                l=k-a[n-1]+a[0];
            }
        }
    }
    s=k-l;
    cout<<s<<endl;
}

Measured memory_bytes: 1920
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll x; cin >> x; ll sum = 0; ll cx = x;
  
  while(cx != 0){
    sum += cx % 10;
    cx /= 10;
  }
  
  if(x % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
--https://www.lua.org/pil/11.4.html
local List = {}
function List.new ()
  return {first = 0, last = -1}
end

function List.pushleft (list, value)
  local first = list.first - 1
  list.first = first
  list[first] = value
end

function List.pushright (list, value)
  local last = list.last + 1
  list.last = last
  list[last] = value
end

function List.popleft (list)
  local first = list.first
  if first > list.last then return false end
  local value = list[first]
  list[first] = nil
  list.first = first + 1
  return value
end

function List.popright (list)
  local last = list.last
  if list.first > last then return false end
  local value = list[last]
  list[last] = nil
  list.last = last - 1
  return value
end

----------

local n,q=io.read("n","n")
local edge={}
local counter={}
for i=1,n do
    counter[i]=0
    edge[i]={}
end
for i=1,n-1 do
    local a,b=io.read("n","n")
    edge[a][b]=false
    edge[b][a]=false
end
for i=1,q do
    local p,x=io.read("n","n")
    counter[p]=counter[p]+x
end

local que=List.new()
List.pushright(que,1)

while true do
    local a=List.popleft(que)
    if a then
        for b,_ in pairs(edge[a]) do
            if not edge[a][b] then
                counter[b]=counter[b]+counter[a]
                edge[a][b]=true
                edge[b][a]=true
                List.pushright(que,b)
            end
        end
    else
        break
    end
end

print(table.concat(counter," "))

Measured memory_bytes: 54496
n = int(raw_input())
a = map(int, raw_input().split())

min = 1000000
max = -1000000
sum = 0

for i in a:
    if min > i:
        min = i
    if max < i:
        max = i
    sum += i

print "%d %d %d" % (min, max, sum)

Measured memory_bytes: 6980
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
	int  n,x;
	cin>>n;
	int ans = 0,odd = 0,even = 0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x%4==0) ans++;
		else if(x&1) odd++;
		else even++;
	}
	if(even){
		if(ans>=odd)  cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	else {
		if((1+ans)>=odd)   cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	return 0;
 } 

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;
typedef unsigned char byte;

int main() {
    speed;
    int h, n, s = 0, v;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v;
        s += v;
    }
    if (s >= h)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 888
n = str(input())

if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] == '7' or n[-1] == '9':
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9116
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int a = N/100;
        int b = N%10;
        String ans = "No";
        if(a==b) ans = "Yes";
        System.out.println(ans);
    }
}


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

string s, t;

string getAns(int pre) {
	int i;
	string ret;
	
	for (i = 0; i < pre; i++) {
		if (s[i] == '?') ret += 'a';
		else ret += s[i];
	}
	
	for (i = 0; i < t.length(); i++) {
		if (s[pre + i] != '?') ret += s[pre + i];
		else if (t[i] != '?') ret += t[i];
		else ret += 'a';
	}
	
	for (i = t.length() + pre; i < s.length(); i++) {
		if (s[i] == '?') ret += 'a';
		else ret += s[i];
	}
	return ret;
}

int main() {
	cin >> s >> t;
	
	string ans;
	for (int i = 0; i <= s.length(); i++) ans += 'z';
	
	for (int i = 0; i < s.length(); i++) {
		if (i + t.length() > s.length()) {
			break;
		}
		
		int j;
		for (j = 0; j < t.length(); j++) {
			if (s[i + j] == t[j] || s[i + j] == '?') continue;
			break;
		}
		if (j == t.length()) {
			ans = min(ans, getAns(i));
		}
	}
	
	if (ans.length() > s.length()) { cout << "UNRESTORABLE" << endl; }
	else { cout << ans << endl; }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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


//O(sqrt(n))
map<ll, int> primeFactor(ll n) {
	map<ll, int> ret;

	while (n % 2 == 0) {
		n /= 2;
		ret[2]++;
	}

	int i = 3;
	while (n > 1 && (ll)i * i <= n) {
		while (n % i == 0) {
			n /= i;
			ret[i]++;
		}
		i += 2;
	}

	if (n != 1) ret.insert({ n,1 });

	return ret;
}

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

	ll n; cin >> n;
	ll ans = 0;
	rep1(c, n-1) {
	  ll ans1 = 1;
	  map<ll,int> mp = primeFactor(n-c);
		for (auto pe : mp) {
			ans1 *= pe.second+1LL;
		}

		ans += ans1;
	}

	cout << ans << endl;
	
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
namespace Number {
    typedef long long int LL;
    // 求取 a, b 的最大公因數
    LL gcd(LL a, LL b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }
    // 求取 a, b 的最大公因數 gcd
    // 以及 x, y 使得 a*x + b*y = gcd
    LL gcd_extend(LL a, LL b, LL *x, LL *y) { 
        if (a == 0) { 
            *x = 0, *y = 1; 
            return b; 
        } 
    
        LL x1, y1; // To store results of recursive call 
        LL gcd = gcd_extend(b%a, a, &x1, &y1); 
    
        *x = y1 - (b/a) * x1; 
        *y = x1; 
    
        return gcd; 
    }
    // 求 a_inv 使得 (a * a_inv) % m = gcd(a, m)
    // 若 a, m 互質，即求 a 在 mod m 群的反元素 a_inv 
    LL mod_inv(LL a, LL m) { 
        LL x, y; 
        LL g = gcd_extend(a, m, &x, &y); 
        // 處理 x 爲負的情形 
        LL a_inv = (x%m + m) % m; 
        return a_inv;
    }
    // 求 x^n % m
    LL mod_pow(LL x, LL n, LL m) {
        if (n == 0) {
            return 1;
        } else if (n & 1) {
            LL half = mod_pow(x, n/2, m);
            return (half * half % m) * x % m;
        } else {
            LL half = mod_pow(x, n/2, m);
            return half * half % m;
        }
    }
    // 連乘
    LL mul(LL from, LL to, LL m) {
        LL ret = 1;
        for (LL i = from; i <= to; i++) {
            ret *= i;
            ret %= m;
        }
        return ret;
    }
    // 求 (C n 取 k) % m
    LL mod_comb(LL n, LL k, LL m) {
        LL mi = k < n-k ? k : n-k;
        LL up = mul(n - mi + 1, n, m);
        LL down = mul(1, mi, m);
        return (up * mod_inv(down, m)) % m;
    }
}

LL x[100005];

const LL M = 1e9 + 7;

LL fact[100005];

void init() {
    fact[0] = 1;
    for (int i = 1; i < 100005; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= M;
    }
}

int main() {
    init();
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    LL ans = 0;
    // for (int i = 0; i < n - 1; i++) {
    //     for (int j = i + 1; j < n; j++) {
    //         LL dis = x[j] - x[j - 1];
    //         LL a = dis * fact[n - 1];
    //         a %= M;
    //         a *= Number::mod_inv(j - i, M);
    //         a %= M;
    //         ans += a;
    //         ans %= M;
    //     }
    // }
    // cout << ans << endl;
    ans = 0;
    LL ts = 0;
    for (int i = 0; i < n - 1; i++) {
        LL dis = x[i + 1] - x[i];
        LL t = fact[n - 1] * Number::mod_inv(i + 1, M) % M;
        ts += t;
        ts %= M;
        ans += ts * dis;
        ans %= M;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const ll EXD = 1000000000000000000;
ll ans = 0ll, t;
bool f1 = false, f2 = false;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	cin >> ans;
	if (ans == 0ll)
	{
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < n; i++)
	{
		cin >> t;
		if (t == 0ll)
		{
			cout << 0 << endl;
			return 0;
		}
		else
		{
			if (EXD / ans >= t)
			{
				ans *= t;
			}
			else
			{
				for (int j = i + 1; j < n; j++)
				{
					cin >> t;
					if (t == 0ll)
					{
						cout << 0 << endl;
						return 0;
					}
				}
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

void solve()
{
	int t;
	cin >> t;
	while(t--)
	{
		int Data[3];
		for(int i = 0; i < 3; ++i)
		{
			cin >> Data[i];
		}
		if((Data[0] * Data[0] + Data[1] * Data[1] == Data[2] * Data[2]) ||
			(Data[1] * Data[1] + Data[2] * Data[2] == Data[0] * Data[0]) || 
			(Data[0] * Data[0] + Data[2] * Data[2] == Data[1] * Data[1]))
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import java.math.BigInteger;
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String A = scan.nextLine();
		String B = scan.nextLine();
		
		if(new BigInteger(A).compareTo(new BigInteger(B)) == 1){
			System.out.println("GREATER");
		}else if(new BigInteger(A).compareTo(new BigInteger(B)) == -1){
			System.out.println("LESS");
		}else if(new BigInteger(A).compareTo(new BigInteger(B)) == 0){
			System.out.println("EQUAL");
		}
	}

}


Measured memory_bytes: 22868
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n, T;
    scanf("%d%d", &n, &T);
    int i;
    int prev = -1;
    ll sum = 0;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (i > 0) {
            if (tmp > prev + T) {
                sum += T;
            }
            else {
                sum += (tmp - prev);
            }
        }
        prev = tmp;
    }
    printf("%lld\n", sum + T);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 128
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0 for _ in range(N - 1)]

for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        ans[min(d1, d2) - 1] += 1

[print(ans[i]) for i in range(N - 1)]


Measured memory_bytes: 46300
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll N,M;
	cin >> N >> M;
	vl X(M);
	FOR(i,0,M)cin >> X[i];
	sort(ALL(X));
	vl d(M-1);
	FOR(i,0,M-1)d[i] = X[i+1] - X[i];
	sort(ALL(d));
	ll ans = 0;
	FOR(i,0,M-N)ans += d[i];
	cout << ans << endl;
}

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

int main()
{
    int n, ans;
    cin >> n;
    int a[n];
    ans = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ans += a[i];
    }
    if(ans %10 != 0){
        cout << ans << endl;
        return 0;
    }
    sort(a, a+n);
    int minus = ans;
    for(int i=0; i<n; i++){
        if(a[i] % 10 != 0){
            minus = a[i];
            break;
        }
    }

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

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

using namespace std;
#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++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

// 最大公約数
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

int main()
{
    ll k;
    cin >> k;
    ll sum = 0;
    for (ll a = 1; a <= k; a++) {
        for (ll b = 1; b <= k; b++) {
            for (ll c = 1; c <= k; c++) {
                ll g = gcd(a, b);
                if (g == 1) {
                    sum += 1;
                } else {
                    g = gcd(g, c);
                    sum += g;
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll flag[100005][105];
int main()
{
	ll n,w,sum=0;
	cin>>n>>w;
	ll wt[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>v[i];
		sum+=v[i];
	}
	ll dp[100005];
	ll ans=0;
	for(int i=0;i<100005;i++)
	{
		dp[i]=0;
		for(int j=0;j<105;j++)
		flag[i][j]=0;
	}
	
	for(int j=0;j<sum+1;j++)
	{
		if(dp[j]!=0 || j==0){
		
		for(int i=0;i<n;i++)
		{
			if(flag[j][i]==0)
			{	
					if(wt[i]<=w-dp[j] && (j+v[i])<100005)
					{
						if(dp[j+v[i]]!=0)
						{
							ans=dp[j+v[i]];
							dp[j+v[i]]=min(dp[j+v[i]],wt[i]+dp[j]);	
							if(ans!=dp[j+v[i]])
							{
								for(int k=0;k<n;k++)
								{
									flag[j+v[i]][k]=flag[j][k];
								}
								flag[j+v[i]][i]=1;
							}
						}
						else
						{
							dp[j+v[i]]=wt[i]+dp[j];
							for(int k=0;k<n;k++)
							{
								flag[j+v[i]][k]=flag[j][k];
							}
							flag[j+v[i]][i]=1;
						}
	
					}
				
			}
		}
	}
//		for(int i=0;i<)	
	}
	ans=0;
	for(int j=0;j<100005;j++)
	{
		if(dp[j]!=0)
		ans=j;
	}
	cout<<ans<<endl;
	return 0;
	
}

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

///--->>> CONTAINERS <<<---///
using i64 = int64_t;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using vpi = vector<pair<ll,ll> >;
using pi = pair<ll,ll>;
using st = set<ll>;
using stk = stack<ll>;
using kiwi = queue<ll>;
using pkiwi = priority_queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;

///--->>> MACROS<<<---///
const ll mx = 3e5+123;
#define MOD 1000000007
#define REP(i,n) for (ll i=1;i<=n;++i)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

///--->>>OPTIMIZE<<<---///
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

///--->>> DEBUGGER<<<---///
#define dbg(args...) do {cerr<<#args<<" : "; diraf(args); } while(0)
void diraf ()  {        cerr << endl;}
template < typename T, typename ... hello>void diraf( T arg, const hello &... rest) {cerr<<arg<< ' ';diraf(rest...);}

int main(int argc, char* argv[]){
    fastio;
    ///freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    ///cout<<fixed<<setprecision(20);
    ll n, cnt=0; cin>>n; bool flag=false;
    for(ll z=1;z<=n;++z){
        ll n1, n2; cin>>n1>>n2;
        if(n1==n2) cnt++;
        else cnt=0;
       /// dbg(cnt);
        if(cnt==3) {flag = true; }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>

using namespace std ;

int main(){
    int n ;
    cin >> n ;
    
    vector<long long int> a(n) ;
    
    for (int i=0 ; i<n ; i++)
        cin >> a[i] ;
    
    vector<vector<long long int> > dp(n, vector<long long int> (n, LONG_MAX)) ;
    vector<vector<long long int> > cost(n, vector<long long int> (n, LONG_MAX)) ;
    
    for (int i=n-1 ; i>=0 ; i--){
        for (int j=i ; j<n ; j++){
            if (i==j){
                dp[i][j] = a[i] ;
                cost[i][j] = 0 ;
            }
            else{
                for (int k=i ; k<=j-1 ; k++){
                    long long int temp_cost = dp[i][k] + dp[k+1][j] + cost[i][k] + cost[k+1][j] ;
                    if (temp_cost < cost[i][j]){
                        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j]) ;
                        cost[i][j] = temp_cost ;
                    }
                }
            }
        }
    }
    
    cout << cost[0][n-1] << "\n" ;
    
    return 0 ;
}


Measured memory_bytes: 5728
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for s in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# d = collections.defaultdict(list)
import sys
sys.setrecursionlimit(15000)

n = int(sys.stdin.readline())
sum = 0
for i in range(1,n+1):
    if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
        continue
    else:
        sum += i
print(sum)


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

using namespace std;

int n;
int arr[100005];

int main()
{
	cin >> n;
	int i;
	for(i=0;i<n;i++)
		cin >> arr[i];
	sort(arr,arr+n);
	cout << arr[n-1]-arr[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define BR printf("\n")
#define INF 2000000000
#define NIL -1

struct Point{
    int x,y,id;
    bool operator < (const Point &p) const {
        return id < p.id;
    }
};

bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

Point A[500000];

struct Node{
    int id,l,r,x,y;
};

Node T[500000];
int np = 0;

int make2Dtree(int l,int r,int d){
    if (r-l <= 0) return NIL;
    int mid = (l+r)/2;
    int t = np++;
    
    if (d == 0) sort(A+l,A+r,lessX);
    else sort(A+l,A+r,lessY);
    
    T[t].id = A[mid].id;
    T[t].x = A[mid].x;
    T[t].y = A[mid].y;
    T[t].l = make2Dtree(l,mid,(d+1)%2);
    T[t].r = make2Dtree(mid+1,r,(d+1)%2);
    
    return t;
}

vector<int> ans;

void findTree(int i,int xs,int xt,int ys,int yt,int d){
    if (d == 0) {
        if(xs <= T[i].x && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,1);
        if (xs <= T[i].x && T[i].x <= xt && ys <= T[i].y && T[i].y <= yt) ans.push_back(T[i].id);
        if(T[i].x <= xt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,1);
    }else{
        if(ys <= T[i].y && T[i].l != NIL) findTree(T[i].l,xs,xt,ys,yt,0);
        if (xs <= T[i].x && T[i].x <= xt && ys <= T[i].y && T[i].y <= yt) ans.push_back(T[i].id);
        if(T[i].y <= yt && T[i].r != NIL) findTree(T[i].r,xs,xt,ys,yt,0);
    }
}

void in_order(Node T[],int i){
    if (T[i].l != NIL) in_order(T,T[i].l);
    printf("%d\n",T[i].id);
    if (T[i].r != NIL) in_order(T,T[i].r);
}

int main(){
    INT(n);
    REP1(i,n){
        INT(x);INT(y);
        A[i].x = x;
        A[i].y = y;
        A[i].id = i;
    }
    make2Dtree(0,n,0);
    INT(q);
    REP1(i,q){
        INT(xs);INT(xt);INT(ys);INT(yt);
        findTree(0,xs,xt,ys,yt,0);
        sort(ans.begin(),ans.end());
        REP1(j,ans.size()) printf("%d\n",ans[j]);
        BR;
        ans.clear();
    }
    return 0;
}

Measured memory_bytes: 16660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int inf = 1<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

int main () {
  string S, T; cin >> S >> T;

  if(S==T) {
    puts("Yes");
    return 0;
  }

  int N = S.size();
  vi XS('z'+1), XT('z'+1);
  for(auto c: S) {
    XS[c]++;
  }
  for(auto c: T) {
    XT[c]++;
  }

  RSORT(XS);
  RSORT(XT);

  printf("%s\n", XS==XT?"Yes":"No");
}

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

int gcd( int x, int y )
{
  if( y == 0 ) {
    return x;
  }

  int ret = 0;
  int mod = x % y;
  ret = gcd( y, mod );

  return ret;
}

int main()
{
  int x, y;
  cin >> x;
  cin >> y;

  cout << gcd( x, y ) << endl;

  return 0;
}




Measured memory_bytes: 3104
import java.util.Scanner;

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

        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();

        if (1 <= S / 100 && S / 100 <= 12) {
            if (1 <= S % 100 && S % 100 <= 12) {
                System.out.println("AMBIGUOUS");
            } else {
                System.out.println("MMYY");
            }
        } else {
            if(1 <= S % 100 && S % 100 <= 12){
                System.out.println("YYMM");
            }else{
                System.out.println("NA");
            }
        }
    }
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ii pair<int,int>
#define iii pair<ii,int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define nu 100000
#define mod 1000000007
#define inf pow(10,8)
#define h pow(10,-8)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main()
{
	fastio;

	string a, b, s;
	cin >> a >> b;

	s = a+b;
	// cout << s << '\n';

	int n = stoi(s), sq;
	// cout << n << '\n';

	sq = sqrt(n);

	if (sq*sq == n)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}

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

int main(void){
  int n,i,j,flag,k;
  char str[1001],ch[8]="Hoshino";

  scanf("%d",&n);
  scanf("%c",&str[0]);

  for(k=0;k<n;k++){
  scanf("%[^\n]%*c",str);
  
  for(i=0;i<strlen(str);i++){
    flag=0;
    for(j=0;j<7;j++){
      if(str[i+j]==ch[j])flag++;
    }
    if(flag==7)str[i+6]='a';
  }
  printf("%s\n",str);
  }
  return 0;
}

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

using namespace std;

int main(){
	int n, oneStep, twoStep;
	scanf("%d", &n);
	int dp[n+1], weight[n+1];

	for(int i = 0; i<n; i++)
		scanf("%d", &weight[i]);

	dp[0] = 0;
	dp[1] = abs(weight[1] - weight[0]);
	for(int i = 2; i<n;i++){
		oneStep = abs(weight[i] - weight[i-1]) + dp[i-1];
		twoStep = abs(weight[i] - weight[i-2]) + dp[i-2];
		if(oneStep < twoStep) dp[i] = oneStep;
		else dp[i] = twoStep;
	}
	printf("%d\n", dp[n-1]);
	return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
		String[] strArr = str.split(" ");
		long sum = 0;
		for (int i = 0; i < N; i++) {
			sum += Long.parseLong(strArr[i]);
		}

		if (sum % ((long) N * ((long) N + 1) / 2) != 0) {
			System.out.println("NO");
			return;
		}
		long k = sum / ((long) N * ((long) N + 1) / 2);

		boolean able = true;
		long edge = 0;
		for (int i = 0; i < N; i++) {
			long d = -Long.parseLong(strArr[i]) - k;
			if (i == N - 1)
				d += Long.parseLong(strArr[0]);
			else
				d += Long.parseLong(strArr[i + 1]);
			// System.out.println(d);
			if (d > 0) {
				able = false;
				break;
			}
			if (d < 0) {
				if (d % N != 0) {
					able = false;
					break;
				}
				edge -= d;
			}
		}
		if (able) {
			// System.out.println(edge);
			able = (edge == N * k);
		}

		if (able)
			System.out.println("YES");
		else
			System.out.println("NO");
	}

}


Measured memory_bytes: 38208
S=input()
S=int(S)
a = [input() for i in range(S)]
AC=0
WA=0
TLE=0
RE=0

for a in a:
    if a=="AC":
        AC+=1
    if a=="WA":
        WA+=1
    if a=="TLE":
        TLE+=1
    if a=="RE":
        RE+=1
print("AC x "+str(AC) )
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))

Measured memory_bytes: 15952
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    int x[100001];

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

    int min = INT_MAX;
    for (int i = 0; i < n - k + 1; i++) {
        int start;
        if (abs(x[i]) < abs(x[i + k - 1])) {
            start = abs(x[i]);
        } else {
            start = abs(x[i + k - 1]);
        }
        int tmp = start + abs(x[i + k - 1] - x[i]);
        if (tmp < min) {
            min = tmp;
        }
    }

    cout << min << endl;

    return 0;
}


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

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector <int> > vvi;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    vi T(N),D(N-1);
    REP(i,N){
        cin >> T[i];
        if(i != 0)D[i-1] = T[i] - T[i-1];
    }
    so(D);
    int over = N - K;
    if(over <= 0){
        cout << N << endl;
        return 0;
    }
    int ans = N;
    REP(i,over){
        ans += D[i] - 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3640
#include<iostream>

using namespace std;

int main(void) {
    int n, sum = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') sum++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
if len([h for _,_,h in XYH if h > 0]) == 1:
    print(*max(XYH, key=lambda xyh: xyh[2]))
    exit()
for cx in range(101):
    for cy in range(101):
        H = -1
        for x, y, h in XYH:
            if h:
                if H == -1:
                    H = h + abs(x-cx)+abs(y-cy)
                else:
                    if H != h + abs(x-cx)+abs(y-cy):
                        break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3064
N, M = map(int, input().split())
PS = []
for i in range(M):
    p, s = input().split()
    PS.append([int(p), s])

a_w = []
for i in range(N+1):
    a_w.append([False, 0])

a_cnt = 0
w_cnt = 0
for p, s in PS:
    # 正解済み
    if a_w[p][0]:
        continue

    # 初めて正解した
    if s == 'AC':
        a_w[p][0] = True
        a_cnt += 1
        w_cnt += a_w[p][1]
    else:
        a_w[p][1] += 1

# print(a_w)
print(a_cnt, w_cnt)

Measured memory_bytes: 32132
from collections import defaultdict
import sys
def input():return sys.stdin.readline().strip()

def main():
    N, P = map(int, input().split())
    S = input()

    ans = 0
    if P in [2, 5]:
        for i, c in enumerate(S[::-1]):
            if int(c) % P == 0:
                ans += N-i
    else:
        d = defaultdict(int)
        d[0] = 1
        num = 0
        ten = 1
        for c in S[::-1]:
            num += int(c) * ten
            num %= P
            d[num] += 1
            ten *= 10
            ten %= P

        ans = sum([d[i]*(d[i]-1)//2 for i in range(P)])

    print(ans)

        
if __name__ == "__main__":
    main()

Measured memory_bytes: 4580
import java.io.*;
import java.util.*;

class Main {

	private static long f(long n, long x) {
		if (n < 0) return 0;
		return n / x + 1;

	}

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		System.out.println(f(b, x) - f(a - 1, x));
	}
}


Measured memory_bytes: 23892
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGeTAC solver = new CGeTAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGeTAC {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int q = sc.nextInt();
            String s = sc.nextLine();
            TreeSet<CGeTAC.Pair> set = new TreeSet<>(new Comparator<CGeTAC.Pair>() {

                public int compare(CGeTAC.Pair a, CGeTAC.Pair b) {
                    return Integer.compare(a.x, b.x);
                }
            });
            int cnt = 1;
            for (int i = 0; i < n - 1; i++) {
                if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                    set.add(new CGeTAC.Pair(i, cnt));
                    cnt++;
                }
            }
            int l, r;
            CGeTAC.Pair x, y;
            for (int i = 0; i < q; i++) {
                l = sc.nextInt() - 1;
                r = sc.nextInt() - 1;
                x = set.lower(new CGeTAC.Pair(r, 0));
                y = set.lower(new CGeTAC.Pair(l, 0));
                if (x == null) {
                    out.println(0);
                } else if (y == null) {
                    out.println(x.y);
                } else {
                    out.println(x.y - y.y);
                }
            }
        }

        static class Pair {
            int x;
            int y;

            Pair(int a, int b) {
                x = a;
                y = b;
            }

        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



Measured memory_bytes: 53796
K, N = gets.split.map(&:to_i)
dists = []
pre = nil
sum = 0
arr = gets.split.map do |x|
  t = x.to_i
  if !pre
    pre = t
  else
    dist = (pre - t).abs
    dists << dist
    sum += dist
    pre = t
  end
end
dists << (pre - K).abs + arr[0]
sum += (pre - K).abs + arr[0]
# p dists
dists.sort_by!{|x|-x}
puts sum - dists[0]


Measured memory_bytes: 23224
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if(a>b){
        cout<<2*a-1<<endl;
    }
    else if(a<b){
        cout<<2*b-1<<endl;
    }
    else{
        cout<<a+b<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int h,w;
	cin>>h>>w;
	char ch[h][w];
	rep(i,h)rep(j,w)cin>>ch[i][j];
	int al[26];
	rep(i,26)al[i]=0;
	rep(i,h)rep(j,w)rep(k,26)if((int)(ch[i][j]-'a')==k)al[k]++;
	int pair=0;
	rep(i,26)pair+=al[i]/2;
	int tmp=0;
	rep(i,26)tmp+=al[i]/4;
	if(tmp>=(h/2)*(w/2)){
		pair-=(h/2)*(w/2)*2;
		if(h%2==0){
			if(w%2==0){
				cout<<"Yes"<<endl;
			}else{
				cout<<((pair>=h/2)?"Yes":"No")<<endl;
			}
		}else{
			if(w%2==0){
				cout<<((pair>=w/2)?"Yes":"No")<<endl;
			}else{
				cout<<((pair>=(h/2+w/2))?"Yes":"No")<<endl;
			}
		}
	}else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  #include <numeric>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)
  
  int main(){
   int n,q;
   cin >> n >> q;
   string s;
   cin >> s;
   vector<int> ans(n+1,0);
   for(int i=1;i < n+1;i++){
     if (s[i-1] == 'A' && s[i] == 'C' && i < n){
       ans[i+1]+=1;
     }
     ans[i]+=ans[i-1];
   }
   //rep(i,n+1) cout << ans[i];
   //cout << endl;
   while(q--){
     int x,y;
     cin >> x >> y;
     //printf("ans #");
     cout << ans[y]-ans[x] << endl;
   }
   
    return 0;
  }



Measured memory_bytes: 1408
#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() {
	int n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	ll t = 0;
	rep(i,m) t+=b[i];
	int j = m;
	int ans = 0;
	rep(i, n+1){
		while(j>0 && t>k){
			--j;
			t-=b[j];
		}
		if(t>k) break;
		if(ans < i+j) ans = i+j;
		//ans = max(ans, i+j);
		if(i >= n) break;
		t+=a[i];
	}
	cout << ans << endl;
 	return 0;
}

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

const ll MODP = 1000000007LL;

ll n, a, b;
ll s[131072];

ll dp[2][131072];
ll dps[2][131072];
ll offs[2];


int find(ll m){
	// m < s[i] na saisho no i
	int lo = 0, hi = n-1;
	if (s[n-1] <= m) return n;
	if (s[0] > m) return 0;
	while(1){
		int mid = (lo + hi + rand()%2)/2;
		if (s[mid] <= m){
			lo = mid;
		}else if (m < s[mid-1]){
			hi = mid;
		}else{
			return mid;
		}
	}
	return -1;
}


ll sum(int idx, int p, int q){
	if (p>q) return 0;
	return ((dps[idx][q] - dps[idx][p]) % MODP + MODP) % MODP;
}

int main(void){
	cin >> n >> a >> b;
	for(int i=0;i<n;i++) cin >> s[i];
	
	dp[0][0] = dp[1][0] = 1;
	dps[0][1] = dps[1][1] = 1;
	for(int i=1;i<=n;i++){
		if (i>1){
			if (s[i-1]-s[i-2]<b) offs[0] = i-1;
			if (s[i-1]-s[i-2]<a) offs[1] = i-1;
		}
		if (i==n) break;
		//cout << endl;
		dp[0][i] = sum(1,offs[1],((i==1) ? i : min(i,find(s[i]-b)+1)));
		//cout << "[" << offs[1] << " " << ((i==1) ? i : min(i,find(s[i]-b))) << ")" << endl;
		dp[1][i] = sum(0,offs[0],((i==1) ? i : min(i,find(s[i]-a)+1)));
		//cout << "[" << offs[0] << " " << ((i==1) ? i : min(i,find(s[i]-a))) << ")" << endl;
		
		
		//cout << dp[0][i] << " " << dp[1][i] << endl;
		
		dps[0][i+1] = (dps[0][i] + dp[0][i]) % MODP;
		dps[1][i+1] = (dps[1][i] + dp[1][i]) % MODP;
	}
	//cout << offs[0] << " " << offs[1] << endl;
	cout << (sum(1,offs[1],n) + sum(0,offs[0],n))%MODP << endl;
	return 0;
}


Measured memory_bytes: 4224
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

solve :: VU.Vector Int -> Int -> Int
solve xs k
    | VU.length xs < k = 10^9 
    | i >= 0 = min (dist + (abs $ 0 - i)) (solve (VU.tail xs) k)
    | j <= 0 = min (dist + (abs $ 0 - j)) (solve (VU.tail xs) k)
    | otherwise = min (dist + min (abs $ 0 - i) (abs $ 0 - j)) (solve (VU.tail xs) k)
    where
        contain = 0 `VU.elem` grids
        grids = VU.take k xs
        i = grids VU.! 0
        j = grids VU.! (k-1) 
        dist = abs $ i - j 

main = do
    [n,k] <- map read . words <$> getLine
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve xs k

Measured memory_bytes: 3452
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int[] a) {
        Map<Integer, Integer> valueToCount = new HashMap<>();
        for (int value : a) {
            valueToCount.put(value, valueToCount.getOrDefault(value, 0) + 1);
        }

        return valueToCount.keySet().stream()
                .mapToInt(value -> valueToCount.get(value) - ((valueToCount.get(value) >= value) ? value : 0)).sum();
    }
}

Measured memory_bytes: 53892
#include "bits/stdc++.h"
using namespace std;
#define int long long

signed main() {
	string s;
	cin >> s;

	char c1;
	char c2;
	if (s[0] == '0') {
		c1 = '0';
		c2 = '1';
	}
	else {
		c1 = '1';
		c2 = '0';
	}

	int ans = 0;
	for (size_t i = 0; i < s.size(); i++)
	{
		if (i % 2 == 0) {
			if (c1 != s[i]) {
				ans++;
			}
		}
		else {
			if (c2 != s[i]) {
				ans++;
			}
		}

	}

	cout << ans << endl;
}




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

long long ggd(long long number1,long long number2){
	long long m = number1;
	long long n = number2;

	if(number2 > number1){
		m = number2;
		n = number1;
	}

	while(m % n != 0){
		long long temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}
long long lcm(long long n1,long long n2){
    long long t = ggd(n1, n2);
    return n1* n2 / t;
}
int main(){
    long long N, M;
    cin >> N >> M;
    vector<long long> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
        a.at(i) /= 2;
    }
    vector<long long> b(N, 1);
    vector<long long> c(N, 1);
    b.at(0) = a.at(0);
    for(int i = 0; i < N - 1; i++){
        b.at(i + 1) = ggd(b.at(i), a.at(i + 1));
    }
    for(int i = 0; i < N; i++){
        a.at(i) /= b.at(N - 1);
    }
    int flag = 0;   
    for(int i = 0; i < N - 1; i++){
        if(a.at(i) % 2 != a.at(i + 1) % 2) flag = 1;
    } 
    if(flag == 1){
        printf("0\n");
        return 0;
    }
    else{
        c.at(0) = a.at(0);
        for(int i = 0; i < N - 1; i++){
            c.at(i + 1) = lcm(c.at(i), a.at(i + 1));
        } 
        c.at(N - 1) *= b.at(N - 1);
        printf("%lld\n", (M / c.at(N - 1) + 1) / 2);
    }
}

Measured memory_bytes: 2560