akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
'''
#TLEチーンコ
i=0
j=0
b=[]
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif a[i] in b:
        print(-1)
        break
    else:
        b.append(a[i])
        i=a[i]
'''
i=0
j=0
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif j==n:
        print(-1)
        break
    else:
        i=a[i]


Measured memory_bytes: 7084
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const int  N     =  5e5+5;
const int  mod   =  1e9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const int  LEVEL =  log2(N)+1;

int n;

void solve(){
	ll ans = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		ans += (n - 1) / i;
	}
	deb1(ans)
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

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

int main(){
  int n;
  cin >> n;
  vector<int> even(100001);
  vector<int> odd(100001);
  for(int i = 0; i < n; i++){
    int v;
    cin >> v;
    if(i%2 == 0){
      even[v]++;
    }
    else{
      odd[v]++;
    }
  }
  
  int even_max = 0;
  int even_second = 0;
  int even_index;
  int odd_max = 0;
  int odd_second = 0;
  int odd_index;

  for(int i = 0; i < 100001; i++){
    if(even_max < even[i]){
      even_max = even[i];
      even_index = i;
    }
    if(odd_max < odd[i]){
      odd_max = odd[i];
      odd_index = i;
    }
  }
  sort(odd.begin(), odd.end());
  sort(even.begin(), even.end());

  odd_second = odd[99999];
  even_second = even[99999];

  int ans = 0;
  if(odd_index != even_index){
    ans += n - odd_max - even_max;
  }
  else{
    ans += n - max(odd_max + even_second, even_max + odd_second);
  }
  cout << ans << endl;
}

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

using namespace std;

int main(void)
{
    int answer;
    vector<int> PQR(3);
    cin >> PQR.at(0) >> PQR.at(1) >> PQR.at(2);
    sort(PQR.begin(), PQR.end());
    answer = PQR.at(0) + PQR.at(1);
    cout << answer << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int H, W;
        cin >> H >> W;
        if (H > W) swap(H, W);
        Int ans = H * W / 2 + (H * W % 2);
        if (H == 1) {
            ans = 1;
        }
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import math
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

PPP = 1000000007

# 一括読み
#N, K, *A = map(int, open(0).read().split())


# 整数の入力
n = int(input())

# スペース区切りの入力
#n, x = input().split()

# スペース区切りの整数の入力
#n, m = map(int, input().split())
#n, x = map(int, input().split())
#print("sp", n, k, file=sys.stderr)
#a = [int(x) for x in input().split()]
#b = [int(x) for x in input().split()]
#print("a", a, file=sys.stderr)
#p, q, r = map(int, input().split())
#s = [int(x) for x in input().split()]
#t = [int(x) for x in input().split()]

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))
#  a.append([int(x) for x in input().split()])
#b = []
#for x in range(m):
#  b.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
#a.sort()
#print(l, file=sys.stderr)

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def ton(n, k, x):
  s = ""
  while n > 0:
    s = str(n%k) + s
    n //= k
  return s


#print("a", a, file=sys.stderr)
#print("b", b, file=sys.stderr)

def getEnergy():
  for y in b:
    yield y

def doit():
  total = 0
  prev = -2
  for x in a:
    total += b[x-1]
    if prev == x - 1:
      total += c[prev-1]
    prev = x

  return total

def yn():
  if doit():
    return "Yes"
  else:
    return "No"

#print(doit([0] * 4))
#doit(a)
#print(doit())
try:
  #doit()
  print(doit())
  #print(yn())
except Exception as e:
  print("e", e, file=sys.stderr)


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

int mod = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    int max = K;
    int keta = 1;
    while (max <= N)
    {
        max *= K;
        keta++;
    }
    cout << keta;
}

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


# define FOR(i, a, b) for(int i{a}; i < (b); ++i)
# define REP(i, n)    FOR(i, 0, n)

using namespace std;

using ll = long long;

template<typename T>
using Vec = vector<T>;


template<typename T>
using vec = vector<T>;
template <class T>
using vv = vector<vector<T>>;

constexpr int ocean = 0;

