akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s,t;
  cin >> s >> t;
  string ans="";ans+=(char)('z'+1);
  for(int i=0; i<s.size()-t.size()+1; i++) {
    string r;
    rep(j,t.size()) {
      if(s[i+j]=='?') continue;
      if(s[i+j]!=t[j]) goto next;
    }
    r=s.substr(0,i)+t+s.substr(i+t.size());
    rep(j,r.size()) {
      if(r[j]=='?') r[j]='a';
    }
    ans=min(ans,r);
  next:;
  }
  if(ans[0]>'z') pr("UNRESTORABLE");
  else pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

long long A[100000];
long long X[100000];

int main(void) {
	int N;
	cin >> N;
	long long real_sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		real_sum += A[i];
	}

	X[0] = real_sum;
	for (int i = 1; i < N; i+=2) {
		X[0] -= 2*A[i];
	}
	for (int i = 1; i < N; i++) {
		X[i] = 2*A[i-1]-X[i-1];
	}
	for (int i = 0; i < N; i++) {
		cout << X[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String str = sc.nextLine();
		str = sc.nextLine();
		sc.close();
		int l = str.length();
		String ans = "Yes";
		if (k >= l ) {
			ans = str;
			System.out.println(ans);

		} else {
			ans = str.substring(0, k);
			System.out.println(ans+"...");

		}
	}
}


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

using namespace std;

class C {
	int N;
	vector<int> dp;
	int options[12]{ 1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049 };
	int n_options{ 12 };
	int MAX{ 100005 };

public:
	void solve()
	{
		cin >> N;

		for (int i{ 0 }; i < N; i++)
		{
			for (int j{ 0 }; j < n_options; j++)
			{
				if ((i + options[j]) < MAX)
				{
					dp[i + options[j]] = min(dp[i + options[j]], dp[i] + 1);
				}
			}
		}

		cout << dp[N] << endl;

	}

	C()
	{
		dp.resize(MAX);
		for (int i{ 0 }; i < MAX; i++) dp[i] = 99999;
		dp[0] = 0;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll n,a,b,c;
vll l;
ll ans=INF;
void rec(ll A, ll B, ll C, ll cost, ll cnt){
  if(cnt>=n){
    if(!A||!B||!C) return;
    chmin(ans,abs(a-A)+abs(b-B)+abs(c-C)+cost);
    return;
  }
  rec(A,B,C,cost,cnt+1);
  rec(A+l[cnt],B,C,A?cost+10:cost,cnt+1);
  rec(A,B+l[cnt],C,B?cost+10:cost,cnt+1);
  rec(A,B,C+l[cnt],C?cost+10:cost,cnt+1);
}


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>a>>b>>c;
  l.resize(n);
  rep(i,n) cin>>l[i];
  rec(0,0,0,0,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from decimal import Decimal

x = int(input())
cnt = 0

while True:
    a = cnt ** 5
    if a < x:
        a = x - a
        z = -1
    else:
        a -= x
        z = 1

    a = Decimal(a) ** Decimal("0.2")
    if a % 1 == 0:
        print(cnt, int(a * z))
        break

    cnt += 1

Measured memory_bytes: 10072
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w,h,c;
    cin >> w >> h >> c;
    PRINT(c*(w/gcd(w,h))*(h/gcd(w,h)));
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,t,u;
  int a, b;
  cin >> s;
  //cin >> a >> b;
  //cin >> s >> t >> u;
  
  if(s[2]==s[3]&&s[4]==s[5]) cout <<  "Yes" << endl; 
  else cout << "No" << endl; 
  
}

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

using namespace std;

using ll = long long;
const int MAX = 50;
const int LAYERS = 2500;

int main() {
    int N, M, S;
    cin >> N >> M >> S;
    vector<vector<tuple<int, int, int>>> adj(N);
    for (int i = 0; i < M; i++) {
        int u, v, a, b;
        cin >> u >> v >> a >> b, u--, v--;
        adj[u].emplace_back(v, a, b);
        adj[v].emplace_back(u, a, b);
    }
    vector<int> Cs(N), Ds(N);
    for (int i = 0; i < N; i++) {
        cin >> Cs[i] >> Ds[i];
    }
    vector<ll> ans(N);
    set<int> has, vis;
    priority_queue<pair<ll, int>> pq;
    pq.emplace(0, min(LAYERS, S) * MAX);
    while (has.size() < N) {
        ll w;
        int ind, n, s;
        tie(w, ind) = pq.top();
        pq.pop();
        if (vis.count(ind))
            continue;
        vis.emplace(ind);
        s = ind / MAX;
        n = ind % MAX;
        if (!has.count(n)) {
            has.emplace(n);
            ans[n] = w;
        }
        pq.emplace(w - Ds[n], n + min(LAYERS, s + Cs[n]) * MAX);
        for (auto edge : adj[n]) {
            int v, a, b;
            tie(v, a, b) = edge;
            if (a > s)
                continue;
            int nind = v + min(LAYERS, s - a) * MAX;
            if (vis.count(nind))
                continue;
            pq.emplace(w - b, nind);
        }
    }
    for (int i = 1; i < N; i++) {
        cout << -ans[i] << endl;
    }
}


Measured memory_bytes: 11508
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a - b >= 0)
		cout << "delicious";
	else if (b - a <= x)
		cout << "safe";
	else
		cout << "dangerous";
}

