akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

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

	int a, b, c;
	cin >> a >> b >> c;

	int max_v = max({a, b, c});
	int res = (max_v * 10) + a + b + c - max_v;

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int a=0,b=0,c=0,count=0,n=0,z=0,i=0;
      	//cin >> a >> b >> c;
      	cin >> n;
      	for(i=1;i<=n;i++){
        	cin >> z;
          	if(i%2&&z%2){count++;}
        }
      cout << count << endl;
	}
}

Measured memory_bytes: 3584
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var r = n
    for (i in 0..n) {
        var cnt = 0
        var t = i
        while (t > 0) {
            cnt += t % 6
            t /= 6
        }
        t = n - i
        while (t > 0) {
            cnt += t % 9
            t /= 9
        }
        r = Math.min(r, cnt)
    }
    println(r)
}


Measured memory_bytes: 31612
s =list(input())
g_s = s[0::2]
k_s = s[1::2]
g_zero = g_s.count('0')
k_zero = k_s.count('0')
if g_zero > k_zero:
  print(k_zero + len(g_s)-g_zero) 
else:
  print(g_zero+ len(k_s)-k_zero)

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, l;
  cin >> n >> l;
  int sum = 0;
  for (int i=1; i<=n; ++i) sum += l+i-1;
  int ans = sum-l;
  for (int i=1; i<=n; ++i) {
    int cur = sum-(l+i-1);
    if (abs(sum-ans) > abs(sum-cur)) {
      ans = cur;
    }
  }
  cout << ans << endl;
  return 0;
}


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

char s[401];

int main(void)
{
	
	int sn;
	char tmp_s[200];
	scanf( "%s", s );
	
	sn = strlen( s );
	
	while(1) {
		sn -= 2;
		strcpy( tmp_s, s + sn/2 );
		if ( strncmp( s, tmp_s, sn / 2 ) == 0 ) break;
	}
	
	printf( "%d\n", sn );
	
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  cin >> n;
  VI a(n);
  int mi = 1e5;
  int ma = -1e5;
  REP(i, 0, n) {
    cin >> a[i];
    mi = min(mi, a[i]);
    ma = max(ma, a[i]);
  }
  cout << ma - mi << endl;
}


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

using namespace std;

template <typename T>
struct SegmentTree {
private:
	size_t n;
	vector<T> node;
	T M0;

public:
	SegmentTree(const vector<T>& v, T m0) {
		M0 = m0;
		n = 1;
		while (n < v.size()) { n *= 2; }
		node.assign(2*n - 1, M0);

		for (int i = 0; i < v.size(); ++i) {
			node[n - 1 + i] = v[i];
		}
		for (int i = n - 2; i >= 0; --i) {
			node[i] = merge(node[2*i + 1], node[2*i + 2]);
		}
	}

	T merge(T a, T b) { return max(a, b); }

	void update(int x, T val) {
		x += (n - 1);
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = merge(node[2*x + 1], node[2*x + 2]);
		}
	}

	T query(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) { r = n; }
		if ((r <= a) || (b <= l)) { return M0; }
		if ((a <= l) && (r <= b)) { return node[k]; }

		T vl = query(a, b, 2*k + 1, l, (l + r) / 2);
		T vr = query(a, b, 2*k + 2, (l + r) / 2, r);
		return merge(vl, vr);
	}
};

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

	constexpr int maxA = 300000;
	SegmentTree<int> seg(vector<int>(maxA + 10, 0), 0);
	for (int i = 0; i < N; ++i) {
		int l = max(0, A[i] - K);
		int r = min(maxA, A[i] + K);
		seg.update(A[i], seg.query(l, r + 1) + 1);
	}
	cout << seg.query(0, maxA + 1) << "\n";

	return 0;
}


Measured memory_bytes: 9588
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op=='?' : break
    if op=='+':
        ans = a+b
    elif op=='-':
        ans = a-b
    elif op=='*':
        ans = a*b
    elif op=='/':
        ans = a//b
    print(ans)