void dfs(const vv<int>& map, vv<bool>& reached, int r, int c) {
    reached[r][c] = true;
    if (reached[r][c] == ocean)
        return;
    for (int i = -1; i <= 1; ++i)
        for (int j = -1; j <= 1; ++j)
        {
            if (i == 0 && j == 0)
                continue;
            int y = r + i;
            int x = c + j;
            if (!reached[y][x] && map[y][x] != ocean)
                dfs(map, reached, y, x);
        }
}

int main()
{

    while (true)
    {
        int w, h;
        cin >> w >> h;

        if (w == 0)
            break;

        vv<int> map(h + 2, vec<int>(w + 2, ocean));

        for (int i = 1; i <= h; ++i)
            for (int j = 1; j <= w; ++j)
                cin >> map[i][j];

        vv<bool> hasReached(h + 2, vec<bool>(w + 2, false));

        // init
        

        int count{};

        for (int i = 1; i < map.size(); ++i)
            for (int j = 1; j < map[0].size(); ++j)
            {
                if (!hasReached[i][j] && map[i][j] != ocean)
                {
                    ++count;
                    dfs(map, hasReached, i, j);
                }
            }

        cout << count << endl;
    }

    return 0;
}


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


void solve(long long N, std::vector<long long> A){
    map<long long, long long>cnts;
    for(auto a: A)cnts[a]++;

    vector<long long> l2;
    vector<long long> l4;

    for(auto it=cnts.rbegin(); it!=cnts.rend(); it++){
        if((*it).second >= 2)l2.push_back((*it).first);
        if((*it).second >= 4)l4.push_back((*it).first);
    }

    long long ans=0l;
    if(l2.size()>=2)ans=l2[0]*l2[1];
    if(!l4.empty())ans=max(ans, l4[0]*l4[0]);
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 7296
// AtCoder Beginner Contest 149 B.cpp

#include <iostream>

using namespace std;

int main() {
    long int a, b, k;
    cin >> a >> b >> k;
    if (a < k) {
        k -= a;
        a = 0;

        if (b < k) {
            b = 0;
        }
        else {
            b -= k;
        }

    }
    else {
        a -= k;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

namespace PanaContest2020
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sSplit = s.Split();

            var a = int.Parse(sSplit[0]);
            var b = int.Parse(sSplit[1]);
            var c = int.Parse(sSplit[2]);
            Console.WriteLine(Problem3.GetAnswer(a, b, c));
        }
    }

    public static class Problem3
    {
        public static string GetAnswer(int a, int b, int c)
        {
            long d = c - a - b;
            var isTrue = d > 0 && 4L * a * b < d * d;
            return isTrue ? "Yes" : "No";
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
using namespace std;

#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef pair<int,int> pii;
template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;

const ll MOD=1e9+7;

int N;

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

    cin>>N;

    ll res = 1LL*(N+2)*(N+1)*N/6;
    for (int i=0;i<N-1;i++) {
      int a,b;cin>>a>>b;
      if (a>b) swap(a,b);
      res -= 1LL* a * (N-b+1);
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int sa = max({a, b, c});
  cout << a + b + c - sa << endl;
}

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

int main() {
  string S;
  cin >> S;
  string X;
  
  for (int i = 0; i < S.size(); i++) {
    if(S[i] == '0') {
      X += '0';
    }
    else if (S[i] == '1') {
      X += '1';
    }
    else if (S[i] == 'B') {
      if (X != "") {
        X.erase(X.size() - 1);
      }
    }
  }
  cout << X << endl;
  return 0;
}


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

int main() {
    int d;
    scanf("%d", &d);
    switch (d) {
        case 22:
            printf("Christmas Eve Eve Eve");
            break;
        case 23:
            printf("Christmas Eve Eve");
            break;
        case 24:
            printf("Christmas Eve");
            break;
        case 25:
            printf("Christmas");
            break;
        default:
            return 0;
    }
}

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

int N;
int W[20000];
int A[20000], B[20000];

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) {
    int P; cin >> P; --P; W[P] = i;
  }
  int x = 1;
  for(int i = 0; i < N; ++i) {
    A[i] = x;
    B[i] = 500000000 - x + W[i];
    if(i < N - 1) x += 1 + max(0, W[i + 1] - W[i]);
  }
  for(int i = 0; i < N; ++i) cout << (i == 0 ? "" : " ") << A[i];
  cout << endl;
  for(int i = 0; i < N; ++i) cout << (i == 0 ? "" : " ") << B[i];
  cout << endl;
  return 0;
}


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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;


void flat(vector<pair<int,int>>& cur) {
    if (cur.size() > 1) {
        int ll = cur.size() - 1;
        if (cur[ll].first == cur[ll-1].first) {
            cur[ll-1].second += cur[ll].second;
            cur.pop_back();
        }
    }
}

void increment(vector<pair<int,int>>& cur) {
    auto& last = cur.back();
    if (last.second > 1) {
        last.second--;
        cur.emplace_back(last.first + 1, 1);
    } else {
        last.first++;
    }
    flat(cur);
}


bool check(const vector<int>& A, int n) {
    vector<pair<int, int>> cur;
    cur.emplace_back(0, A[0]);
    FOR(i, 1, A.size() - 1) {
        if (A[i] > A[i - 1]) {
            cur.emplace_back(0, A[i] - A[i - 1]);
            flat(cur);
            continue;
        }

        int del = 0;
        while (cur.size() > 0 && A[i - 1] - (del + cur.back().second) >= A[i]) {
            del += cur.back().second;
            cur.pop_back();
        }

        cur.back().second -= A[i - 1] - A[i] - del;
        if (cur.back().first == n - 1) {
            int t = cur.back().second;
            cur.pop_back();
            if (cur.size() == 0) {
                return false;
            }
            increment(cur);
            cur.emplace_back(0, t);
        } else {
            increment(cur);
        }
        flat(cur);
    }

    return true;
}

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

    int N;
    cin >> N;

    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int l = 0;
    int r = N;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (check(A, mid)) {
            r = mid;
        } else {
            l = mid;
        }
    }
    cout << r << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int sum = 0;
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++) {
            int hoge = l + i;
            sum += hoge;
            if(Math.abs(min) > Math.abs(hoge)) {
                min = hoge;
            }
        }
        System.out.println(sum - min);
    }
}

