akhauriyash/Code-Regression huggingface dataset:
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int a[20], b[20], c[20];
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i], a[i]--;
  int ans = 0;
  for(int i = 0; i < n; i++) cin >> b[i], ans += b[i];
  for(int i = 0; i < n; i++) cin >> c[i];
  for(int i = 0; i + 1 < n; i++) if(a[i] + 1 == a[i + 1]) ans += c[a[i]];
  cout << ans << endl;
  return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#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)



int main(void){

	int N; cin >> N;

	int p = N/100;
	int x = 100*p+10*p+p;
	if(N<= x) cout << x << endl;
	else{
		cout << x+111 << endl;
	}
	return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
using namespace std;

int main() {
	string s,t;
	int N;
	cin >> N >> s >> t;
	int x = 0;
	for (int i = 1; i <= N; i++) {
		if (s.substr(N - i, i) == t.substr(0, i))x = i;
	}
	cout << 2 * N - x << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = std::vector<int>;
using VI2D = std::vector<vector<int>>;
using VLL = std::vector<long long>;
using VLL2D = std::vector<vector<long long>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T, std::size_t N>
struct make_vector_type {
	using type =
		typename std::vector<typename make_vector_type<T, (N - 1)>::type>;
};

template <typename T>
struct make_vector_type<T, 0> {
	using type = typename std::vector<T>;
};

template <typename T, size_t N>
auto make_vector_impl(const std::vector<std::size_t>& ls, T init_value) {
	if constexpr(N == 0) {
		return std::vector<T>(ls[N], init_value);
	} else {
		return typename make_vector_type<T, N>::type(
			ls[N], make_vector_impl<T, (N - 1)>(ls, init_value));
	}
}

template <typename T, std::size_t N>
auto make_vector(const std::size_t (&ls)[N], T init_value) {
	std::vector<std::size_t> dimensions(N);
	for(int i = 0; i < N; i++) {
		dimensions[N - i - 1] = ls[i];
	}
	return make_vector_impl<T, N - 1>(dimensions, init_value);
}

template <typename T>
std::vector<T> make_vector(std::size_t size, T init_value) {
	return std::vector<T>(size, init_value);
}

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max<T>(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min<T>(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int k;
	cin >> k;
	REP(i, k) { cout << "ACL"; }
	cout << endl;
	return 0;
}


Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc1 := bufio.NewScanner(os.Stdin)
	sc1.Split(bufio.ScanWords)
	sc1.Scan()
	num, _ := strconv.Atoi(sc1.Text())
	cache := make([]*int, num+1)
	fmt.Println(fib(num, cache))

}

func fib(n int, cache []*int) int {
	if n <= 1 {
		return 1
	}

 	if cache[n] != nil {
		return *(cache[n])
	}

	result := fib(n -2, cache) + fib(n -1, cache)
	cache[n] = &result
	return result
}


Measured memory_bytes: 1088
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  vll x(m);
  rep(i,m) cin>>x[i];
  sort(all(x));
  vll y(m-1);
  rep(i,m-1){
    y[i]=x[i+1]-x[i];
  }
  if(n==1){
    ll ans=0;
    rep(i,m-1){
      ans+=y[i];
    }
    COUT(ans);
  }
  else{
    sort(all(y));
    n--;
    ll ans=0;
    rep(i,m-1-n){
      ans+=y[i];
    }
    COUT(ans);
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n,k;
string str;
int main() {
    cin>>n>>k>>str;
    if (str[k-1]=='A') str[k-1]='a';
    if (str[k-1]=='B') str[k-1]='b';
    if (str[k-1]=='C') str[k-1]='c';
    cout<<str<<'\n';
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 100005
#define mp map<int,int>
using namespace std;
int d[N];
int main() {
	int n;
	cin>>n;
	rep(i,0,n)cin>>d[i];
	sort(d,d+n);
	cout<<d[n/2]-d[n/2-1];
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;


string Main(string S, string T)
{
    return T+S;
}

int main(void){
    string S, T;
    cin >> S >> T;
    cout << Main(S, T) << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == s.at(1) && s.at(0) == s.at(2)){
    cout << "Yes" <<endl;
  }
  else if(s.at(1) == s.at(2) && s.at(2) == s.at(3)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var X = cin.ReadInt;

            int count = 0;

            for(int ia = 0; ia <= A; ia++)
            {
                for(int ib = 0; ib<= B; ib++)
                {
                    for (int ic = 0; ic <= C; ic++)
                    {
                        if (500 * ia + 100 * ib + 50 * ic == X)
                        {
                            count++;
                        }
                    }
                }
            }




            WriteLine(count);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 27808
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

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

    vector<ll> sunuke = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    if (K <= 9) {
        for (int i = 0; i < K; i++) {
            cout << sunuke[i] << endl;
        }
        return 0;
    }
    ll now = 10;
    while ((int)sunuke.size() < K) {
        string s = to_string(now);
        int n = s.size();
        ll sum = 0;
        for (int j = 0; j < (int)s.size(); j++) {
            sum += (int)(s[j] - '0');
        }
        ll d = 1;
        for (int i = 0; i < n; i++) {
            //if (s[n - 1 - i] == '9') continue;
            if (now > sum * d) {
                int c = (int)(s[n - 1 - i] - '0');
                now += (ll)(9 - c) * d;
                sum += (9 - c);
                d *= 10;
                if (i == n - 1) {
                    sunuke.push_back(now);
                    now++;
                }
            } else {
                sunuke.push_back(now);
                now++;
                break;
            }
        }
    }
    for (auto a : sunuke) {
        cout << a << "\n";
    }
}


Measured memory_bytes: 256
def helper(h, n):
    prev = 0
    curr = abs(h[1]-h[0])
    for i in range(2, n):
        next = min(curr+abs(h[i]-h[i-1]), prev+abs(h[i]-h[i-2]))
        prev = curr
        curr = next
    return curr

def main():
    n = int(input())
    h = list(map(int, input().split(" ")))
    print(helper(h, n))

if __name__ == "__main__":
    main()

Measured memory_bytes: 13980
N,K = map(int,input().split())
num_list =list(map(int,input().split()))
sum_list = [0]
sum_di = []
sum = 0

for i in range(N):
    x= (num_list[i]+1)/2
#    print(x)
    sum =sum + x
    sum_list.append(sum)

for i in range(N-K+1):
    sum_di.append(sum_list[K+i]-sum_list[i])
#   print(sum_list)
#    print(sum_di)

print(max(sum_di))

Measured memory_bytes: 25060
#include <iostream>
#include <limits.h>

using namespace std;

int main()
{
	long long i, j, k, N, M, a[50], b[50], c[50], d[50], dis, ans[50];

	cin >> N; cin >> M;
	for (i = 0; i < N; i++) {
		cin >> a[i];
		cin >> b[i];
	}
	for (i = 0; i < M; i++) {
		cin >> c[i];
		cin >> d[i];
	}

	for (i = 0; i < N; i++) {
		long long min = LLONG_MAX;
		for (j = 0; j < M; j++) {
			dis = llabs(a[i] - c[j]) + llabs(b[i] - d[j]);
			if (min > dis) {
				min = dis;
				ans[i] = j+1;
			}
		}
	}

	for (i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;
const int maxn = 2e5 + 10;
int a[2][maxn];
int s[2][maxn];
int f(int x, int *p) {
  return x == p[x] ? x : p[x] = f(p[x], p);
}
int n, k, l;
void join(int x, int y, int *p, int *s) {
  p[y] = x;
}
int main() {
  scanf("%d%d%d", &n, &k, &l);
  REPE(i, 1, n) {
    a[0][i] = a[1][i] = i;
  }
  REP(i, k) {
    int u, v;
    scanf("%d%d", &u, &v);
    int fa = f(u, a[0]);
    int fb = f(v, a[0]);
    if (fa != fb) join(fa, fb, a[0], s[0]);
  }
  REP(i, l) {
    int u, v;
    scanf("%d%d", &u, &v);
    int fa = f(u, a[1]);
    int fb = f(v, a[1]);
    if (fa != fb) join(fa, fb, a[1], s[1]);
  }
  map<pair<int, int>, int> m;
  REPE(i, 1, n) {
    int fa = f(i, a[0]);
    int fb = f(i, a[1]);
    m[{fa, fb}]++;
  }
  REPE(i, 1, n) {
    int fa = f(i, a[0]);
    int fb = f(i, a[1]);
    int ans = m[{fa, fb}];
    printf("%d%c", ans, " \n"[i == n]);
  }
  return 0;
}



Measured memory_bytes: 13696
n, k = (int(i) for i in input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

ans = float('inf')
for i in range(n-k+1):
    if ans > hl[i+k-1] - hl[i]:
        ans = hl[i+k-1] - hl[i]
print(ans)

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

const int INF = 1e9;

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

  int N, L; cin >> N >> L;
  vector<int> a(N); for (int i = 0; i < N; ++i) cin >> a[i];
  deque<int> deq;
  for (int i = 0; i < N; ++i) {
    while (!deq.empty() && a[deq.back()] >= a[i]) deq.pop_back();
    deq.push_back(i);

    if (i >= L - 1) {
      if (i != L - 1) cout << ' ';
      cout << a[deq.front()];
    }
    if (deq.front() == i - L + 1) deq.pop_front();
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 6804
#include <iostream>
#include <set>

#define MOD 1000000007
#define N   100000


using ll = long long;

ll dp[N+1];

int main() {
    std::set< int > a;
    int n, m;

    std::cin >> n >> m;
    for (int i=0; i<m; ++i) {
        int tmp;
        std::cin >> tmp;
        a.insert(tmp);
    }
    dp[0] = 1;
    dp[1] = (a.find(1) != a.end()) ? 0LL : 1LL;
    for (int i=2; i<=n; ++i) {
        if (a.find(i) == a.end()) {
            dp[i] = dp[i-1] + dp[i-2];
            dp[i] %= MOD;

        } else {
            dp[i] = 0;
        }
    }
    std::cout << dp[n] << std::endl;

    return 0;
}


Measured memory_bytes: 5760
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

ll calc(ll n, ll b) {
    if (n < b) return n;
    return calc(n/b, b) + n%b;
}

ll solve(ll n, ll s) {
    for (ll i = 2; i*i <= n; i++) {
        if (calc(n, i) == s) {
            return i;
        }
    }
    vector<ll> cand;
    for (ll i = 1; i*i <= n-s; i++) {
        if ((n-s)%i == 0) cand.push_back((n-s)/i+1);
    }
    sort(cand.begin(), cand.end());
    for (ll el : cand) {
        if (calc(n, el) == s) return el;
    }
    if (n == s) {
        return n+1;
    }
    return -1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, s;
    cin >> n >> s;
    cout << solve(n, s) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
h = LI()
dp = [float('INF')]*N
dp[0],dp[1] = 0,abs(h[1]-h[0])
for i in range(2,N):
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]))
print(dp[-1])


Measured memory_bytes: 13928
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, m, l, row, col, tmp;
    cin >> n >> m >> l;
    row = n;
    col = m;
    int A[n][m], B[m][l];
    for (int i=0; i<2; i++){
        if (i == 1){
            row = m;
            col = l;
        }
        for (int j=0; j<row; j++){
            for (int k=0; k<col; k++){
                scanf("%d", &tmp);
                if (i == 0) A[j][k] = tmp;
                else B[j][k] = tmp;
            }
        }
    }
    long long int sum;
    for (int i=0; i<n; i++){
        for (int j=0; j<l; j++){
            sum = 0;
            for (int k=0; k<m; k++){
                sum += A[i][k] * B[k][j];
            }
            printf("%lld", sum);
            if (j < l-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 3272
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    string s;
    cin>>s;

    for (int64 i = 0; i < s.length(); i++)
    {
        cout<<"x";
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] s = new String[n];
        Arrays.setAll(s, i -> sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int countEndA = 0;
        int countStartB = 0;
        int countEndAStartB = 0;
        for (int i = 0; i < n; i++) {
            String replaced = s[i].replace("AB", "");
            result += (s[i].length() - replaced.length()) / 2;
            boolean isEndA = replaced.endsWith("A");
            boolean isStartB = replaced.startsWith("B");
            if (isEndA && isStartB) {
                countEndAStartB++;
                countEndA++;
                countStartB++;
            } else {
                if (isEndA) {
                    countEndA++;
                }
                if (isStartB) {
                    countStartB++;
                }
            }
        }
        if (0 < countEndA && 0 < countStartB && countEndA == countStartB) {
            if (countEndA == countEndAStartB) {
                result += countEndAStartB - 1;
            } else {
                result += countEndA;
            }
        } else {
            result += Math.min(countEndA, countStartB);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 43584
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(ll i=j;i<k;i+=in)
#define DF(i,j,k,in) for(ll i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); it++)
#define fitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2;it+=in)
#define Dfeach(it,l,in) for (auto it = l.end()-1; it != l.begin()-1; it-=in)
#define Dfitr(it,it1,itr2,in) for(auto it=itr1;it!=itr2-1;it-=in)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef map<ll,ll> mll;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll s,w;
cin>>s>>w;
if(w>=s) cout<<"unsafe";
else cout<<"safe";
return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, K);
  ll m = N % K;
  print(min(m, abs(K - m)));
}


Measured memory_bytes: 256
# C
from itertools import combinations
n = int(input())
names = [0 for _ in range(5)]
for _ in range(n):
    start = input()[0]
    if start == 'M':
        names[0] += 1
    if start == 'A':
        names[1] += 1
    if start == 'R':
        names[2] += 1
    if start == 'C':
        names[3] += 1
    if start == 'H':
        names[4] += 1
comb = combinations(names, 3)
total = 0
for c in comb:
    total += c[0]*c[1]*c[2]
print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c>21){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        while (true) {
            int n = scan.nextInt();
            if (n == 0) break;

            int[][] t = new int[n][n + 1];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n + 1; j++) {
                    t[i][j] = scan.nextInt();
                }
            }

            int[] dp = new int[1 << n];
            for (int i = 0; i < (1 << n); i++) {
                dp[i] = 100000000;
            }
            dp[0] = 0;

            for (int i = 0; i < (1 << n); i++) {
                for (int j = 0; j < n; j++) {
                    if ((i >> j) % 2 == 1) continue;
                    int minT = t[j][0];
                    for (int k = 0; k < n; k++) {
                        if (((i >> k) % 2 == 1) && (minT > t[j][k + 1])) {
                            minT = t[j][k + 1];
                        }
                    }
                    if (dp[i | (1 << j)] > dp[i] + minT) {
                        dp[i | (1 << j)] = dp[i] + minT;
                    }
                }
            }

            System.out.println(dp[(1 << n) - 1]);
        }
    }
}

Measured memory_bytes: 35776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	static long mod=1_000_000_007;
	
	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt(), k=fs.nextInt();
		int[] a=fs.readArray(n);
		sort(a);
		if (k==n) {
			long prod=1;
			for (int i:a) prod=mul(prod, i);
			print(prod);
			return;
		}
		boolean havePos=false;
		for (int i:a) if (i>=0) havePos=true;
		if (!havePos) {
			long prod=1;
			if (k%2==0) {
				//ans == pos
				for (int i=0; i<k; i++) prod=mul(prod, a[i]);
			}
			else {
				//ans == neg
				for (int i=0; i<k; i++) prod=mul(prod, a[n-i-1]);
			}
			print(prod);
			return;
		}
		
		//we know we can make it positive
		int nNegs=0;
		for (int i:a) if (i<0) nNegs++;
		
		int[] pos=new int[n-nNegs], negs=new int[nNegs];
		int pIndex=n-nNegs-1, nIndex=0;
		for (int i=0; i<n; i++) {
			if (a[i]>=0) pos[pIndex--]=a[i];
			else negs[nIndex++]=a[i];
		}

		long[] posCS=new long[pos.length+1], negCS=new long[negs.length+1];
		posCS[0]=negCS[0]=1;
		for (int i=1; i<=pos.length; i++) posCS[i]=mul(posCS[i-1], pos[i-1]);
		for (int i=1; i<=negs.length; i++) negCS[i]=mul(negCS[i-1], negs[i-1]);
		
		int nPos=Math.min(pos.length, k);
		int nNeg=k-nPos;
		if (nNeg%2==1) {
			nNeg++;
			nPos--;
		}
		while (nNeg+2<=nNegs && nPos>=2 && 
				pos[nPos-1]*(long)pos[nPos-2] < negs[nNeg]*(long)negs[nNeg+1]) {
			nPos-=2;
			nNeg+=2;
		}
		print(mul(posCS[nPos], negCS[nNeg]));
	}
	
	static void print(long a) {
		System.out.println((a%mod+mod)%mod);
	}
	
	static long mul(long a, long b) {
		return a*b%mod;
	}
	
	static void sortAbs(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l, (aa, b)-> {
			return -Integer.compare(Math.abs(aa), Math.abs(b));
		});
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


Measured memory_bytes: 57528
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int diff = 0;
        int prev = sc.nextInt();
        int x0 = prev;
        for(int i = 1; i < n; i++) {
        	int x = sc.nextInt();
        	diff = Math.max(diff, x - prev);
        	prev = x;
        }
        diff = Math.max(diff, k - prev + x0);
        System.out.println(k - diff);
    }
}


Measured memory_bytes: 62316
N, Y = map(int, input().split())

resx, resy, resz = (-1, -1, -1)
xmax = min(N, Y//10000)
for x in range(xmax+1):
    for y in range(N-x+1):
        z = N - x - y
        total = 10000*x + 5000*y + 1000*z

        if total == Y:
            resx, resy, resz = (x, y, z)
            break
        else:
            continue

print(resx, resy, resz)

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

int main()
{
  string s;
  int q, t, f;
  char c;
  int rev_flag = 1, a_count = 0, b_count = 0;
  vector<char> a(200000);
  vector<char> b(200000);

  cin >> s >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> t;
    if (t == 1)
      rev_flag *= -1;
    else
    {
      cin >> f >> c;
    if ((f == 1 && rev_flag == 1) || (f != 1 && rev_flag != 1))
    {
      a[a_count] = c;
      a_count++;
    }
    else
    {
      b[b_count] = c;
      b_count++;
    }
    }
  }
  if (rev_flag == 1)
  {
    for (int i = 0; i < a_count; i++)
      cout << a[a_count - i - 1];
    cout << s;
    for (int i = 0; i < b_count; i++)
      cout << b[i];
  }
  else
  {
    for (int i = 0; i < b_count; i++)
      cout << b[b_count - i - 1];
    reverse(s.begin(), s.end());
    cout << s;
    for (int i = 0; i < a_count; i++)
      cout << a[i];
  }
  cout << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main()
{
    int a, b, c, ans;
    cin >> a >> b >> c;

    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());

    ans = v[0] + v[1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    cout << (abs(x-a)<=abs(x-b)?"A":"B");    
    return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
int main() {
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl

typedef long long ll;
using namespace std;

int main() {
	char stc[1024];
	int counter = 0;
	string str;
	while (str = "", getline(cin, str), str != ".") {
		counter = 0;
		bool flag = true;
		REP(i, str.size()) {
			if (flag == false ) break;
			if (str[i] == '[' || str[i] == '(') {
				stc[counter++] = str[i];
			} else if (str[i] == ']') {
				if (counter == 0 || stc[--counter] != '[') {
				  flag = false;
				}
			} else if (str[i] == ')') {
				if (counter == 0 || stc[--counter] != '(') {
				  flag = false;
				}
			}
		}
		if (counter == 0 && flag == true) {
			PRINT("yes");
		} else {
			PRINT("no");
		}
	}
	return 0;
}

Measured memory_bytes: 1172
h,w=gets.split.map(&:to_i)
a=[*1..h].map{gets}
def check(arr,y,x,h,w)
  flag1=0
  flag2=0
  h.times{|i|
    if arr[i][x]=='#' then flag1=1 end
  }
  w.times{|j|
    if arr[y][j]=='#' then flag2=1 end
  }
  return flag1+flag2>1
end
h.times{|j|
  f=0
  w.times{|i|
    if check(a,j,i,h,w) then print a[j][i]; f=1 end
  }
  if f==1 then puts "" end
}

Measured memory_bytes: 1788
#include<iostream>
#include<cmath>

int main() {
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		long double x1, y1, x2, y2, x3, y3, x4, y4, ax, ay, bx, by;
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		ax = x1 - x2; ay = y1 - y2;
		bx = x3 - x4; by = y3 - y4;
		if (std::abs(ax*by - ay*bx) < 0.00000000000000000000000000000001) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3140
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP  make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, m;
    cin >> n >> m;
    cout << n / m + (n % m != 0) * 1 << '\n';
}


Measured memory_bytes: 256
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 17:43:58 2019
//
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)

	fmt.Println(max(0, min(B, D)-max(A, C)))
}


Measured memory_bytes: 512
def f(n):
    if n % 2 == 0:
        return n//2
    else:
        return 3*n + 1

s = int(input())
lst = [s]
for i in range(1, 1000001):
    x = f(lst[-1])
    if x in lst:
        break
    lst.append(x)
print(i+1)

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    int s = 0, t = 0;
    irep(i, x.size()) {
        if(x[i] == 'T') {
            if(!s) { t++; }
            else   { s--; }
        } else {
            s++;
        }
    }

    cout << s+t << endl;
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 640
import java.util.Scanner;

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

	public static void solve() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if (n == 0 && p == 0) {
				break;
			}

			int[] player = new int[n];
			for (int i = 0; i < n; i++) {
				player[i] = 0;

			}

			int index = 0;
			int wan = p;

			while (true) {
				if (wan > 0) {
					player[index % n]++;
					wan--;
					if (player[index % n] == p) {
						break;
					}
				} else {
					wan += player[index % n];
					player[index % n] = 0;
				}
				index++;
			}

			System.out.println(index % n);
		}
	}
}

Measured memory_bytes: 26680
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;
typedef long long llong;
const int MOD=1000000007;

int main(int argc, char**argv){
    string s;
    cin >> s;

    int out = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == '1') out++;
    }
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int R,C,N;
	int[] r,c,a;
	long[] min;
	ArrayList<Edge>[][] graph;
	boolean[][] used;
	long[][] b;
	private class Edge{
		int t,w;
		public Edge(int t,int w){
			this.t = t;
			this.w = w;
		}
	}
	public void dfs(int type,int pos,long weight){
		if(used[type&1][pos])return;
		used[type&1][pos] = true;
		b[type&1][pos] = weight;
		min[type&1] = Math.min(min[type&1],weight);
		for(Edge e : graph[type&1][pos]){
			dfs((type+1)&1,e.t,e.w - weight);
		}
	}

	public void solve() {
		R = nextInt();
		C = nextInt();
		N = nextInt();
		r = new int[N];
		c = new int[N];
		a = new int[N];

		graph = new ArrayList[2][];
		graph[0] = new ArrayList[R];
		graph[1] = new ArrayList[C];
		for(int i = 0;i < R;i++)graph[0][i] = new ArrayList<Edge>();
		for(int i = 0;i < C;i++)graph[1][i] = new ArrayList<Edge>();

		for(int i = 0;i < N;i++){
			r[i] = nextInt() - 1;
			c[i] = nextInt() - 1;
			a[i] = nextInt();

			graph[0][r[i]].add(new Edge(c[i],a[i]));
			graph[1][c[i]].add(new Edge(r[i],a[i]));
		}

		used = new boolean[2][];
		used[0] = new boolean[R];
		used[1] = new boolean[C];

		b = new long[2][];
		b[0] = new long[R];
		b[1] = new long[C];
		min = new long[2];
		for(int i = 0;i < N;i++){
			if(used[0][r[i]] || used[1][c[i]])continue;
			min[0] = Long.MAX_VALUE;
			min[1] = Long.MAX_VALUE;
			dfs(0,r[i],0);
			if(min[0] + min[1] < 0){
				out.println("No");
				return;
			}
		}

		for(int i = 0;i < N;i++){

			if(a[i] == b[0][r[i]] + b[1][c[i]])continue;
			out.println("No");
			return ;

		}

		out.println("Yes");
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 75328
#include <bits/stdc++.h>
using namespace std;
//#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
//#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
//#define ALL(v) (v).begin(), (v).end()
//const auto MOD = 998244353;

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if((m1==1&&d1==31)||(m1==2&&d1==28)||(m1==3&&d1==31)||(m1==4&&d1==30)||(m1==5&&d1==31)||(m1==6&&d1==30)||(m1==7&&d1==31)||(m1==8&&d1==31)||(m1==9&&d1==30)||(m1==10&&d1==31)||(m1==11&&d1==30)){
        cout << 1 << endl;
    }else{
cout << 0 << endl;
    }
}


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