Measured memory_bytes: 5592
def main():
    N, M = map(int, input().split())
    switches = []
    for _ in range(M):
        tp = list(map(int, input().split()))
        temp = [int(x) for x in tp[1:]]
        switches.append(temp)

    P = [int(p) for p in input().split()]
    d = dict()
    for i in range(M):
        for j in range(len(switches[i])):
            sw = switches[i][j]
            if sw not in d: d[sw] = [i]
            else: d[sw].append(i)

    states = dict()
    # on = 1, off = 0
    ground = tuple([(P[i]+1) % 2 for i in range(M)])
    states[ground] = 1
    for sw in range(1, N+1):
        if sw in d:
            new = dict()
            for s in states:
                st = list(s)
                for j in d[sw]:
                    st[j] = (st[j]+1) % 2
                st = tuple(st)
                new[st] = new.get(st, 0) + states[s]
            for st in new:
                states[st] = states.get(st, 0) + new[st]
        else:
            for s in states:
                states[s] *= 2
        # print(sw, states)
    # print(states)
    final = tuple([1 for _ in range(M)])
    return states.get(final, 0)


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int h, n;
    cin >> h >> n;
    vector<pair<int, int>> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i].first >> vec[i].second;
    }
    vector<int> dp(h + 1, INF);
    dp[0] = 0;
    for (int i = 1; i <= h; ++i) {
        for (int j = 0; j < n; ++j) {
            int cur = max(0, i - vec[j].first);
            dp[i] = min(dp[i], vec[j].second + dp[cur]);
        }
    }
    cout << dp[h] << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