Measured memory_bytes: 24020
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	const int mod = 1e9 + 7;
	int n;
	cin >> n;
	vector<vi> g(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].pb(v);
		g[v].pb(u);
	}
	vector<vi> dp(n, vi(2, 0)); // white 0; black 1
	function<void(int, int)> dfs = [&](int v, int p) {
		dp[v][0] = 1;
		dp[v][1] = 1;
		for (int to : g[v]) {
			if (to != p) {
				dfs(to, v);
				dp[v][0] = (ll)dp[v][0] * (dp[to][0] + dp[to][1]) % mod;
				dp[v][1] = (ll)dp[v][1] * dp[to][0] % mod;
			}
		}
	};
	dfs(0, -1);
	cout << (dp[0][0] + dp[0][1]) % mod;
}


Measured memory_bytes: 19584
import java.io.*;
import java.util.stream.*;
import static java.util.stream.Collectors.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine()) - 1;
        System.out.println(
            Stream.iterate(new int[]{1, 1}, fib -> new int[]{fib[1], fib[0] + fib[1]})
                .skip(n < 0 ? 0 : n)
                .map(fib -> fib[1])
                .findFirst()
                .orElse(1)
        );
    }
}

Measured memory_bytes: 30924
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int N, P, A, O = 0;
    cin >> N >> P;
    rep(i, N) {
        cin >> A;
        if (A % 2) O++;
    }
    ll ans = 1;
    if (O == 0) {
        if (P) {
            ans = 0;
        } else {
            rep(i, N) ans *= 2;
        }
    } else {
        rep(i, N - 1) ans *= 2;
    }
    cout << ans << endl;
}

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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var tmp1 = Math.Max(abc[0], abc[1]) * 10 + Math.Min(abc[0], abc[1]) + abc[2];
            var tmp2 = Math.Max(abc[1], abc[2]) * 10 + Math.Min(abc[1], abc[2]) + abc[0];
            Console.WriteLine(Math.Max(tmp1, tmp2));
        }
    }
}


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