Measured memory_bytes: 256
#!python3

from heapq import heappop, heappush

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

# input
N = int(input())
A = LI()


def main():
    A.sort(reverse=True)
    hq = [-A[0]]
    ans = 0
    for a in A[1:]:
        ans -= heappop(hq)
        heappush(hq, -a)
        heappush(hq, -a)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33040
def sums(N):
  return 1 + (N-1) * 0.5

N, K = map(int, input().split())
Ps = list(map(int, input().split()))

exp = [0 for _ in range(N)]
for i in range(0, N):
  exp[i] = sums(Ps[i])

summed = [0 for _ in range(N)]
summed[0] = exp[0]

for i in range(1, N):
  summed[i] = summed[i-1] + exp[i]

max_i=summed[K-1]

for i in range(K, N):
  max_i = max(max_i, summed[i]-summed[i-K])

print(max_i)


Measured memory_bytes: 90248
#include <iostream>

using namespace std;

int main(){
  long long n, prev, a, b;
  long long fatig = 0; 
  cin >> n >> a >> b;
  
  cin >> prev;
  for (int i=1;i<n;i++) {
    long long fatig_tmp;
    long long d, x;
    cin >> x;
    fatig_tmp = a*(x - prev);
    if (fatig_tmp > b) {
      fatig_tmp = b;
    }
    fatig += fatig_tmp;
    prev = x;
  }
  cout << fatig << endl;
  return(0);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


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

}

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

int main()
{
  int x[2], y[2];
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  int dx = x[1] - x[0], dy = y[1] - y[0];
  cout << x[1] - dy << ' ' << y[1] + dx << ' '
       << x[0] - dy << ' ' << y[0] + dx << endl;
}

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

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[k-1])

Measured memory_bytes: 3060
package main

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