/*
 * D.cpp
 *
 *  Created on: 2020/06/14
 *      Author: admin
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;


int main(){
	long long N;
	cin >> N;
	long long A[N];
	for (int i=0; i<N; i++){
		cin >> A[i];
	}
	bool dp[1000010];
	for (int i=0; i<1000010; i++) dp[i] = true;

	sort(A, A + SIZE_OF_ARRAY(A));

	long long count = 0;
	for(int i=0; i<N; i++){
		if(dp[A[i]]){
			if(i<N-1){
				if(A[i]==A[i+1]){
					for(long long m=1; A[i]*m < 1000010; m++){
						dp[A[i]*m] = false;
					}
				}
			}
		}
		if(dp[A[i]]){
			count++;
			for(long long m=1; A[i]*m < 1000010; m++){
				dp[A[i]*m] = false;
			}
		}
	}
	cout << count;

}


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

int main(int argc, char const *argv[])
{
    std::vector<int> v(3);
    std::cin >> v[0] >> v[1] >> v[2];
    std::sort(v.begin(), v.end());
    if (v[0] == 5 && v[1] == 5 && v[2] == 7) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=500100,mod=998244353;
typedef long long ll;
int ksm(ll a,int b,int c=1){
	for(;b;b/=2,a=a*a%mod)
		if(b&1)c=c*a%mod;
	return c;
}
int pn[N],pm[N],jc[N],jc2[N],n,m,ans;
void init(){
	jc[0]=1;
	for(int i=1;i<N;++i)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[N-1]=ksm(jc[N-1],mod-2);
	for(int i=N-1;i;--i)jc2[i-1]=(ll)jc2[i]*i%mod;
	pm[0]=pn[0]=1;
	for(int i=1;i<N;++i)pm[i]=(ll)pm[i-1]*(m+1)%mod,pn[i]=(ll)pn[i-1]*(n+1)%mod;
}
int C(int n,int k){
	if(n<k||k<0)return 0;
	return (ll)jc[n]*jc2[k]%mod*jc2[n-k]%mod;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;init();
	for(int i=0;i<=n;++i){
		int tmp=(ll)C(n,i)*C(m,i)%mod*jc[i]%mod*pm[n-i]%mod*pn[m-i]%mod;
		if(i&1)ans=(ans-tmp+mod)%mod;
		else ans=(ans+tmp)%mod;
	}
	cout<<ans<<endl;	
	return 0;
}


Measured memory_bytes: 8064
import java.util.Scanner;

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

		if(c >= a && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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 argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  // let (x3, y3) = (0, 0)
  // the area(s/2) will be |(x2y1 - x1y2) / 2 |
  // just find x2y1 - x1y2 = s
  // limit is 0 ~ 1e9
  // set x2 = 1e9, y2 = 1
  // so find 1e9y - x = s
  // y = (s + x) / 1e9
  // s + x should be 1e9's multiple
  // x can be (1e9 - s % 1e9) % 1e9
  ll s;
  cin >> s;
  int x1, y1, x2 = 1e9, y2 = 1, x3 = 0, y3 = 0;
  x1 = (ll)(1e9 - s % (ll)1e9) % (ll)1e9;
  y1 = (s + x1) / 1e9;
  printf("%d %d %d %d %d %d\n", x1, y1, x2, y2, x3, y3);
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

D, G = get_ints

A = []
D.times do |i|
  num = i + 1
  p, c = get_ints
  A << [num, p, c, num * 100 * p + c]
end

dp = Array.new(2000) { {point: 0, data: [] } }
dp[0] = {
  point: 0,
  data: Array.new(D+1, 0)
}
A.each do |n, p, c, point|
  if dp[n][:point] < point
    stock = Array.new(D+1, 0)
    stock[n] += p
    dp[p] = {
      point: point,
      data: stock,
    }
  end
end

def next_turn(data, d, ax)
  index = d.step(1, -1).find { |x| data[x] < ax[x-1][1] }
  num, p, c, point = ax[index - 1]
  result = data.dup
  result[index] += 1
  if result[index] == p
    [result, num * 100 + c]
  else
    [result, num * 100]
  end
end

i = 1
loop do
  from = dp[i-1]
  from[:data]
  next_data, point = next_turn(from[:data], D, A)
  next_kouho = from[:point] + point
  if next_kouho > dp[i][:point]
    dp[i] = {
      point: next_kouho,
      data: next_data,
    }
  end
  A.each do |n, p, c, point|
    if dp[i][:data][n] == 0 && dp[i+p][:point] < point + dp[i][:point]
      new_data = dp[i][:data].dup
      new_data[n] = p
      dp[i+p] = {
        point: point + dp[i][:point],
        data: new_data,
      }
    end
  end
  break if dp[i][:point] >= G
  i += 1
end

puts dp[i][:data].sum

# xx = []
# 1.step(D) do |d|
#   xx += A.combination(d).map do |array|
#     total_count = 0
#     total_point = 0
#     array.each do |n, p, c, point|
#       total_count += p
#       total_point += point
#     end
#     {
#       total_count: total_count,
#       total_point: total_point,
#       data: array,
#     }
#   end
# end
#
# xx.sort! do |a, b|
#   test = a[:total_count] <=> b[:total_count]
#   if test != 0
#     test
#   else
#     # 同じ数ならポイントの高いものから
#     b[:total_point] <=> a[:total_point]
#   end
# end
#
# target = xx.find { |x| x[:total_point] >= G }
#
# ans = target[:total_count]
#
# target[:data].each do |n, p, c, point|
#   stock_count = ans - p
#   stock_point = target[:total_point] - point
#   if D * 100 * p > point
#     (G - stock_point) D * 100
#   end
# end
#
# binding.pry
#


Measured memory_bytes: 15448
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S := sc.nextStr()
	N := len(S)
	for c := byte('a'); c <= byte('z'); c++ {
		for i := 0; i < N-1; i++ {
			if S[i] == c && S[i+1] == c {
				fmt.Fprintln(wtr, i+1, i+2)
				return
			}
			if i < N-2 && S[i] == c && S[i+2] == c {
				fmt.Fprintln(wtr, i+1, i+3)
				return
			}
		}
	}

	fmt.Fprintln(wtr, "-1 -1")
}


Measured memory_bytes: 1024
S = list(input())
cnt = 0
max_cnt = 0
for s in S:
        if s == 'A' or s == 'C' or s == 'G' or s == 'T':
                cnt = cnt + 1
        else:
                if max_cnt < cnt:
                        max_cnt = cnt
                cnt = 0
print(max(max_cnt, cnt))

Measured memory_bytes: 2940
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
n , k = map(int,input().split())
cnt = 1
while n>=k:
	n=n//k
	cnt = cnt + 1
print(cnt)

Measured memory_bytes: 38384
use strict;
use warnings;
use utf8;

use Data::Dumper;
use feature qw(say);

my $nk = <STDIN>;
chomp $nk;
my ($n, $k) = split / /, $nk;

my $input = <STDIN>;
chomp $input;
my $array = [split / /, $input];
my $sorted_array = [sort { $a <=> $b } @$array];

my $sum = 0;
for (my $i = 0; $i < $k; $i++) {
    $sum += $sorted_array->[$i];
}
say $sum;

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

int main() {
  string c;
  cin >> c;
 if (c == "a"||c =="e"||c =="i"||c =="o"||c =="u") {
     cout << "vowel" << endl;
} 
 else{
     cout << "consonant" << endl;
}
}

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;


signed main(){
    i64 n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    vector<i64> ans(n, 0);
    for(int i = 0; i < n - 1; ++i){
        if(a[i] >= a[i + 1])
            ans[i + 1] = max(ans[i] + 1, ans[i + 1]);
    }
    cout << *max_element(ans.begin(), ans.end()) << endl;
}


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

namespace ConsoleApp15
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);

            Console.WriteLine(a - b + 1);
            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
#!/usr/bin/env python3

import sys

DEBUG = False

def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

def read_int():
    return int(sys.stdin.readline())

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return

def solve(s, t):
    if len(t) > len(s):
        return "UNRESTORABLE"

    ans = None
    for i in range(0, len(s)):
        can_insert = True
        for j in range(0, len(t)):
            pos = i + j
            if pos >= len(s) or (s[pos] != '?' and s[pos] != t[j]):
                can_insert = False
                break
        if not can_insert:
            continue
        inserted = s[0:i] + t + s[i + len(t):]
        inserted = inserted.replace("?", "a")

        if ans is None or inserted < ans:
            ans = inserted

    if ans is None:
        return "UNRESTORABLE"
    return ans


def main():
    s = sys.stdin.readline().rstrip()
    t = sys.stdin.readline().rstrip()
    print(solve(s, t))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


ll int N ,M,K;
cin >> N >> M >> K;
vector<ll int > A(N);
vector<ll int > B(M);

rep(i,N){
	cin >> A[i];
}
rep(i,M){
	cin >> B[i];
}
ll int counterA=0;
//ll int counterB=0;
ll int counter=1;

ll int max=0;
ll int time=A[0];


long long int i =0;
if(time > K){
	time -= A[0];
	counter -=1;
	counterA =1;
}
else{
	if(N!=1){
	while(time + A[i+1] <= K){
		time += A[i+1];
		i += 1;
		counter += 1;
		if(i+1==N){
			break;
		}
		else{}
	}
}
else{}
}
long long int j=0;
while(time + B[j] <= K){
	time += B[j];
	j += 1;
	counter += 1;
		if(j==M){
			break;
		}
		else{}
}
max = counter;
if(j == M || counterA == 1){
cout << max << endl;
return 0;
}
else{}

while(i>=0){
time -= A[i];
i -= 1;
counter -= 1;
while(time + B[j] <= K){
	time += B[j];
	j += 1;
	counter += 1;
		if(j==M){
if(counter > max){
	max = counter;
}
else{}
cout << max << endl;
return 0;
		}
		else{}
}
if(counter > max){
	max = counter;
}
else{}
}





/*
for (long long int i=0;i<=1<<(N+M-1);i++){
	for(long long int j=0;;j++){
		if(i>>j&1){
			if(time+A[counterA]<=K){
			if(counterA == N){
				break;
			}
			else{
			time += A[counterA];
			counter += 1;
			counterA+=1;
			}
			}
			else{
				break;
			}
		}
		else{
			if(time+B[counterB]<=K){
			if(counterB == M){
				break;
			}
			else{
			time += B[counterB];
			counter += 1;
			counterB += 1;
			}
			}
			else{
				break;
			}
		}

	}
	if(counter > max){
		max = counter;
	}
	else{}
	
	
 counterA=0;
 counterB=0;
 counter=0;
 time = 0;
}
*/
cout << max;

		









	return 0;

}