int main(){
	int n;
	cin >> n;
	vector<double> x(n);
	double s=0;
	for(int i = 0; i < n; i++) {
		cin >> x[i];
      	s += 1.0/x[i];
	}
  	printf("%.7lf\n",1.0/s);
}


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

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) (v).begin(), (v).end()
#define sz(v) (int) (v).size()

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  cout << (1000 - (n % 1000)) % 1000 << '\n';
  return 0;
}

Measured memory_bytes: 3636
n, q = map(int, input().split())
ps = []
total = 0

for i in range(n):
    name, time = map(str, input().split())
    ps.append([name, int(time)])

while len(ps) > 0:
    if ps[0][1] <= q:
        total += ps[0][1]
        print(ps[0][0], total)
        del ps[0]
    else:
        total += q
        ps[0][1] -= q
        ps.append(ps[0])
        del ps[0]



Measured memory_bytes: 13012
#include <bits/stdc++.h>
using namespace std;
int bit[40];

int main(){
  fill(bit, bit + 40, 0);
  int N;
  cin >> N;
  if(N == 0){
    cout << "0" << endl;
    return 0;
  }
  bool sgn = false;
  if(N > 0) sgn = true;
  N = abs(N);
  for(int i = 0; i < 40; i++){
    bool t = N % 2;
    if(t && ((sgn && i % 2) || (!sgn && !(i % 2)))) {
      bit[i]++;
      bit[i+1]++;
    } else if(t) {
      bit[i]++;
    }
    N /= 2;
  }
  for(int i = 0; i < 40; i++){
    if(bit[i] >= 4){
      bit[i] -= 4;
      bit[i+2]++;
    } else if(bit[i] >= 2){
      bit[i] -= 2;
      bit[i+1]++;
      bit[i+2]++;
    }
  }
  bool c = false;
  for(int i = 39; i >= 0; i--){
    if(bit[i] != 0) c = true;
    if(c) cout << bit[i];
  }
  cout << endl;
  return 0;
}


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

#define int long long
const int INF = 100000000000000000;

const int MAX_T = 305;

unordered_map<int, int> MAP;

int Hash(const string& a, const string& b) {
    static const int A = 10000000000000007;
    static const int B = 10000000000000009;

    int ret = 0;

    for(int i = 0; i < a.length(); i++) {
        ret += a[i] - 'a' + 1;
        ret *= A;
    }
    ret *= B;
    for(int i = 0; i < b.length(); i++) {
        ret += b[i] - 'a' + 50;
        ret *= B;
    }
    return ret;
}

string S;
string S1, S2;

void dfs(int pos, string &s1, string &s2) {
    if(S1.length() <= pos) {
        MAP[Hash(s1, s2)]++;
    } else {
        s1.push_back(S1[pos]);
        dfs(pos+1, s1, s2);
        s1.pop_back();
        s2.push_back(S1[pos]);
        dfs(pos+1, s1, s2);
        s2.pop_back();
    }
}

int ans = 0;

void dfs2(int pos, string &s1, string &s2) {
    if(S2.length() <= pos) {
        ans += MAP[Hash(s1,s2)];
    } else {
        s1.push_back(S2[pos]);
        dfs2(pos+1, s1, s2);
        s1.pop_back();
        s2.push_back(S2[pos]);
        dfs2(pos+1, s1, s2);
        s2.pop_back();
    }
}

