akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
#define ml 1000000

/*
	方法
	はじめと終わりが何番目の要素かを記録しておく
	DeleteFirst Lastが簡単になる
	Deleteでは、数字があれば、そこからひとつづつ前に出して来る、その後endを一つ下げる
	Insertでは、リストがからならそのまま、あるならstartを一つ下げて入れる
*/

void mInsert(int* a, int& start, int& end, int& flag);
void mDelete(int* a, int& start, int& end, int& flag);
void mDeleteFirst(int* a, int& start, int& end, int& flag);
void mDeleteLast(int* a, int& start, int& end, int& flag);

int main() {
	int n;
	cin >> n;
	int a[ml];
	int start = 900000;//800000にするとうまくいく
	int end = 900000;//800000にするとうまくいく
	int flag = 0;
	string meirei;
	for (int i = 0; i < n; i++) {
		cin >> meirei;
		if (meirei == "deleteLast")mDeleteLast(a, start, end, flag);
		else if (meirei == "deleteFirst")mDeleteFirst(a, start, end, flag);
		else if (meirei == "delete")mDelete(a, start, end, flag);
		else if (meirei == "insert")mInsert(a, start, end, flag);
		start %= ml;
		end %= ml;
		//cout << start << endl << end << endl << flag << endl;
	}
	cout << a[start % ml];
	if ((start % ml) != (end % ml)) {
		for (int i = start + 1; (i % ml) <= end % ml; i++) {
			cout << " " << a[i];
		}
	}
	cout << endl;
	return 0;
}

void mInsert(int* a, int& start, int& end , int& flag) {
	if (flag == 0) {
		flag = 1;
		cin >> a[start % ml];
	} else {
		start--;
		start += ml;
		cin >> a[(start) % ml];
	}
}

void mDelete(int* a, int& start, int& end, int& flag) {
	int kesu;
	cin >> kesu;
	for (int i = start; (i % ml) <= end; i++) {
		if (a[i] == kesu) {
			if ((start % ml) == (end % ml)) {
				flag = 0;
			} else {
				for (int j = i; (j % ml) <= end; j++) {
					a[j % ml] = a[(j + 1) % ml];
				}
				end--;
				end += ml;
			}
				break;
		}
	}
}

void mDeleteFirst(int* a, int& start, int& end, int& flag) {
	if ((start % ml) == (end % ml)) {
		flag = 0;
	}
	else {
		start++;
	}
}

void mDeleteLast(int* a, int& start, int& end, int& flag) {
	if ((start % ml) == (end % ml)) {
		flag = 0;
	}
	else {
		end--;
		end += ml;
	}
}


Measured memory_bytes: 7052
Syain_num = int(input())
Joshi = input().rstrip().split(' ')
Ans = [0] * Syain_num

for i in range(Syain_num-1):
   Ans[int(Joshi[i])-1] = Ans[int(Joshi[i])-1] + 1

[print(i) for i in Ans]


Measured memory_bytes: 27992
#include<iostream>
#include<string.h>
#include<algorithm>
#include<functional>
using namespace std;

