akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

ll solve(ll N, ll P){
    ll res = 1;
    for(ll i = 2; i * i <= P; i++){
        if(P / i < N) break;
        if(P % i != 0) continue;
        ll cnt = 0;
        while(P % i == 0){
            P /= i;
            cnt++;
        }
        if(cnt >= N) res *= pow(i, (cnt / N));
    }
    if(P != 1 && N == 1) res *= P;
    return res;
}

int main(){
    ll N,P;
    cin >> N >> P;
    ll ans;
    ans = solve(N, P);
    cout << ans << endl;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
int main()
{
    double n, T, A, ans = 1e9, p;
    cin >> n >> T >> A;
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        if (ans >= abs(A - (T - tmp * 0.006)))
        {
            p = i;
            ans = abs(A - (T - tmp * 0.006));
        }
    }
    cout << p + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

public class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] p = Console.ReadLine()
            .Split(' ')
            .Select(int.Parse)
            .ToArray(); ;

        int count = 0;

        for (int i = 0; i < n -2; i++)
        {
            if ((p[i] < p[i + 1] && p[i + 1] < p[i +2])
                || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) count++;
        }

        Console.WriteLine(count);
    }
}

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




int main()
{
    /*ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);*/

    long long int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;


    cin>>n;
    s=0;
    map <long long int , long long int> mp;
    for(i=0;i<n;i++)
    {
        cin>>a;
        s+=a;
        mp[a]++;
    }

    cin>>q;
    while(q--)
    {
        cin>>a>>b;
        d=b-a;
        s+=(mp[a]*d);
        mp[b]+=mp[a];
        mp[a]=0;
        cout<<s<<"\n";
    }


    return 0;


}


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

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


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

struct Segment {
  int s,t;
  bool operator < ( const Segment &seg) const {
    if( s != seg.s ) return s < seg.s;
    return t < seg.t;
  }
};

int main() {
  int N,C,K;
  cin >> N >> C >> K;
  vector<Segment> vec;
  rep(i,N) {
    int T;
    cin >> T;
    vec.push_back((Segment){T,T+K});
  }
  sort(ALL(vec));
  int cnt = 0;
  rep(i,N) {
    ++cnt;
    int remain = C - 1;
    int lim = vec[i].t;
    while( remain > 0 && i + 1 < N && vec[i+1].s <= lim ) ++i, --remain;
  }
  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 1400
//header{{{
//#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int h,w,k;
    cin >> h >> w >> k;

    vector<vector<int> > mat(h,vector<int>(w));
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            mat[i][j] = c - '0';
        }
    }

    int res = INF;
    for(int bit = 0; bit < (1 << (h-1)); ++bit){
        int cnt = __builtin_popcount(bit);
        vector<int> sum(cnt+1);
        rep(i,w){
            int pos = 0;
            sum[pos] += mat[0][i];
            rep(j,h-1){
                if(bit & (1 << j)){
                    ++pos;
                }
                sum[pos] += mat[j+1][i];
            }
            int maxv = 0;
            for(auto e : sum){
                chmax(maxv,e);
            }
            pos = 0;
            //if(bit == 0) cout << maxv << '\n';
            if(maxv > k){
                sum[pos] = 0;
                sum[pos] = mat[0][i];
                rep(j,h-1){
                    if(bit & (1 << j)){
                        ++pos;
                        sum[pos] = 0;
                    }
                    sum[pos] += mat[j+1][i];
                }
                ++cnt;
            }
            maxv = 0;
            for(auto e : sum){
                chmax(maxv,e);
            }
            //if(bit == 0) cout << " " << maxv << '\n';
            if(maxv > k) goto ng;
        }
        //cout << cnt << '\n';
        chmin(res,cnt);
ng:;
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"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
	}
}

// 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
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	W := sc.nextStr()
	set := make(map[rune]int)
	for _, r := range W {
		set[r]++
	}
	all := true
	for _, c := range set {
		if c%2 != 0 {
			all = false
		}
	}

	if all {
		fmt.Fprintln(wtr, "Yes")
	} else {
		fmt.Fprintln(wtr, "No")
	}
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
int main()
{
	ll n, a, b;
	cin >> b >> a >> n;
	cout << (n + max(a, b) - 1) / max(a, b);
}


