akhauriyash/Code-Regression huggingface dataset:
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, x = LI()
A = LI()


def main():
    ans = 0
    for i in range(1, N):
        s = A[i - 1] + A[i]
        d = max(0, s - x)
        ans += d
        A[i] -= min(d, A[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 19912
object Main {
  def main(args: Array[String]): Unit = {
    var Array( red_card, green_card, blue_card )
      = scala.io.StdIn.readLine.split( " " ).map{ _.toInt }
    val count = scala.io.StdIn.readInt

    var total_count = 0

    while( red_card >= green_card ) {
      total_count += 1
      green_card *= 2
    }

    while( green_card >= blue_card ) {
      total_count += 1
      blue_card *= 2
    }

    if( total_count <= count ) println( "Yes" )
    else                       println( "No" )
  }
}

Measured memory_bytes: 54616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
bool t[101];
int main(){
    int n,k;
    cin >> n >> k;
    rep(i,k){
        int d;
        cin >> d;
        rep(s,d){
            int a;
            cin >> a;
            a--;
            t[a] = 1;    
        }
    }
    int sm = 0;
    rep(i,n){
        if(!t[i]){
            sm++;
        }
    }
    cout << sm << endl;
    return 0;
}

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

namespace ABC088B_CardGameForTwo
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(a);
            Array.Reverse(a);

            int aliceNum = 0;
            int bobNum = 0;

            for(int i = 0; i < a.Length; i++)
            {
                if (i % 2 == 0)
                {
                    aliceNum += a[i];
                }
                else
                {
                    bobNum += a[i];
                }
            }

            Console.WriteLine(aliceNum - bobNum);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long N;
  cin >> N;

  if(N%2!=0) cout << 0 << endl;
  else {
    long long ans = 0;
    N /= 2;
    while(N) {
      ans += N/5;
      N /= 5;
    }
    cout << ans << endl;
  }

  
}


Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    ll mod_A = A / 10 * 10;
    ll mod_B = B / 10 * 10;
    ll mod_C = C / 10 * 10;
    ll mod_D = D / 10 * 10;
    ll mod_E = E / 10 * 10;

    ll diff_A = A - mod_A;
    ll diff_B = B - mod_B;
    ll diff_C = C - mod_C;
    ll diff_D = D - mod_D;
    ll diff_E = E - mod_E;

    vector<pair<ll, ll>> vp;
    vp.push_back(make_pair(diff_A, A));
    vp.push_back(make_pair(diff_B, B));
    vp.push_back(make_pair(diff_C, C));
    vp.push_back(make_pair(diff_D, D));
    vp.push_back(make_pair(diff_E, E));

    sort(vp.begin(), vp.end());
    bool initial_flag = false;
    bool already = false;
    debug(vp);
    ll ans = 0;
    REP(i, 5) {
        if (vp[i].first != 0) {
            initial_flag = true;
        }
        if (initial_flag && already != true) {
            ans += vp[i].second;
            already = true;
        } else {
            ans += ceil((double)vp[i].second / 10.0) * 10;
        }
        debug(ans);
    }
    cout << ans << endl;

    return 0;
}


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

#define y1 hasjdnasd
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

#define ll long long
#define oo 1e18 + 7
#define int long long

const int N = 2e5 + 5;
int n;
int h[N] , val[N] , f[N];

void up(int pos , int val)
{
    for(int i = pos ; i <= n ; i += i & -i)
        f[i] = max(f[i] , val);
}

int get(int pos)
{
    int res = 0;
    for(int i = pos ; i ; i -= i & -i)
        res = max(res , f[i]);
    return res;
}