int main(){
    int N,K;
    int L[55];
    int sum=0;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    sort(L,L+N,greater<int>());
    for(int i=0;i<K;i++){
        sum+=L[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr double mv[2][4] = {
    { +1, -1, 0, 0 }, { 0, 0, +1, -1 }
};
struct Data { Int axis[2], dir; };
double range(const vector<Data>& D, double t, int axis) {
    double M = -1e9, m = 1e9;
    for (auto &d : D) {
        double x = d.axis[axis] + t * mv[axis][d.dir];
        M = max(M, x);
        m = min(m, x);
    }
    return M - m;
}
double slope(const vector<Data>& D, double t, int axis) {
    return (range(D, t+0.1, axis) - range(D, t, axis)) / 0.1;
}
double func(const vector<Data>& D, double t) {
    return range(D, t, 0) * range(D, t, 1);
}
int main()
{
    int N; cin >> N;
    vector<Data> D(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i].axis[0] >> D[i].axis[1];
        char c; cin >> c;
        D[i].dir = (c == 'R' ? 0 : c == 'L' ? 1 : c == 'U' ? 2 : 3);
    }
    vector<double> T;
    T.push_back(0);
    for (int axis = 0; axis < 2; axis++) {
        double d = slope(D, 0.25, axis);
        Int curr = 0;
        while (curr < 2e8) {
            Int ok = 2e8, ng = curr;
            while (ok - ng > 1) {
                Int mid = (ok + ng) / 2;
                double t = mid / 2.0 + 0.25;
                (slope(D, t, axis) > d + 0.5 ? ok : ng) = mid;
            }
            T.push_back(ok / 2.0);
            curr = ok;
            d = slope(D, ok / 2.0 + 0.25, axis);
        }
    }
    double ans = 1e18;
    for (auto t : T) {
        ans = min(ans, func(D, t));
    }
    cout << fixed << setprecision(12) << ans << '\n';
    return 0;
}

Measured memory_bytes: 2560
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	s = input()
	k = int(input())
	s_ = [[s[0],1]]
	ct = 0
	for i in s[1:-1]:
		if(s_[-1][0] == i):
			s_[-1][1] += 1
		else:
			s_.append([i,1])
	for i in s_:
		if(i[1] > 1):
			ct += math.ceil((i[1] - 1)/2)
	ct *= k
	if((len(s) - 1) % 2 == 1 and len(s_ ) == 1):
		print((len(s) - 1) * k // 2)
	elif(s[0] == s[-2] and s_[0][1] == s_[-1][1] and len(s_) != 1):
		print(ct + k - 1)
	else:
		print(ct)


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65516
def A():
    A, B, C = map(int, input().split())
    if A == B or B == C or A == C:
        if (A+B+C) != A*3:
            print('Yes')
            return
    print('No')

def B():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in A:
        if i%2==0 and not (i%3==0 or i%5==0):
            print('DENIED')
            return
    print('APPROVED')

from collections import Counter
from itertools import takewhile
def C():
    N = int(input())
    lst = []
    for i in range(N):
        lst.append(input())

    c = Counter(lst)
    m = max(c.values())
    r = [x for x, _ in takewhile(lambda x: x[1]==m, c.most_common())] 
    for s in sorted(r):
        print(s)
C()

Measured memory_bytes: 45032
//e4-e5-f4
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp"
//#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define PI 3.14159265359
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define tc(x) ll x; cin>>x; while(x--)
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define print(a)  for (auto x : a) cout << x << " "; cout << endl
#define sl set<ll>
#define usl unordered_set<ll>
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vpl vector<pll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define setbits(a) __builtin_popcountll(a)
#define ps(x,y) fixed<<setprecision(y)<<x;
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define P 1000000007
#define Q 1000000006
#define inf 1e18
#define N 17
#define M 105
//using namespace boost::multiprecision; 
//using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(all(v), rng);
ll a[N][N], dp[1<<N];

void solve(){
    ll n;
    cin>>n;
    f(i,0,n) f(j,0,n) cin>>a[i][j];
    f(mask,0,1<<n){
        vl v;
        f(i,0,n) if(mask>>i & 1) v.pb(i);
        f(i,0,sz(v)) f(j,i,sz(v)) dp[mask] += a[v[i]][v[j]];
    }
    f(mask,0,1<<n){
        for(ll submask = mask; submask; submask = (submask-1) & mask & ((1<<n)-1)){
            ll x = submask^mask;
            dp[mask] = max(dp[mask], dp[submask] + dp[x]);
        }
    }
    cout<<dp[(1<<n) - 1];
}

signed main() {
    teevra_gati
    
    solve();

    return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	
	int n, k;
	cin >> n >> k;

	vector<ll> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];

	sort(a.begin(), a.end());
	ll ans = 0;
	for(int i = 0; i < k; i++)
		ans += a[i];

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int mod=998244353;
const int N=1e6+10;
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll maxs=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[0]!=0)
        {
            cout<<0<<endl;
            return 0;
        }
        if(i!=0&&a[i]==0)
        {
            cout<<0<<endl;
            return 0;
        }
        b[a[i]]++;
		maxs = max(maxs,a[i]);
    }
     ll ans=1;
     for(int i=0;i<maxs;i++)
     {
         for(int j=0;j<b[i+1];j++)
         {
             ans=ans*b[i]%mod;
         }
     }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4796
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


int main() {
    
    ll D = lin(); ll G = lin();
    
    vector<pair<ll,ll> > prob;
    pair<ll,ll> temp;
    vector<ll>compscore;
    for(auto i = 0; i<D; i++){
        cin >> temp.first >> temp.second;
        
        prob.push_back(temp);
        compscore.push_back(100*(i+1)*prob.back().first + prob.back().second);
    }
    
    ll out;
    ll maxProb;
    ll ans = INT_MAX;
    ll unusedMaxind;
    ll solved;
    for(auto i = 0; i < 1<<D; i++){   /// completeした問題の種類について全探索
        out = G;
        maxProb = -1;
        unusedMaxind = -1;
        solved = 0;
        for(auto j = 0; j<D; j++){
            
            if((i>>j & 1) == 1){
                out -= compscore[j];
                solved += prob[j].first;
            }else{
                if (maxProb < (100*(j+1))) {
                    maxProb = (100*(j+1));
                    unusedMaxind = j;
                }
            }
        }
        
        if (prob[unusedMaxind].first * (100) * (unusedMaxind+1) < out) {
            solved = INT_MAX;
        }else if (out > 0){
            solved += (out/(100*(unusedMaxind+1)));
            out -=(out/(100*(unusedMaxind+1))) * (100*(unusedMaxind+1));
            if (out != 0){
                solved++;
            }
        }
        
        if (ans > solved) ans = solved;
        
        
        
    }
    
    cout << ans << endl;
    
    return 0;
}










Measured memory_bytes: 256
import random
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
a,b,h,m = MI()
h*=5
h+=m/12
al = abs(h-m)*6
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(al*math.pi/180))
print(ans)