int main(){
	long long n,k;
	while(1){
		cin>>n>>k;
		if(!n && !k)break;
		int data[n];
		long long sum[n-k+1];
		sum[0]=0;
		rep(i,n){
			cin>>data[i];
			if(i<k)sum[0]+=data[i];
		}
		rep(i,n-k){
			sum[i+1]=sum[i]+data[i+k]-data[i];
		}
		sort(sum,sum+n-k+1);
		cout<<sum[n-k]<<endl;
	}
	return 0;
}

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

#define int long long

auto main() -> signed {
    string s;
    cin >> s;
    while(true) {
        s = s.substr(0, s.size()-1);
        if(s.size()%2!=0) {
            s = s.substr(0, s.size()-1);
        }
        if(s.substr(0, s.size()/2)==s.substr(s.size()/2, s.size())) break;
    }
    cout << s.size() << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string s;

	cin >> n >> s;

	int x = 0;
	int num = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'I') {
			x = x + 1;
			if (x > num) {
				num = x;
			}
		}
		else if (s[i] == 'D') {
			x = x - 1;
		}
	}
	cout << num << endl;
}

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

int main(){
 long long int m = 1000000007;
 int n;
  cin>>n;
  vector<long long int>v(n),pre(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  pre[n-1]=v[n-1];
  for(int i=n-2;i>=0;i--)
  {
    pre[i]=(v[i]%m+pre[i+1]%m)%m;
  }
  
 long long int ans=0;
  
  for(int i=0;i<n-1;i++)
  {
    ans = (ans%m + (v[i]%m * pre[i+1]%m)%m)%m;
    if(ans<0)
      ans = (ans%m+m)%m;
     //cout<<ans<<endl;
  }
  cout<<ans%m<<endl;
}


Measured memory_bytes: 6336
#include<cstdio>
#define ll long long

ll n;

int s[10000],_s;

int main(){
	scanf("%lld",&n);
	while(n){
		if(n%26)
			s[++_s]=n%26;
		else{
			s[++_s]=26;
			n-=26;
		}
		n/=26;
	}
	for(int i=_s;i;i--)
		putchar(s[i]+'a'-1);
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
ll a, b;
cin >> a >> b;
cout << (a+b)%24 << endl;
    return 0;
}

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

#define MAX 100001

int main(){
	int n;	cin>>n;
	vector<int> even(MAX), odd(MAX);
	for(int i=0;i<MAX;i++) even[i]=odd[i]=0;
	
	int x;
	for(int i=1;i<=n;i++){
		cin>>x;
		if(i%2) odd[x]++;
		else even[x]++;
	}

	int e1=0, o1=0, e2=0, o2=0;

	int e1pos, o1pos;
	for(int i=0;i<MAX;i++){
		if(e1<even[i]){
			e1=even[i];
			e1pos=i;
		}

		if(o1<odd[i]){
			o1=odd[i];
			o1pos=i;
		}
	}

	for(int i=0;i<MAX;i++){
		if(e2<even[i]){
			if(i==e1pos) continue;
			e2=even[i];
		}

		if(o2<odd[i]){
			if(i==o1pos) continue;
			o2=odd[i];
		}
	}


	int ans;
	if(e1pos != o1pos){
		ans=(n/2 - e1) + (n/2 - o1);
	}else{
		int test1, test2;
		test1 = n-e1-o2;
		test2 = n-e2-o1;
		ans=min(test1, test2);
	}

	cout<<ans<<endl;

	return 0;
}


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

const int MAXN = 110;
int nums[MAXN],n;

int main()
{
	scanf("%d",&n);
	for(int i = 0; i < n; ++i)
		scanf("%d",&nums[i]);
    int res = 999999999,cost = 0;
    for(int i = -100; i <= 100; ++i)
    {
        cost = 0;
        for(int j = 0; j < n; ++j)
            cost += (nums[j]-i)*(nums[j]-i);
        res = min(res,cost);
    }
    printf("%d\n",res);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), L(N);
  vector<pair<int, int>> range(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> L[i];
    range[i].first = X[i]+L[i];
    range[i].second = X[i]-L[i];
  }
  sort(range.begin(), range.end());
  int edge = -1000000000;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (edge <= range[i].second) {
      ans++;
      edge = range[i].first;
    }
  }
  cout << ans;
}


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