func main() {
	scanInit()

	n := nextInt()

	minsum := 99999999
	for i := 1; i < n; i++ {
		b := n - i
		minsum = min(minsum, sumKeta(i)+sumKeta(b))
	}

	fmt.Println(minsum)

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

// 各桁の和
func sumKeta(n int) int {
	keta := 0
	for n > 0 {
		keta += n % 10
		n /= 10
	}
	return keta
}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
*abcd, = map(str, input())

a = [""]*len(abcd)
ans = []

def rec(i: int, a: list) -> None:
    if i == len(abcd)-1:
        statement = "".join(_abcd+_a for _abcd, _a in zip(abcd, a))
        if eval(statement) == 7:
            global ans
            ans.append(statement)

        return

    a[i] = "-"
    rec(i+1, a)
    a[i] = "+"
    rec(i+1, a)

rec(0, a)
print(ans[0]+"=7")


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long ll;

const int MAXN = 2e5 + 1, MOD = 998244353;
int N;
ll num[MAXN][4], pow2[MAXN];
pair<int, int> points[MAXN];

struct BIT
{
    int data[MAXN] = {0};
    
    int lowbit(int x)
    {
        return x & -x;
    }

    void add(int x, int k)
    {
        while (x <= N)
        {
            data[x] += k;
            x += lowbit(x);
        }
    }

    int sum(int x)
    {
        int out = 0;
        while (x > 0)
        {
            out += data[x];
            x -= lowbit(x);
        }
        return out;
    }
};

inline ll mul(ll x, ll y)
{
    return x * y % MOD;
}

int main()
{
    cin >> N;
    pow2[0] = 1;
    for (int i = 1; i <= N; i++)
    {
        cin >> points[i].first >> points[i].second;
        pow2[i] = pow2[i - 1] * 2 % MOD;
    }
    // discretize y
    sort(points + 1, points + N + 1, [](pair<int, int> a, pair<int, int> b) -> bool { return a.second < b.second; });
    for (int i = 1; i <= N; i++)
    {
        points[i].second = i;
    }
    // discretize x
    sort(points + 1, points + N + 1);
    for (int i = 1; i <= N; i++)
    {
        points[i].first = i;
    }

    for (int mode = 0; mode <= 1; mode++)
    {
        BIT bit;
        for (int i = 1; i <= N; i++)
        {
            int a = bit.sum(points[i].second - 1), b = i - bit.sum(points[i].second) - 1;
            if (mode == 0)
            {
                num[i][0] = a;
                num[i][1] = b;
            }
            else
            {
                num[N + 1 - i][2] = b;
                num[N + 1 - i][3] = a;
            }
            bit.add(points[i].second, 1);
        }
        reverse(points + 1, points + 1 + N);
    }

    ll ans = 0;
    for (int i = 1; i <= N; i++)
    {
        ans = (ans + pow2[N - 1] + mul(mul(pow2[num[i][0]] - 1, pow2[num[i][2]] - 1), pow2[num[i][1] + num[i][3]])) % MOD;
        ans = (ans + mul(mul(pow2[num[i][1]] - 1, pow2[num[i][3]] - 1), pow2[num[i][0] + num[i][2]])) % MOD;
        ans = ((ans - mul(mul(pow2[num[i][0]] - 1, pow2[num[i][1]] - 1), mul(pow2[num[i][2]] - 1, pow2[num[i][3]] - 1))) % MOD + MOD) % MOD;
    }
    cout << ans << endl;
    // system("pause");
}

Measured memory_bytes: 10368
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()

	ans := map[int]int{}

	nmax := 10050
	for x := 1; x <= 105; x++ {
		for y := 1; y <= 105; y++ {
			for z := 1; z <= 105; z++ {
				v := x*x + y*y + z*z + x*y + y*z + x*z
				if v < nmax {
					ans[v]++
				}
			}
		}
	}

	for i := 1; i <= N; i++ {
		fmt.Println(ans[i])
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

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

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

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

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

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

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

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

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


Measured memory_bytes: 2628
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const ll mod = 998244353;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint dp[200005], sum[200005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> l(k), r(k);
	rep(i,k){
		cin >> l[i] >> r[i];
		++r[i];
	}
	dp[1] = 1;
	sum[0] = 0;
	sum[1] = 1;
	for(int i = 2; i <= n; ++i){
		mint score = 0;
		rep(j,k){
			int left = i - r[j];
			int right = i - l[j];
			chmax(left, 0);
			chmax(right, 0);
			score += sum[right] - sum[left];
			//cout << j << " " << left << " " << right << endl;
		}
		//cout << i << ": " << score.x << " ";
		dp[i] = score;
		sum[i] = sum[i-1] + dp[i];
		//cout << sum[i].x << endl;
	}
	cout << dp[n].x << endl;
	return 0;
}


Measured memory_bytes: 6728
#include <cstdio>

using namespace std;

char s[100010];

int main()
{
	int n,A,B;scanf("%d%d%d",&n,&A,&B);
	int s1=0,s2=0;
	scanf("%s",s);
	for (int i=0;i<n;i++)
	{
		if (s[i]=='a')
		{
			if (s1+s2<A+B) {s1++;puts("Yes");} else puts("No");
		}
		if (s[i]=='b')
		{
			if (s1+s2<A+B&&s2<B) {s2++;puts("Yes");} else puts("No");
		}
		if (s[i]=='c') puts("No");
	}
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using V = vector<int>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }


int main() {
  int n, q; cin >> n >> q;
  V c(n); cin >> c;
  rep(i, n) --c[i];
  int B = sqrt(2*q); // number of buckets

  // input and sort queries
  using Query = array<int, 3>;
  vector<Query> query(q);
  rep(i, q) {
    int l, r; cin >> l >> r;
    --l;
    query[i] = {l, r, i};
  }
  sort(all(query), [&] (const Query &a, const Query &b) {
    if (a[0] / B != b[0] / B) return a[0] < b[0];
    else if (a[0] / B % 2 == 0) return a[1] < b[1];
    else return a[1] > b[1];
  });

  // edit here
  int sum = 0;
  int l = 0, r = 0;
  V cnt(n), ans(q);

  auto add = [&] (const int i) {
    if (cnt[c[i]] == 0) ++sum;
    ++cnt[c[i]];
  };
  auto del = [&] (const int i) {
    --cnt[c[i]];
    if (cnt[c[i]] == 0) --sum;
  };
  // 

  // O(n \sqrt{q})
  for(const auto [li, ri, i] : query) {
    while (li < l) add(--l);
    while (ri < r) del(--r);
    while (r < ri) add(r++);
    while (l < li) del(l++);
    ans[i] = sum;
  }

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


Measured memory_bytes: 15488
-- Ball
import Control.Monad

main = readLn
  >>= (\ n -> replicateM n getLine)
--   >>= mapM solve . map (map read . words)
  >>= putStr . unlines . map(tellYesNo . dfs 0 0 . map read . words)

-- solve :: [Int] -> IO ()
-- solve = putStrLn . tellYesNo . dfs 0 0

dfs :: Int -> Int -> [Int] -> Bool
dfs _ _ [] = True
dfs l r (x:xs)
  | l < x && r < x = dfs x r xs || dfs l x xs
  | l < x = dfs x r xs
  | r < x = dfs l x xs
  | otherwise = False

tellYesNo :: Bool -> String
tellYesNo b
  | b == True = "YES"
  | otherwise = "NO"

Measured memory_bytes: 4028
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static int n;
    static int[] p = new int[105];
    static int[][] dp = new int[105][105];

    public static void main(String[] args) {
        read();
        System.out.println(solve());
    }

    public static void read() {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            p[i - 1] = sc.nextInt();
            p[i] = sc.nextInt();
        }
    }

    public static int solve() {
        for (int i = 0; i < 105; i++) {
            for (int j = 0; j < 105; j++) {
                dp[i][j] = 1 << 31 - 1;
            }
        }

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

        for (int l = 2; l <= n; l++) {
            for (int i = 1; i <= n - l + 1; i++) {
                int j = i + l - 1;
                for (int k = i; k <= j; k++) {
                    dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k + 1][j] + (p[i - 1] * p[k] * p[j]));
                }
            }
        }

        return dp[1][n];
    }
}