Measured memory_bytes: 9696
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;

int main() {
    string a,b;
    ll c=0,d=0;
    cin >> a >> b;
    for (ll i=0;i<a.size()+b.size();++i){
        if (i%2!=0){
            cout << b[c];
            ++c;
        }else{
            cout << a[d];
            ++d;
        }
    }
    cout << endl;
    return 0;
}


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

using namespace std;

int main(){
  long long int N, x, y;
  cin >> N;
  for(int i=1; i<=(int)sqrt(N); i++){
    if(N%i == 0) x = i;
  }
  y = N / x;
  cout << x+y-2 << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A = MAP()
print('bust' if sum(A)>=22 else 'win')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;

#define M 2005
int n;
char s[M];
int a[M][M],f[M][M],l[M][M],r[M][M];

int main () {
//freopen("a.in","r",stdin);
	scanf("%d",&n);
	for1(1,n,i) {
		scanf("%s",s+1);
		for1(1,n,j) a[i][j]= s[j]=='#'?0:s[j]-'0';
	}
	
	ll ans=0;
	FOR2(n,1,i) FOR2(n,1,j) { 
		if(a[i][j]) {
			bool t[2]={a[i+1][j],a[i][j+1]};
			if(!(t[0]|t[1])) {
				l[i][j]=r[i][j]=j;
				for1(i+1,n,k) l[k][j]=n+1,r[k][j]=0;
			}
			else if(t[0]&&!t[1]) {
				l[i][j]=r[i][j]=j;
				f[i][j]=f[i+1][j];
			}
			else if(!t[0]&&t[1]) {
				f[i][j]=f[i][j+1];
				l[i][j]=j,r[i][j]=r[i][j+1];
				for1(i+1,n,k) l[k][j]=l[k][j+1],r[k][j]=r[k][j+1];
			}
			else {
				int tot=f[i+1][j]+f[i][j+1];
				l[i][j]=j,r[i][j]=r[i][j+1];
				
				int las_r=0;		
				for1(i+1,n,k) {
					if(l[k][j+1]<=r[k][j]&&l[k][j+1]>las_r) tot-=f[k][l[k][j+1]];
					las_r=r[k][j];
					l[k][j]=min(l[k][j],l[k][j+1]);
					r[k][j]=max(r[k][j],r[k][j+1]);
				}
				f[i][j]=tot;
			}
		}
		ans+=a[i][j]*f[i][j];
		f[i][j]+=a[i][j];
	}
	cout<<ans<<endl;
}

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

using namespace std;

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

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

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

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h,w,t,p;

ll f[1000][1000];

void calc(ll &cy,ll &cx,ll d,ll c){
    if(d == 1){
        rep(i,h){
            rep(j,c){
                f[cy + i][cx + 2 * c - 1 - j] += f[cy + i][cx + j];
            }
        }
        cx += c;
    }
    else{
        rep(i,c){
            rep(j,w){
                f[cy + 2 * c - 1 - i][cx + j] += f[cy + i][cx + j];
            }
        }
        cy += c;
    }
}

int main(){
    while(cin >> w >> h >> t >> p && w){
        rep(i,1000)rep(j,1000)f[i][j] = 0;
        rep(i,h)rep(j,w)f[i][j] = 1;
        ll cx = 0;
        ll cy = 0;
        rep(i,t){
            ll d,c;
            cin >> d >> c;
            calc(cy,cx,d,c);
        }
        ll ans = 0;
        // rep(i,cy + h){
        //     rep(j,cx + w){
        //         cout << f[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << cy << " " << cx << endl;
        rep(i,p){
            ll x,y;
            cin >> x >> y;
            x += cx;
            y += cy;
            cout << f[y][x] << endl;
            // ans += f[y][x];
        }
        // cout << ans << endl;
    }
}


Measured memory_bytes: 10916
#include <iostream>
using namespace std;
int main()
{
    long long int max, min, sum, input, i , n;
    cin >> n;
    cin >> input;
    max=input;
    min=input;
    sum=0;
    for(i=1;i<=n;i++)
    {
        sum = sum + input;
        if (input>=max)
        max=input;
        if (input<=min)
        min=input;
        cin >> input;
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3116
' Imports System.Collections.Generic
' Imports System.Globalization
' Imports System.IO
' Imports System.Linq
' Imports System.Text
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim S As String = Console.ReadLine()
        Dim hs As New HashSet(Of Char)(S)
        If hs.Count() <> 2
            Console.WriteLine("No")
        Else
            Dim cnt = 0
            For Each c As Char In hs
                If S.Count(function (x) x = c) = 2
                    cnt += 1
                End If
            Next
            If cnt = 2
                Console.WriteLine("Yes")
            Else
                Console.WriteLine("No")
            End If
        End If
        Return
    End Sub
End Class

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

//C++14 (GCC 5.4.1)
int main() {
    string N;
    cin >>N;

    
    //-----------------------------------
    int blue=0,red=0;
    rep(i,N.size()){
        if(N[i]=='1')blue++;else red++;
    }

    cout << N.size()-abs(blue-red) <<endl;
    return (0);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int m, d;
int ans;

signed main() {
	cin >> m >> d;
	for (int i = 4; i <= m; i++) {
		for (int j = 22; j <= d; j++) {
			if (j % 10 >= 2) {
				if ((j / 10)*(j % 10) == i) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

static const int INF = 0x3f3f3f3f;

signed main() { 
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = INF;
        rep(i, n) cin >> a[i];
        sort(all(a));
        rep(i, n) {
                amin(ans, a[i] - a[0] + a[n - 1] - a[0]);
                amin(ans, a[n - 1] - a[i] + a[n - 1] - a[0]);
        }
        cout << ans << endl;
        return 0;
}               



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

int main(){
    string s;
    cin >> s;
    stack<char> c;
    for(auto& i : s){
        if(c.size() && c.top() != i) c.pop();
        else c.push(i);
    }
    cout << s.length() - c.size() << '\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define snd sd.ft
#define td sd.sd
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
 
#define ninf -1000000000
#define pinf 1000000000
 
typedef long long int ll; 
const ll MOD= 1e9+7;
typedef vector<pair<ll,ll> > vecpair;
typedef vector<pair<ll, pair<ll,ll> > > vecpair3;
typedef pair<ll, ll> pi; 
 
//double mei ye line cout << fixed << setprecision(10); kam mei le 
 
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
 
struct subset // disjoint set use subsets.claer and subsets.resize............
{
	int parent,sz;
};
vector< subset> subsets;
int find( int i)
{
    if (subsets[i].parent != i)
        subsets[i].parent = find(subsets[i].parent);
 
    return subsets[i].parent;
}
void uniona(int x, int y){
	if( x == y)
	return ;
    int xroot = find( x);
    int yroot = find( y);
    if (subsets[xroot].sz < subsets[yroot].sz){
        subsets[xroot].parent = yroot;
        subsets[yroot].sz += subsets[xroot].sz;
    }
    else{
        subsets[yroot].parent = xroot;
        subsets[xroot].sz += subsets[yroot].sz;
    }
}
//..............................
 
int n,k;
int h[100005],dp[100005];

ll solve(ll i)
{
	if(i>n)
      return pinf;
  else if(i==n)
    	return 0;
  else if(dp[i]!=pinf)
    return dp[i];
  //dp[i]=min(abs(h[i]-h[i+1])+solve(i+1),abs(h[i]-h[i+2])+solve(i+2));
  for(int j=1;j<=k;j++)
  {
      dp[i]=min((ll)dp[i],abs(h[i]-h[i+j])+solve(i+j));
  }
    return dp[i];
}
int main()
{
	std:ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> k;
	for(int i=0;i<100005;i++)
    dp[i]=pinf;
  	for(int i=1;i<=n;i++)
    {
    	cin >> h[i];
    }	
  	int ans=solve(1);
  	//for(int i=1;i<=n;i++)
  	//	 debug(dp[i]);
	cout << dp[1];
	return 0;
}

Measured memory_bytes: 5760
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))

A = 0
B = 1
cnt = 0

for _ab in ab[::-1]:
    a = _ab[A] + cnt
    b = _ab[B]
    if a%b == 0:
        continue
    elif a <= b:
        cnt += b-a
    else:
        cnt += b - a%b

print(cnt)

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
#define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define dbg(x)                       cout << #x << " is " << x << endl;
#define endl                           '\n'

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n>>k;
	ll a[n],dp[n];
	rep(i,0,n) cin>>a[i],dp[i]=INT_MAX;
	dp[0]=0;
	rep(i,1,n)	
	{
		rep(j,1,min(i+1,k+1))
			dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);
	}
	ret(dp[n-1])	
	
	return 0;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

constexpr ll INF = 1e16;

#define rep(i, N) for(ll i=0; i<N; ++i)

ll max(ll a, ll b) {return a < b ? b : a; }
ll min(ll a, ll b) {return a > b ? b : a; }
double maxf(double a, double b) { return a < b ? b : a; }

int main() {
  int n;
  cin>>n;
  double dn, d, ans, dd;

  if (n%2 == 0){
    cout<<"0.50000000"<<endl;
  }else{
    d = n/2;
    dn = n;
    dd = dn - d;
    ans = dd/dn;
    cout<<ans<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[211111],b[211111];
int n;
bool isok(int x){
	b[n]=(a[n]>=x);
	for(int i=1;i<n;i++){
		b[n-i]=(a[n-i]>=x);
		b[n+i]=(a[n+i]>=x);
		if(b[n-i]==b[n-i+1]||b[n+i]==b[n+i-1])return b[n-i+1];
	}
	return b[1];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++){
		scanf("%d",&a[i]);
	}
	int l=1,r=2*n-1,ans;
	while(l<=r){
		int mid=(l+r)/2;
		if(isok(mid)){
			l=mid+1;
			ans=mid;
		}
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;

#define vi vector<int>
#define vii vector<vector<int>>
#define ll long long int

void testcase()
{
    ll n;
    cin >> n;
    ll ar[n], ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> ar[i];
    }
    for (int i = 0; i < n; i++)
    {
        if ((ar[i] & 1))
        {
            continue;
        }
        else
        {
            // cout << 1 << "\n";
            while (!(ar[i] & 1))
            {
                ar[i] /= 2;
                ans++;
            }
        }
    }
    cout << ans << "\n";
}

int main()
{
    ios_base ::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    testcase();
    return 0;
}


Measured memory_bytes: 3704
#include<stdio.h>

int main(void)
{

    int n, i;
    int a[101];

    scanf("%d",  &n);

    for(i = 0; i < n; i++)
        scanf("%d", &a[i]);

    for(i = n - 1; i >= 0; i--)
        if(i != 0)
            printf("%d ", a[i]);
        else
            printf("%d\n", a[i]);


    return 0;
}

    

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

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

    if (s[0] == '1') cout << 9;
    else cout << 1;
    if (s[1] == '1') cout << 9;
    else cout << 1;
    if (s[2] == '1') cout << 9;
    else cout << 1;
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<tuple<string, int, int>>Restaurants;
	int N;

	cin >> N;
	
	string InputS;
	int InputP;
	
	for (int i = 1; i <= N; i++) {
		cin >> InputS >> InputP;
		Restaurants.emplace_back(InputS, -InputP, i);
	}

	sort(Restaurants.begin(), Restaurants.end());

	for (auto x:Restaurants) {
		cout << get<2>(x) << endl;
	}
}

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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	vector<bool> A(N, false);
	for (int i = 0; i < K; i++) {
		int d;
		cin >> d;
		for (int j = 0; j < d; j++) {
			int a;
			cin >> a;
			a--;
			A[a] = true;
		}
	}

	int count = 0;

	for (int i = 0; i < N; i++) {
		if (!A[i]) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 3000;
int const modulo = 1000000007;

int v[5 + nmax];
int _pow[5 + nmax];

void precompute() {
  _pow[0] = 1;
  for(int i = 1;i <= nmax; i++)
    _pow[i] = 1LL * _pow[i - 1] * 2 % modulo;
}

int dp[5 + nmax][5 + nmax];
int last[5 + nmax][5 + nmax];

void refresh(int x, int y, int time) {
  dp[x][y] = 1LL * dp[x][y] * _pow[time - last[x][y] - 1] % modulo;
  last[x][y] = time;
}

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

  precompute();
  int n, q;
  std::cin >> n >> q;
  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  for(int i = 1;i <= n; i++)
    for(int j = 1;j <= n; j++)
      dp[i][j] = (v[i] < v[j]);
      
  for(int i = 1;i <= q; i++) {
    int x, y;
    std::cin >> x >> y;
    refresh(x, y, i);
    refresh(y, x, i);
    dp[y][x] = dp[x][y] = (dp[x][y] + dp[y][x]) % modulo;

    for(int j = 1; j <= n; j++) 
      if(j != x && j != y) {
        refresh(j, x, i);
        refresh(j, y, i);
        refresh(x, j, i);
        refresh(y, j, i);
        dp[j][x] = dp[j][y] = (dp[j][x] + dp[j][y]) % modulo;
        dp[x][j] = dp[y][j] = (dp[x][j] + dp[y][j]) % modulo;    
      }
  }
  int result = 0;
  for(int i = 1;i <= n; i++)
    for(int j = 1;j < i; j++) {
      refresh(i, j, q + 1);
      result += dp[i][j];
      if(modulo <= result)
        result -= modulo;
    }
  std::cout << result;
  return 0;
}


Measured memory_bytes: 74124
d[5000],c;
main(w,n,i,C,W,b){
  for(;scanf("%d%d",&w,&n),w;printf("Case %d:\n%d\n%d\n",++c,d[w],b),bzero(d,w*5))
      for(;n--;)
          for(i=w,scanf("%d,%d",&C,&W);i>=W;i--)
              d[i]=fmax(d[i],d[i-W]+C),b=d[i]-d[w]?b:i;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long long X;
  cin >> X;

  int res = 0;

  res += X / 500 * 1000;

  res += X % 500 / 5 * 5;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxm=4005,maxv=maxm/2,maxn=200005,mod=1000000007;
int n,ans;
int a[maxn],b[maxn];
int f[maxm][maxm],C[maxm][maxm];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for (int i=1;i<=n;i++)f[maxv-a[i]][maxv-b[i]]++;
	for (int i=1;i<maxm;i++)C[i][0]=C[0][i]=1;
	for (int i=1;i<maxm;i++)
		for (int j=1;j<maxm;j++){
			f[i][j]=(f[i-1][j]+f[i][j-1]+f[i][j])%mod;
			C[i][j]=(C[i-1][j]+C[i][j-1])%mod;
		}
	for (int i=1;i<=n;i++)ans=(ans+f[maxv+a[i]][maxv+b[i]])%mod;
	for (int i=1;i<=n;i++)ans=(ans+mod-C[a[i]*2][b[i]*2])%mod;
	ans=1LL*ans*(mod+1)/2%mod;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int c(string s,string t){
    set<char> ss,tt;
    REPARR(i,s){
        ss.insert(s[i]);
    }
    REPARR(i,t){
        tt.insert(t[i]);
    }
    int ans=0;
    for(char s:ss){
        if(tt.find(s)!=tt.end()){
            ans++;
        }
    }
    
    return ans;
}

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ma=0;
    REP(i,n){
        chmax(ma,c(s.substr(0,i),s.substr(i)));
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
int main(){
    
    int n;
    std::cin>> n;
    
    constexpr int N_MAX=50;
    
    int v[N_MAX]={};
    //vは 1 ~ n までの添え字なので 1 basedになるように値を入れる。v[0]は使用しない
    for(int i = 1; i <= n ; i++){
        std::cin >> v[i];
    }
    
    //昇順
    std::sort(v+1,v+n+1);
    
    double result=(v[1]+v[2])/2.0;//前回の計算結果。初回はここで計算してしまう
    
    //足す値が i = 3以降について計算していく
    for(int i = 3 ;i<=n;i++){
        result += v[i];
        result/=2.0;
    }
    
    printf("%lf\n", result);
    
    
    return 0;
}

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

int main(){
    int num[3], count5=0, count7=0;
    for (int i=0; i<3; i++){
        cin >> num[i];
        if (num[i]==5){
            count5++;
        } else if (num[i]==7){
            count7++;
        }
    }

    if (count5==2 && count7==1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long

using namespace std;

string str;

inline bool check(int len, int n) {
    int i, cnt = 0;
    bool flag = 1;
    for(i = 1; i <= len; i++) {
        if((str[i] + cnt) % 2 == 1) {
            if(i + len - 1 > n)
                return 0;
            cnt++;
        }
    }
    return 1;
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i;
    ios::sync_with_stdio(false);
    cin >> str;
    int n = str.size();
    str = " " + str;
    for(i = 1; i <= n; i++) {
        str[i] -= '0';
    }
    int rez = 0;
    for(int pas = 1 << 17; pas; pas >>= 1) {
        if(rez + pas <= n && check(rez + pas, n))
            rez += pas;
    }
    cout << rez;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt(), k = nxt();
    basic_string <ll> h(n, 0);
    generate(all(h), nxt);

    vector <ll> dp(n, (ll)1e18);

    dp[0] = 0;
    for(ll i=0; i<n; i++)
    {
        for(ll j=i+1; j<i+1+k && j<n; j++)
        {
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
        }
    }

    cout << dp[n-1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};
const MOD: i64 = 1_000_000_007;

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_n(n);
    let mut ans = 0;

    for i in 0..60 {
        let mut cnt = 0;
        for j in 0..n {
            if a[j] >> i & 1 == 1 {
                cnt += 1;
            }
        }
        let a = (cnt * (n - cnt)) as i64 % MOD;
        let b = powmod(2, i) % MOD;
        let c = (a * b) % MOD;
        ans += c;
        if ans < 0 {
            ans += MOD;
        }
        ans %= MOD;
    }
    println!("{}", ans);
}

fn powmod(x: i64, n: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    if n % 2 == 0 {
        let k = powmod(x, n / 2);
        return (k * k) % MOD;
    } else {
        let k = powmod(x, n / 2);
        return (((k * k) % MOD) * x) % MOD;
    }
}


Measured memory_bytes: 88900
def gcd(a,b):
    if a < b:
        a, b = b, a
    while  a % b != 0:
        a, b = b, a % b
    return b

a,b,c,d = map(int, input().split())
res = 0
lcm = c*d // gcd(c,d)
divisible = (b//c) - ((a-1)//c) + (b//d) - ((a-1)//d) - (b//lcm) + ((a-1)//lcm)
res = b-a+1 - divisible
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
    int N; cin >> N;
    vector<double> A(N);
    rep(i, 0, N) cin >> A[i];
    double a = 0;
    rep(i, 0, N) {
        a += 1 / A[i];
    }
    double ans = 1 / a;
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }
        int anchor = partition(num, 0, n - 1);
        for (int i = 0; i < n; i++) {
            if (i != anchor) {
                System.out.print(num[i]);
            } else {
                System.out.print("[" + num[i] + "]");
            }
            if (i != n - 1) {
                System.out.print(" ");
            } else {
                System.out.println();
            }
        }
    }

    public static int partition(int[] num, int p, int r) {
        int x = num[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (num[j] <= x) {
                i++;
                swap(num, i, j);
            }
        }
        swap(num, i + 1, r);
        return i + 1;
    }

    public static void swap(int[] num, int a, int b) {
        int temp = num[a];
        num[a] = num[b];
        num[b] = temp;
    }
}



Measured memory_bytes: 71368
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n,ans=0;
  cin >> n;
  int p[n];
  rep(i,n)
    cin >> p[i];
  for (int i = 1; i < n - 1; i++) {
    if ((p[i] > p[i - 1] && p[i] < p[i + 1])
        || (p[i] < p[i - 1] && p[i] > p[i + 1])) {
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] occur = new int[100];
		int max = 0;

		Arrays.fill(occur, 0);

		while ((line = br.readLine()) != null) {
			int i = Integer.parseInt(line);
			int j = ++occur[i - 1];
			max = j > max ? j : max;
		}
		for (int i = 0; i < 100; i++) {
			if (occur[i] == max)
				System.out.println(i + 1);
		}
	}
}

Measured memory_bytes: 16872
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	dp := makeGrid(n+1, k+1)
	dp[0][0] = 1
	for i := 1; i < n+1; i++ {
		for j := 1; j < k+1; j++ {
			dp[i][j].addAs(dp[i-1][j-1])
			if i-j >= 0 {
				dp[i][j].addAs(dp[i-j][j])
			}
		}
	}
	fmt.Fprintln(writer, dp[n][k])
}

func makeGrid(h, w int) [][]mint {
	index := make([][]mint, h, h)
	data := make([]mint, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



Measured memory_bytes: 9468
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl

string S;



int main()
{

	cin >> S;
	int N = S.length();
	if(N == 1){
		cout << "YES";
		return 0;
	} else if (N == 2) {
		if(S[0] != S[1]){
			cout << "YES";
		} else {
			cout << "NO";
		}
		return 0;
	}
	vector <int> a;
	a.resize(3);
	REP(i,N){
		a[S[i]-'a']++;
	}
	sort(a.begin(),a.end());

	int ans[3];
	ans[0] = N/3;
	ans[1] = N/3;
	ans[2] = N/3;

	REP(i,N%3){
		ans[i]++;
	}
	bool flag = true;
	REP(i,3){
		if(a[2-i]!=ans[i])
			flag = false;
	}
	if(flag){
		cout << "YES";
	} else {
		cout << "NO";
	}
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;

/*
10^n - 8^n
*/

ll powe(ll x, ll y){
    //xのy乗をMODで割った余り
    ll tmp=1;
    rep(i,y){
        tmp = (tmp * x)%MOD;
        while(tmp<0) tmp+MOD;
    }
    return tmp;
}

void solve(){

    ll n;
    cin >> n;
    ll t1,t2,t3;
    t1 = powe(10,n);
    t2 = powe(8,n);
    t3 = powe(9,n);
    ll ans = (((t1 + MOD*MOD - 2*t3)%MOD + t2)%MOD);
    while(ans<0) ans+MOD;
    cout << ans << endl;
    
    //cout << t1 << endl;
    //cout << t2 << endl;
    //cout << t3 << endl;

}

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


Measured memory_bytes: 3600
fun main(args: Array<String>) {
    val (n, a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    val s = readLine()!!
    if (c < d) {
        if (f2(s, a, c) && f2(s, b, d)) {
            println("Yes")
        } else {
            println("No")
        }
    } else {
        if (f2(s, a, c) && f3(s, b, d)) {
            println("Yes")
        } else {
            println("No")
        }
    }
}

fun f2(s: String, l: Int, r: Int): Boolean {
    var ok = true
    s.slice((l - 1)..(r - 1)).reduce { a, b -> if (a == '#' && b == '#') ok = false;b }
    return ok
}

fun f3(s: String, l: Int, r: Int): Boolean {
    for (i in (l - 2)..(r - 2)) {
        if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') return true
    }
    return false
}

Measured memory_bytes: 41376
#include <stdio.h>

struct Node{
  int p,l,r;
};
struct Node T[10000];
int n;

void inParse(int v) {
  if(v==-1) return;
  inParse(T[v].l);
  printf(" %d",v);
  inParse(T[v].r);
}

void preParse(int v) {
  if(v==-1)return;
  printf(" %d",v);
  preParse(T[v].l);
  preParse(T[v].r);
}

void postParse(int v) {
  if(v==-1) return;
  postParse(T[v].l);
  postParse(T[v].r);
  printf(" %d",v);
}

int main(int argc, char const *argv[]) {
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=-1)T[l].p=v;
    if(r!=-1)T[r].p=v;
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1)root =i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\nInorder\n");
  inParse(root);
  printf("\nPostorder\n");
  postParse(root);
  printf("\n");
  return 0;
}

Measured memory_bytes: 620
h,w = gets.chomp.split(' ').map(&:to_i)
arr_ans = []
arr_ans.push('#'*(w+2))
h.times do
  arr_ans.push('#' + gets.chomp + '#')
end
arr_ans.push("#"*(w+2))
arr_ans.each do |arr|
  puts arr
end


Measured memory_bytes: 14276