Measured memory_bytes: 764
#include<cstdio>
namespace QiFeng233{
	int a,b,c;
	void solve(){
		scanf("%d%d%d",&a,&b,&c);
		if((a==b&&a!=c)||(a==c&&b!=c)||(b==c&&a!=b))printf("Yes\n");
		else printf("No\n");
	}
}
signed main(){
	QiFeng233::solve();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;
 
 
int main(){
    ll n, m;
    cin >> n >> m;
    ll count=0;
    rep(i, m){
      ll a; cin >> a;
      count+=a;
      if (count>n){
          cout << -1 << endl;
          break;
      }
    }
    
    if (count<=n){
        cout << n-count << endl;
    }
 
}


Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
typedef long long ll;
const int N=20;
map<pair<int,int>,ll> f[N][N];
ll a[N],n;
ll dp(int l,int r,int x,int y){
	if (l>r)return 0;
	if (l==r)return a[l]*(x+y);
	if (f[l][r].count(make_pair(x,y)))
		return f[l][r][make_pair(x,y)];
	ll ans=1e18;
	for (int i=l;i<=r;i++)
		ans=min(ans,a[i]*(x+y)+dp(l,i-1,x,x+y)+dp(i+1,r,x+y,y));
	return f[l][r][make_pair(x,y)]=ans;
}
int main(){
	cin>>n;n-=2;
	for (int i=0;i<=n+1;i++)scanf("%lld",&a[i]);
	cout<<dp(1,n,1,1)+a[0]+a[n+1]<<endl;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,m,x;
   cin>>n>>m>>x;
   vector<int> a(n);
   rep(i,n){
      a[i]=0;
   }
   rep(i,m){
      int b;
      cin>>b;
      a[b]++;
   }
   int left=0,right=0;
   for(int i=x;i<n;i++){
      left+=a[i];
   }
   for(int i=x;i>0;i--){
      right+=a[i];
   }
   cout<<min(left,right);

}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for input in S:
    if input == 'AC':
        AC += 1
    elif input == 'WA':
        WA += 1
    elif input == 'TLE':
        TLE += 1
    else:
        RE += 1

print("""AC x {ac}
WA x {wa}
TLE x {tle}
RE x {re}""".format(ac = AC, wa = WA, tle = TLE, re = RE))

Measured memory_bytes: 16204
[H,N] = list(map(int,input().split()))
A=  list(map(int,input().split()))

#Aを大きい順に並べ替え
A.sort(reverse=True)

#大きい方からNこの合計がH以上ならYes
sum=0
for i in range(0,N):
    sum = sum + A[i]

if sum>=H:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 52292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;

int ans[maxn];
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	
	int cnt;
	for(int i = 1 ; i < n ; i++){
		for(int j = i + 1 ; j <= n ; j++){
			cnt = min(j - i, abs(j - y) + 1 + abs(i - x));
			ans[cnt]++;
		}
	}
	for(int i = 1 ; i < n ; i++)cout << ans[i] << endl;
}

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

using namespace std;

const long long MAX = 500005;

const long long MAX1 = 1e6 + 5;

long long tree[MAX], p[MAX1], ans[MAX], a[MAX];

pair <long long, pair<long long, long long> > pr[MAX];

void update(long long idx, long long val) {

    while(idx < MAX) {

        tree[idx] += val;

        idx += (idx & -idx);

    }

}

long long read(long long idx) {

    long long sum = 0;

    while(idx > 0) {

        sum += tree[idx];

        idx -= (idx & -idx);

    }

    return sum;

}