signed main() {
    int N;
    
    cin >> N;
    cin >> S;

    S1 = S.substr(0,N);
    S2 = S.substr(N,N);
    reverse(begin(S2), end(S2));

    // cerr << S1 << " " << S2 << endl;

    string a,b;
    dfs(0,a,b); 
    dfs2(0,a,b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 28788
#include <bits/stdc++.h>
using namespace std;
struct Trie {
    array<Trie*, 26> next;
    array<int, 26> count;
    int end;
};
int main() {
    int N; cin >> N;
    vector<string> S(N); for (auto &s : S) cin >> s;
    Trie *trie = new Trie();
    for (int i = 0; i < N; i++) {
        const string &s = S[i];
        Trie *t = trie;
        for (int j = 0; j < s.size(); j++) {
            t->count[s[j] - 'a']++;
            if (!t->next[s[j] - 'a']) t->next[s[j] - 'a'] = new Trie();
            t = t->next[s[j] - 'a'];
        }
        t->end++;
    }
    vector<array<array<int, 26>, 26>> counts(N);
    vector<int> ends(N);
    for (int i = 0; i < N; i++) {
        const string &s = S[i];
        Trie *t = trie;
        for (int j = 0; j < s.size(); j++) {
            ends[i] += t->end;
            for (int k = 0; k < 26; k++) {
                counts[i][s[j] - 'a'][k] += t->count[k];
            }
            t = t->next[s[j] - 'a'];
        }
    }
    int Q; cin >> Q;
    while (Q--) {
        int i; cin >> i; i--;
        string p; cin >> p;
        int cnt = ends[i];
        for (int j = 0; j < 26; j++) {
            for (int k = 0; k < 26; k++) {
                if (p[k] == j + 'a') break;
                cnt += counts[i][j][p[k] - 'a'];
            }
        }
        cout << cnt + 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 309504
#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 = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
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 n,a,b;
    cin >> n >> a >> b;
    ll c = b-a;
    if (c%2 == 0){
        PRINT("Alice");
    }
    else{
        PRINT("Borys");
    }
}


Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b;
  return 0;
}


Measured memory_bytes: 3644
def binary_search(a,n,key):
  left = 0
  right = n
  while left < right:
    mid = (left + right) // 2
    if a[mid] == key:
      return 1
    elif key < a[mid]:
      right = mid
    else:
      left = mid + 1
  return 0

n1 = int(input())
s1 = list(map(int,input().split()))
s1.sort()
n2 = int(input())
s2 = list(map(int,input().split()))
i = 0
cnt = 0
while i < n2:
  cnt += binary_search(s1,n1,s2[i])
  i += 1
print(cnt)


Measured memory_bytes: 6552
#include <iostream>
using namespace std; //666654
int n,a,b,sum;
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) {
		int x=0,m=i;
		while(m) x+=m%10,m/=10;
		if(x>=a&&x<=b) sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    ll a[100];
    cin >> n;

    ll mn = INF;
    ll mx = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    cout << mx - mn << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {
  def sieve(n:Int) = {
    val list = Array.tabulate(n+1) { _ % 2 }
    val primes = new ArrayBuffer[Int]
    list(1) = 0
    list(2) = 2
    primes += 2

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
    {
      if(list(i) == 1) {
        (i*i to n by i*2).foreach { list(_) = 0 }
        primes += primes(primes.length-1)+i
      }
    }
    for(i<-Math.sqrt(n).toInt+1 to n if list(i)==1)
      primes += primes(primes.length-1)+i
    primes.toArray
  }

  def main(args:Array[String]) = {
    val p = sieve(110000)
    var n = 0
    while( { n = readInt; n} != 0 ) println(p(n-1))
  }
}

Measured memory_bytes: 49112
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int ans = 0;
    while (true) {
        if (a[0] == a[1] && a[1] == a[2]) {
            break;
        }
        if (a[1] == a[2]) {
            a[0] += 2;
            ans++;
        }
        else {
            a[0] += 1;
            a[1] += 1;
            ans++;
        }
        sort(a, a + 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX_N = 100;

int main() {
  int a[MAX_N+1][MAX_N+1];
  int n; cin >> n;

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      a[i][j] = 0;
      
    
  for (int i = 0; i < n; i++) {
    int u, k; cin >> u >> k;
    for (int j = 0; j < k; j++) {
      int t; cin >> t;
      a[u][t] = 1;
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j > 1) cout << ' ';
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];

    for(int i = k; i < n; i++){
        if(a[i-k] < a[i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
}

Measured memory_bytes: 4048
while True:
    h, w = map(int, input().split())
    
    if h==0 and w==0: break
    
    for i in range(h):
        for j in range(w):
            if i==0 or i==h-1:
                print("#" ,end='')
            elif j==0 or j==w-1:
                print("#", end='')
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,ans=0;;
  cin>>N;
  vector<int> B(N-1);
  REP(i,N-1)cin>>B[i];
  ans+=B[0]+B[N-2];
  REP(i,N-2){
    ans+=min(B[i],B[i+1]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
def solve(n, m, ps):
    qs = sorted(ps)
    num_bottles = 0
    req_money = 0
    for a, b in qs:
        if num_bottles >= m:
            break
        num_buy = min(m - num_bottles, b)
        req_money += a * num_buy
        num_bottles += b
    return req_money


def main():
    n, m = (int(z) for z in input().split())
    ps = [tuple(int(z) for z in input().split()) for _ in range(n)]
    res = solve(n, m, ps)
    print(res)


if __name__ == "__main__":
    main()

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

using namespace std;

string s;

int dp[305][305][305];

int dfs(int l, int r, int k)
{
    if(r < l)
        return 0;
    if(l == r)
        return 1;
    int &res = dp[l][r][k];
    if(res != -1)
        return res;
    res = max(dfs(l, r - 1, k), dfs(l + 1, r, k));
    if(s[l] == s[r])
        res = max(res, dfs(l + 1, r - 1, k) + 2);
    if(k)
        res = max(res, dfs(l + 1, r - 1, k - 1) + 2);
    return res;

}

int main()
{
    int k;
    cin >> s >> k;
    memset(dp, -1, sizeof dp);

    cout << dfs(0, s.size() - 1, k);

    return 0;

}

Measured memory_bytes: 111232
N, K = map(int, (input().split()))
MOD = 10**9+7
m, M = sum(list(range(K))), sum(list(range(N, N-K, -1)))
ans = (M - m + 1) % MOD

for i in range(K, N+1):
    m += i
    M += N-i
    ans = (ans + (M - m + 1) % MOD ) % MOD
print(ans)

Measured memory_bytes: 16808
//
//  main.cpp
//  apg4b
//
//  Created by 垣本耀介 on 2020/06/12.
//  Copyright © 2020 垣本耀介. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int N;
    cin >> N ;
    vector<string> s(N);
    for (int i=0; i<N; i++) {
        cin >> s.at(i) ;
    }
    
    int M;
    cin >> M ;
    vector<string> t(M);
    for (int i=0; i<M; i++) {
        cin >> t.at(i) ;
    }
    
    int max= 0;
    
    for (int i=0; i<N; i++) {
        int count=0;
        
        for (int j=0; j<N; j++) {
            if(s.at(i) == s.at(j)){
                count++;
            }
        }
        for (int k=0; k<M; k++) {
            if(s.at(i) == t.at(k))
                count--;
        }
        
        if (count > max){
            max = count;
        }
    }
    
    cout <<endl << max <<endl;
}


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

main(){
	int N;
	int D;
	int X;

	cin >> N;
	cin >> D >> X;

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

	int sum = N;
	for(int i=0;i<N;i++){
		int tmpD = D-1;
		int amari = tmpD % A[i];
		sum = sum + (tmpD-amari)/A[i];
		//while(true){
		//	if((D-1)-A[i]*(i+1)>=0){
		//		sum = sum + 1;
		//	}else{
		//		break;
		//	}
		//}
	}
	int wa = sum + X;
	cout<<wa<<endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
seq = list(map(int, input().split()))
lcm_num = lcm(seq)

ans = 0
for num in seq:
    ans += (lcm_num - 1) % num

print(ans)


Measured memory_bytes: 66792
using System;
using System.Collections.Generic;

namespace dp
{
    class Program
    {
        static long[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new long[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = long.Parse(line[i]);
            }
            return numList;
        }
        static void Main(string[] args)
        {
            var nw = Console.ReadLine().Split(' ');
            var n = int.Parse(nw[0]);
            var w = int.Parse(nw[1]);
            var iTable = new long[n][];
            var rTable = new long[n + 1][];
            for (var i = 0; i < n; ++i)
            {
                iTable[i] = ReadNumList();
                rTable[i] = new long[n * 1000 + 1];
                for (var vi = 1; vi < rTable[i].Length; ++vi)
                {
                    rTable[i][vi] = n * 1000000001L;
                }
            }
            rTable[n] = new long[n * 1000 + 1];
            for (var vi = 1; vi < rTable[n].Length; ++vi)
            {
                rTable[n][vi] = n * 1000000001L;
            }

            for (var i = 0; i < n; ++i)
            {
                for (var vi = 0; vi < rTable[0].Length; ++vi)
                {
                    var iWeight = iTable[i][0];
                    var iValue = iTable[i][1];
                    var selectWorldIndex = Math.Max(0, vi - iValue);
                    rTable[i + 1][vi] = Math.Min(rTable[i][vi], rTable[i][selectWorldIndex] + iWeight);
                }
            }
            var max = 0L;
            for (var vi = 0; vi < rTable[0].Length; ++vi)
            {
                if (rTable[n][vi] <= w)
                {
                    max = vi;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 107160
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int diff(string& s, string& t, int ii) {
  int nt = t.size();
  int ret = 0;
  for (int i = 0; i < nt; ++i) {
    if (s[ii + i] != t[i]) {
      ++ret;
    }
  }
  return ret;
}

int main() {
  string s, t;
  cin >> s >> t;

  int ns = s.size();
  int nt = t.size();

  int ret = INT_MAX;
  for (int i = 0; i <= ns - nt; ++i) {
    ret = min(ret, diff(s, t, i));
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3596
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;

int main(){
int N,M;
cin>>N>>M;
int table[N+2];
rep(i,N+1){
  table[i]=0;
}
rep(i,M){
  int L,R;
  cin>>L>>R;
  table[L]++;
  table[R+1]--;
}
int count=0;
rep3(i,N){
  table[i]+=table[i-1];
  if(table[i]==M){
    count++;
  }
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 4004
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

long long GCD (long long C, long long D) {
   while (1) {
      if (C == 0 || D == 0) break;
      if (D>C) D -= (D/C)*C;
      else C -= (C/D)*D;
   }
   return max(C,D);
}


int main(void) {
   ll N,K;
   cin>>N>>K;
   vector<ll> A(N,0);
   rep(i,0,N) cin>>A[i];
   ll gcd = A[0];
   rep(i,0,N) {
      gcd = GCD(gcd,A[i]);
   }
   // cout<<gcd<<endl;
   bool flag = false;
   if (K <= *max_element(A.begin(),A.end())) {
      if (K%gcd == 0) {
         flag = true;
      }
   }
   if (flag)cout<<"POSSIBLE"<<endl;
   else cout<<"IMPOSSIBLE"<<endl;


   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define int long long
#define endl '\n'
struct UnionFind {
  vector<int> data;
  UnionFind(int v) : data(v, -1) {}
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
  void merge(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (size(y) > size(x))
        swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }
};

signed main() {
  std::ios::sync_with_stdio(false);
  int N, M, K; cin >> N >> M >> K;
  UnionFind u(N);
  vector<vector<int>> F(N);
  vector<vector<int>> B(N);
  REP(i, M) {
    int x, y; cin >> x >> y;
    x--; y--;
    F[x].push_back(y);
    F[y].push_back(x);
    u.merge(x, y);
  }
  REP(i, K) {
    int x, y; cin >> x >> y;
    x--; y--;
    B[x].push_back(y);
    B[y].push_back(x);
  }
  REP(i, N) {
    int sz = u.size(i);
    sz--; // remove themself
    sz -= F[i].size();
    for (int b : B[i]) {
      if (u.same(i, b)) {
        sz--;
      }
    }
    if (i > 0) cout << ' ';
    cout << sz;
  }
  cout << endl;
}


Measured memory_bytes: 13684
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

using namespace std;

int main(void){
  int N,ans=0;
  cin >> N;
  int A[N],B[N],C[N-1];
  rep(i,N) cin >> A[i];
  rep(i,N) cin >> B[i];
  rep(i,N-1) cin >> C[i];
  rep(i,N){
    ans+=B[A[i]-1];
    if(i>=1 && A[i]-A[i-1]==1) ans+=C[A[i]-2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
y = int(input().split()[0])
result = ""
i = 0
while True:
    z = (-2) ** (i+1)
    x = y % z
    if x != 0:
        y = y + x
        result = "1" + result
    else:
        result = "0" + result
    if y == 0:
        break
    i = i + 1
print(result)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ff first
#define ss second
#define IO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;

int main() {
    IO;
    int n;
    cin >> n;
    if(n % 10 == 3)
        cout << "bon\n";
    else if(n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8)
        cout << "pon\n";
    else cout << "hon\n";

    return 0;
}


Measured memory_bytes: 3660
import collections
from operator import mul
from functools import reduce

N,A,B = map(int, input().split())
V = list(map(int, input().split()))
VV = sorted(V,reverse = True)
ave = 0
ml = []

for i in range(A,B + 1):
  avet = sum(VV[:i]) / i
  if avet >= ave:
    ml.append(i)
    ave = max(ave,avet)
  else:
    break

dic = collections.Counter(V)
#print(dic,ml)

def cmb(n,r):
  r = min(n - r,r)
  if r == 0:
    return 1
  over = reduce(mul,range(n, n - r, -1))
  under = reduce(mul,range(1,r + 1))
  return over // under

res = 0

for j in ml:
  r = dic[VV[j - 1]]
  rr = VV.index(VV[j - 1])
  res += cmb(r,j - rr)

print(ave)
print(res)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    set<string> Set;
    bool ng=false;
    char c = '*';
    rep(i,n){
        string s; cin>>s;
        if (s[0]!=c && c!='*'){
            ng = true;
            break;
        }
        c = s.back();
        if (Set.count(s)){
            ng = true;
            break;
        }
        Set.ins(s);
    }
    if (ng){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<set>
#include<numeric>
#include<cmath>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> d(k);
	for (int i = 0; i < k; i++)
	{
		cin >> d[i];
	}
	for (int x = n; x < 100000; x++)
	{
		int tmp = x;
		set<int> s;
		while (tmp != 0)
		{
			s.insert(tmp % 10);
			tmp /= 10;
		}

		bool flag = true;

		for (int i = 0; i < k; i++)
		{
			if (s.count(d[i]))
			{
				flag = false;
			}
		}
			if (flag==true)
			{
				cout << x << endl;
				break;
			}
		}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
int count;
while(!(line=br.readLine()).equals("0")){
int n=Integer.parseInt(line);
count=0;
for(int i=1;i<=6;i++){
int d=(int)Math.pow(5,i);
if(n<d){
break;
}
count+=(int)(n/d);
}
System.out.println(count);
}
}
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}


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

#define INF 100000000
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int X,A,B;
  cin >> X >> A >>B;
  if( B <= A ){
    cout << "delicious" << endl;
  }else if(B-A <= X){
    cout << "safe" << endl;
  }else {
    cout << "dangerous" << endl;
  }
}



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

int main()
{
    int a = 0;
    int b = 0;

    // input
    std::cin >> a;
    std::cin >> b;

    if (a < 1 || b < 1)
    {
        std::cout << "Error : out of range!" << std::endl;
        return -1;
    }

    // output
    std::cout << a / b << " ";
    std::cout << a % b << " ";
    std::cout << std::fixed << std::setprecision(8) << static_cast<double>( a ) / static_cast<double>( b ) << std::endl;

    return 0;
}


Measured memory_bytes: 3264
D, G = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(D)]

ans = float('inf')

for i in range(1 << D):
    number = 0
    score = 0
    chosen = []
    for j in range(D):
        if (1 & (i >> j)) == 1:
            chosen.append(j)
            score += P[j][0] * 100 * (j+1) + P[j][1]
            number += P[j][0]

    index = D-1
    while score < G:
        if index < 0:
            break
        if index in chosen:
            pass
        else:
            for _ in range(1, P[index][0]+1):
                score += 100 * (index + 1)
                number += 1

                if score >= G:
                    break

        index -= 1
    ans = min(ans, number)
            

print(ans)


Measured memory_bytes: 3064