main()
{
    //freopen("Q.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    FOR(i , 1 , n)
        cin >> h[i];
    FOR(i , 1 , n)
        cin >> val[i];
    FOR(i , 1 , n)
        up(h[i] , get(h[i] - 1) + val[i]);
    cout << get(n);
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int p[n];
	for(int i = 0; i < n; ++i){
		cin >> p[i];
		--p[i];
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		if(p[i] != i) continue;
		else if(i != n-1 && p[i+1] == i+1) {
			++ans;
			swap(p[i], p[i+1]);
		}
		else ++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n, m;
ll p[100100];
ll x[100100],y[100100];
bool used[100100];
vector<int> edge[100100];
vector<ll> vp[100100];
set<ll> vi[100100];
ll siz = 0;

void solve(ll s) {
	used[s] = 1;
	vp[siz].push_back(p[s]);
	vi[siz].insert(s + 1);
	rep(i, edge[s].size()) {
		if (!used[edge[s][i]])solve(edge[s][i]);
	}
}

int main() {
	cin >> n >> m;
	rep(i, n)cin >> p[i];
	rep(i, m) {
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
		edge[x[i]].push_back(y[i]);
		edge[y[i]].push_back(x[i]);
	}
	rep(i, n) {
		if (!used[i]) {
			solve(i);
			siz++;
		}
	}
	ll cnt = 0;
	rep(i, siz) {
		rep(j, vp[i].size()) {
			ll num = vp[i][j];
			if (vi[i].find(num) != vi[i].end())cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 23668
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int d, t, s;
	cin >> d >> t >> s;
	int x = d / s;
	int y = d % s;
	if (t * s >= d)
		cout << "Yes" << en;
	else
		cout << "No" << en;


	return 0;
}




Measured memory_bytes: 3652
<?php

list($h, $w) = explode(' ', trim(fgets(STDIN)));

$need_magic_power_list = [];
for ($i = 0; $i < 10; $i++)
{
	$need_magic_power_map[$i] = explode(' ', trim(fgets(STDIN)));
}

// for ($i = 0; $i < 10; $i++)
// {
// 	unset($need_magic_power_map[$i][$i]);
// }

$need_magic_power_list = [];
// for ($i = 0; $i < 10; $i++)
// {
// 	if ($i === 1)
// 	{
// 		$need_magic_power_list[$i] = 0;
// 		continue;
// 	}

// 	// $tmp = $need_magic_power_map;
// 	$targets = [0 => true, 1 => true, 2 => true, 3 => true, 4 => true, 5 => true, 6 => true, 7 => true, 8 => true, 9 => true];
// 	$need_magic_power_list[$i] = calc_magic_power($targets, $i, $need_magic_power_map[$i][1]);
// }
for ($k = 0; $k < 10; $k++)
{
	for ($i = 0; $i < 10; $i++)
	{
		for ($j = 0; $j < 10; $j++)
		{
			if ($need_magic_power_map[$i][$k] + $need_magic_power_map[$k][$j] < $need_magic_power_map[$i][$j])
			{
				$need_magic_power_map[$i][$j] = $need_magic_power_map[$i][$k] + $need_magic_power_map[$k][$j];
			}
		}
	}
}

$total_magic_power = 0;
for ($i = 0; $i < $h; $i++)
{
	$line = explode(' ', trim(fgets(STDIN)));

	foreach ($line as $value)
	{
		if ((int)$value === -1)
		{
			continue;
		}

		// $total_magic_power += $need_magic_power_list[(int)$value];
		$total_magic_power += $need_magic_power_map[(int)$value][1];
	}
}

echo $total_magic_power;

function calc_magic_power($targets, $index, $direct_change_value, $prev = [])
{
	global $need_magic_power_map;
	global $need_magic_power_list;

	if (isset($need_magic_power_list[$index]))
	{
		return $need_magic_power_list[$index];
	}

	if (!isset($targets[$index]) || count($targets) < 1)
	{
		return (int)$direct_change_value;
	}

	if ($direct_change_value <= min($need_magic_power_map[$index]))
	{
		return (int)$direct_change_value;
	}

	$line = $need_magic_power_map[$index];
	$list = [];
	// unset($targets[$index]);
	$prev[$index] = true;
	foreach ($targets as $key => $value)
	{
		if (!isset($targets[$key]) || !isset($need_magic_power_map[$key][1]) || isset($prev[$key]))
		{
			continue;
		}

		$cost = isset($line[$key])? $line[$key] : 0;
		$list[$key] = $cost + calc_magic_power($targets, $key, $need_magic_power_map[$key][1], $prev);
	}

	return min($list);
}


Measured memory_bytes: 3700
a,b,c=map(int,input().split())
k=int(input())
while k>0:
    if a>=b:
        b*=2
    elif b>=c:
        c*=2
    else:
        break
    k-=1
if a<b and b<c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let n: usize = tr.read();
    let mut ss: Vec<String> = (0..n).map(|_| tr.read()).collect();

    ss.sort();
    ss.dedup();
    println!("{}", ss.len());
}



Measured memory_bytes: 14928
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

int h, w, dp[1000][1000];
char in[1000][1000];

int main()
{
  cin >> h >> w;
  for(int i = 0; i<h; i++)
    for(int j = 0; j<w; j++)
      cin >> in[i][j];
  for(int i = 0; i<h; i++)
    for(int j = 0; j<w; j++)
    {
      if(i)
        dp[i][j]+=dp[i-1][j];
      if(j)
        dp[i][j]+=dp[i][j-1];
      if(!i && !j)
        dp[i][j] = 1;
      if(in[i][j]=='#')
        dp[i][j] = 0;
      dp[i][j]%=MOD;
    }
  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int tmpSum = 0;
        int sum = 0;
        for(int i=0; i<=n; i++) {
            String s = Integer.toString(i);
            for(int j=0; j<s.length(); j++) {
                tmpSum += Character.getNumericValue(s.charAt(j));
            }
            if(tmpSum >= a && tmpSum <= b) {
                sum += i;
            }
            tmpSum = 0;
        }
        System.out.println(sum);
    }
}


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

struct query{
  int type;//0=empty, 1=add-sum ,2=set-min
  ll value;
  query(int a=0,ll b=0):type(a),value(b) {}
};



ll INF=(1LL<<60);


struct segtree{
  int SIZE;
  vector<query> s;
  vector<ll> t;// sum-add
  vector<ll> u;// min-set

  segtree(int n=1){
    SIZE=1;
    while(SIZE<n)SIZE*=2;
    s.clear();
    t.clear();
    u.clear();
    s.resize(SIZE*2, query());
    t.resize(SIZE*2, 0);
    u.resize(SIZE*2, 0);
  }
  
  void func(int k,int l,int r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(int k,int l,int r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    int m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(int a,int b,query x,int k,int l,int r){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      int m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  ll Dfs(int type,int a,int b,int k,int l,int r){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      int m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  void Add(int a,int b,ll x){
    Update(a,b,query(1,x), 0,0,SIZE);
  }
  void Set(int a,int b,ll x){
    Update(a,b,query(2,x), 0,0,SIZE);
  }
  ll Getsum(int a,int b){
    return Dfs(1,a,b, 0,0,SIZE);
  }

  ll Getmin(int a,int b){
    return Dfs(2,a,b, 0,0,SIZE);
  }
  
};



int main(){
  
  int n,q;
  scanf("%d %d",&n,&q);
  segtree T(n);
  
  for(int i=0;i<q;i++){
    int type,a,b,c;
    scanf("%d %d %d",&type,&a,&b);
    if(type==0){
      scanf("%d",&c);
      T.Add(a,b+1,c);
    }else{
      printf("%lld\n", T.Getmin(a,b+1) );
    }
  }
  return 0;
}



Measured memory_bytes: 10992
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,K;cin>>N>>K;
    map<int,int>memo;
    REP(i,N){
        int a;cin>>a;
        memo[a]++;
    }
    priority_queue<int>q;
    for(auto v:memo){
        q.push(v.second);
    }
    int ans=N;
    REP(i,K){
        if(q.empty())break;
      	ans-=q.top();
        q.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 14964
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
ans = 0
for i in range(N-1,-1,-1):
    A[i] += ans
    ans += B[i]*((A[i]+B[i]-1)//B[i]) - A[i]
print(ans)


Measured memory_bytes: 14904
<?php
    list($sx,$sy,$gx,$gy) = explode(" ",trim(fgets(STDIN)));
    
    $difx=$gx-$sx;
    $dify=$gy-$sy;

    for($i=0;$i<$dify;$i++){
        echo "U";
    }

    for($i=0;$i<$difx;$i++){
        echo "R";
    }

    for($i=0;$i<$dify;$i++){
        echo "D";
    }

    for($i=0;$i<$difx;$i++){
        echo "L";
    }
    
    echo "L";
    
    for($i=0;$i<=$dify;$i++){
        echo "U";
    }

    for($i=0;$i<=$difx;$i++){
        echo "R";
    }
    
    echo "DR";

    for($i=0;$i<=$dify;$i++){
        echo "D";
    }

    for($i=0;$i<=$difx;$i++){
        echo "L";
    }    
    
    echo "U";

?>  

Measured memory_bytes: 3704
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    B = [(A[i], i) for i in range(N)]
    B.sort(key = lambda x: x[0], reverse = True)

    DP = [[0] * (N + 1) for _ in range(N + 1)]

    for i, b in enumerate(B):
        a = b[0]
        tmp = b[1]
        for x in range(i + 1):
            DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
            DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

    ans = 0
    for i in range(N + 1):
        ans = max(ans, DP[i][N - i])

    print (ans)

    # for tmp in DP:
    #     print (tmp)

if __name__ == '__main__':
    main()

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

int main(){
  int D;
  cin >> D;
  if(D==25){
    cout << "Christmas" << endl;
  }else if(D==24){
    cout << "Christmas Eve" << endl;
  }else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }else{
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

#define N 100001
char isprime[N];
int is2017like_acum[N];
void eratosthenes()
{
    for (int i = 2; i < N; i++) isprime[i] = 1;
    for (int i = 2; i < sqrt(N); i++)
    {
        if (isprime[i])
        {
            for (int j = 0; i * (j + 2) < N; j++)
            {
                isprime[i *(j + 2)] = 0;
            }
        }
    }
    int cnt = 0;
    for (int i = 3; i <= N; i += 2)
    {
        if (isprime[i] && isprime[(i + 1) / 2])
        {
            ++cnt;
        }
        is2017like_acum[i] = cnt;
    }
}

int main(int argc, char *argv[])
{
    eratosthenes();
    int q;
    scanf("%d", &q);
    for (int i = 0; i < q; ++i)
    {
        int l, r;
        scanf("%d %d", &l, &r);
        if (l > 2)
            printf("%d\n", is2017like_acum[r] - is2017like_acum[l - 2]);
        else
            printf("%d\n", is2017like_acum[r]);
    }
}


Measured memory_bytes: 1152
fun main(args:Array<String>?): Unit {
    val n = readLine()!!.trim().toInt()
    val score = readLine()!!.trim().split(' ').map(String::toLong).sorted().toLongArray()
    val sumScore = LongArray(n + 1){if (it == 0) 0 else score[it - 1]}
    for (i in 1 .. n) sumScore[i] += sumScore[i - 1]
    val m = readLine()!!.trim().toInt()
    val level = readLine()!!.trim().split(' ').map(String::toInt)
    val target = readLine()!!.trim().split(' ').map(String::toLong)
    for (i in 0 until m){
        println(
                if (sumScore[upperBound(score, level[i])] >= target[i]) "Yes" else "No"
        )
    }
}
fun upperBound(array: LongArray, target: Int): Int {
    var left = 0
    var right = array.size
    while(left < right){
        val mid = (left + right) / 2
        if (array[mid] <= target){
            left = mid + 1
        }else {
            right = mid
        }
    }
    return right
}


Measured memory_bytes: 206592
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int a,b;
    cin >>a>>b;
    if(a<=8&&b<=8){
        cout<<"Yay!"<<endl;
    }
    else{
        cout<<":("<<endl;
    }
}




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


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


int main() {
    int n, k; cin >> n >> k;
    vector<ll> cnt(k + 1);

    for (int i = k; i >= 1; --i) {
        int g = i;
        cnt[g] = modpow((k / g), n, MOD);
        cnt[g] %= MOD;
        int gg = g * 2;
        while (gg <= k) {
            cnt[g] -= cnt[gg];
            gg += g;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= k; ++i) {
        ans %= MOD;
        ans += cnt[i] * i;
    }
    cout << (ans % MOD) << endl;
}


Measured memory_bytes: 4060
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  long long X;
  cin >> X;
  long long now=100;
  long long year=0;
  while(now<X){
    now=now*1.01;
    year++;
  }

  cout << year << endl;
  
  return 0;
}


Measured memory_bytes: 3636
S = input()

count_1 = 0
count_2 = 0

if len(set(S))==2:
    list = list(set(S))

    if S.count(list[0])==2 and S.count(list[1])==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


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

int main() {
  int N,L;
  cin >> N >> L;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  for(int i=0; i<N; i++){
    cout << s.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 256
def lower_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] < v then l = m
    else r = m
    end
  end
  l + 1
end

loop do
  n, q = gets.split.map(&:to_i)
  break if n == 0
  era = {}
  n.times do
    name, ey, wy = gets.split
    era[wy.to_i] = [name, ey.to_i]
  end
  era = era.sort
  q.times do
    y = gets.to_i
    k = era.transpose[0]
    v = era.transpose[1]
    x = lower_bound(k, y)
    if x != n && k[x] - y < v[x][1]
        puts "#{v[x][0]} #{v[x][1] - (k[x] - y)}"
    else puts "Unknown"
    end
  end
end

Measured memory_bytes: 57004
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#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 P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE a(n); rep(i, n)cin >> a[i];
	VE b(m), c(m); rep(i, m)cin >> b[i] >> c[i];
	vector<P>tmp;
	rep(i, m) {
		tmp.push_back(make_pair(c[i], b[i]));
	}
	sort(ALLR(tmp));
	int now = 0;
	int idx = 0;
	vector<int>tmp2;
	while (true) {
		if (idx == m || now >= 100000)break;
		if (tmp[idx].second != 0) {
			tmp2.push_back(tmp[idx].first);
			tmp[idx].second--;
			now++;
		}
		else {
			idx++;
			if (idx == m)break;
			tmp2.push_back(tmp[idx].first);
			tmp[idx].second--;
			now++;
		}
	}
	sort(ALL(a));
	rep(i, n) {
		if (i >= tmp2.size())break;
		if (a[i] <= tmp2[i]) {
			a[i] = tmp2[i];
		}
		else {
			break;
		}
	}
	int sum = 0;
	rep(i, n) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
int k,a,b,i,j,m,n;
int main(){
	scanf("%d%d%d",&k,&a,&b);
	for(i=a;i<=b;i++){
		if(i%k==0){
			printf("OK");
			break;
		}
	}
	if(i==b+1){
		printf("NG");
	}
	return 0;
}

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

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

      if(a == b&& b  == c){
            ans =1;
      }else if((a == b && b != c)||(b == c && c != a) || ( a == c && c != b)){
            ans = 2;
      }else{
            ans = 3;
      }
      cout << ans << endl;
}


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

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A) {
        cout << K;
    }
    else if (K <= A + B) {
        cout << A;
    }
    else {
        cout << 2 * A + B - K;
    }
} 

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int a[4];
	int b[4];
	int i, j;
	int c1;
	int c2;

	while (scanf("%d", &a[0]) != EOF){
		for (i = 1; i < 4; i++){
			scanf("%d", &a[i]);
		}

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

		c1 = c2 = 0;

		for (i = 0; i < 4; i++){
			if (a[i] == b[i]){
				c1++;
			}
		}

		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]){
					c2++;
				}
			}
		}

		c2 -= c1;

		printf("%d %d\n", c1, c2);
	}

	return (0);
}

Measured memory_bytes: 596
// 2011/07/21 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int c[30][6];
		for(int i=0; i<n; i++){
			for(int j=0; j<6; j++){
				string str;
				cin >> str;
				if(str=="Red")
					c[i][j] = 1;
				else if(str=="Yellow")
					c[i][j] = 2;
				else if(str=="Blue")
					c[i][j] = 3;
				else if(str=="Magenta")
					c[i][j] = 4;
				else if(str=="Green")
					c[i][j] = 5;
				else if(str=="Cyan")
					c[i][j] = 6;
			}
		}
/*
		for(int i=0; i<n; i++){
			for(int j=0; j<6; j++)
				cout << c[i][j] << ' ';
			cout << endl;
		}
*/
		for(int i=0; i<n; i++){
			if(c[i][0]>c[i][5]){
				int tmp = c[i][0];
				c[i][0] = c[i][5];
				c[i][5] = tmp;

				tmp = c[i][2];
				c[i][2] = c[i][3];
				c[i][3] = tmp;
			}
			if(c[i][1]>c[i][4]){
				if(c[i][2]<c[i][3]){
					int tmp = c[i][1];
					c[i][1] = c[i][2];
					c[i][2] = c[i][4];
					c[i][4] = c[i][3];
					c[i][3] = tmp;
				}
				else{
					int tmp = c[i][1];
					c[i][1] = c[i][4];
					c[i][4] = tmp;

					tmp = c[i][2];
					c[i][2] = c[i][3];
					c[i][3] = tmp;
				}
			}
			if(c[i][2]>c[i][3]){
				int tmp = c[i][2];
				c[i][2] = c[i][1];
				c[i][1] = c[i][3];
				c[i][3] = c[i][4];
				c[i][4] = tmp;
			}
			if(c[i][1]==1){
				int tmp = c[i][1];
				c[i][1] = c[i][2];
				c[i][2] = c[i][0];
				c[i][0] = tmp;
				tmp = c[i][4];
				c[i][4] = c[i][3];
				c[i][3] = c[i][5];
				c[i][5] = tmp;
			}
			if(c[i][2]==1){
				int tmp = c[i][2];
				c[i][2] = c[i][1];
				c[i][1] = c[i][0];
				c[i][0] = tmp;
				tmp = c[i][3];
				c[i][3] = c[i][4];
				c[i][4] = c[i][5];
				c[i][5] = tmp;
			}
		}
/*
		for(int i=0; i<n; i++){
			for(int j=0; j<6; j++)
				cout << c[i][j] << ' ';
			cout << endl;
		}
*/
		int d[30];
		for(int i=0; i<n; i++)
			d[i] = ((((c[i][0]*10+c[i][1])*10+c[i][2])*10+c[i][3])*10+c[i][4])*10+c[i][5];

		for(int i=0; i<n-1; i++)
			for(int j=i+1; j<n; j++)
				if(d[i]>d[j]){
					int tmp = d[i];
					d[i] = d[j];
					d[j] = tmp;
				}
/*
		for(int i=0; i<n; i++)
			cout << d[i] << endl;
*/
		int m = n;
		for(int i=0; i<n-1; i++)
			if(d[i]==d[i+1])
				m--;

		cout << n-m << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,ans=0;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(i%2==0&&a[i]%2==1)ans++;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3604
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k *50 == x:
                cnt +=1


print(cnt)

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

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

const int INF = 1000000007;

int main(void){
	int h[1100] = {0};
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>h[i];

	int ans=0;
	for(int l=0;l<n;l++) {
		while(h[l] > 0) {
			int r;
			for(r=l+1;r<n;r++) {
				if(h[r] == 0) break;
			}

			for(int i=l;i<r;i++) --h[i];
			ans++;
		}
	}

	cout<< ans <<endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate


def make_dp(vvv, n, k):
    dp = [-(10 ** 9)] * (k + 1)
    dp[0] = 0

    for i in range(min(n, k)):
        i += 1
        vv = vvv[:i]
        vv.sort(reverse=True)
        sm = sum(vv)
        dp[i] = max(dp[i], sm)
        while i < k and vv and vv[-1] < 0:
            sm -= vv.pop()
            i += 1
            dp[i] = max(dp[i], sm)

    return list(accumulate(dp, func=max))


n, k = list(map(int, input().split()))
vvv = list(map(int, input().split()))

acl = make_dp(vvv, n, k)
vvv.reverse()
acr = make_dp(vvv, n, k)
acr.reverse()

ans = max(map(sum, zip(acl, acr)))
ans = min(ans, sum(v for v in vvv if v > 0))
print(ans)


Measured memory_bytes: 3064
import copy

arrays = []
n,m,q = 0,0,0

def main():
    global n, m, q
    global arrays
    n, m, q = map(int, input().split())
    abcd = [list(map(int, input().split())) for _ in range(q)]
    ans = 0
    dfs([], 1)
    for array in arrays:
        tmp = 0
        for i in range(q):
            if array[abcd[i][1]-1] - array[abcd[i][0]-1] == abcd[i][2]:
                tmp += abcd[i][3]
        ans = max(ans, tmp)
    print(ans)

def dfs(stack, i):
    stack.append(i)
    if len(stack) == n:
        arrays.append(copy.deepcopy(stack))
        if i < m:
            stack.pop()
            dfs(copy.deepcopy(stack), i + 1)
        return
    dfs(copy.deepcopy(stack), i)
    if i < m:
        stack.pop()
        dfs(copy.deepcopy(stack), i + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 108080
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stdlib.h>

using namespace std;
char in[120];
pair<pair<string, int>, int> p[110];

int main () {
  int N;
  cin >> N;
  for (int i = 0; i< N; i++) {
    int t;
    string tmp;
    cin >> tmp >> t;
    
    p[i]=make_pair(make_pair(tmp,-t),i);
  }  
  sort(p,p+N);
  for (int i = 0; i<N;i++) {
    cout << p[i].second+1 << endl;
  }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

char str[200005];
int c = 0;

int main()
{
	scanf("%s", str + 1);
	int len = strlen(str + 1);
	for(int i = 1;i <= len;++i)
		c = (c + (str[i] - '0')) % 9;

	if(c == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void inp_str(int*);


int main(void) {

int input[100];
inp_str(input);

int A,B,T;

A=input[0];
B=input[1];
T=input[2];

int C;
int ans;

C=T/A;
ans=C*B;

/*printf("%d\n",A);
printf("%d\n",B);
printf("%d\n",T);
printf("%d\n",C);*/
printf("%d\n",ans);


/*int i;
for(i=0;i<N;i=i+1){
if(S[i]==S[K-1]){
	out[i]=S[i];
}else{
	out[i]='*';
}
}
out[N]=S[N];

printf("%s\n",out);


//printf("%d\n",M);

//printf("%d\n",C);




/*

if(flag==1) {
	printf(":(\n");
}else{
printf("Yay!\n");
} 

*/
    return 0;
}


void inp_str(int instr[]){
char *ptr;
int z,i,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       z = getchar();
      if (z == '\n' || z == EOF) break;
   }
}
	count=0;
    ptr = strtok(str, " ");
    i = atoi(ptr);
    instr[count]=i;
    count=count+1;
    // 2回目以降
    while(ptr != NULL) {
        // strtok関数により変更されたNULLのポインタが先頭
        ptr = strtok(NULL, " ");
        // ptrがNULLの場合エラーが発生するので対処
        if(ptr != NULL) {
		    i = atoi(ptr);
    instr[count]=i;
    		count=count+1;
        }
    }
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int N,C; cin>>N>>C;
    vector<vector<bool>> used(C,vector<bool>(100010,false));
    int s,t,c;
    for (int i = 0; i < N; ++i) {
        cin>>s>>t>>c; --s; --c;
        for (int j = s; j < t; ++j) {
            used[c][j]=true;
        }
    }

    int ans=0;
    for (int i = 0; i <= 100000; ++i) {
        int cnt=0;
        for (int j = 0; j < C; ++j) {
            if(used[j][i]) cnt++;
        }
        //if(cnt==3) cout<<i<<endl;
        chmax(ans,cnt);
    }
    cout<<ans<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


Measured memory_bytes: 640
S = input()
N = len(S)
K = int(input())
S_list = sorted(set(list(S)))

memo = {}

for small_char in S_list:
    for i in range(N):
        if S[i] == small_char:
            for j in range(i+1, i+K+1):
                word = S[i:j]
                memo[word] = None
    if len(memo) >= K:
        break

ans_list = sorted(list(memo.keys()))
print(ans_list[K-1])


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String a[]){	
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int s = b+c;
			int d = 0;
			while(s!=0){
				s = s/10;
				d++;
			}
			System.out.println(d);
		}
		scanner.close();
	}
}



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

namespace C___Five_Transportations
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var moveTimes = new long[5];

            moveTimes[0] = long.Parse(Console.ReadLine());
            moveTimes[1] = long.Parse(Console.ReadLine());
            moveTimes[2] = long.Parse(Console.ReadLine());
            moveTimes[3] = long.Parse(Console.ReadLine());
            moveTimes[4] = long.Parse(Console.ReadLine());

            Console.WriteLine(Math.Ceiling((decimal)N/moveTimes.Min())+4);
        }
    }
}