Measured memory_bytes: 26500
x, y = map(int, input().split())

f = False
for num_of_tsuru in range(0, x+1):
    num_of_kame = x - num_of_tsuru
    if (2*num_of_tsuru) + (4*num_of_kame) == y:
        f = True
        break

if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9172
import           Control.Applicative
import           Control.Monad

grade :: [Int] -> String
grade [m, f, r]
    | m == -1 || f == -1 = "F"
    | total >= 80 = "A"
    | total >= 65 = "B"
    | total >= 50 = "C"
    | total >= 30 && r >= 50 = "C"
    | total >= 30 = "D"
    | otherwise   = "F"
  where
    total = m + f

main :: IO ()
main = do
    xss <- fmap (fmap read . words) . lines <$> getContents :: IO [[Int]]
    let yss = takeWhile (/= [-1, -1, -1]) xss
    forM_ yss $ \ys -> do
        putStrLn $ grade ys



Measured memory_bytes: 4068
val = [int(x) for x in input().split()]

if val[1] <= val[2]:
    print(val[2]-(val[1]+val[0]) if val[2]-(val[1]+val[0]) > 0 else 0)
else:
    print(val[1]-(val[2]+val[0]) if val[1]-(val[2]+val[0]) > 0 else 0)


Measured memory_bytes: 3060
import java.util.*;
import java.math.*;
class Main {
    //
    static final int MOD = 1_000_000_007; // 10^9+7
    //static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        String s = sc.next();
        char[] str = s.toCharArray();
        int[] strnum = new int[n];
        int[] mod = new int[n];
        for(int i = 0;i < n;i++){
            strnum[i] = str[i]-'0';
        }
        mod[n-1] = strnum[n-1]%p;
        for(int i = n-2;i >= 0;i--){
            mod[i] = (int)(mod[i+1]+strnum[i]*pow(10,n-i-1,p))%p;
            if(mod[i]<0)mod[i]+=p;
        }
        long ans = 0;
        if(p==2||p==5){
            for(int i = 0;i < n;i++){
                if(strnum[i]%p==0)ans+=i+1;
            }
        }else{
            long[] count = new long[p];
            for(int i = 0;i < n;i++){
                count[mod[i]]++;
            }
            ans += count[0]*(count[0]+1)/2;
            for(int i = 1;i < p;i++){
                ans += count[i]*(count[i]-1)/2;
            }
            //System.out.println("poyo");
        }
        System.out.println(ans);

    }
    public static long pow(long a, long b, int M) {
		long ret = 1;
		long tmp = a;
		while (b > 0) {
			if ((b & 1) == 1)
				ret = (ret * tmp) % M;
			tmp = (tmp * tmp) % M;
			b = b >> 1;
        }
        
		return ret;
	}
}



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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int X, Y, A, B, C;
std::vector<P> apples;

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

  std::cin >> X >> Y >> A >> B >> C;

  for(int i=0;i<A;++i){
      int p;
      std::cin >> p;

      apples.emplace_back(p, 0);
  }

  for(int i=0;i<B;++i){
      int p;
      std::cin >> p;

      apples.emplace_back(p, 1);
  }

  for(int i=0;i<C;++i){
      int p;
      std::cin >> p;

      apples.emplace_back(p, 2);
  }

  std::sort(apples.rbegin(), apples.rend());

  int cur = 0;
  int n = 0, rn = 0, gn = 0;
  ll mx = 0;

  while(n < X + Y){
      int p, c;
      std::tie(p, c) = apples[cur];

      if(c == 0){
          if(rn < X){
              n += 1;
              rn += 1;
              mx += p;
          }
      }else if(c == 1){
          if(gn < Y){
              n += 1;
              gn += 1;
              mx += p;
          }
      }else{
          n += 1;
          mx += p;
      }

      cur += 1;
  }

  std::cout << mx << std::endl;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t x;
	cin >> x;
	//処理
	for (int64_t i = -200; i < 200; i++) {
		for (int64_t j = -200; j < 200; j++) {
			if (i * i * i * i * i - j * j * j * j * j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string x;
    cin>>x;
    int rock=0,paper=0;

    int ans=0;
    for(int i=0;i<x.length();i++){
        if (x[i]=='g'&& rock>paper){
            ans++;
            paper++;
        }else if (x[i]=='g'&&rock<=paper){
            rock++;
        }else if (x[i]=='p'&&rock<=paper){
            ans--;
            rock++;
        }
        else if(x[i]=='p'&&rock>paper){
            paper++;
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n; i++)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    LL n;
    cin >> n;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<LL> b;
    if(a[0]%2 == 1) b.pb(n);
    rep1(i, n){
        if((a[i]-a[i-1])%2 == 1) b.pb(n-i);
    }
    LL x = 0;
    rep(i, b.size()) x = x^b[i];

    cout << (x ? "first" : "second") << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_V 100
#define min(a, b) ((a) < (b) ? (a) : (b))

const int INF = 100000000;
int cost[MAX_V][MAX_V];
int V;

int
prim()
{
	int mincost[MAX_V];
	bool used[MAX_V];
	int u, v;
	int i;

	for (i = 0; i < V; ++i)
	{
		mincost[i] = INF;
		used[i] = false;
	}

	int res = 0;
	mincost[0] = 0;
	while (true)
	{
		v = -1;
		for (u = 0; u < V; ++u)
		{
			if (!used[u] && (v == -1 || mincost[u] < mincost[v]))
				v = u;
		}

		if (v == -1)
			break;

		used[v] = true;
		res += mincost[v];
		for (u = 0; u < V; ++u)
			mincost[u] = min(mincost[u], cost[v][u]);
	}

	return res;
}

int
main(int argc, char** argv)
{
	int c;
	int i, j;

	scanf("%d", &V);
	for (i = 0; i < V; ++i)
	{
		for (j = 0; j < V; ++j)
		{
			scanf("%d", &c);
			cost[i][j] = (c != -1) ? c : INF;
		}
	}

	printf("%d\n", prim());
	return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// エラトステネスのふるい
/*
int MAX=101010;
vector<int> is_prime(MAX,1);
is_prime[0]=0,is_prime[1]=0;
for(int i=2;i<MAX;i++){
    if(!is_prime[i]) continue;
    for(int j=i*2;j<MAX;j+=i) is_prime[j]=0;
}*/

int main(){
    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i) ans+=j;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3624
use std::io::{self, BufRead, BufWriter, Write};

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let a_line = lines.next().unwrap().unwrap();
    let mut splited = a_line.trim().split_whitespace();
    let n: i32 = splited.next().unwrap().parse().unwrap();
    let _m: i32 = splited.next().unwrap().parse().unwrap();

    let mut all_opened: usize = 0;
    for i in 0 .. n {
        let bit = 1 << i;
        all_opened |= bit;
    }

    let mut dp: Vec<i32> = vec![std::i32::MAX; all_opened as usize + 1];
    dp[0] = 0;

    loop {
        let a_line = match lines.next() {
            Some(x) => x.unwrap(),
            None => break,
        };
        let mut splited = a_line.trim().split_whitespace();
        let a: i32 = splited.next().unwrap().parse().unwrap();
        let _b: i32 = splited.next().unwrap().parse().unwrap();
        
        let a_line = lines.next().unwrap().unwrap();
        let splited = a_line.trim().split_whitespace();
        let cs = splited.map(|s| s.parse::<i32>().unwrap());

        let mut keys: usize = 0;
        for c in cs {
            let bit = 1 << (c - 1);
            keys |= bit;
        }

        for i in 0 .. dp.len() {
            let opened = i as usize;
            let new_opened = opened | keys;
            let new_cost = if dp[opened] < std::i32::MAX {
                dp[opened] + a
            } else {
                std::i32::MAX
            };
            if new_cost < dp[new_opened] {
                dp[new_opened] = new_cost;
            }
        }
    };

    let ans = if dp[all_opened] < std::i32::MAX {
        dp[all_opened]
    } else {
        -1
    };

    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let stdout = io::stdout();
    let output = BufWriter::new(stdout.lock());

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"2 3
10 1
1
15 1
2
30 2
1 2", br"25
",
        ),
        (
            br"12 1
100000 1
2", br"-1
",
        ),
        (
            br"4 6
67786 3
1 3 4
3497 1
2
44908 3
2 3 4
2156 3
2 3 4
26230 1
2
86918 1
3", br"69942
",
        ),
    ];

    #[test]
    fn test_e() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
//#include <algorithm>
#define endl "\n"
typedef long long ll;

using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

//int  frq[200];
int main(){
	Lancer();
	//cout << fixed << setprecision(12);

	ll even, odd, res, r1,r2;
	cin >> even >> odd;
	r1 = (even*(even - 1)) / 2;
	r2 = (odd*(odd - 1)) / 2;
	res = r1 + r2;
	cout << res;
	cout << endl;
	return 0;
}


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

#define ll       long long
#define LL       long long
#define ull      unsigned ll
#define pii      pair<int, int>
#define pll      pair<ll, ll>
#define mp       make_pair
#define ff       first
#define ss       second
#define sz(s)    (int) s.size()
#define all(s)   s.begin(), s.end()

template<typename T> inline void smin(T &a, T b) {
    a = a < b ? a : b;
}
template<typename T> inline void smax(T &a, T b) {
    a = a > b ? a : b;
}

template<typename T> inline void Int(T &n) {
    n = 0;
    int f = 1;
    register int ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n *= f;
}
template<typename T, typename TT> inline void Int(T &n, TT &m) {
    Int(n), Int(m);
}
template<typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) {
    Int(n), Int(m, l);
}

#define error(args...) { string _s = #args; replace(all(_s), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {
    cout << endl;
}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ", ";
    err(++it, args...);
}