int32_t main() {

    long long n, q, x;

    cin >> n >> q;

    for(long long i = 1; i <= n; ++i)

        cin >> a[i];

    for(long long i = 0; i < q; ++i) {

        cin >> pr[i].second.first >> pr[i].first;

        pr[i].second.second = i;

    }

    sort(pr, pr + q);

    memset(p, -1, sizeof(p));

    memset(tree, 0, sizeof(tree));

    x = 0;

    for(long long i = 1; i <= n; ++i) {

        if(p[a[i]] != -1)

            update(p[a[i]], -1);

        p[a[i]] = i;

        update(i, 1);

        while(x < q and pr[x].first == i) {

            ans[pr[x].second.second] = read(pr[x].first) - read(pr[x].second.first-1);

            x++;

        }

    }

    for(long long i = 0; i < q; ++i)

        cout << ans[i] << endl;

    return 0;

}



Measured memory_bytes: 34972
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 100000;

ll fact[N_MAX+1], rfact[N_MAX+1];

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> a(2*n);
    for(int i=0;i<2*n;++i) a[i] = (s[i]=='B')?1:0;
    init(n);

    if(a[0] == 0 || a[2*n-1] == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<ll> is_l(2*n, 1);
    for(int i=1;i<2*n;++i) {
        if(a[i-1] == a[i]) {
            is_l[i] = 1-is_l[i-1];
        } else {
            is_l[i] = is_l[i-1];
        }
    }

    if(accumulate(is_l.begin(), is_l.end(), 0) != n) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1LL;
    for(int i=1;i<2*n;++i) {
        if(!is_l[i]) {
            ans *= is_l[i-1];
            ans %= MOD;
            --is_l[i-1];
        }
        is_l[i] += is_l[i-1];
    }
    ans *= fact[n];
    ans %= MOD;
    cout << ans << endl;
}

/*
4
BWBBWWWB
*/

Measured memory_bytes: 5268
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string N;
void input(){
    fast_io();
    cin >> N;
}

int solve(){
    int ans = 0;
    for (int i = 0; i < N.length(); i++)
    {
        ans += N[i]-'0';
        ans %= 9;
    }
    if(ans) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}   

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

Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt();
        if(a>8||b>8) System.out.println(":(");
        else System.out.println("Yay!");


    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25208
n = int(input())
d = list(map(int, input().split()))
wari = 998244353

if d[0] != 0 or d.count(0) != 1:
    print(0)
else:
    d.sort()
    ans = 1
    nx = 0
    pre = 1
    cnt = 0
    for i in range(n):
        if d[i] == nx:
            cnt += 1
        else:
            if d[i] == nx + 1:
                ans = ans * pre ** cnt
                pre = cnt
                cnt = 1
                nx += 1
            else:
                ans = 0
                break
    ans = ans * pre ** cnt
    print(ans%wari)

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	
	vector<int> b;
	for(int i = 0; i < n; i++)
	{
		b.push_back(a[n - 1 - i]);
		i++;
	}
	
	if(a.size() % 2 == 0)
	{
		for(int i = 0; i < n; i++)
		{
			b.push_back(a[i]);
			i++;
		}
	}
	else
	{
		for(int i = 1; i < n; i++)
		{
			b.push_back(a[i]);
			i++;
		}
	}
	
	for(auto itr = b.begin(); itr != b.end(); itr++)
	{
		cout << *itr << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3828
#include<stdio.h>
int main()
{
	int n,T;
	scanf("%d%d",&n,&T);
	int c[n],t[n],min=10000,count=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d%d",&c[i],&t[i]);
	}
	
	for(int j=0;j<n;j++)
	{
		if(t[j]<=T)
		{
			if(c[j]<=min)
			{
				min=c[j];
			}
			count++;
		}
	}
	
	if(count>0)
	{
		printf("%d",min);
	}
	
	else if(count==0)
	{
		printf("TLE");
	}
	
	return 0;
}

Measured memory_bytes: 128
k = int(input())

def lunlun(x):
    s = str(x)
    good = 0
    for i in range(1, len(s)):
        if abs(int(s[i - 1]) - int(s[i])) > 1:
            # what is the "digit value" of s[i]
            return 10 ** (len(s) - i - 1)
    return good