int main() {

    int N , K ;
    cin >> N >> K;

    vector<int> p(N);

    for(int i = 0;i<N;i++){

        cin >> p[i];
    }

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

    int ans = 0;

    for(int i = 0; i < K ;i++){
        ans += p[i];
    }

    cout << ans << endl;


}

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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> A(0);
  for(int i = 0; i < n; i++) {
    string s;
    int j;
    cin >> s >> j;
    A.push_back(make_tuple(s, j*-1, i+1));
  }
  sort(A.begin(), A.end());
  for(tuple<string, int, int> t : A) {
    int j,k;
    string s;
    tie(s, j, k) = t;
    cout << k << endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

void Yes(){
    cout << "Yes\n";
    exit(0);
}

void No(){
    cout << "No\n";
    exit(0);
}

const int SIZE = 1e5+100;
ll n;
ll a[SIZE],cou2[3];

int main(){
    cin >> n;
    ll cou[3];
    bool f;
    for(int i = 0; i < 3; i++)cou[i] = -1;

    for(int i = 0; i < n; i++){
        f = false;
        cin >> a[i];
        for(int j = 0; j < 3; j++){
            if(cou[j] == -1){
                cou[j] = a[i];
                cou2[j]++;
                f = true;
                break;
            }
            else{
                if(cou[j] == a[i]){
                    cou2[j]++;
                    f = true;
                    break;
                }
            }
        }
        if(!f){
            No();
        }
    }
 
    if(cou[1] == -1){
        if(cou[0] == 0) Yes();
        else
        {
            No();
        }
    }
        


    for(int i = 0; i < 3; i++){
        if(cou[i] == -1){
                if(cou[0] == 0){
                    if(cou2[0]*2 == cou2[1]){
                        Yes();
                    }
                    else{
                        No();
                    }
                }
                else if(cou[1] == 0){
                    if(cou2[1]*2 == cou2[0]){
                        Yes();
                    }
                    else{
                        No();
                    }                    
                }
                else{
                    No();
                }
            }
    }


    if(cou2[0] == cou2[1] && cou2[1] == cou2[2]){
        for(int i = 0; i < 3; i++){
            int j,k,l;
            j = i;
            k = i+1;
            l = i+2;
            if(k >= 3)  k-= 3;
            if(l >= 3) l -= 3;
            ll tmp = (cou[j]^cou[k]);
            if(tmp != cou[l]) No();
        }
        Yes();
        if(cou[0]^cou[1] == cou[2] && cou[2]^cou[0] == cou[1] && cou[1]^cou[2] == cou[0]){
            Yes();
        }
        else{
            No();
        }
    }
    else{
        No();
    }
}

Measured memory_bytes: 1024
W,H,N=map(int,input().split())
x=[]
y=[]
a=[]
minx,maxx,miny,maxy=0,W,0,H

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        minx=max(x,minx)
    if a==2:
        maxx=min(maxx,x)
    if a==3:
        miny=max(y,miny)
    if a==4:
        maxy=min(y,maxy)

print(max(0,maxx-minx)*max(0,maxy-miny))

Measured memory_bytes: 3064
#include <iostream>
  using namespace std;
 long long  a[51000000];
 long long  n,a1,b1;
 long  panduan(long long  x)
 {
     long long  t=b1*x;
     long long  add=0;
     for(int i=1;i<=n;i++)
     {
         if(a[i]-t>0)
         {
             if((a[i]-t)%(a1-b1)==0)
                 add+=(a[i]-t)/(a1-b1);
             else
                 add+=(a[i]-t)/(a1-b1)+1;
         }
     }
     return add<=x;
 }
 int  main()
 {
     cin>>n>>a1>>b1;
     for(int i=1;i<=n;i++)
        cin>>a[i];
     long long  y=0,z=1e10;
     long long  mid;
     int t;
     while(y<z-1)
     {
         mid=(y+z)/2;
         if(panduan(mid))
         {
             z=mid;
             t=mid;
         }
         else
             y=mid;
     }
     cout<<z<<endl;
     return 0;
 }


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

using namespace std;

int main(){
	int n,y;
	cin >> n >> y;
	for(int i=0;i<=n;i++){
		for(int j=0;i+j<=n;j++){
			int x = n - i - j;
			if(x*10000 + i*5000 + j*1000 == y){
				cout << x << " " << i << " " << j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256