akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	cin >> n;
	lli ans = 0;
	for(int i = 1;i < n;++i){
		ans = ans + (n / i);
		if(n % i == 0) ans = ans - 1;
	}
	cout << ans << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

const int N = 200001;
bool b[N];

bool is_prime(int a){
  if (a <= 1){
    return false;
  }

  for(int i=2; i*i<a; i++)
    if(a % i == 0)
      return false;

  return true;
}

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

  for (int i=x; i<N; i++){
    if (is_prime(i)){
        cout << i << endl;
        return 0;
      }
  }



  return 0;
}

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

ll roll (ll lo, ll hi)
{
    ll res = 0;
    hi++;
    for (int i = -1; i <= 60; i++)
        for (int j = 0; j <= 60; j++)
        {
            ll iv;
            if (i == -1) iv = 0;
            else iv = (1LL << i);

            if (lo & iv) continue;
            if (!(hi & (1LL << j))) continue;
            ll lval = lo + iv, hval = hi - (1LL << j);
            ll lk = (lval >> (max (i, j))), hk = (hval >> (max (i, j)));
            if ((lk & hk) != lk)
                continue;
            ll nt = 1;
            for (int k = min (i, j); k < max (i, j); k++)
            {
                if (k < 0) continue;
                if (i < j)
                {
                    if (!(lval & (1LL << k)))
                        nt = (2 * nt) % MOD;
                }
                else
                {
                    if (hval & (1LL << k))
                        nt = (2 * nt) % MOD;
                }
            }
            for (int k = 0; k < min (i, j); k++)
                nt = (3 * nt) % MOD;
            res = (res + nt) % MOD;
        }
    return res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll L, R;
    cin >> L >> R;
    
    ll ans = 0;
    for (int i = 0; i <= 60; i++)
    {
        ll v = (1LL << i);
        if (L >= 2 * v || R < v)
            continue;
        ans += roll (max (0LL, L - v), min (v - 1, R - v));
        ans %= MOD;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n); rep (i, n) cin >> a[i];
    ll now = 1;
    rep (i, n) {
        if (a[i] == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }
    ll limi = 1e18;
    rep (i, n) {
        if (limi / now + 1 <= a[i]) {
            cout << -1 << "\n";
            return 0;
        }
        now *= a[i];
    }
    cout << now << "\n";
    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);

int func (int n, int a)
{
    int res=0;
    while(n>0)
    {
        res+=n%a;
        n/=a;
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin>>N;
    int ans=N;
    REP(i,N+1)
    {
        int cnt=func(i,9)+func(N-i,6);
        ans=min(cnt,ans);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, t; cin >> n >> t;
  int ans = 1, mn = MOD, mx = 0;

  rep(i, n) {
    int a; cin >> a;
    
    chmin(mn, a);
    if (mx == a-mn) ++ans;
    if (chmax(mx, a-mn)) ans = 1;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;


ll n, a, b;

int main(){

cin >> n >> a >> b;

ll dis = b - a - 1;

if(dis % 2 == 0) {cout << "Borys";}
else {cout << "Alice";}

return 0;
}



Measured memory_bytes: 256
s=input()
rev_s = list(reversed(s))
temp=''
for i in rev_s:
    if(temp==''):
        temp=i
    else:
        temp+=i
    if(temp=='maerd' or temp=='remaerd' or temp=='esare' or temp=='resare'):
        temp=''
if(temp==''):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
int main(){
  int n = (1e5 + 2);
  sieve(n);
  vector<int> sum(n, 0);
  for(int i = 0; i < n; i++) {
    int res = 0;
    if(IsPrime[i] == 1 && IsPrime[(i+1)/2] == 1){
      res = 1;
    }
    sum[i + 1] = sum[i] + res;
  }
  int q;
  cin >> q;
  vector<int> l(n), r(n);
  for(int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  for(int i = 0; i < q; i++){
    cout << sum[r[i] + 1] - sum[l[i]] << '\n';
  }
  return 0;
}

Measured memory_bytes: 1792
// V solo
#include <bits/stdc++.h>

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)2e5 + 7;
const int INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

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

int n, a[N];
int main (){
  scanf ("%d", &n);
  forn (i, 1, n) scanf ("%d", a + i);
  int b1 = 0, b2 = 0, b3 = 0;
  forn (i, 1, n){
    if (a[i] & 1) b1++;
    else if (a[i] % 2 == 0 && a[i] % 4 != 0) b2++;
    else if (a[i] % 4 == 0) b3++;
  }
  if (b2 == 0){
    if (b1 <= b3 + 1) return printf ("Yes\n"), 0;
    else return printf ("No\n"), 0;
  }
  else if (b2 > 0){
    if (b1 <= b3) return printf ("Yes\n"), 0;
    else return printf ("No\n"), 0;
  }
  return 0;
}


Measured memory_bytes: 640
def fun(a):
    if len(a)==1:
        return 0
    dp = [0]*len(a)
    dp[0]=a[0]
    dp[1]=dp[0]+abs(a[0]-a[1])
    for i in range(2,len(a)):
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) ,dp[i-2]+abs(a[i]-a[i-2]))
    return dp[-1]-a[0]
  
n = int(input())
a = list(map(int , input().split()))
print(fun(a))

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

using ll = long long;
using P = pair<int, int>;
using edge = struct{int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1001001001;

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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

//void initC(int n);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

int ans = 0;

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    
    combination c(n+5);
    
    mint ans = 0;
    rep(ri,2) {
        rep(i,n) {
        mint now = c(i,k-1);
        if (ri == 1) now = -now;
        ans += now*a[i];
        }
        reverse(a.begin(), a.end());
    }
    cout << ans.x << endl;
}

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

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

int main() {
  string s,ans="";
  cin >> s;
  for (int i =0 ;i < s.size() ; i++) {
    if (s.at(i)== 'B' && ans != "") ans.erase(ans.size()-1);
    if (s.at(i)== '0') ans += "0";
    if (s.at(i)== '1') ans += "1";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

priority_queue < pii > q;
int n,h,ans;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>h;
    for(int i=1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        q.push(mp(a,1));
        q.push(mp(b,-1));
    }
    while(!q.empty()){
        if(h<=0)break;

        int dmg = q.top().fi;
        int type = q.top().se;
        q.pop();
        if(type==1){
            ans += h / dmg;
            if(h%dmg != 0){ans++;}
            h = -1;
        }
        else{
            ans ++ ;
            h -= dmg;
        }
    }
    cout<<ans<<newl;
}


Measured memory_bytes: 2420
import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

n = int(input())
arr = list(map(int, input().split()))

swap_count = 0
for i in range(n):
	mini = i
	for j in range(i, n):
		if arr[j] < arr[mini]:
			mini = j
	if mini != i:
		temp = arr[i]
		arr[i] = arr[mini]
		arr[mini] = temp
		swap_count += 1

print_arr(arr)
print(swap_count)



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,n;
  cin>>a>>b>>n;
  while(n--){
    int q,w;
    cin>>q>>w;
    if(q<b&&w>a){
      cout<<1<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_035
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int bitCnt = 0;
            int now = 1;
            while (now <= n)
            {
                if ((n & now) > 0) bitCnt++;
                now *= 2;
            }

            if (bitCnt == 1)
            {
                WriteLine("No");
                return;
            }

            WriteLine("Yes");

            WriteLine("1 2");
            WriteLine("2 3");
            WriteLine(3+" "+(n+1));
            WriteLine((n+1)+" "+(n+2));
            WriteLine((n+2)+" "+(n+3));

            for(int i = 4; i + 1 <= n; i += 2)
            {
                WriteLine(i + " " + (i + 1));
                WriteLine((i + 1) + " " + (1 + n));
                WriteLine((1 + n) + " " + (i + n));
                WriteLine((i + n) + " " + (i + 1 + n));
            }

            if (n % 2 == 0)
            {
                int first = 1;
                while ((n & first) == 0) first *= 2;

                WriteLine(n + " " + (first + 1));
                WriteLine((2 * n) + " " + (n + (n ^ first)));
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
  int x, y;
  std::set<int> st1{1, 3, 5, 7, 8, 10, 12};
  std::set<int> st2{4, 6, 9, 11};
  scanf("%d %d", &x, &y);
  if (x == 2 || y == 2) {
    printf("No");
  } else if (st1.count(x) != 0 && st1.count(y) != 0 ||
             st2.count(x) && st2.count(y) != 0) {
    printf("Yes");
  } else {
    printf("No");
  }
}


Measured memory_bytes: 256
s1=input()
s2=input()
ls1=len(s1)
ls2=len(s2)
f=[[0 for j in range(ls2+1)] for i in range(ls1+1)]
for i in range(ls1+1):
    f[i][0]=i
for i in range(ls2+1):
    f[0][i]=i
for i in range(1,ls1+1):
    for j in range(1,ls2+1):
        if s1[i-1]!=s2[j-1]:
            f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)
        else:
            f[i][j]=f[i-1][j-1]
print(f[i][j])


Measured memory_bytes: 42892
function main()
  
  N = parse(Int,readline())
  X = map(x -> parse(Int,x), split(readline()))
  
  check = zeros(Int,100)
  
  ans = zeros(Int,100)
  
  for i in 1:100,j in 1:N
    ans[i] += (X[j]-i)^2
  end
  
  println(minimum(ans))
  
end

main()

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

namespace Atc_0040
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int A = int.Parse(S.Split(' ')[0]);
            int B = int.Parse(S.Split(' ')[1]);

            List<int> nums = new List<int>();

            nums.Add(A + B);
            nums.Add(A * B);
            nums.Add(A - B);

            Console.WriteLine(nums.Max());

        }
    }
}


Measured memory_bytes: 28276
x1 = 0
y1 = 0
x2, y2, n = list(map(int, input().split()))
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        if x1 < x:
            x1 = x
    elif a == 2:
        if x < x2:
            x2 = x
    elif a == 3:
        if y1 < y:
            y1 = y
    elif a == 4:
        if y < y2:
            y2 = y

w = x2 - x1
h = y2 - y1
if 0 < w and 0 < h:
    S = (x2 - x1) * (y2 - y1)
else:
    S = 0
if 0 < S:
    print(S)
else:
    print(0)



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

int main(){
    double a,b,c,d,e,f;

    while(cin >> a >> b >> c >> d >> e >> f){
        double de = (a*e) - (b*d);
        double x = 0;
        double y = 0;
        x = e*c + (-b)*f;
        x /= de;
        y = a*f + (-d)*c;
        y /= de;
        if(x == 0)
            x = 0.000;
        if(y == 0)
            y = 0.000;

        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *next;
  struct node *prev;
};
typedef struct node *Node;
Node head;
void delete(Node);
int main(){
  int n,i,flag,key;
  char inst[12];
  Node index;
  scanf("%d",&n);
  head = (Node *)malloc(sizeof(Node));
  head->next = head;
  head->prev = head;
  for(i=0;i<n;i++){
    scanf("%s",inst);
    if( 'F' == inst[6] ){
      delete(head->next);
    }
    else if( 'L' == inst[6]){
      delete(head->prev);
    }
    else{
      scanf("%d",&key);
      if( 'i' == inst[0]){
	Node tmp;
	tmp = (Node *)malloc(sizeof(Node));
	tmp->key = key;
	tmp->next = head->next;
	head->next->prev = tmp;
	head->next = tmp;
	tmp->prev = head;
      }
      else{
	index = (Node *)malloc(sizeof(Node));
	index = head->next;
	while( index != head && index->key != key){
	  index = index->next;
	}
	if( index == head ){
	  continue;
	}
	delete(index);
      }
    }
  }
  index = head->next;
  flag = 0;
  while(index != head){
    if( flag > 0){
      printf(" ");
    }
    flag++;
    printf("%d",index->key);
    index = index->next;
  }
  printf("\n"); 
  return 0;
}
void delete(Node tmp){
  tmp->next->prev = tmp->prev;
  tmp->prev->next = tmp->next;
  free(tmp);
}

Measured memory_bytes: 31788
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
  int H, W;
  cin >> H >> W;

  REP (i, H) {
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
const int d = 365;
//const int d = 5;
int c[26];
int s[d][26];
int last[26] = {0};


int score(vector<int> t){
    vector<int> last(26,0);
    int ans = 0;
    rep(i,d){
        ans += s[i][t[i]];
        last[t[i]] = i+1;
        rep(j,26) ans -= c[j] * (i+1-last[j]);
        //cout << ans << endl;
    }
    return ans;
}

//day 1-index i_day 's contest is k
int nowscore(int i,int k){
    int res = s[i][k];
    int before = last[k];
    last[k] = i+1;
    rep(j,26) res -= c[j] * (i+1-last[j]);
    last[k] = before;
    return res;
}

int main(){
    int tmp;
    cin >> tmp;
    rep(i,26) cin >> c[i];
    rep(i,d)rep(j,26) cin >> s[i][j];

    vector<int> ans(d,-1);
    for(int i=0;i<d;i++){
        int id = -1;
        int mx = -INF;
        for(int j=0;j<26;j++){
            int res = nowscore(i,j);
            if(mx < res){
                id = j;
                mx = res;
            }
        }
        ans[i] = id;
        last[id] = i+1; 
    }

    rep(i,d) cout << ans[i]+1 << endl;
    //cout << (score(ans) + 1e6) << endl;

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = N - K + 1;
  cout << ans << endl;
  return 0;
}

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

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

    while (1) {
        int N, M;
        cin >> N >> M;
        if (!N & !M) break;
        vector<long long> codeBook(M, 0);
        vector<long long> inputSignal(N, 0);
        for (int i = 0; i < M; i++) {
            cin >> codeBook[i];
        }
        for (int i = 0; i < N; i++) {
            cin >> inputSignal[i];
        }
        vector<vector<long long>> dp(256, vector<long long>(N + 10, INF));
        dp[128][0] = 0;
        for (int i = 0; i < N; i++) {
            for (int start = 0; start < 256; start++) {
                if (dp[start][i] == INF) continue;
                for (auto c : codeBook) {
                    int next = start + c;
                    next = next > 255 ? 255 : next;
                    next = next < 0 ? 0 : next;
                    dp[next][i + 1] =
                        min(dp[start][i] + (next - inputSignal[i]) * (next - inputSignal[i]),
                            dp[next][i + 1]);
                }
            }
        }
        long long ans = INF;
        for (int i = 0; i < 256; i++) {
            ans = min(dp[i][N], ans);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 44324
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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()
{
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll A[26]={0};
  FOR(i,'a','z'+1){
    REP(j,N){
      if(S.at(j)==i){
        A[i-'a']++;
      }
    }
  }

  mint ans = 1;
  REP(i,26){
    ans*=A[i]+1;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;
typedef long long int ll;
#define space " "
#define vi vector<int>
#define pb push_back

#define MOD (int)(1e9  + 7)

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi r , g , b ;
    for(int i= 0  ; i < n ;i++ ) {
        if(s[i]== 'R') r.pb(i) ;
        else if(s[i] == 'G') g.pb(i);
        else b.pb(i) ;
    }
    ll res = 0 ;
    for(int i = 0 ; i <n  ;i++ ) {
        for(int j = i + 1 ; j < n ; j++ ){
            if(s[i] != s[j] ) {
                char chr = 'R' + 'G' + 'B' - s[i] - s[j] ;
                if(chr == 'R'){
                    res += (int) r.size() - (upper_bound(r.begin() , r.end() ,  j) - r.begin());
                    if(binary_search(r.begin() , r.end() , j + j - i )) res -- ;
                }else  if(chr == 'G'){
                    res += (int) g.size() - (upper_bound(g.begin() , g.end() ,  j) - g.begin());
                    if(binary_search(g.begin() , g.end() , j + j - i )) res -- ;
                }else  if(chr == 'B'){
                    res += (int) b.size() - (upper_bound(b.begin() , b.end() ,  j) - b.begin());
                    if(binary_search(b.begin() , b.end() , j + j - i )) res -- ;
                }
            }
        }
    }
    cout << res << endl ;





        return 0;

}

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

using namespace std;
using ll = long long;

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

int main() {
  int n, m;
  cin >> n >> m;
  if (n == m)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 3608
N, K = map(int, input().split())
*A, = map(int, input().split())
A = [a-1 for a in A]

# Douling(ダブリング)
i = 1
to = [[a for a in A]]
while pow(2, i) < K:
    t = [to[i-1][to[i-1][j]] for j in range(N)]
    to.append(t)
    i += 1

ans = 0
for j in range(i):
    if K & (1 << j) > 0:
        ans = to[j][ans]
print(ans+1)

Measured memory_bytes: 217856
n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
c = [0] * (m + 1)

for ai in a:
    for i in range(ai, m + 1, ai):
        c[i] += 1

ans = 0
for ai in a:
    if c[ai] == 1:
        ans += c[ai]

print(ans)

Measured memory_bytes: 32188
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7

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

	if (A >= 13) {
		printf("%d", B);
	}
	else if(A>=6){
		printf("%d",B/2);
	}
	else {
		printf("0");
	}



}





Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	if(n%2==0){
		bool ch=true;
		for(ll i=0;i<n/2;i++){
				if(s[i]!=s[i+n/2]){
					ch=false;
				}
		}
		if(ch){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
  int main(){
  char a, b;
  cin >> a >> b;
  if(a == b){
    cout << "H\n";
  }
    else{
      cout << "D\n";
    }
  }

Measured memory_bytes: 3576
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return yen * (100 +per) / 100;}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		foreach(i;1..s/2+1){
			foreach(j;i..s){
				if (tax(x,i) + tax(x,j) == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}
//[(0,0),(0,1),..]
/*		iota(1,s)
.permutations.writeln;
.map!(a => Tuple!(a,iota(1,s)))
.filter!(a => tax (x,a[0]) + tax (x,a[1]) == s)
.map!(a => tax (y,a[0]) + tax(y,a[1]))
.reduce!(max);
*/

Measured memory_bytes: 2400
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Stream;

/**
 *
 * @author Pradyumn Agrawal coderbond007
 */

public class Main{
    public static InputStream inputStream = System.in;
    public static StringTokenizer tok = null;
    public static BufferedReader br = new BufferedReader(new InputStreamReader(inputStream), 32768);
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

    public static void main(String[] args) throws java.lang.Exception{
        new Thread(null, new Runnable() {
            public void run() {
                try {
                    new Main().run();
                    out.close();
                } catch(IOException e){

                }
            }
        }, "1", 1 << 26).start();
    }
    public void run() throws IOException
    {
        int n = ni(),c = ni(),k = ni();
        int[] a = na(n);
        Arrays.sort(a);
        int ret = 1;
        int last = a[0];
        int ind = 0;
        for(int i = 1;i < n; i++){
            if(last + k < a[i] || i - ind  + 1 > c) {
                last = a[i];
                ind = i;
                ret++;
            }
        }
        out.println(ret);
    }
    public static int ni() throws IOException {
        return Integer.parseInt(ns());
    }
    public static long nl() throws IOException {
        return Long.parseLong(ns());
    }
    public static double nd() throws IOException {
        return Double.parseDouble(ns());
    }
    public static char nc() throws IOException {
        return ns().charAt(0);
    }
    public static BigInteger nextBigInteger() throws IOException {
        return new BigInteger(ns());
    }
    public static String ns() throws IOException {
        while(tok == null || !tok.hasMoreElements()){
            try {
                tok = new StringTokenizer(br.readLine());
            } catch (IOException e){
                throw new RuntimeException(e);
            }
        }
        return tok.nextToken();
    }
    public static int[] na(int n) throws IOException {
        int[] a = new int[n];
        for(int i = 0;i < n; i++){
            a[i] = ni();
        }
        return a;
    }
    public static long[] nal(int n) throws IOException {
        long[] a = new long[n];
        for(int i = 0;i < n; i++){
            a[i] = nl();
        }
        return a;
    }
    public static char[] ns(int n) throws IOException {
        return ns().substring(0,n).toCharArray();
    }
    public static char[][] nm(int n, int m) throws IOException{
        char[][] map = new char[n][];
        for(int i = 0;i < n; i++){
            map[i] = ns(m);
        }
        return map;
    }
}

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int arr[3][3];
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	int N;
	cin>>N;
	map<int,int> Hash;
	while(N--)
	{
		int x;
		cin>>x;
		Hash[x]++;
	}
	int FLAG=0;
	for(int i=0;i<3;i++)
	{
		if(Hash[arr[i][i]]==0)
		{
			FLAG=1;
			break;
		}
	}
	if(FLAG==0)
		cout<<"Yes";
	else
	{
		FLAG=0;
		for(int i=0;i<3;i++)
		{
			if(Hash[arr[i][2-i]]==0)
			{
				FLAG=1;
				break;
			}
		}
		if(FLAG==0)
			cout<<"Yes";
		else
		{
			FLAG=0;
			for(int i=0;i<3;i++)
			{ 	
				FLAG=0;
				for(int j=0;j<3;j++)
				{
					if(Hash[arr[i][j]]==0)
					{
						FLAG=1;
						break;
					}
				}
				if(FLAG==0)
				{
					break;
				}
			}
			if(FLAG==0)
			{
				cout<<"Yes";
			}
			else
			{
				FLAG=0;
				for(int i=0;i<3;i++)
				{
					FLAG=0;
					for(int j=0;j<3;j++)
					{
						if(Hash[arr[j][i]]==0)
						{
							FLAG=1;
							break;
						}
					}
					if(FLAG==0)
						break;
				}
				if(FLAG==0)
					cout<<"Yes";
				else
					cout<<"No";
			}
		}
	}

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main {

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

	static int matrix[][];
	static int color[][];
	static int dist[][];

	static Queue<Integer> queueX = new ArrayDeque<>();
	static Queue<Integer> queueY = new ArrayDeque<>();

	static final int WHITE = 0;
	static final int GRAY = 1;
	static final int BLACK = 2;

	static final int MATRIX = 200;

	static int count = 0;
	static int t;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String str[] = br.readLine().split(" ");
			t = Integer.parseInt(str[0]);
			int n = Integer.parseInt(str[1]);

			if (t == 0 && n == 0)
				break;

			matrix = new int[MATRIX][MATRIX];
			color = new int[MATRIX][MATRIX];
			dist = new int[MATRIX][MATRIX];

			queueX = new ArrayDeque<>();
			queueY = new ArrayDeque<>();

			for (int i = 0; i < n; i++) {
				str = br.readLine().split(" ");
				int x = Integer.parseInt(str[0]) + 100;
				int y = Integer.parseInt(str[1]) + 100;
				matrix[y][x] = -1;
			}
			str = br.readLine().split(" ");
			int sx = Integer.parseInt(str[0]) + 100;
			int sy = Integer.parseInt(str[1]) + 100;
			count = 1;
			bfs(sx, sy);
			System.out.println(count);
		}
	}

	static void bfs(int x, int y) {
		queueX.add(x);
		queueY.add(y);
		for (int i = 0; i < MATRIX; i++) {
			for (int j = 0; j < MATRIX; j++) {
				dist[i][j] = Integer.MAX_VALUE;
				color[i][j] = WHITE;
			}
		}
		color[y][x] = GRAY;
		dist[y][x] = 0;

		int a, b;

		while (!queueX.isEmpty() && !queueY.isEmpty()) {
			a = queueX.poll();
			b = queueY.poll();

			for (int i = 0; i < 6; i++) {
				int nx = a + dx[i];
				int ny = b + dy[i];

				if (nx >= 0 && nx < MATRIX && ny >= 0 && ny < MATRIX) {
					if (matrix[ny][nx] == -1)
						continue;
					if (color[ny][nx] == WHITE) {
						dist[ny][nx] = dist[b][a] + 1;
						if (dist[ny][nx] <= t) {
							color[ny][nx] = GRAY;
							queueX.add(nx);
							queueY.add(ny);
							count++;
						}
					}
				}
			}
			color[b][a] = BLACK;
		}
	}
}


Measured memory_bytes: 82848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	private static final String[] card = new String[]{
			"S 1", "S 2", "S 3", "S 4", "S 5", "S 6", "S 7", "S 8", "S 9", "S 10", "S 11", "S 12", "S 13",
			"H 1", "H 2", "H 3", "H 4", "H 5", "H 6", "H 7", "H 8", "H 9", "H 10", "H 11", "H 12", "H 13",
			"C 1", "C 2", "C 3", "C 4", "C 5", "C 6", "C 7", "C 8", "C 9", "C 10", "C 11", "C 12", "C 13",
			"D 1", "D 2", "D 3", "D 4", "D 5", "D 6", "D 7", "D 8", "D 9", "D 10", "D 11", "D 12", "D 13"
	};

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		List<String> list = new ArrayList<String>();

		for (String str : card) {
			list.add(str);
		}

		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			list.remove(br.readLine());
		}

		for (String string : list) {
			sb.append(string).append("\n");
		}

		System.out.print(sb);
	}
}

Measured memory_bytes: 24212
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

from itertools import combinations

def main():
    n = II()
    initials = ['M', 'A', 'R', 'C', 'H']
    names = {name: [] for name in initials}
    for i in range(n):
        s = IS()
        if not s[0] in initials: continue
        names[s[0]].append(s)
    cnt = 0
    for a,b,c in combinations(initials, 3):
        cnt += len(names[a])*len(names[b])*len(names[c])
    print(cnt)

if __name__ == '__main__':
    main()


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

using namespace std;
int main(){
#ifdef LOCAL_EXEC
#else
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#endif // LOCAL_EXEC
long long int n,k,i,j,x,y,z,mod=998244353;
cin>>n>>k;
vector<pair<long long int,long long int> >vt;
long long int dp[n+1]={0};
for(i=1;i<=k;i++){
    cin>>x>>y;
    vt.push_back({x,y});
}
sort(vt.begin(),vt.end());
dp[1]=1;
for(i=2;i<=n;i++){
    dp[i]=dp[i-1]%mod;
    for(j=0;j<vt.size();j++){
        if(i>vt[j].first)
            dp[i]+=(dp[i-vt[j].first]+mod-dp[max(0ll,i-vt[j].second-1)]+mod)%mod;
    }
    dp[i]%=mod;
   // cout<<dp[i]<<" ";

}
cout<<(dp[n]-dp[n-1]+mod)%mod;
}


Measured memory_bytes: 5156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll n, m;
    cin >> n >> m;

    vector<ll> x;
    for (int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        x.push_back (temp);
    }

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    sort(ALL(x));

    vector<ll> dx;
    for (int i = 0; i < m-1; i++) {
        dx.push_back (x[i+1] - x[i]);
    }

    sort(ALL(dx));

    for (int i = 0; i < m - n; i++) {
        ans += dx[i];
    }

    cout << ans << endl;


    

}

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

static const int MARGIN = 1;

int main() {
	int n;
	int table[1024][1024];
	vector<string> map;

	while(cin >> n, n) {
		int ans = 0;
		// init;
		for(int i = 0; i < 1024; i++)
			for(int j = 0; j < 1024; j++)
				table[i][j] = 0;
		map.clear();

		// input;
		for(int i = 0; i < n; i++) {
			string tmp;
			cin >> tmp;
			map.push_back(tmp);
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(map[i][j] == '.') {
					int tmp;
					tmp = min(table[i - 1 + MARGIN][j + MARGIN], table[i + MARGIN][j - 1 + MARGIN]);
					if(map[i - tmp][j - tmp] == '.') 
						table[i + MARGIN][j + MARGIN] = tmp + 1;
					else
						table[i + MARGIN][j + MARGIN] = tmp;
					if(table[i + MARGIN][j + MARGIN] > ans)
						ans = table[i + MARGIN][j + MARGIN];
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 6236
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[10];
bool cmp(int a,int b)
{
	return a>b;
}
int k;
int main()
{
	for(int i=0;i<3;i++)
		cin>>a[i];
	cin>>k;
	sort(a,a+3,cmp);
	for(int i=0;i<k;i++)
	{
		a[0]*=2;
	}
	cout<<a[0]+a[1]+a[2];
    return 0;
}


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

int main(){
	string W,T;
	int cnt=0;

	cin >> W;
    for(int i=0;i<W.size(); i++)W[i] = tolower(W[i]);
	while(1){
		cin >> T;
		if(T == "END_OF_TEXT")break;
		for(int i=0;i<T.size(); i++)T[i] = tolower(T[i]);
		if(T == W)cnt++;
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3148
using System;
using System.Linq;

namespace abc094_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = 0; int c = 0;
            for (int i = 0; i < x[1]; i++)
            {
                if (a[i] < x[2]) b++;
                else c++;
            }
            Console.WriteLine(Math.Min(b, c));
        }
    }
}

Measured memory_bytes: 13268
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main(N, M, K, AB, CD):
    friend_chain = UnionFindTree(N)
    friend_count = [0] * N
    block_count = [0] * N
    for a, b in AB:
        a, b = a - 1, b - 1
        friend_chain.union(a, b)
        friend_count[a] += 1
        friend_count[b] += 1
    for c, d in CD:
        c, d = c - 1, d - 1
        if friend_chain.same(c, d):
            block_count[c] += 1
            block_count[d] += 1
    print(*[friend_chain.size(i) - 1 - friend_count[i] - block_count[i] for i in range(N)])

class UnionFindTree:
    def __init__(self, n: int) -> None:
        self.parent = [-1] * n

    def find(self, x: int) -> int:
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x: int, y: int) -> bool:
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return False
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x
        return True

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def size(self, x: int) -> int:
        return -self.parent[self.find(x)]

    def same_all(self, indices: Iterable[int]) -> bool:
        f, v = self.find, self.find(indices[0])
        return all(f(i) == v for i in indices)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(M)]
    CD = [tuple(map(int, input().split())) for _ in range(K)]
    main(N, M, K, AB, CD)


Measured memory_bytes: 107104
n = gets.to_s.to_i

ans = n
(n+1).times do |i|
  
  c = 0
  t = i
  while t > 0
    c += t%6
    t /= 6
  end
  
  t = n-i
  while t > 0
    c += t%9
    t /= 9
  end
  
  ans = c if ans > c
end

puts ans

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

using namespace std;

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;
    if (a > b) return cout << 0 << endl, 0;
    if (n == 1) return cout << (a == b) << endl, 0;
    cout << 1LL * (b - a) * (n - 2) + 1 << endl;
}


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

int main(){
   int N;
   string S;
   cin >> N >> S;
   ll r=0, g=0, b=0;
   for (auto c : S){
      if (c=='R') r++;
      if (c=='G') g++;
      if (c=='B') b++;
   }
   ll sum = r*g*b;

   for(int i=0;i<N-2;i++){
      for(int j=i+1;(2*j-i)<N;j++){
         int k = 2*j-i;
         if(k<N){
            if((S[k] != S[i]) and (S[k] != S[j]) and (S[i] != S[j])){
               sum--;
            }
         }
      }
   }
   cout << sum << endl;
   return 0;  
}

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

using namespace std; 
const int MAX_N = 100005; 
int dp[MAX_N]; 
int h[MAX_N]; 
int n; 

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n); 
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]); 
	}

	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]); 
		if (i > 2) {
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])); 
		}
	}

	printf("%d", dp[n]); 
	return 0; 
}

Measured memory_bytes: 1024