const int mod = (int) 1e9 + 7;

int add(int a, int b) {
    a += b;
    if(a >= mod) a -= mod;
    return a;
}
int sub(int a, int b) {
    a -= b;
    if(a <= 0) a += mod;
    return a;
}
int mul(int a, int b) {
    return (ll) a * b % mod;
}

const int inf = (int) 1e9 + 5;
const ll  Inf = (ll) 2e18 + 5;
const int   N = (int) 3e2 + 5;




int solve() {
    int n, k;
    Int(n, k);
    vector<int> dp(k + 1, 0);
    vector<int> a(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        Int(a[i]);
    }
    for(int i = 0; i <= k; i++) {
        if(dp[i] == 0) {
            for(int j = 1; j <= n; j++) {
                if(i + a[j] <= k) {
                    dp[i + a[j]] = 1;
                }
            }
        }
    }
    dp[k] ? puts("First") : puts("Second");
    return 0;
}

int main() {
    int test = 1, tc = 0;
    //Int(test);
    while(test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}




Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
p = 0
q = 0
for x in a:
  if x%2 == 1:
    p += 1
  elif x%4 == 0:
    q += 1
if (p == q+1 and  p+q == n) or  p <= q:
  print("Yes")
else:
  print("No")

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

int main() {
    int n; cin >> n;
    vector<double> p(n);
    for (int i=0; i<n; ++i) cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0.0));
    dp[0][0] = 1.0;
    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }
    double ans = 0.0;
    for (int i=n/2 +1; i<=n; ++i) {
        ans += dp[n][i];
    }
    printf("%.15lf\n", ans);
}

