akhauriyash/Code-Regression huggingface dataset:
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

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

void solve() {
    ll n, p; string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2) {
        ll k = 0;
        for (int i = 0; i < n; ++i) {
            int d = s[i] - '0';
            if (d & 1) continue;
            ans += i + 1;
        }
        cout << ans << '\n';
        return;
    }
    if (p == 5) {
        ll k = 0;
        for (int i = 0; i < n; ++i) {
            int d = s[i] - '0';
            if (d == 5 || d == 0) ans += i + 1;
        }
        cout << ans << '\n';
        return;
    }
    ll q = 1, r = 0;
    map<ll, ll> m;
    m[0] = 1;
    for (int i = n - 1; i >= 0; --i) {
        ll d = s[i] - '0';
        r += d * q; r %= p;
        ++m[r];
        q *= 10; q %= p;
    }
    for (auto &pa: m) {
        ans += pa.second * (pa.second - 1) / 2;
    }
    cout << ans << '\n';
}

int main() {
    fast_io; cin_exception;
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}


Measured memory_bytes: 1044
s=input()
q=int(input())
s1="";s2=""
adds=[s1,s2]
sta=0
for i in range(q):
    a=tuple(input().split(" "))#;print(a)
    if a[0]=="1":
        sta^=1
    else:
        if a[1]=="1":
            if not sta:
                s1=a[2]+s1
            else:
                s2+=a[2]
        if a[1]=="2":
            if sta:
                s1=a[2]+s1
            else:
                s2+=a[2]                
ans=s1+s+s2
#print(s1,s,s2)
if sta:
    print(ans[::-1])
else:print(ans)


Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
typedef double db;
const int MX=1000;
ll mod=1e9+7;
ll g[MX+5][MX+5];
string s[MX+5];
int main()
{
    FasterIO;
    int i,j,k,n,m,x,y;
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>s[i];
    n--;
    m--;
    if(s[n][m]=='.')g[n][m]=1;
    for(j=m-1;j>=0;j--)
    {
        if(s[n][j]=='#')continue;
        g[n][j]=g[n][j+1];
    }
    for(j=n-1;j>=0;j--)
    {
        if(s[j][m]=='#')continue;
        g[j][m]=g[j+1][m];
    }
    n--;
    m--;
    for(i=n;i>=0;i--)
    {
        for(j=m;j>=0;j--)
        {
            if(s[i][j]=='#')continue;
            g[i][j]=(g[i][j+1]+g[i+1][j])%mod;
        }
    }
    cout<<g[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 9216
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    l <- take 2 . sort . map strToInt . words <$> getLine
    -- 出力
    putStrLn . show . sum $ l


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

using ll=long long;
const ll INF=1e15;
void cmax(ll& x,ll y){
    x=max(x,y);
}
ll knapsack(int N,int W,vector<ll> w,vector<ll> v){
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            cmax(dp[i+1][j],dp[i][j]);
            if(j+w[i]<=W) cmax(dp[i+1][j+w[i]],dp[i+1][j]+v[i]);
        }
    }
    return *max_element(dp[N].begin(),dp[N].end());
}
int main(){
    int n,m,w,t;
    cin>>n>>m>>w>>t;
    vector<string> s(m);
    vector<ll> v(m),p(m);
    for(int i=0;i<m;i++){
        cin>>s[i]>>v[i]>>p[i];
    }
    vector<int> l(n),x(n),y(n);
    vector<vector<string>> r(n);
    vector<vector<ll>> q(n);
    for(int i=0;i<n;i++){
        cin>>l[i]>>x[i]>>y[i];
        r[i].resize(l[i]),q[i].resize(l[i]);
        for(int j=0;j<l[i];j++) cin>>r[i][j]>>q[i][j];
    }
    vector<ll> income(1<<n,0);
    for(int bit=0;bit<(1<<n);bit++){
        vector<ll> wv,vv;
        for(int i=0;i<n;i++){
            if((bit>>i)&1){
                for(int j=0;j<l[i];j++){
                    for(int k=0;k<m;k++){
                        if(r[i][j]==s[k]){
                            wv.push_back(v[k]);
                            vv.push_back(p[k]-q[i][j]);
                        }
                    }
                }
            }
        }
        income[bit]=knapsack(wv.size(),w,wv,vv);
    }
    
    vector<ll> tourDist(1<<n,INF);
    {
       vector<vector<ll>> dp(1<<n,vector<ll>(n,INF));
       auto dist=[&](int i,int j){
           return abs(x[i]-x[j])+abs(y[i]-y[j]);
       };
       for(int i=0;i<n;i++) dp[1<<i][i]=abs(x[i])+abs(y[i]);
       for(int bit=0;bit<(1<<n);bit++){
           for(int i=0;i<n;i++){
               tourDist[bit]=min(tourDist[bit],dp[bit][i]+abs(x[i])+abs(y[i]));
               for(int j=0;j<n;j++){
                   dp[bit|(1<<j)][j]=min(dp[bit|(1<<j)][j],dp[bit][i]+dist(i,j));
               }
           }
       }
    }

    cout<<knapsack(1<<n,t,tourDist,income)<<endl;
    return 0;
}