n = 1
last = 0
total = 0
while total < k:
    skip = lunlun(n)
    if skip == 0:
        last = n
        total += 1
        n += 1
    else:
        n += skip

print(last)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] arr = br.readLine().split("\\s");
            double x1 = Double.parseDouble(arr[0]), y1 = Double.parseDouble(arr[1]), x2 = Double.parseDouble(arr[2]), y2 = Double.parseDouble(arr[3]);
            double h = Math.abs(y1 - y2);
            double w = Math.abs(x1 - x2);
            System.out.println(String.valueOf(Math.sqrt(Math.pow(h,2)+Math.pow(w,2))));
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24500
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
 
	int n, k;
	float odd;
	
	cin >> n >> k;
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int h;
		cin >> h;
		if (h >= k) {
			ans = ans + 1;
		}
	}
	
	cout << ans << endl;
 
 
}

Measured memory_bytes: 384
def solve():
    N_str = raw_input()
    num_digits = len(N_str)
    N = int(N_str)

    ans = 0
    test = 10 ** num_digits - 1
    while True:
        base = 10 ** (num_digits - 1)
        for _ in xrange(10):
            if test <= N:
                ans = test
                break
            test -= base
        if ans:
            break

    print sum([int(d) for d in str(ans)])


if __name__ == "__main__":
    solve()


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


using namespace std;





#define ll                  long long int


#define endl                '\n'


#define rep(i,a,b)          for(ll i=a;i<b;i++)





void solve()


{


    ll n;


    cin>>n;


    ll a[n+1];


    rep(i,1,n+1) cin >> a[i];


    ll ps[n+1],dp[n+1];


    dp[0] = 0;dp[1] = 0;


    ps[1] = a[1];


    for(ll i=3;i<=n;i+=2) ps[i] = ps[i-2] + a[i];


    rep(i,2,n+1){


        if (i&1){


            dp[i] = max(dp[i-1],a[i]+dp[i-2]);


        }


        else{


            dp[i] = max(dp[i-2] + a[i],ps[i-1]);


        }


    }


    cout << dp[n] << endl;




}




int32_t main(){


    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


    solve();


    return 0;


}



Measured memory_bytes: 8328
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,a,b,ans;
int main(){
	cin>>n>>a>>b;
	ans+=(n/(a+b))*a;
	n%=(a+b);
	if(n>a)
		ans+=a;
	else
		ans+=n;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
_, _, x, y = list(map(int, input().split()))
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_list.append(x)
x_list.sort()

y_list.append(y)
y_list.sort()

if x_list[0] < y_list[0]:
    if x_list[-1] >= y_list[0]:
        print("War")
    else:
        print("No War")
else:
    if y_list[-1] >= x_list[0]:
        print("War")
    else:
        print("No War")


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

bool cmp(int a,int b) {return a>b;}
int main()
{
    int n;
    int a[110];
    while(scanf("%d",&n)!=EOF)
    {
        for(int i = 0;i < n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n,cmp);
        int ans=1;
        for(int i=1;i<n;i++)
        {
            if(a[i]<a[i-1]) ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, M, As):
    prices = sorted(As, reverse=True) + [0]
    halfed_idx = []
    n = 0
    idx = 0
    for _ in range(M):
        if len(halfed_idx) == 0:
            prices[n] //= 2
            halfed_idx.append(n)
            n += 1
        else:
            if prices[n] > prices[halfed_idx[idx]]:
                prices[n] //= 2
                halfed_idx.append(n)
                n += 1
            else:
                prices[halfed_idx[idx]] //= 2
                halfed_idx.append(halfed_idx[idx])
                idx += 1
    print(sum(prices))


def solve2(N, M, As):
    """later (ave 2.3 second)"""
    As.sort()
    for i in range(M):
        p = As.pop() // 2
        As.insert(bisect.bisect_right(As, p), p)
    print(sum(As))


if __name__ == '__main__':
    N, M = map(int, input().split())
    As = [int(i) for i in input().split()]

    # N, M = 10 ** 5, 10 ** 5
    # from random import randint
    # As = [randint(1, 10 ** 9) for _ in range(N)]
    solve(N, M, As)
    # solve2(N, M, As)


Measured memory_bytes: 20536
#include<iostream>
#include<cstdio>
#include<math.h>
#define N 100
using namespace std;
int main()
{
	int n, total = 0;
	int A[N];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}

	for (int i = 0; i < n; i++)
	{
		int mini = A[i];
		int minnum = i;
		for (int j = i + 1; j < n; j++)
		{
			if (A[j] < mini)
			{
				mini = A[j];
				minnum = j;
			}
		}
		if (minnum != i)
		{
			swap(A[minnum], A[i]);
			total++;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << A[i];
		if (i < n - 1)
			cout << ' ';
	}
	cout << endl;
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 3136
#import <stdio.h>
#import <stdlib.h>
typedef long long INT;
int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}
int main(){
    INT n;
    scanf("%lld",&n);
    INT d[100001] = {0};
    for(int i=0;i<n;i++){
        scanf("%lld",d+i);
    }
    qsort(d, n, sizeof(INT), compare_int);
    printf("%lld",d[n/2]-d[n/2-1]);
}


Measured memory_bytes: 7888
import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 22592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll ct=0;
    ll mi=1LL<<60;
    ll ans=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]<0) ct++;
        mi = min(mi,llabs(A[i]));
        ans+=llabs(A[i]);
    }
    cout << (ct&1==1 ? ans-2*mi : ans) << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll inf = 1000000001;

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

    int n; cin>>n;
    vector<double>v;
    rep(i,n){
        double a; cin>>a;
        v.push_back(a);
    }
    sort(all(v));
    
    double total = v[0];
    rep(i,n-1) total = (total+v[i+1])/2;
    
    cout << total << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>