Measured memory_bytes: 13268
from collections import deque
H, W = map(int, input().split())
A = [input() for _ in range(H)]
q = deque([])
grid = [[-1] * W for _ in range(H)]
dire = ((1,0),(0,1),(-1,0),(0,-1))
d = 0
 
for i in range(H):
    for j in range(W):
        if A[i][j] == "#":
            q.append((i,j))
            grid[i][j] = 0
 
while q:
    i, j = q.popleft()
    d = grid[i][j]
    for dy, dx in dire:
        ny,nx = i+dy, j+dx
        if ny>=0 and ny<H and nx>=0 and nx<W and grid[ny][nx] < 0:
            q.append((ny, nx))
            grid[ny][nx] = grid[i][j] + 1
 
print(d)

Measured memory_bytes: 88412
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        x -= i + 1;
        a[i] = x;
    }
    sort(a.begin(), a.end());
    int c;
    if (n % 2 == 0) {
        c = (a[n / 2 - 1] + a[n / 2]) / 2;
    } else {
        c = a[n / 2];
    }
    c--;
    long long ans = __LONG_LONG_MAX__;
    long long tmpans;
    for (int i = 0; i < 3; i++) {
        tmpans = 0;
        for (int j = 0; j < n; j++) { tmpans += abs(a[j] - c); }
        ans = min(ans, tmpans);
        c++;
    }
    cout << ans << endl;
}

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