Measured memory_bytes: 70656
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, ans, a[200009], b[200009], c[600009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>a[i];
    rep(i,N) cin>>b[i];
    
    ll ret=0;
    rep(i,29){
        rep(x,N) c[x]=b[x]&((1<<(i+1))-1);
        sort(c,c+N);
        rep(x,2*N) c[N+x]=c[x]+(1<<(i+1));
        ll tot=0;
        rep(x,N){
            int y=a[x]&((1<<(i+1))-1);
            tot+=lower_bound(c,c+3*N,(4<<i)-y)-lower_bound(c,c+3*N,(3<<i)-y);
        }
        if(tot%2) ret+=1<<i;
    }
    cout1(ret);
}

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

bool isprime[50001];

void eratos(int n){
  
  for(int i=0  ; i <= n ; i++){
    isprime[i]=true;
  }
  isprime[0]=isprime[1]=false;
  for(int i=2 ; i <= sqrt(n) ; i++){
    if(isprime[i]){
      int j=i+i;
      while(j <= n){
	isprime[j]=false;
	j=j+i;
      }
    }
  }

}

int main(){
  
  eratos(50000);
  
  int n;
  while(1){
    cin >>n;
    if(n == 0)break;
    int ans=0;
    for(int i=0 ; i <= n/2 ; i++){
      if(isprime[i] && isprime[n-i])ans++;
    }
    cout <<ans<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize,
        lr: [(usize1, usize1);n]
    }
    let mut ret = 0;
    for (l,r) in lr {
        ret += r+1-l;
    }
    println!("{}", ret);
}

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