int main () {
  int N;
  std::cin >> N;
  char s[N];
  std::cin >> s;

  std::vector<char> left(26);
  std::vector<char> right(26);
  for (int i = 0; i < 26; i++) {
    left[i] = 0;
    right[i] = 0;  
  }


  int answer = 0;
  int answer_sub = 0;
  
  // for文で全体を見ていく.
  if ( N == 1 ) {
    std::cout << 0 << std::endl;
    return 0;  
  }


    // 最初に初期値について
  int iterator = 0;
  for (int i = 0; i <= N; i++) {
    iterator = s[i] - 'a';
    if (i == 0){
      left[iterator] += 1;   
    }
    else {
      if (left[iterator] == 1) {
        answer_sub = 1;
        answer = 1;
      }
      right[iterator] += 1;  
    }  
  }
  if (N == 2){
    std::cout << answer_sub << std::endl;  
    return 0;
  }
    // 右に切断箇所をずらしていく．
  int left_past = 0;
  int right_past = 0;
  for (int i = 1; i < N; i++) {
    iterator = s[i] - 'a';
    
    // 元々のデータ
    left_past = left[iterator];
    right_past = right[iterator];
    
    // 後のデータ
    left[iterator] += 1;
    right[iterator] -= 1;
    
    // ずらしたことによるanswerの変更について

      // 元はなかったけどずらしたことにより増えた
    if (right[iterator] > 0 && left_past == 0) {
      answer_sub++;
      if (answer <= answer_sub) {
        answer = answer_sub;  
      }  
    }

      // ずらしたけどセーフ
    /* if (left_past > 0 && right[iterator] > 0) {
      なにもしなくていい
    }*/

      // ずらしたら減った
    if (left_past > 0 && right[iterator] == 0) {
      answer_sub--;  
    }
  }
  
  // answerを出力
  std::cout << answer << std::endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
string o,e;
cin >> o>>e;
for (ll i = 0; i < e.size();i++){
    cout << o[i] << e[i];
}
if (o.size() != e.size()) cout << o[o.size()-1];
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x, y;

	while(1)
	{
		scanf("%d%d", &x, &y);

		if (x == 0 && y == 0)
			break;

		if (x > y)
		{
			int t = x;
			x = y;
			y = t;
		}

		printf("%d %d\n", x, y);
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
int main()
{
    int a,b;
    while(cin >> a >> b) {
        int sum = a + b;
        int cnt = 0;
        for(int i = 1;(sum / i) != 0; i *= 10) {
            cnt++;
        }
        cout << cnt << endl;
    }
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    string s; cin >> s;
    if (s[0] == 'S') cout << "Cloudy" << endl;
    if (s[0] == 'C') cout << "Rainy" << endl;
    if (s[0] == 'R') cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (t); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= (t); i--)
#define all(x) (x).begin(),(x).end()
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))