Measured memory_bytes: 13208
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve()
{
    int N, K; cin >> N >> K;
    bool K_is_even = (K%2==0);

    LL n_rem0 = 0;
    LL n_rem2 = 0;

    REP1(i, N)
    {
        if (i%K ==  0 ) n_rem0++;
        else if (K_is_even and i%K == K/2) n_rem2++;
    }
    cout << n_rem2 * n_rem2 * n_rem2 + n_rem0 * n_rem0 * n_rem0 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int u,k,v;
    int A[100][100]={{}};
    for(int i=0;i<n;i++){
         cin>>u>>k;
         if(k!=0){
             for(int i=0;i<k;i++){
                cin>>v;
                A[u-1][v-1]=1;
             }
         }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
            cout<< A[i][j];
            }
            else{
                cout<<" "<<A[i][j];
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3120
day = strip(readline())
if day == "SUN"
    println(7)
elseif day == "MON"
    println(6)
elseif day == "TUE"
    println(5)
elseif day == "WED"
    println(4)
elseif day == "THU"
    println(3)
elseif day == "FRI"
    println(2)
elseif day == "SAT"
    println(1)
end

Measured memory_bytes: 169004
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    cout << A - (S == U) << " " << B - (T == U) << endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>

int bubbleSort(int *numbers, int array_size)
{
  int i, j, temp,count=0;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {
      
      if (numbers[j-1] > numbers[j]) {
	count++;
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
  return count;
}

int main(){
  int array_size,i,count;
  int *numbers;

  scanf("%d",&array_size);

  numbers = (int *)malloc(sizeof(int) * array_size);

  for(i = 0;i<array_size;i++){
    scanf("%d",&numbers[i]);
  }

  count = bubbleSort(numbers,array_size);

  for(i = 0;i<array_size;i++){
    if(i == array_size - 1)
      printf("%d\n",numbers[i]);
    else
      printf("%d ",numbers[i]);
  }

  printf("%d\n",count);

  return 0;
  
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    if(n<=2*m) printf("0");
    else printf("%d\n",n-2*m);
    return 0;
}


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

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

struct Read {
	long long operator()(void) {
		long long d;
		std::cin >> d;
		return d;
	}
}read;
struct ReadReal {
	double operator()(void) {
		double d;
		std::cin >> d;
		return d;
	}
}readReal;
struct ReadString {
	std::string operator()(void) {
		std::string s;
		std::cin >> s;
		return s;
	}
}readString;

struct Print {
	void operator()(double d, int digit) {
		std::cout << std::fixed << std::setprecision(digit) << d;
	}
	template <typename T>
	void operator()(T t) {
		std::cout << t;
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		if (v.empty()) return;
		Print()(v[0]);
		for(int i = 1;  i < v.size(); ++i) {
			Print()(sep);
			Print()(v[i]);
		}
		return;
	}
	template <typename T1, typename T2>
	void operator()(const std::vector<pair<T1, T2>> &v,
			const string &pair_sep = " ", const string &elem_sep = " ") {
		if (v.empty()) return;
		Print()(v[0].first);
		Print()(pair_sep);
		Print()(v[0].second);
		for(int i = 1;  i < v.size(); ++i) {
			Print()(elem_sep);
			Print()(v[i].first);
			Print()(pair_sep);
			Print()(v[i].second);
		}
		return;
	}
}print;
struct Println {
	void operator()(void) {
		std::cout << std::endl;
	}
	void operator()(double d, int digit) {
		print(d, digit);
		Println()();
	}
	template <typename T>
	void operator()(T t) {
		print(t);
		Println()();
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		print(v, sep);
		Println()();
	}
	template <typename T1, typename T2>
	void operator()(const std::vector<pair<T1, T2>> &v,
			const string &pair_sep = " ", const string &elem_sep = " ") {
		print(v, pair_sep, elem_sep);
		Println()();
	}
}println;

bool SelectionSort(vector<string> *vec) {
	auto &v = *vec;
	bool is_stable = true;
	REP(i, v.size()) {
		int minj = i;
		FOR(j, i + 1, v.size()) {
			if (v[minj][1] > v[j][1]) {
				minj = j;
			}
		}
		FOR(j, i + 1, minj) {
			if (v[i][1] == v[j][1]) {
				is_stable = false;
			}
		}
		swap(v[i], v[minj]);
	}
	return is_stable;
}
bool BubbleSort(vector<string> *vec) {
	auto &v = *vec;
	bool is_stable = true;
	REP(i, v.size()) {
		for(int j = v.size() - 1; j >= i + 1; --j) {
			if (v[j - 1][1] > v[j][1]) {
				swap(v[j - 1], v[j]);
				if (v[j - 1][1] == v[j][1]) {
					is_stable = false;
				}
			}
		}
	}
	return is_stable;
}

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

	auto size = read();
	vector<string> v_bubble;
	v_bubble.reserve(size);
	REP(i, size) {
		v_bubble.emplace_back(readString());
	}
	vector<string> v_selection(v_bubble);

	auto is_stable = [](bool result)
		{ return result ? "Stable" : "Not stable"; };
	bool result_v = BubbleSort(&v_bubble);
	println(v_bubble);
	println(is_stable(result_v));

	bool result_s = SelectionSort(&v_selection);
	println(v_selection);
	println(is_stable(result_s));

	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
struct Coordinate {
	int x, y;
	Coordinate operator+(const Coordinate that) const {
		return Coordinate{ x + that.x, y + that.y };
	}
};

constexpr std::array<Coordinate, 4> direction{ Coordinate{1, 0}, Coordinate{-1, 0}, Coordinate{0, 1}, Coordinate{0, -1} };
int count_route(const Coordinate current, const int delivered, const std::vector<std::vector<int>>& state) {
	int count{ 0 };
	for (const auto dir : direction) {
		for (auto next = current + dir; 0 <= next.x && next.x < state.size() && 0 <= next.y && next.y < state[next.x].size(); next = next + dir) {
			if (state[next.x][next.y] == -1) {
				if (delivered == 0) {
					++count;
				}
			}
			else if (state[next.x][next.y] > 0) {
				if ((delivered & (1 << (state[next.x][next.y] - 1))) != 0) {
					count += count_route(next, delivered ^ (1 << (state[next.x][next.y] - 1)), state);
					break;
				}
			}
		}
	}
	return count;
}
int main() {
	int m, n; std::cin >> m >> n;
	while (m != 0 && n != 0) {
		std::vector<std::vector<int>> state(n, std::vector<int>(m));
		for (auto& line : state) for (auto& cell : line) std::cin >> cell;
		Coordinate start{ -1, -1 };
		int count{ 0 };
		for (auto i = 0; i < n; ++i) {
			for (auto j = 0; j < m; ++j) {
				if (state[i][j] == 2) {
					start = Coordinate{ i, j };
					state[i][j] = -1;
				}
				if (state[i][j] == 1) {
					state[i][j] = ++count;
				}
			}
		}
		std::cout << count_route(start, (1 << count) - 1, state) << '\n';
		std::cin >> m >> n;
	}
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  string s;
  cin >> s;

  while(1){
    if(sz(s) == 0) break;

    //cout << s << endl;

    bool ok = false;
    string t = s.substr(sz(s)-5);
    string u = "";
    string v = "";
    if(sz(s) >= 6) u = s.substr(sz(s)-6);
    if(sz(s) >= 7) v = s.substr(sz(s)-7);
    if(t == "dream" || t == "erase"){
      ok = true;
      s.erase(s.begin()+sz(s)-5, s.end());
    }else if(u == "eraser"){
      ok = true;
      s.erase(s.begin()+sz(s)-6, s.end());
    }else if(v == "dreamer"){
      ok = true;
      s.erase(s.begin()+sz(s)-7, s.end());
    }

    if(!ok){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int n,m;
  while( cin >> n >> m , n && m ){

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

    sort( ve , ve + n );

    /*  for( int i = 0 ; i < n ; i++ ){
      cout << ve[i] << " ";
    }
    cout << endl;
    */

    int sum = 0;
    int cnt = 1;
    for( int i = n - 1 ; i >= 0 ; i-- ){
      if( cnt == m ){
	cnt = 0;
      }
      else sum += ve[i];
      cnt++;
    }
    
    cout << sum << endl;

  }
  return 0;
}

Measured memory_bytes: 1180
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

n = getN()

nums = []
for i in range(n):
    nums.append(getN())

mx = 0
nxt = -1
dup = 1
for num in nums:
    if num == mx:
        dup += 1
    elif num > mx:
        nxt = mx
        mx = num
        dup = 1
    else:
        if num > nxt:
            nxt = num

if dup >= 2:
    for i in range(n):
        print(mx)

else:
    for num in nums:
        if num == mx:
            print(nxt)
        else:
            print(mx)


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int ans=0;
    rp(i,101){
        if(a<=i&&i<=b&&c<=i&&i<=d){
            ans ++;
        }
    }
    cout << (ans!=0?ans-1:0) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (1e9)

struct Node { int key; Node *prev, *next; };

Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  x->prev = nil;
  nil->next = x;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void deleteNode(Node* t) {
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int n) {
  deleteNode(listSearch(n));
}

int main() {
  int n, x;
  string str;
  cin >> n;

  init();

  while(n--) {
    cin >> str;
    if(str == "insert") {
      cin >> x;
      insert(x);
    } else if(str == "delete") {
      cin >> x;
      deleteKey(x);
    } else if(str == "deleteFirst") {
      deleteFirst();
    } else {
      deleteLast();
    }
  }

  Node *cur = nil->next;
  cout << cur->key;
  cur = cur->next;
  while(cur != nil) {
    cout << " " << cur->key;
    cur = cur->next;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 34452
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

ll X,Y,Z;
vector<ll> A,B,C;
ll l_max[300010];
ll r_max[300010];

int main() {

    cin >> X >> Y >> Z;
    A.resize(X + Y + Z);
    B.resize(X + Y + Z);
    C.resize(X + Y + Z);

    REP(i, X + Y + Z) cin >> A[i] >> B[i] >> C[i];

    vector< pair<ll,ll> > Gold;
    REP(i, X + Y + Z) Gold.push_back(make_pair(A[i] - B[i], i));
    sort(Gold.begin(), Gold.end());
    reverse(Gold.begin(), Gold.end());

    priority_queue< pair<ll,ll> > que1;
    ll sum = 0;
    REP(i,X) {
        que1.push(make_pair(C[Gold[i].second] - A[Gold[i].second], Gold[i].second));
        sum += A[Gold[i].second];
    }
    l_max[X - 1] = sum;
    for (int i = X; i <= X + Z; i++) {
        que1.push(make_pair(C[Gold[i].second] - A[Gold[i].second],Gold[i].second));
        sum += A[Gold[i].second];
        sum -= A[que1.top().second];
        sum += C[que1.top().second];
        que1.pop();
        l_max[i] = sum;
    }

    priority_queue< pair<ll,ll> > que2;
    sum = 0;
    for (int i = X + Y + Z - 1; i >= X + Z; i--) {
        que2.push(make_pair(C[Gold[i].second] - B[Gold[i].second], Gold[i].second));
        sum += B[Gold[i].second];
    }
    r_max[X + Z] = sum;
    for (int i = X + Z - 1; i >= X; i--) {
        que2.push(make_pair(C[Gold[i].second] - B[Gold[i].second], Gold[i].second));
        sum += B[Gold[i].second];
        sum -= B[que2.top().second];
        sum += C[que2.top().second];
        que2.pop();
        r_max[i] = sum;
    }

    ll ans = 0;
    for (int i = X - 1; i < X + Z; i++) {
        ans = max(ans, l_max[i] + r_max[i + 1]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9328
let id x = x

let read_ints =
  let rec aux acc = function
    | 0 -> acc
    | n -> aux ((Scanf.scanf "%d " id) :: acc) (n-1) in
  aux []

let odd_sum =
  let rec aux acc = function
    | [] -> acc
    | hd1 :: hd2 :: tl -> aux (hd1 + acc) tl in
  aux 0

let () =
  let n = Scanf.scanf "%d\n" id in
  let l = read_ints (2*n) in
  print_int (odd_sum (List.sort compare l))


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int sol = 1e9;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin >> a;
        int k = 0;
        while (a % 2 == 0)
            a /= 2, k++;
        sol = min(sol, k);
    }
    cout << sol;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>

struct edge {
	int u, v, w;
};

int d, l, n, a[30];
std::vector<edge> ans;

int myLog(int x) {
	if (x == 1) return 1;
	return myLog(x/2) + 1;
}

int main() {
	scanf("%d", &l);
	n = myLog(l);
	a[n] = 0;
	for (int i = n - 1, j = 1; i > 0; i--, j *= 2) {
		ans.push_back({i, i+1, 0});
		ans.push_back({i, i+1, j});
		a[i] = a[i + 1] + j;
	}
	d = a[1];
	for (int i = 2; i <= n; i++) {
		if (d + 1 + a[i] < l) {
			ans.push_back({1, i, d+1});
			d += a[i] + 1;
		}
	}
	printf("%d %d\n", n, int(ans.size()));
	for (auto e: ans) {
		printf("%d %d %d\n", e.u, e.v, e.w);
	}
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision
using namespace std;

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

  if(T * S < D) {
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

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

  ll a, b, x;
  std::cin >> a >> b >> x;

  ll cnt1 = b / x;
  ll cnt2 = a == 0 ? -1 : (a - 1) / x;

  ll ans = cnt1 - cnt2;
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &v[i])
	}

	sort.Ints(v)
	sum := float64(v[0])
	for i := 1; i < n; i++ {
		sum = (sum + float64(v[i])) / 2.0
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
#include<stdio.h>

#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int*,int,int,int,int);
void mergeSort(int*,int,int,int);

int main(){
  int A[MAX],n,i;
  cnt=0;

scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&A[i]);
mergeSort(A,n,0,n);
for(i=0;i<n;i++){
if(i)printf(" ");
printf("%d",A[i]);
  }
printf("\n");;
printf("%d\n",cnt);
  
  return 0;
}
void merge(int A[],int n,int left,int mid,int right){
int i,j=0,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=R[n2]=SENTINEL;
i=0;
  for(k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]){
      A[k]=L[i++];
    }
    else
      {
	A[k]=R[j++];
      }
  }
}

void mergeSort(int A[],int n,int left,int right){
  if(left+1<right){
    int mid=(left+right)/2;
    mergeSort(A,n,left,mid);
mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}



Measured memory_bytes: 5672
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt();
    if(Math.abs(x-a)>Math.abs(x-b)){
      System.out.println("B");
    }else{
      System.out.println("A");
    }
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> p(N), p_sorted(N);
    for (int i = 0; i < N; i++){
        cin >> p[i];
        p_sorted[i] = p[i];
    }

    sort(p_sorted.begin(), p_sorted.end());

    int cnt = 0;
    for (int i = 0; i < N; i++){
        if (p[i] != p_sorted[i]){
            cnt++;
        }
    }

    if (cnt == 0 || cnt == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            for (int i = 1; ; i++)
            {
                var read = Console.ReadLine();
                var num = int.Parse(read);
                if(num==0)
                {
                    break;
                }
                Console.WriteLine("Case " + i + ": " + num);
            }
        }
    }
}

Measured memory_bytes: 9312
#include<iostream>
#include<cassert>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps = 1e-10;
class Info{
public:
  int s,e,c,time;
  double consume;
  Info(){};
  Info(int ts,int te,int tc):s(ts),e(te),c(tc){
    consume=e-s;
    consume*=(double)c;
    time=e-s;
  };
};

double can_water(vector<Info >in,double L,double p,double ini){
  double vol=ini;
  int lasttime=0;//last time that scheduled
  rep(i,in.size()){
    vol=min(L,vol+(double)(in[i].s-lasttime)*p);
    vol=vol+in[i].time*p-in[i].consume;
    if ( vol<=eps)return -1;
    vol=min(vol,L);
    lasttime=in[i].e;
  }

  vol=vol+(86400-lasttime)*p;
  vol=min(vol,L);
  return vol;
}

double solve(vector<Info > &in,double L){
  double mini=0,maxi=100000000,ret=0,mid;
  while(mini+eps<maxi){
    double mid = (mini+maxi)/2;
    double day1=can_water(in,L,mid,L);
    if ( day1<=0){mini=mid+eps;continue;}
    
    double day2 = can_water(in,L,mid,day1);
    //printf("%.6lf %.6lf %.6lf\n",mid,day1,day2);
    if (day2>0 && day2-day1>=0)maxi=mid-eps,ret=mid;
    else mini=mid+eps;
  }
  assert(ret>0);
  return ret;
}

main(){
  int n,L;
  while(cin>>n>>L&&n){
    vector<Info> in;
    int s,t,c;
    rep(i,n){
      cin>>s>>t>>c;
      in.push_back(Info(s,t,c));
    }
    printf("%.8lf\n",solve(in,L));
  }
}

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

int main() {
string s;
cin>>s;
int ans=0;
if(s[0]=='1'){
    ans++;
}
if(s[1]=='1'){
    ans++;
}
if(s[2]=='1'){
    ans++;
}
cout<<ans<<endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int R;
	cin >> R;

	if(R < 1200){
		cout << "ABC" << endl;
	}
	else if(R < 2800){
		cout << "ARC" << endl;
	}
	else{
		cout << "AGC" << endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        String word = input.readLine();
        int max = -1;
        for (int i = 1; i < n; i++) {
            max = Math.max(max, getDistinct(word.substring(0, i), word.substring( i)));
        }
        System.out.println(max);
    }

    public static int getDistinct(String word1 ,String word2){
        HashSet<Character> wordFreq1 = new HashSet<>();
        for (char c : word1.toCharArray()) {
            wordFreq1.add(c);
        }
        HashSet<Character> wordFreq2 = new HashSet<>();
        for (char c : word2.toCharArray()) {
            wordFreq2.add(c);
        }
        wordFreq1.retainAll(wordFreq2);
        return wordFreq1.size();
    }
}


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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

void solve(){
    ll n, k;
    cin >> n >> k;
    n *= 500;
    if(n >= k){
    	cout << "Yes\n";
    }
    else{
    	cout << "No\n";
    }
}

int main(){
    IOS;
    //io_set();
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        solve();
    }
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
vector<bool> GetPrimeTable(int n)
{
	vector<bool> IsPrimeNumber(n+1, true);
	for(int i = 2; i <= n; i++){
		while(IsPrimeNumber[i] == false){
			i++;
		}
		for(int j = 2; i*j <= n; j++){
			IsPrimeNumber[i*j] = false;
		}
	}
	return IsPrimeNumber;
}

int GetPrimeCount(vector<bool>& IsPrimeNumber, int n)
{
	int Count = 0;
	for(int i = 2; i <= n; i++){
		if(IsPrimeNumber[i] == true){
			Count++;
		}
	}
	return Count;
}

int main()
{
	vector<int> Input;
	while(true){
		int Nubmer;
		cin >> Nubmer;
		if(cin.eof() == true) break;
		Input.push_back(Nubmer);
	}
	int MaxNumber = *std::max_element(Input.begin(), Input.end());
	vector<bool> IsPrimeNumber = GetPrimeTable(MaxNumber);
	for(int i = 0; i < Input.size(); i++){
		cout << GetPrimeCount(IsPrimeNumber, Input[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};
struct Node T[MAX];
int n;

//???????????????//
void preParse(int u){
  if(u == NIL)
    return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

//???????????????//
void inParse(int u){
   if(u == NIL)
     return;
   inParse(T[u].l);
   printf(" %d", u);
   inParse(T[u].r);
}

//???????????????//
void postParse(int u){
  if(u == NIL)
    return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;
  
  scanf("%d", &n);
  for(i =0; i<n; i++)
    T[i].p = NIL;
    
  for(i=0; i<n; i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)
      T[l].p = v;
    if(r != NIL)
      T[r].p = v;
  }
  
  for(i=0; i<n; i++)
    if(T[i].p == NIL)
      root = i;
  puts("Preorder");
  preParse(root);
  printf("\n");
  
  puts("Inorder");
  inParse(root);
  printf("\n");
  
  puts("Postorder");
  postParse(root);
  printf("\n");
  
  return 0;
}

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

using namespace std;

int main()
{
     int n,k,m,tmp1;

     string tmp2;

    cin>>n>>m;

    int sum1=0,sum2=0;

    vector<int> v(n,0);

    for(int i=0;i<m;i++)
    {
        cin>>tmp1>>tmp2;

        if(v[tmp1-1]!=-1)
        {
            if(tmp2=="AC")
            {
                sum1=sum1+1;
                sum2=sum2+v[tmp1-1];
                v[tmp1-1]=-1;


            }
            else
            {
                v[tmp1-1]++;

            }
        }


    }

    cout<<sum1<<" "<<sum2;



     return 0;
}


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

namespace ConsoleApp15
{
    class Class99
    {
        static void Main()
        {
            string S = Console.ReadLine();
            bool ans = true;
            for(int i = 0; i < S.Length - 1; i+=2)
            {
                if (S[i] == 'h' && S[i + 1] == 'i')
                { continue; }
                else
                {
                    ans = false;break;
                }
            }
            if (S.Length % 2 != 0) ans = false;
            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
int main() {
	int n;
	scanf("%d", &n);
	for (int i =3; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		for (; x; x /= 10) {
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
		}
	}
	putchar('\n');
}



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define uu unsigned
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define pi pair<int,int>
#define pl pair<ll,ll>
#define mkp make_pair
#define ss second
#define ff first
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define pb push_back
#define pf push_front
#define printcas cout<<"Case "<<cas<<": "
#define _ continue;
#define endl '\n'
#define __ cout<<endl;continue;
#define vc4d(nam,type,a,b,c,d,fix) vector<vector<vector<vector<type>>>> nam(a,vector<vector<vector<type>>>(b,vector<vector<type>>(c,vector<type>(d,fix))))
const ll oo=(1ll<<60);

int main()
{
     io;
    int T=1;
    //cin>>T;
    //for(int cas=1;cas<=T;cas++)
    while(T--)
    {
       string s;int cnt=0,ans=0,i;
       cin>>s;
       for(i=0;i<3;i++)
       {
           if(s[i]=='R')
           {
               cnt=0;
               while(i<3 and s[i]=='R')cnt++,i++;
               ans=max(cnt,ans);
           }
       }
       cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String[] NM = scan.nextLine().split(" ");
		String[] tmp;
		int[] road = new int[Integer.parseInt(NM[0])];
		for(int i = 0; i < road.length; i++){
			road[i] = 0;
		}
		for(int i = 0; i < Integer.parseInt(NM[1]); i++){
			tmp = scan.nextLine().split(" ");
			road[Integer.parseInt(tmp[0])-1]++;
			road[Integer.parseInt(tmp[1])-1]++;
		}
		for(int i = 0; i < road.length; i++){
			System.out.println(road[i]);
		}
	}
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll n,m,seg[530000];
void segstart(void){
    memset(seg,0,sizeof(seg));
    for(ll i=1;;i*=2){
        if(n<=i){m=i;break;}
    }
    m--;

    //for(ll i=m;i<n;i++)cin>>seg[i];
    for(int i=m-1;i>=0;i--){
        seg[i]=max(seg[2*i+1],seg[2*i+2]);
    }

}
ll ans(ll a,ll b){
    if(b==-1)return 0;
    ll ret=0;a+=m;b+=m;
    
    while(1){
        if(a==b){
            ret=max(ret,seg[a]);
            break;
        }
        if(b==a+1){
            ret=max(ret,seg[a]);
            ret=max(ret,seg[b]);
            break;
        }
        if(a%2)a/=2;
        else{
            ret=max(ret,seg[a]);
            a/=2;
        }
        if(b%2){
            ret=max(ret,seg[b]);
            b/=2;b--;
        }
        else{b/=2;b--;}
    }
    return ret;
}

void update(ll a,ll b){
    seg[a+m]=b+ans(0,a-1);
    a+=m;

    while(a){
        a=(a-1)/2;
        seg[a]=max(seg[2*a+1],seg[2*a+2]);
    }
}


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    ll h[n],a[n],dp[n+1][2];
    vector<pair<ll,ll> > v;
    for(int i=0;i<n;i++){
        cin>>h[i];
        h[i]--;
        v.pb(make_pair(h[i],i));
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    segstart();
    memset(dp,0,sizeof(dp));
    sort(be(v));
    ll b[n];
    for(int i=0;i<n;i++){
        b[i]=v[i].second;
    }
    for(int i=0;i<n;i++){
        update(b[i],a[b[i]]);
    }
    cout << ans(0,n) <<endl;

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int tot = 0;
  rep(i, 0, s.size()) tot += s[i] - '0';
  if (tot % 9 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;
int p;

int exp(string str);
int term(string str);
int fact(string str);

int exp(string str)
{
	int val = term(str);
	while(str[p] == '+' || str[p] == '-'){
		if(str[p++] == '+'){
			val += term(str);
		} else {
			val -= term(str);
		}
	}
	
	return val;
}

int term(string str)
{
	int val = fact(str);
	while(str[p] == '*' || str[p] == '/'){
		if(str[p++] == '*'){
			val *= fact(str);
		} else {
			val /= fact(str);
		}
	}
	
	return val;
}

int fact(string str)
{
	int val = 0;
	if(str[p] == '('){
		p++;
		val = exp(str);
		p++;
	} else {
		string s = "";
		while('0' <= str[p] && str[p] <= '9'){
			s += str[p++];
		}
		if(s.size() > 0){
			val = atoi(s.c_str());
		}
	}
	
	return val;
}

int main()
{
	int n;
	string str;
	
	while(cin >> n && n){
		while(n--){
			cin >> str;
			p = 0;
			cout << exp(str) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll b, ll n) { return (n < b ? n : f(b, n / b) + n % b); }
int main() {
    ll n, s;
    cin >> n >> s;
    if ( n == s ) { cout << n + 1 << endl; return (0); }
    for (ll i = 2; i * i <= n; i++) {
        if (f(i, n) == s) { cout << i << endl; return (0); }
    }
    for (ll i = ceil(sqrt(n)) - 1; i > 0; i--) {
        ll b = (n - s) / i + 1;
        if (b > 1 && f(b, n) == s) {cout << b << endl; return (0); }
    }
    cout << -1 << endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int seconds,h,m,s;
    scanf("%d",&seconds);
    h = seconds /3600;
    m = (seconds- h*3600) /60;
    s = seconds- h*3600 - m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2132
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;

int main(){
  int a,b,c;
  cin >>a>>b>>c;
  if((a<=c && c<=b) || (a>=c && c>=b)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main(int argc, char **argv)
{
    string s,result;
    cin>>s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'B'){
           if(result.size() > 0)
                result.pop_back();
            continue; 
        }
        else result.append(1,s[i]);
    }
    
    for(int i = 0;i < result.size();i++){
        cout<<result[i];
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << (char)toupper(s1.front()) << (char)toupper(s2.front()) << (char)toupper(s3.front()) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3592
r, c = [int(i) for i in input().strip().split()]
table = [[None] * (c + 1) for _ in range(r + 1)]

for i in range(r):
    line = [int(i) for i in input().strip().split()]
    for j in range(c):
        table[i][j] = line[j]

for i in range(c):
    _sum = 0
    for j in range(r):
        _sum += table[j][i]
    table[r][i] = _sum

for i in range(r+1):
    table[i][c] = sum(table[i][:c])

for line in table:
    print(" ".join([str(i) for i in line]))




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

int main() {

  while(1) {
    int n,k,m;
    cin >> n >> k >> m;
    if(n==0 && k==0 && m==0) break;

    vector <int> stn;
    for(int i=0;i<n;i++) stn.push_back(i+1);
    m--;
    int i=m;
    while(stn.size() != 1) {
      stn.erase(stn.begin()+i);
      i = (i+(k-1))%stn.size();
     }
    cout << stn[0] <<endl;
  }
  return 0 ;
}

Measured memory_bytes: 1324
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), K = in.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = in.nextInt();
		}
		Arrays.sort(h);
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= N - K; i++) {
			ans = Math.min(ans, h[i + K - 1] - h[i]);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49620
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

yokosen = []
for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            yokosen.append(h+1)
            break
yokosen.pop()
yokosen.append(H)

ans = [[0]*W for _ in range(H)]

n = 1
y = 0
for i in range(len(yokosen)):
    for w in range(W):
        flag = False
        for h in range(y, yokosen[i]):
            ans[h][w] = n
            if S[h][w] == "#":
                flag = True
                l = w
        if flag:
            n += 1
    
    for w in range(l+1, W):
        for h in range(y, yokosen[i]):
            ans[h][w] = n-1
    
    y = yokosen[i]

for r in ans:
    print(*r)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            vals = vals.OrderBy(x => x).ToArray();
            var prevcost = vals[0];
            var result = 0;
            for(var i=0; i<vals.Length; i++)
            {
                result += vals[i] - prevcost;
                prevcost = vals[i];
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13396