namespace AtCoderCS
{
	public interface IReader
	{
		string ReadLine();
	}
	public class ConsoleReader : IReader
	{
		public string ReadLine() {
			return Console.ReadLine();
		}
	}

	public interface IWriter
	{
		void WriteLine(string line);
		void WriteLine(int value);
		void WriteLine(ulong value);
	}
	public class ConsoleWriter : IWriter
	{
		public void WriteLine(string line){
			Console.WriteLine(line);
		}
		public void WriteLine(ulong value) { Console.WriteLine(value); }
		public void WriteLine(int value) { Console.WriteLine(value); }
	}

	public class Solver
	{
		IReader _reader;
		IWriter _writer;

		public Solver(IReader reader = null, IWriter writer = null) {
			if (reader == null) {
				_reader = new ConsoleReader();
			} else {
				_reader = reader;
			}

			if (writer == null) {
				_writer = new ConsoleWriter();
			} else {
				_writer = writer;
			}
		}

		public void Run() {
			//// 整数の入力
			//int a = int.Parse(Console.ReadLine());
			//// スペース区切りの整数の入力
			//string[] input = Console.ReadLine().Split(' ');
			//int b = int.Parse(input[0]);
			//int c = int.Parse(input[1]);
			//// 文字列の入力
			//string s = Console.ReadLine();
			////出力
			//Console.WriteLine((a + b + c) + " " + s);

			var s = _reader.ReadLine();
			//_writer.WriteLine(s);

			//bit全探索
			//+ を入れられる場所の数
			var n = s.Length - 1;

			ulong sum = 0;
			// bit mask の生成
			// 2^n     = 1 << n
			for (ulong mask = 0; mask <= ((1ul << n) - 1); mask++) {
				int lastIdx = 0;

				// 各bitを下から舐める
				for (int i = 0; i < n; i++) {
					//iビット目が立っている？
					if (0 != (mask & (1ul << i))) {
						// '+'を i番目 と i+1番目の間に入れる
						var sub = s.Substring(lastIdx, i - lastIdx + 1);
						sum += ulong.Parse(sub);
						lastIdx = i + 1;
					}
				}
				// 残り全部
				var rest = s.Substring(lastIdx, s.Length - lastIdx);
				sum += ulong.Parse(rest);
			}
			_writer.WriteLine(sum);
		}
	}

	class MainClass
	{
		public static void Main(string[] args) {
			new Solver().Run();
		}
	}
}


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

struct circle{
	double x;
	double y;
	double r;
};

int judge_intersection(circle ca, circle cb){
	double dis2 = (ca.x - cb.x) * (ca.x - cb.x)
				+ (ca.y - cb.y) * (ca.y - cb.y);
	if((ca.r > cb.r) && ((ca.r - cb.r) * (ca.r - cb.r) > dis2)){
		return 2;
	} else if((cb.r > ca.r) && ((ca.r - cb.r) * (ca.r - cb.r) > dis2)){
		return -2;
	} else if((ca.r + cb.r) * (ca.r + cb.r) >= dis2){
		return 1;
	} else {
		return 0;
	}
}

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		circle ca, cb;
		cin >> ca.x >> ca.y >> ca.r
			>> cb.x >> cb.y >> cb.r;
		cout << judge_intersection(ca, cb) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