using namespace std;

using ll = long long;

int solve(int a, int b, int c) {
  int m = max(a, max(b, c));
  if (m == a)
    return b + c;
  else if (m ==b)
    return a + c;
  else
    return a + b;
}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << solve(a,b,c) << endl;

  return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B && B != C) cout << "Yes" << endl;
  else if (A == C && A != B) cout << "Yes" << endl;
  else if (B == C && A != B) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main (void){
	int r,g,b,n;
	while(scanf("%d%d%d",&r,&g,&b)!=EOF){
		n=r*100 + g*10 +b;
		if(n%4==0){
			printf("YES");}
		else printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String we = sc.next();

		if(we.equals("SAT")) {
			System.out.println(1);
		}
		else if(we.equals("FRI")) {
			System.out.println(2);
		}
		else if(we.equals("THU")) {
			System.out.println(3);
		}
		else if(we.equals("WED")) {
			System.out.println(4);
		}
		else if(we.equals("TUE")) {
			System.out.println(5);
		}
		else if(we.equals("MON")) {
			System.out.println(6);
		}
		else if (we.equals("SUN")){
			System.out.println(7);
		}
	}

}


Measured memory_bytes: 20820
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,a*n)<<endl;
}
 
   

Measured memory_bytes: 888
x = list(map(int, input().split()))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
y = Base_10_to_n(x[0], x[1])
print(len(str(y)))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        while (true) {
            int N = in.nextInt();
            if (N == 0) break;
            
            int sum = 1;
            for (int i = 2; i <= (int)Math.sqrt(N); i++) {
                if (N % i == 0) {
                    sum += i;
                    if (N / i > (int)Math.sqrt(N))
                        sum += N / i;
                }
            }
            
            if (N < sum) {
                System.out.println("abundant number");
            } else if (N == 1 || N > sum) {
                System.out.println("deficient number");
            } else {
                System.out.println("perfect number");
            }
        }
    }
}



Measured memory_bytes: 26468
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int sum=0; 
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	for(int x,i=1;i<=m;i++)scanf("%d",&x),sum+=x;
	if(sum>n)return puts("-1"),0;
	else printf("%d\n",n-sum);
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<P<int,int>> v(n);
  for(int i = 0; i < n; ++i){
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    if(abs(v[i].second - i) % 2 == 1)cnt++;
  }
  cout << cnt/2 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

vector<ll> yakusu(ll n){
    vector<ll> ret;
    for(ll i = 1; i*i <= n; i++){
        if(n % i != 0) continue;
        ret.push_back(i);
        if(i*i != n) ret.push_back(n/i);
    }
    sort(ret.begin(), ret.end());
    return ret;
}

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

bool is_prime(ll a){
    if(a == 1) return true;
    for(ll i=2; i*i<=a; i++){
        if(a%i == 0) return false;
    }
    return true;
}