//  void y(void){cout << "yes"<< endl;}
  void Y(void){cout << "YES" << endl;}
  void y(void){cout << "Yes" << endl;}
//  void n(void){cout << "no"<< endl;}
  void N(void){cout << "NO" << endl;}
  void n(void){cout << "No" << endl;}
  
  
  
//	int a,b,c,d,e,f,g,h,ans,res;
//	char a,b,c,d,e,f,g,h;
//	string a,b,c,d,e,f,g,h;
	double a,b,c,d,e,f,g,h;
	
void take(int x){
	if(x==1)
		cin >> a;
	else if(x==2)
		cin >> a >> b;
	else if(x==3)
		cin >> a >> b >> c;
	else if(x==4)
		cin >> a >> b >> c >> d;
	else if(x==5)
		cin >> a >> b >> c >> d >> e;
	else if(x==6)
		cin >> a >> b >> c >> d >> e >> f;
	else if(x==7)
		cin >> a >> b >> c >> d >> e >> f >> g;
	else if(x==8)
		cin >> a >> b >> c >> d >> e >> f >> g >> h;
	return ;
}
  
int main(void){
	take(2);//数
	double ans=a/b;
	
	
/*	if(){
		
		
	//	y();	//Yes
	//	Y();	//YES
	//	n();	//No
	//	N();	//NO
	}
	
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}/*
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	else if(){
		
		
	//	y();
	//	Y();
	//	n();
	//	N();
		
	}
	
	else{
		
		
	//	y();
	//	Y();
	//	n();
		N();
		
	}*/
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(int argc, const char * argv[])
{
    int i, j;
    int a, b;
    while (1) {
        scanf("%d %d", &a, &b);
        if (a==0 && b==0) {
            break;
        }
        for (i=0; i<a; i++) {
            for (j=0; j<b; j++) {
                if (j%2 == 1) {
                    if (i%2 == 1) {
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }else{
                    if (i%2 == 1) {
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

ll dp[sz][2],n;
vector<int> ar[sz];

void dfs(int u,int pr)
{
    dp[u][0]=1;
    dp[u][1]=1;
    for(int v:ar[u])
    {
        if(v!=pr)
        {
            dfs(v,u);
            dp[u][0]=((dp[u][0]*dp[v][0])%mod+(dp[u][0]*dp[v][1])%mod)%mod;
            dp[u][1]=((dp[u][1]*dp[v][0])%mod);
        }
    }
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        cin>>n;

        for(int i=0;i<n-1;i++)
        {
            int u,v;
            cin>>u>>v;
            ar[u].push_back(v);
            ar[v].push_back(u);
        }

        dfs(1,0);

        cout<<(dp[1][0]%mod+dp[1][1]%mod)%mod;

        
    }

    return 0;
}

Measured memory_bytes: 17604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int a, b, c, d;

int main() {
  while (cin >> a >> b >> c >> d) {
	if (a+b > c+d) puts("Left");
	else if (a+b < c+d) puts("Right");
	else puts("Balanced");
  }
}


















Measured memory_bytes: 256