int main()
{
	str s, t;
	cin >> s >> t;
	for (int i = 0; i < s.size(); i++)
	{
		cout << s.at(i);
		if (i != t.size())
		{
			cout << t.at(i);
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ull = unsigned long long;

int main(){
    int n;
    ull ans=0LL;
    cin>>n;
    
    vector<ull> a(n+1), b(n), arr(n+1,0);
    for(int i=0;i<=n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }

    for(int i=0;i<n;i++){
        ull tmp = min(a[i]-arr[i], b[i]);
        arr[i]+=tmp;
        arr[i+1]+=min(a[i+1], b[i]-tmp);
        ans+=arr[i];
    }
    ans+=arr[n];
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2560
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

// 多重vectorを可変引数テンプレートで http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//

#pragma endregion

int main(){
    string s;
    cin >> s;
    i64 n = s.length();
    i64 k;
    cin >> k;
    vector<vector<vector<i64>>> dp(n + 1, vector<vector<i64>>(4, vector<i64>(2, 0)));
    dp[0][1][0] = 1;
    dp[0][1][1] = s[0] - '1';
    for(i64 i = 1; i < n; ++i){
        if(s[i] == '0'){
            for(i64 j = 1; j <= 3; ++j){
                dp[i][j][0] = dp[i - 1][j][0];
            }
            for(i64 j = 1; j <= 3; ++j){
                if(j == 1) dp[i][j][1] = dp[i - 1][j - 1][1] * 9 + dp[i - 1][j][1] + 9;
                else dp[i][j][1] = dp[i - 1][j - 1][1] * 9 + dp[i - 1][j][1];
            }
        }else{
            for(i64 j = 1; j <= 3; ++j){
                dp[i][j][0] = dp[i - 1][j - 1][0];
            }
            for(i64 j = 1; j <= 3; ++j){
                if(j == 1) dp[i][j][1] = dp[i - 1][j][1] + dp[i - 1][j - 1][1] * 9 + dp[i - 1][j][0] + dp[i - 1][j - 1][0] * (s[i] - '1') + 9;
                else dp[i][j][1] = dp[i - 1][j][1] + dp[i - 1][j - 1][1] * 9 + dp[i - 1][j][0] + dp[i - 1][j - 1][0] * (s[i] - '1');
            }
        }
    }
    cout << dp[n - 1][k][1] + dp[n - 1][k][0] << endl;
}

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

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

    int count = 0;
    for(int i = 0; i < 3; i++ ) {
        if(S[i] == T[i]) count++;
    }

    cout << count << endl;



}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
	char str[100];
    scanf("%s",str);
	
	int strlen = 0;
	for(int i=0;str[i]!='\0';i++){
		strlen++;
	}
	
	int num = strlen-1;
	unsigned long int sum = 0;
	for(unsigned long int i=0;i<pow(2,num);i++){
		int bits[num];
		for(unsigned long int j=0;j<num;j++){
			bits[j]=0;
		}
		
		int x = i;
		for(int j=0;j<num;j++){
			bits[j] = x%2;
			x /= 2;
		}
		
	
		unsigned long int temp=0;
		for(int j=0;j<strlen;j++){
			char strj[2];
			strj[0] = str[j];
			strj[1] = '\0';
			temp = temp*10 + atoi(strj);
			if(bits[j]==1){
				sum+=temp;
				temp=0;
			}
		}
		sum+=temp;
		temp=0;
	}
	
	printf("%lu\n",sum);
	return 0;
}

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

int A[101010];

int main(){
  int N; cin>>N;
  rep(i,N) cin>>A[i+1];
  int sum=0;
  rep(i,N+2){
    sum+=abs(A[i]-A[i+1]);
  }
  rep(i,N){
    int tmp=sum-abs(A[i+1]-A[i])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2]);
    cout<<tmp<<endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<assert.h>
#include<numeric>
#include<iomanip>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

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

ll pow_mod(ll x, ll y, ll mod) {
	if (y == 0)return 1;

	if (y == 1)return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

string s;
int N;

int main() {
	cin >> N;
	cin >> s;
	int ans=0;
	rep(i, 0, N) {
		if (s[i] == '.')ans++;
	}
	int temp = ans;
	rep(i, 0, N) {
		if (s[i] == '.')temp--;
		else temp++;
		ans = min(ans, temp);
	}
	cout << ans;
	return 0;
}

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

void print(int *a,int size){
  for(int i=0;i<size-1;i++){
    cout<<a[i]<<" ";
  }
  cout<<a[size-1]<<endl;
}

int main(){
  int n;
  cin>>n;
  int *array = new int[n];
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  print(array,n);
  for(int i=1;i<n;i++){
    int v=array[i];
    int j=i-1;
    while(j>=0 && array[j] > v){
      array[j+1]=array[j];
      j--;
    }
    array[j+1]=v;
    print(array,n);
  }

  delete []array; 
  return 0;
}

Measured memory_bytes: 1192