int main(){
    ll A, B;
    cin >> A >> B;
    auto va = yakusu(A);
    auto vb = yakusu(B);
    vector<ll> koyaku;
    ll ib = 0;
    rep(i, 0, va.size()){
        bool f = true;
        rep(j, ib, vb.size()){
            if(vb[j] > va[i]){
                ib = min(0LL, j - 1);
                f = false;
                break;
            }else if(vb[j] == va[i]){
                ib = j + 1;
                f = false;
                koyaku.push_back(va[i]);
                break;
            }
        }
        if(f) break;
    }

    //for(auto k : koyaku) cerr << k << endl;

    ll ans = 0;
    rep(i, 0, koyaku.size()){
        if(is_prime(koyaku[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
unittest
{
	assert( [ "4", "4", "0", "3", "2" ].parse.expand.solve == 4 );
	assert( [ "8", "2", "0", "1", "6", "0", "8", "2", "1" ].parse.expand.solve == 9 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	for( auto i = 0L; i < as.length; i++ )
	{
		auto c = as[ i ] / 2;
		as[ i ] -= c * 2;
		if( i + 1 < as.length && 0 < as[ i ] && 0 < as[ i + 1 ] )
		{
			c++;
			as[ i + 1 ]--;
		}
		ans += c;
	}
	return ans;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;

// i: 左からみた桁数(0桁あり), j: 非ゼロの使用回数, k: 0:最大値の可能性あり 1: なし
int dp[101][4][2];

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

  int ndigits = n.size();
  int K;
  cin>>K;

  dp[0][0][0] = 1;
  REP(i,ndigits)REP(j,4)REP(k,2) {
    // printf("i: %d, j: %d, k: %d\n", i, j, k);
    // nd: nの今の桁のdigit
    int nd = n[i]-'0';
    // d: 次の桁のdigit
    REP(d,10) {
      // ni: 次の桁の位置
      // nj: 次の桁まででの非ゼロの数
      // nk: 次の桁まででの最大かどうかの状態
      int ni = i+1, nj = j, nk = k;
      // 次の桁のdigitが0でないなら非ゼロの数を増やす
      if(d!=0) nj++;
      // 使用できる非ゼロの数より多くなるなら遷移しない
      if(nj>K) continue;
      // 最大値の可能性がある場合
      if(k==0) {
        // 最大値を超えるので遷移しない
        if(d>nd) continue;
        // 最大値より小さくなるのでkを遷移させる
        if(d<nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
      // printf("d: %d, dp[%d][%d][%d]: %d -> dp[%d][%d][%d]: %d\n", d, i, j, k, dp[i][j][k], ni, nj, nk, dp[ni][nj][nk]);
    }
    // printf("\n");
  }

  // printf("dp[n][K][0]: %d\n", dp[ndigits][K][0]);
  // printf("dp[n][K][1]: %d\n", dp[ndigits][K][1]);

  int ans = dp[ndigits][K][0] + dp[ndigits][K][1];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;



use std::ops::{ Add, Sub , Div , Mul };
static global_mod : i64 = 1000000007;





fn main() {

    input! { 
       n: usize,
       b: [i64;n-1],
    }

    
    let mut ans = vec![0;n];
    ans[0] = b[0];
    ans[n-1] = b[n-2];
    for i in 1..n-1{
        ans[i] = cmp::min(b[i], b[i-1]);
        //mydbg!(ans);
    }

    let mut ans2 = 0;
    for item in ans{
        ans2 += item;
    }
    println!("{}",ans2);
    
    
    

}


Measured memory_bytes: 4352
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int contain(vector<Point> v, Point p) {
	bool in = false;
	for (int i = 0; i < v.size(); ++i) {
		Point a = v[i] - p, b = v[(i + 1) % v.size()] - p;
		if (a.py > b.py) swap(a, b);
		if (a.py <= 0 && 0 < b.py)
			if (crs(a, b) < 0) in = !in;
		if (crs(a, b) == 0 && dot(a, b) <= 0) return 1;
	}
	return in ? 2 : 0;
}
// ------ Main ------ //
int n, q; vector<Point> v; Point r;
int main() {
	cin >> n; v.resize(n);
	for (int i = 0; i < n; i++) cin >> v[i].px >> v[i].py;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> r.px >> r.py;
		cout << contain(v, r) << endl;
	}
	return 0;
}

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

long long gcd(long a, long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main() {
    long long A, B;
    cin >> A >> B;
    long long ans = lcm(A, B);
    cout << ans << endl;
}

Measured memory_bytes: 256