Measured memory_bytes: 6404
#include<vector>
#include<iostream>
int main(){
    int N;
    std::cin>>N;
    std::vector<unsigned long long>A(N);
    std::vector<unsigned long long>sum(N);
    for(int i=0;i<N;++i){
        std::cin>>A[i];
    }
    for(int i=N-1;i>=0;--i){
        if(i==N-1){
            sum[i]=A[i];
        }
        else{
            sum[i]=(sum[i+1]+A[i])%1000000007;
        }
    }
    unsigned long long ans=0;
    for(int i=0;i<N-1;++i){
        ans=(ans+sum[i+1]*A[i])%1000000007;
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 6420
def main():
    n, m = map(int, input().split())
    ary = sorted(list(map(int, input().split())), reverse=True)
    if ary[m-1] >= sum(ary) / (4*m):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int a[1000000];

int main () {
    int n, A;
    scanf("%d",&n);
    for(int i=2;i<=n;i++) {
        scanf("%d",&A);
        a[A]+=1;
    }
    for(int i=1;i<=n;i++) printf("%d\n",a[i]);
}

Measured memory_bytes: 2460
import itertools
h,w,k = map(int,input().split())
grid = []
black = 0
cnt = 0
for _ in range(h):
    s = input()
    grid.append(s)
#print(grid)

row = list(itertools.product([0,1],repeat=h))
column = list(itertools.product([0,1],repeat=w))
result = 0
for i in row:
    for j in column:
        cnt = 0
        for m in range(len(i)):
            for n in range(len(j)):
                if i[m]==0 and j[n] == 0 and grid[m][n] == '#':
                    cnt += 1

        if cnt == k:
            #print("i,j",i,j)
            result += 1

print(result)

Measured memory_bytes: 9136
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	h,w=map(int,input().split())
	A=[list(map(int,input().split())) for _ in range(h)]
	B=[list(map(int,input().split())) for _ in range(h)]
	C=[[0]*w for _ in range(h)]
	for i in range(h):
		for j in range(w):
			C[i][j]=abs(A[i][j]-B[i][j])
	D=[[0]*w for _ in range(h)]
	D[0][0]=(1<<C[0][0]+5000)|(1>>C[0][0]+5000)
	for i in range(h):
		for j in range(w):
			if i>0:
				D[i][j]=D[i][j]|(D[i-1][j]<<C[i][j])|(D[i-1][j]>>C[i][j])
			if j>0:
				D[i][j] = D[i][j]|(D[i][j-1] << C[i][j]) | (D[i][j-1] >> C[i][j])

	val=D[-1][-1]
	ans=5000

	for i in range(10000):
		if val>>i&1:
			ans=min(ans,abs(i-5000))
	print(ans)

if __name__ == "__main__":
	main()


Measured memory_bytes: 13940
import math

def f(n):
    t = 0
    for i, c in enumerate(n):
        if c.isdigit():
            t += int(c)*(16**(1-i))
        else:
            if c == 'a':
                t += (16**(1-i))*10
            elif c == 'b':
                t += (16**(1-i))*11
            elif c == 'c':
                t += (16**(1-i))*12
            elif c == 'd':
                t += (16**(1-i))*13
            elif c == 'e':
                t += (16**(1-i))*14
            elif c == 'f':
                t += (16**(1-i))*15
    return t

def aaa():
    color = None
    s = None
    for k, v in data.items():
        t = 0
        for i in range(3):
            t += (RGB[i]-v[i])**2
        else:
            dk = math.sqrt(t)
        if s is None or dk < s:
            color = k
            s = dk
    else:
        print color

data = {'black':(0, 0, 0), 
        'blue':(0, 0, 255),
        'lime':(0, 255, 0),
        'aqua':(0, 255, 255),
        'red':(255, 0, 0),
        'fuchsia':(255, 0, 255),
        'yellow':(255, 255, 0),
        'white':(255, 255, 255)}

while True:
    line = raw_input()
    if line == '0': break
    color = line[1:]
    RGB = [f(color[i:i+2]) for i in range(0, 6, 2)]
    aaa()

Measured memory_bytes: 4444
i,j;main(a){
	for(puts("98 99");i<98;i++)
	{
		i%49||scanf("%d",&a);
		for(int j=0;j<99;j++)
		{
			putchar((i%2|j%2||a--<2)^i>48?'#':'.');
		}
		puts("");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> order(n);
  rep(i,n) order[i] = i;
  vector<pair<int,int>> pos(n,{0,0});
  rep(i,n) cin >> pos[i].first >> pos[i].second;
  double ans = 0;
  double count = 0;
  do{
    double dist =0;
    for(int i=0;i<n-1;i++){
      double x2 = pos[order[i]].first - pos[order[i+1]].first;
      x2*=x2;
      double y2 = pos[order[i]].second - pos[order[i+1]].second;  
      y2*=y2;
      dist+=sqrt(x2+y2);
    }
    ans +=dist;
    count++; 
  }while(next_permutation(order.begin(),order.end()));
  ans/=count;
  printf("%.12lf\n",ans) ;
}

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

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

  lint sum = 0;
  for(auto c : S) {
    sum += c - '0';
  }
  cout << (sum%9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int temp1,temp2;
    temp1=temp2=0;
    bool f=(n-1)%2;
    for(int i=n-1;i>=0;i--){
        if(i%2==f)temp1+=arr[i];
        else temp2+=arr[i];
    }
    cout<<temp1-temp2;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

int main(){
    int L, R, d;
    cin >> L >> R >> d;

    ll ans = 0;
    REPi(i,L,R+1){
        if(i % d == 0)
            ans++;
    }

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(LL, k, Q);
	vector<LL> d(k);
	cin >> d;
	inc(q, Q) {
		IN(LL, n, x, m);
		n--;
		LL s = 0, t = 0;
		inc(i, k) {
			LL dd = d[i] % m;
			if(dd == 0) { dd = m; }
			s += dd;
			if(i < n % k) { t += dd; }
		}
		LL v = (x % m) + (n / k) * s + t;
		OUT(n - v / m);
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int c;
  bool b=true;
  
  for (int i=0;i<4;i++){
    c=0;
    for (int j=0;j<4;j++){
      if (S.at(i)==S.at(j))c++;
    }
    if (c!=2){
      b=false;
      break;
    }
  }
  
  if (b==true)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
    int a, b;
    cin >> a >> b;
    if(a+b == 15){
        cout << "+" << endl;
    }else if(a*b == 15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }


    return 0;
}

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

int main() {
  ll n, d;
  cin >> n >> d;
  vector<pair<ll, ll> > p(n);
  ll ans = 0;
  rep(i, n) cin >> p[i].first >> p[i].second;
  rep(i, n) {
    ll dist = p[i].first * p[i].first + p[i].second * p[i].second;
    if (d * d >= dist) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void)
{
  int n,m;
  cin>>m;
  n=m%10;
  if(n==2||n==4||n==5||n==7||n==9)
    cout<<"hon";
  else if(n==0||n==1||n==6||n==8)
    cout<<"pon";
  else
    cout<<"bon"; 
} 

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

int main() {

  string S ;

  cin >> S ;

  vector<string> vec(S.size()) ;

  vector<string> str(S.size()) ;

  for( int i = 0 ; i < S.size() ; i++){

    vec[i] = S.at(i) ;

  }


  for( int i = 0 ; i < S.size() ; i++){

    str[i] = S.at(S.size() - 1 - i) ;

  }

  vector<string> zen((S.size()-1)/2) ;

  vector<string> go((S.size()-1)/2) ;

  for ( int i = 0 ; i < (S.size()-1)/2 ; i++){

    zen[i] = S.at(i) ;

  }

  for ( int i = 0 ; i < (S.size()-1)/2 ; i++){

    go[i] = S.at((S.size()-1)/2 - 1 - i) ;

  }

  vector<string> mae((S.size()-1)/2) ;

  vector<string> ushiro((S.size()-1)/2) ;

for ( int i = 0 ; i < (S.size()-1)/2 ; i++){

  mae[i] = S.at((S.size()-1)/2 + 1 + i ) ; 

}

for ( int i = 0 ; i < (S.size()-1)/2 ; i++){

  ushiro[i] = S.at(S.size() - 1 - i) ;

}

if( vec == str && zen == go && mae == ushiro) cout << "Yes" << endl;

else cout << "No" << endl;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    token = lines[0].split()
    k = int(token[0])
    x = int(token[1])

    return (k, x)


def solve(k, x):


    start = max(-1000000, x - (k-1))
    end = min(1000000, x + (k-1))

    result = " ".join([str(i) for i in range(start, end + 1)])
        

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

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

int main(){
  int n; cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  double ans = (v.at(0) + v.at(1)) / 2.0;
  for (int i = 2; i < n; i++){
    ans = (ans + v.at(i)) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
pypy -cH,W,A,B=`tr \  ,`';M=10**9+7;Z=C=1
for I in range(H-1):Z=C=C*(W+H-B-2-I)*pow(I+1,M-2,M)%M
for I in range(1,H-A):C=C*(B-1+I)*(H-I)*pow(I*(W+H-B-1-I),M-2,M)%M;Z+=C
print Z%M'

Measured memory_bytes: 89784
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	char ch;
	int alphabet[26] = {0};
	while(cin >> ch) {
		if(ch >= 'a' && ch <= 'z') {
			alphabet[ch - 'a']++;
		}
		if(ch >= 'A' && ch <= 'Z') {
			alphabet[ch - 'A']++;
		}
	}
	for(int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a'+i, alphabet[i]);
	}
}


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

using namespace std;
#define int long long
int pre(int x)
{
    return x*(x+1)/2;
}
int qsum(int l, int r)
{
    return pre(r) - pre(l-1);
}
signed main() {
    int n;
    cin >> n;
    int i;
    int sq = sqrt(n);
    int sum = 0;
    for(i=1;i<=sq;i++)
        sum+=(i*(n/i)*(1+(n/i))/2);
    for(i=1;i<=n/(1+sq);i++)
        sum+=(i*(i+1)*qsum(1+n/(i+1), n/i)/2);
    cout << sum;    
}

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

int n,m;
int memo[1004]={0};

int main(){
  int i,j,sum=0;
  cin >> n >> m;
  for(i=0;i<(m-n);i++)sum+=i;
  

  cout <<sum-n<< endl;

  return 0;
}


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

long long solve(int n, Sushi s1, Sushi s2, Sushi x) {
    Sushi max_s(n+1, 0);
    for (int i = 1; i <= n; i++) max_s[i] = max(max_s[i-1], s2[i]);
    
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        long long res = s1[i] + max(0LL, max_s[n-i] - x[i]);
        if (ans < res) ans = res;
    }
    
    return ans;
}

int main() {
    int n;
    long long c;
    cin >> n >> c;
    Sushi x(n+2, 0), v(n+2, 0); x[n+1] = c;
    for (int i = 1; i <= n; i++) cin >> x[i] >> v[i];
    
    Sushi s1(n+1, 0), s2(n+1, 0);
    for (int _ = 0; _ < 2; _++) {
        if (_) {
            for (int i = 1; i <= n; i++) s2[i] = s2[i-1] + v[i];
            for (int i = 1; i <= n; i++) s2[i] -= abs(c - x[i]);
        } else {
            for (int i = 1; i <= n; i++) s1[i] = s1[i-1] + v[i];
            for (int i = 1; i <= n; i++) s1[i] -= x[i];
        }
        reverse(v.begin(), v.end()); reverse(x.begin(), x.end());
    }
    
    
    long long ans = 0;
    for (int _ = 0; _ < 2; _++) {
        long long res = solve(n, s1, s2, x);
        if (ans < res) ans = res;
        reverse(x.begin(), x.end());
        for (auto& d : x) d = abs(c - d);
        swap(s1, s2);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
eval"X,Y,*A=#"+`tr ' ' ,`
b=X+Y-a=A.inject(0,:^)
r=b/2
50.downto(0){r+2**_1>X||r|=a&1<<_1}
p r<1||r>X||b/2&a|b%2>0?-1:X-r

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

const int N = 1e5 + 5;

vector<int> v[N];
int cost[N][3];

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    int n, m, s, t, x, y;
    memset(cost, -1, sizeof cost);
    cin >> n >> m;
    while (m--)
    {
        cin >> x >> y;
        v[x].push_back(y);
    }
    cin >> s >> t;
    cost[s][0] = 0;
    queue<pair<int, int>> q;
    q.push({s, 0});
    while (!q.empty())
    {
        x = q.front().first, y = q.front().second;
        q.pop();
        for (auto it: v[x])
        {
            int newCost = (y + 1) % 3;
            if (cost[it][newCost] == -1)
            {
                cost[it][newCost] = cost[x][y] + 1;
                q.push({it, newCost});
            }
        }
    }
    cout << (cost[t][0] == -1? -1: cost[t][0] / 3);
    return 0;
}

Measured memory_bytes: 10160
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

a = []
a.append(input())
s = 1
for i in range(1,x):
    l = input()
    if l in a: s =0
    a.append(l)
    if l[0] != a[i-1][len(a[i-1])-1]: s=0
j(s)

Measured memory_bytes: 5404
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    ll mx = 0;
    ll ans = 0;
    rep(i,n) {
        if (mx > a[i]) {
            ans += mx-a[i];
        }
        chmax(mx, a[i]);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4708
D,G = map(int,input().split())

#pc = [map(int,input().split()) for i in range(D)]
prob = [list(map(int, input().split())) for i in range(D)]


### piの問題に対して全部解いたと仮定して
### 不足分は配点の大きい問題から解く

min_count = 10000
for i in range(1<<D):
    score = 0
    count = 0
    for j in range(D):
        if (i>>j)&1:
            score += (j+1)*100 * prob[j][0] + prob[j][1] # 全問得点+ボーナス
            count += prob[j][0]

    ## 不足分を配点の大きい問題から一問ずつ加点
    for j in reversed(range(D)):
        if not (i>>j)&1:
            for k in range(0, prob[j][0]-1):
                if score >= G:
                    break
                score += (j+1)*100
                count += 1

    if score >= G:
        min_count = min(count, min_count)

print(min_count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,M,m;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    if(i==0){
    	m=a[i];
      M=a[i];
    }
    M=max(a[i],M);
    m=min(a[i],m);
  }
  cout<<M-m<<endl;
  
}


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

typedef long long LL;

const double PI = acos(-1.0);

char s[2000800];
char t[1000800];
int f[1000800];

void getFail(char *P, int *f) {
	int m = strlen(P);
	f[0] = f[1] = 0;
	for (int i = 1; i < m; ++i) {
		int j = f[i];
		while (j && P[i] != P[j]) j = f[j];
		f[i+1] = P[i] == P[j] ? j+1 : 0;
	}
}

int find(char *T, char *P, int *f) {
	int n = strlen(T), m = strlen(P), j = 0;
	getFail(P, f);
	for (int i = 0; i < n; ++i) {
		while (j && P[j] != T[i]) j = f[j];
		if (P[j] == T[i]) j++;
		if (j == m) return 1;
	}
	return 0;
}

int find2(char *T, char *P, int *f) {
	int n = strlen(T), m = strlen(P), j = 0;
	getFail(P, f);
	int mx = 0, cur = 0, pre = -1e9;
	for (int i = 0; i < n; ++i) {
		while (j && P[j] != T[i]) j = f[j];
		if (P[j] == T[i]) j++;
		if (j == m) {
            int pos = i-m+1;
            if (pos - pre == m) {
                cur++;
                pre = pos;
            } else {
                mx = max(mx, cur);
                cur = 1;
                pre = pos;
            }
		}
	}
	mx = max(mx, cur);
	return mx;
}


int work() {
    scanf("%s", s);
    scanf("%s", t);

    getFail(t, f);
    int lent = strlen(t);
/*
    for (int i = 1; i <= lent; ++i) {
        printf("%d\t%d\t%d\n", f[i], i - f[i], i % ( i - f[i] ));
    }
*/


    int Period = lent - f[lent], rp = 1;
    if (f[lent] != 0 && lent % Period == 0) {
        rp = lent / Period;
        t[Period] = '\0';
        lent = Period;
    }
    //printf("%s\n", t);

    getFail(s, f);
    int lens = strlen(s);
    Period = lens - f[lens];
    if (f[lens] != 0 && lens % Period == 0) {
        s[Period] = '\0';
        lens = Period;
    }

    //printf("s=%s\nt=%s\n", s, t);

    if (lent == lens) {
        for (int i = 0; i < lens-1; ++i) s[lens+i] = s[i];

        int lens_new = 2 * lens - 1;
        s[lens_new] = '\0';
        if (find(s, t, f)) {
            printf("-1\n");
            return 0;
        }
        s[lens] = '\0';
    }

    int lens_new = lens;

    while (lens_new < 2*lent) {
        for (int i = 0; i < lens; ++i) s[lens_new+i] = s[i];
        lens_new += lens;
    }

    for (int i = 0; i < lens-1; ++i) s[lens_new+i] = s[i];
    lens_new += lens - 1;
    s[lens_new] = '\0';
    //printf("s=%s\nt=%s\n", s, t);
    printf("%d\n", find2(s, t, f) / rp);
    return 0;

}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 7040
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int C = A + B;

    if(C >= 10){
      System.out.println("error");
    }else{
      System.out.println(C);
    }
  }
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,M;
    cin >> N >> M;

    vector<pair<ll, ll> >lr(M);
    rep(i,M) cin >> lr[i].first>> lr[i].second;

    ll left = 0;
    ll right = INF;
    rep(i,M)
    {
        if( left < lr[i].first ) left = lr[i].first;
        if( right > lr[i].second ) right = lr[i].second;
    }
    //cout << left << " " << right << endl;
    if( N < left || left > right )
    {
        cout << 0 << endl;
    }
    else cout << right - left + 1 << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
// #include <string>
// #include <set>
// #include <algorithm>

using namespace std;
typedef unsigned long long ull;


void p() {
    cout << "\n";
}
template<class Head, class... Body>
void p(Head head, Body... body) {
    cout << head << ",";
    p(body...);
}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for (const auto i : v) {
        os << i << " ";
    }
    os << "]";
    return os;
}

int main(int argc, char const *argv[]) {
    int N;
    string S;
    cin >> N >> S;

    vector<vector<int>> next_positions(N);
    for (int i = N-1; i >= 0; i--) {
        next_positions[i].resize(10, -1);
        for (int j = 0; j < 10; j++) {
            if (i < N-1) {
                next_positions[i][j] = next_positions[i+1][j];
            }
            if (S[i] - '0' == j) {
                next_positions[i][j] = i;
            }
        }
    }
    // cout << next_positions << endl;

    int ans = 0;
    // vector<int> ns;
    for (int n = 0; n < 1000; n++) {
        int a = n / 100;
        int b = (n / 10) % 10;
        int c = n % 10;

        int position = 0;
        position = next_positions[position][a];
        if (position == -1 || position == N-1) continue;
        position = next_positions[position+1][b];
        if (position == -1 || position == N-1) continue;
        position = next_positions[position+1][c];
        if (position == -1) continue;

        ans += 1;
        // ns.push_back(n);
    }

    cout << ans << endl;
    // cout << ns << endl;

    return 0;
}


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

int main() {
    int n, m;
    while (cin >> n >> m, n + m) {
        vector<int> rec(m, -1e9);
        for (int i = 0; i < n; i++) {
            int d, v; cin >> d >> v;
            d--;
            rec[d] = max(rec[d], v);
        }
        int sum = 0;
        for (int i = 0; i < m; i++)
            sum += rec[i];
        cout << sum << endl;
    }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int vis[710] = {}, state[710] = {}, pos[1500] = {}, ngh[710][710] = {};
vector<int> gr[710];

void dfs(int u, int wtf, pair<int,int>& cnt){
	vis[u] = 1;
	state[u] = wtf;
	if(wtf) cnt.ff++; else cnt.ss++;
	for(int v:gr[u]){
		if(!vis[v]) dfs(v,wtf^1,cnt);
		else if(state[v] == state[u]) { cout<<"-1\n"; exit(0); }
	}
}

int main()
{
	nfs_mw;
	int i,j,n,m,u,v;
	cin>>n>>m;
	for(i=0; i<m; i++) {
		cin>>u>>v;
		ngh[u][v] = ngh[v][u] = 1;
	}

	for(i=1; i<=n; i++)
		for(j=1; j<=n; j++)
			if(i!=j && !ngh[i][j])
				gr[i].pb(j);

	vector< pair<int,int> > pairs;
	for(i=1; i<=n; i++) if(!vis[i]) {
		pair<int,int> nxt = mp(0,0);
		dfs(i,0,nxt);
		pairs.pb(nxt);
	}

	pos[0] = 1;
	for(auto p:pairs)
		for(j=n; j>=0; j--) {
			if(!pos[j]) continue;
			pos[j] = 0;
			pos[j+p.ff] = 1;
			pos[j+p.ss] = 1;
		}

	int ans = 700*700*700;
	for(j=n; j>=0; j--) if(pos[j]) ans = min(ans, (((j*(j-1))/2) + (((n-j)*(n-j-1))/2)));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3072