akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=55;
ll a[maxn],b[maxn];
ll dfs(int dep,ll x)
{
	if(x==a[dep])
		return b[dep];
	if(dep==0)
		return 1;
	if(x<=1)
		return 0;
	if(1+a[dep-1]>=x)
		return dfs(dep-1,x-1);
	if(2+a[dep-1]==x)
		return b[dep-1]+1;
	return b[dep-1]+1+dfs(dep-1,x-2-a[dep-1]);
}
int main()
{
	int n;ll x;
	cin>>n>>x;
	a[0]=b[0]=1;
	for(int i=1;i<=n;i++)
	{
		a[i]=2*a[i-1]+3;
		b[i]=2*b[i-1]+1;
	}
	printf("%lld\n",b[n]-dfs(n,a[n]-x));
	return 0;
}


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int ans = 1001001001;
    for (int p = 1; p <= 100; p++)
    {
        int now =0;
        rep(i,n) now += (x[i]-p)*(x[i]-p);
        ans = min(ans, now);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


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


if __name__ == '__main__':
    n =input()
    sum = 0
    for i in range(1,len(n)+1):
        if i %2 >0:
            if i ==len(n):
                sum +=  int(n)- 10**(i-1)+1
            else:
                sum += 9 * (10**(i-1))

    print(sum)


Measured memory_bytes: 5144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

char im[102][102];
char newim[202][102];
int main(){
   int h,w;
   cin >> h >> w;
   for(int i=1;i <= h;i++){
      for(int j=1;j <= w;j++) cin >> im[i][j];
   }
   for (int i=1;i <= 2*h;i++){
      for(int j=1; j<=w;j++){
         newim[i][j]=im[(i+1)/2][j];
      }
   }
   //printf("\n");
   for(int i=1;i <=2*h;i++){
      for (int j=1;j<=w;j++){
         cout << newim[i][j];
      }
      printf("\n");
   }
 
   
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n,k,x,y;
  scanf("%d %d %d %d", &n,&k,&x,&y);
  int sum = 0;
  for(int i=1; i<=n;i++){
    if(i >= k+1)
      sum += y;
    else
      sum += x;
  }
  printf("%d", sum);
  return 0;
}
      

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main() {
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
  while (scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) == 8)
    if (xb2 < xa1 || xa2 < xb1 || yb2 < ya1 || ya2 < yb1)
      puts("NO");
    else
      puts("YES");
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import os
import sys
from io import BytesIO, IOBase

sys.stdout, stream = IOBase(), BytesIO()
sys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)
sys.stdout.write = lambda s: stream.write(s.encode())

input = BytesIO(os.read(0, os.fstat(0).st_size)).readline


def main():
    n = int(input())
    s = input().rstrip(b'\r\n')
    print('Yes' if s.count(b'R') - s.count(b'B') > 0 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int w[2000];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    rep(i,n) cin >> w[i]; 
    
    int Min = INT_MAX;
    
    rep(i,n){
        int s1 = 0;
        for(int j=0; j<=i; j++) s1 += w[j];
        int s2 = 0;
        for(int k=i+1; k<n; k++) s2 += w[k];
        Min = min(Min, abs(s1-s2));
    }
    
    cout << Min << ln;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  if (N%2==0) cout << N/2-1 << endl;
  else cout << (N-1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  string s;
  cin >> s;
  int a = 0, c = 0, b = 0;
  REP(i, s.length())
  {
    if (s[i] == 'a')
    {
      a++;
    }
    if (s[i] == 'b')
    {
      b++;
    }
    if (s[i] == 'c')
    {
      c++;
    }
  }

  if (abs(a - b) <= 1 && abs(b - c) <= 1 && abs(a - c) <= 1)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
def calc(N, K):
    N = N % K
    d = []
    while True:
        x = abs(N - K)
        if x in d:
            return min(d)
        else:
            d += [x]
            N = x


(N, K) = tuple([int(s) for s in input().split()])
print(calc(N, K))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	 	Scanner scanner = new Scanner(System.in);
	 	int K = scanner.nextInt();
	 	int N = scanner.nextInt();
	 	int[] A = new int[N];
	 	int[] D = new int[N];
	 	for (int i = 0; i < N; i++) {
	 		A[i] = scanner.nextInt();
	 	}
	 	for (int i = 0; i < N-1; i++) {
	 		D[i] = A[i+1] - A[i];
	 	}
	 	D[N-1] = A[0] + K - A[N-1];

	 	/*
	 	for (int i = 0; i < N; i++) {
 			System.out.println(D[i]);
 		}*/

	 	int max=D[0];
        for (int j = 1; j < N; j ++) {
            max = Math.max(max, D[j]);//[4]
        }
        //System.out.println(max);
        System.out.println(K - max);
	}
}

Measured memory_bytes: 86932
X,N = map(int,input().split())
p = list(map(int,input().split()))
p = set(p)
mini = 10**3
ans = 0
for i in range(10**3):
    if X - i not in p:
        print(X-i)
        exit()
    if X + i not in p:
        print(X+i)
        exit()
        


Measured memory_bytes: 61668
import operator
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


p = []
rank = []


def make_set(x):
    p[x] = x
    rank[x] = 0


def _union(x, y):
    link(find_set(x), find_set(y))


def link(x, y):
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[x] += 1


def find_set(x):
    if x != p[x]:
        p[x] = find_set(p[x])
    return p[x]


def solve():
    n = read_int()
    a = [read_int_list() for i in range(n)]
    global p, rank
    p = [0] * n
    rank = [0] * n

    for x in range(n):
        make_set(x)

    def get_cost(i, j):
        return min(abs(a[i][0] - a[j][0]), abs(a[i][1] - a[j][1]))

    roads = []
    for j in range(2):
        l = sorted(range(n), key=lambda i: a[i][j])
        for i in range(n - 1):
            cost = get_cost(l[i], l[i + 1])
            road = (cost, l[i], l[i + 1])
            roads.append(road)
    roads.sort()

    res = 0
    for road in roads:
        c, u, v = road
        if find_set(u) != find_set(v):
            res += c
            _union(u, v)
    return res


def main():
    res = solve()
    print(res)


main()


Measured memory_bytes: 62464
S = input()
N = len(S)

ans1 = sum([1 for i in range(N) if i % 2 == 0 and S[i] == "0"]) + sum([1 for i in range(N) if i % 2 != 0 and S[i] == "1"])
ans2 = sum([1 for i in range(N) if i % 2 == 0 and S[i] == "1"]) + sum([1 for i in range(N) if i % 2 != 0 and S[i] == "0"])
print(min(ans1, ans2))


Measured memory_bytes: 3572
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        long L = int.Parse(str[1]);
        long T = int.Parse(str[2]);
        long count = 0;
        long[] P = new long[N];
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            long X = int.Parse(str[0]);
            if(int.Parse(str[1]) == 1){
                P[i] = (X+T)%L;
                count += (X+T)/L;
            }
            else{
                P[i] = (X+T*L-T)%L;
                if(X < T){
                    count -= (T-X-1)/L+1;
                }
            }
        }
        Array.Sort(P);
        if(count >= 0){
            count %= N;
        }
        else{
            count = -count;
            count %= N;
            count = N-count;
            count %= N;
        }
        int c = (int)count;
        for(int i=c;i<N;i++){
            sb.Append(P[i]+"\n");
        }
        for(int i=0;i<c;i++){
            sb.Append(P[i]+"\n");
        }
    }
}

Measured memory_bytes: 20796
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N; ++i)
using namespace std;

int main(){
    int N,ans = 0;
    int MOD = 1e9 + 7;
    cin >> N;
    vector<int> A(N), B(N,0);
    rep(i, N) cin >> A[i];
    rep(i, N/2) B[i] = B[N-i-1] = N-2*i-1;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    bool flag = true;
    rep(i, N) if(A[i] != B[i]) flag = false;
    if(flag){
        ans = 1;
        rep(i, N/2) ans =  ans * 2 % MOD;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var s string
	var ans int

	n := 0
	
	fmt.Scan(&s)

	for i := 0; i < len(s); i++ {
		if i % 2 == 0 && s[i] != '0' {
			n++
		} else if i % 2 == 1 && s[i] != '1' {
			n++
		}
	}

	if len(s) - n < n {
		ans = len(s) - n
	} else {
		ans = n
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll sum = 0;
    if (k <= a) {
        sum += k;
        cout << sum << endl;
        return 0;
    }
    else {
        sum += a;
        k -= a;
        if (k - b <= 0) {
            cout << sum << endl;
            return 0;
        }
        else {
            k -= b;
            if (k > 0) sum -= k;
            cout << sum << endl;
            return 0;
        }
    }


    return 0;
}

Measured memory_bytes: 3652
import math, sys

N = int(input())

sqrt_n = round(math.sqrt(N))
# print(sqrt_n)

min_f = sys.maxsize
for i in range(sqrt_n, 0, -1):
    if N % i == 0:
        len_A = len(str(i))
        len_B = len(str(N//i))
        F = max(len_A, len_B)
        min_f = min(min_f, F)

print(min_f)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX 8
#define FREE 0
#define NOT_FREE 1
#define ture 2
#define false 3
int bord[MAX][MAX];
int count,row[MAX],col[MAX],dpos[MAX*2-1],dneg[MAX*2-1];

void print(){
  int i,j;
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      if(bord[i][j]){
        if(row[i] != j){
          return;
        }
      }
    }
  }
  for(i=0;i<MAX;i++){
    for(j=0;j<MAX;j++){
      if(row[i]==j){
        printf("Q");
      }
      else{
        printf(".");
      }
    }
    printf("\n");
  }

}

void queen(int i){
  int j;
  if(i==MAX) {
    print();
    return;
  }

  for(j=0;j<MAX;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+(MAX-1)] == NOT_FREE){
      continue;
    }
    row[i]=j;
    col[j] = dpos[i+j] = dneg[i-j+(MAX-1)] = NOT_FREE;
    queen(i+1);
    
    row[i] = col[j] = dpos[i+j] = dneg[i-j+(MAX-1)] = FREE;
    
  }
  
}

void init(){
  int i,j;
  for(i=0;i<MAX*2-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
  for(i=0;i<MAX;i++){
    row[i]=FREE;
    col[i]=FREE;
    /*for(j=0;j<MAX;j++){
      bord[i][j]=false;
    }*/
  }
}

int main(){
  int i,j,r,c,n;
  
  init();
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d %d",&r,&c);
    /*row[r]=NOT_FREE;
    col[c]=NOT_FREE;
    dpos[r+c]=NOT_FREE;
    dneg[r-c+(MAX-1)]=NOT_FREE;*/
    bord[r][c]=ture;
  }

  queen(0);
  
  
  return 0;
}



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

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    if (n & 1)
        return cout << "0\n", 0;
    ll ans = 0, ans2 = 0, tmp = 10;
    while (tmp <= n) {
        ans += n / tmp;
        tmp *= 5;
    }
    return cout << ans << "\n", 0;
}

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

/*
どう足掻いてもDPには見えないけど、どうやってその発想に至るのだろう
3個の寿司の皿の枚数をa、2をb、1をcとする
dp[a][b][c]:寿司がa,b,cの時の操作回数の期待値
これは、
・dp[a-1][b+1][c]
・dp[a][b-1][c+1]
・dp[a][b][c-1]
・dp[a][b][c]
の線形和で表現できる。
例えば、a=1,b=1,c=2の時、
1/4*dp[0][2][2] + 1/4*dp[1][0][3] + 1/4*dp[1][1][1] + 0 + 1 

dp[i][j][k]=(i/n)*dp[i-1][j+1][k] + (j/n)*dp[i][j-1][k+1] +
(k/n)*dp[i][j][k-1] + (n-i-j-k/n)*dp[i][j][k] + 1
この式から、
(i+j+k/n)*dp[i][j][k] = (i/n)*dp[i-1][j+1][k] + (j/n)*dp[i][j-1][k+1] +
(k/n)*dp[i][j][k-1] + 1
あるいは、
dp[i][j][k] = (i/i+j+k)*dp[i-1][j+1][k] + (j/i+j+k)*dp[i][j-1][k+1] +
(k/i+j+k)*dp[i][j][k-1] + (n/i+j+k)

dp[1][0][0]= dp[0][1][0] + 1/3
dp[0][0][2] = dp[0][0][1] + 1/2
dp[0][0][1] = dp[0][0][0] + 1

*/

double dp[305][305][305];

void solve(){
    int n;
    cin >> n;
    int v[n+10];
    int a,b,c;
    a=0;
    b=0;
    c=0;
    rep(i,n){
      cin >> v[i];
      if(v[i]==3) a++;
      else if(v[i]==2) b++;
      else c++;
    }
    dp[0][0][0]=0;
    rep(i,n+1){
      rep(j,n+1){
        rep(k,n+1){
          if(i==0&&j==0&&k==0) dp[i][j][k]=0;
          else{
            if(i==0&&j==0) dp[i][j][k]= ((double)k/(double)(i+j+k))*dp[i][j][k-1] + ((double)n/(double)(i+j+k));
            else if(i==0&&k==0) dp[i][j][k]= ((double)j/(double)(i+j+k))*dp[i][j-1][k+1] + ((double)n/(double)(i+j+k));
            else if(j==0&&k==0) dp[i][j][k]= ((double)i/(double)(i+j+k))*dp[i-1][j+1][k] + ((double)n/(double)(i+j+k));
            else if(i==0) dp[i][j][k] = ((double)j/(double)(i+j+k))*dp[i][j-1][k+1] + ((double)k/(double)(i+j+k))*dp[i][j][k-1] + ((double)n/(double)(i+j+k));
            else if(j==0) dp[i][j][k] = ((double)i/(double)(i+j+k))*dp[i-1][j+1][k] + ((double)k/(double)(i+j+k))*dp[i][j][k-1] + ((double)n/(double)(i+j+k));
            else if(k==0) dp[i][j][k] = ((double)i/(double)(i+j+k))*dp[i-1][j+1][k] + ((double)j/(double)(i+j+k))*dp[i][j-1][k+1] + ((double)n/(double)(i+j+k));
            else dp[i][j][k] = ((double)i/(double)(i+j+k))*dp[i-1][j+1][k] + ((double)j/(double)(i+j+k))*dp[i][j-1][k+1] + ((double)k/(double)(i+j+k))*dp[i][j][k-1] + ((double)n/(double)(i+j+k));
            //cout << "i:" << i << " j:" << j << " k:" << k << " " << dp[i][j][k] << endl;
          }
        }
      }
    }
    cout << setprecision(12) << dp[a][b][c] << endl;

}

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


Measured memory_bytes: 219392
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if(x>=2000) {
    cout << 1 << endl;
  }
  else {
    for(int i=0; i<=20; i++) {
      for(int j=0; j<=20; j++) {
        for(int k=0; k<=20; k++) {
          for(int l=0; l<=20; l++) {
            for(int m=0; m<=20; m++) {
              for(int n=0; n<=20; n++) {
                if(i*105+j*104+k*103+102*l+101*m+100*n==x) {
                  cout << 1 << endl;
                  return 0;
                }
              }
            }
          }
        }
      }
    }
    cout << 0 << endl;
  }
}

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

using namespace std;

int n, k, m;

int main(void){
    while (1) {
        cin >> n >> k >> m;
        if (!n && !k && !m) break;
        
        queue<int> que;
        for (int i = 1; i < n+1; i++) que.push(i);
        for (int i = 0; i < m-1; i++) {
            int t = que.front();
            que.pop();
            que.push(t);
        }
        que.pop();
        //cout << que.front() << endl;
        
        for (int i = 0; i < n-2; i++) {
            for (int j = 0; j < k-1; j++) {
                int t = que.front();
                que.pop();
                que.push(t);
            }
            que.pop();
            //cout << que.front() << endl;
        }
        cout << que.front() << endl;
    }
    return 0;
}

Measured memory_bytes: 3028
from collections import defaultdict


n = int(input())

dic = [defaultdict(lambda: 0) for i in range(n)]

keys = [None]*n

for i in range(n):
    s = input()
    for j in range(len(s)):
        dic[i][s[j]] += 1

    keys[i] = set(dic[i])

key = keys[0]

for i in range(1,n):
    key = key & keys[i]

key = list(key)
key.sort()
nums = [0]*len(key)
ans = ""

for j in range(len(key)):
    tmp = [0]*n
    for i in range(n):
        tmp[i] = dic[i][key[j]]
    nums[j] = min(tmp)
    ans += key[j]*nums[j]
print(ans)


Measured memory_bytes: 3444
import java.util.*;
import java.lang.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        double inverseA[] = new double[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            inverseA[i] = 1 / (double)A[i];
        }

        double sumInverseA = 0;
        for(int i = 0; i < N; i++){
            sumInverseA += inverseA[i];
        }


        System.out.println(1 / sumInverseA);




    }
}





Measured memory_bytes: 21712
local mab = math.abs
local mmi = math.min
local h, w = io.read("*n", "*n")
local a = {}
for i = 1, h do
  for j = 1, w do
    a[(i - 1) * w + j] = io.read("*n")
  end
end
for i = 1, h do
  for j = 1, w do
    local idx = (i - 1) * w + j
    a[idx] = mab(a[idx] - io.read("*n"))
  end
end

-- top
local odd, ev = {}, {}
for i = 1, w do
  odd[i] = {}
  ev[i] = {}
  for j = 1, 6401 do
    odd[i][j] = false
    ev[i][j] = false
  end
end
for i = 1, 81 do odd[1][i] = false end
odd[1][1 + a[1]] = true
for j = 2, w do
  local av = a[j]
  local lim = 80 * j + 1
  for dst = 1, lim do
    local f = false
    if odd[j - 1][1 + mab(dst - 1 - av)] then
      f = true
    end
    if not f and dst + av <= lim - 80 and odd[j - 1][dst + av] then
      f = true
    end
    odd[j][dst] = f
  end
end
local mmi = math.min
-- rem
for i = 2, h do
  local refsrc = i % 2 == 0 and odd or ev
  local refdst = i % 2 == 0 and ev or odd
  do -- j = 1
    local av = a[(i - 1) * w + 1]
    local lim = 80 * i + 1
    for dst = 1, lim do
      local f = false
      if refsrc[1][1 + mab(dst - 1 - av)] then
        f = true
      end
      if not f and dst + av <= lim - 80 and refsrc[1][dst + av] then
        f = true
      end
      refdst[1][dst] = f
    end
  end
  for j = 2, w do
    local av = a[(i - 1) * w + j]
    local lim = mmi(6400, (i + j - 1) * 80) + 1
    for dst = 1, lim do
      local f = false
      if refsrc[j][1 + mab(dst - 1 - av)] or refdst[j - 1][1 + mab(dst - 1 - av)] then
        f = true
      end
      if not f and dst + av <= lim - 80 then
        if refsrc[j][dst + av] or refdst[j - 1][dst + av] then
          f = true
        end
      end
      refdst[j][dst] = f
    end
  end
end
local ret = 1000000007
do
  local lim = (h + w - 1) * 80 + 1
  local refdst = h % 2 == 0 and ev or odd
  for p = 1, lim do
    if refdst[w][p] then
      ret = p - 1
      break
    end
  end
end
print(ret)


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define mod ((ll)1e9+7)
#define N ((ll)2e6+10)
#define pb push_back
#define in insert
#define F first
#define S second
#define MAX_CHARS 256
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x, ll y, ll p) { ll res = 1; while (y) {if (y % 2) res = (res * x % p) % p; x = (x * x) % p; y /= 2; } return res;}
int sv[1000000] = {0};
ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];
void InverseofNumber(ll p) {naturalNumInverse[0] = naturalNumInverse[1] = 1; for (ll i = 2; i <= N; i++)naturalNumInverse[i] = naturalNumInverse[p % i] * (mod - mod / i) % mod;}
void InverseofFactorial(ll p) {factorialNumInverse[0] = factorialNumInverse[1] = 1; for (ll i = 2; i <= N; i++)factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;}
void factorial(ll p) {fact[0] = 1; for (ll i = 1; i <= N; i++) {fact[i] = (fact[i - 1] * i) % mod;}}
ll Binomial(ll n, ll R) {ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod; return ans;}
/*TOIENT FUNCTION*/ll phi(ll n) {ll ans = n; for (ll i = 2; i * i <= n; i++) {if (n % i == 0) {while (n % i == 0) n /= i; ans -= ans / i;}} if (n > 1) ans -= ans / n; return ans;}


void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {

//    InverseofNumber(mod);
//    InverseofFactorial(mod);
//    factorial(mod);
    speed
    // fileIO();
    ll k; string s; cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
    }
    else {
        for (ll i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    }



    return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#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<cstring>
#include<ctime>
#include<stdio.h>
#define ll long long
#define maxn 100000
using namespace std;
ll n;
string ans;
int main()
{
	cin>>n;
	ans="";
	while(n>0)
	{
		n--;
		int tmp=n%26;
		n/=26;
		ans+='a'+tmp;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
//import java.util.Collections;

public class Main{
    public static void main(String[] args) throws Exception{
        int number;
        ArrayList<Integer> prime = new ArrayList<>();
        ArrayList<Integer> exist = new ArrayList<>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        for(int i = 0; i<n ; i++) {
            line = br.readLine();
            number = Integer.parseInt(line);
            if(isPrime(number)){
                prime.add(number);
            }
        }
//        Collections.sort(exist);
//        number = exist.get(exist.size()-1);
//
//        if(number >= 2){
//            prime.add(2);
//        }
//
//        for (int i = 3; i <= number; i += 2) {
//            isPrime = true;
//            for (int p : prime) {
//                comp = (double) i / (double) p;
//                if (p == 1) {
//                    continue;
//                }
//                if (i % p == 0) { //iが見つかった素数で割り切れる
//                    isPrime = false;
//                    break;
//                } else if (p > comp) {
//                    break;
//                }
//            }
//            if (isPrime) {
//                prime.add(i);
//            }
//        }
//        for( int e : exist){
//            if(prime.contains(e)){
//                count++;
//            }
//        }
        
        System.out.println(prime.size());
    }
//  素直に解説のとおりに実装
    static boolean isPrime(int n){
        if(n==2) {
            return true;
        }
        if(n<2 || n%2==0){
            return false;
        }

        int i = 3;
        while(i<=Math.sqrt((double)n)){
            if(n%i==0){
                return false;
            }
            i = i + 2;
        }
        return true;
    }
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(all(a));
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int cnt = (int) (lower_bound(all(a), a[i] + a[j]) - a.begin());
			ans += cnt - j - 1;
		}
	}
	cout << ans;
}
	

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 998244353
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define f first
#define s second
#define b begin
#define e end
#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a;i<b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define itfr(it,x) for(it=x.begin();it!=x.end();it++)
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;

int solve(int N, vector<int> v)
{
    int dp[N+1];
    dp[1] = 1; 
    for(int i = 2; i <= N; i++)
    {
        dp[i] = 0; 
        for(int j = 0; j < v.size(); j++)
            if(v[j] < i)
                dp[i] = (dp[i]%mod + dp[i-v[j]]%mod)%mod;
    }
    return dp[N];
}

int main()
{
   flash;
   //sieve();
   ll T=1,t,n,m,q,k,i,j;
   // cin>>T;
   while(T--)
   {
      cin>>k;
      m = 0; q = 0;  j=0;
      // cin>>n>>k;
      // vector<int> vec;
      FOR(i,0,k)
      {
         cin>>m>>t;
         if(m!=t) q=0;
         else  q++;
         if(q==3)
            j=1;
         // FOR(j,m,t+1)
            // vec.pb(j);
      }
      if(j) yes;
      else  no;
      // cout<<solve(n,vec);
   }
}

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

int main() {
  int n;
  cin>>n;
  vector<int> mao(n);
  for (int i=0; i<n; i++)
    cin>> mao.at(i);
  
  
  vector<int> mao2=mao;
  sort(mao2.begin(),mao2.end());
  
  int z=0;
  for (int i=0; i<n;i++) {
    if (mao.at(i)!=mao2.at(i)) {
      z++;
    }
  }
  
  if (z==0 || z==2) {
    cout<< "YES"<<endl;
  }
  else {
    cout<< "NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

typedef long long ll;

const int N = 1e5 + 5;

int A[N];

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int r;
    cin >> r;

    cout << r * r;
    return 0;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e6+5;
string s;
ll n,m;
ll a[N];

// 素因数分解O(ルートn)
template <typename T> map<T,T> prime_factor(T n) {
  map<T, T> res;
  for(int i = 2; i*i <= n; i++) {
    while(n%i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

// テーブルを作る前処理
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

// a*b/m
ll mul(ll a, ll b, ll m) {
    a = mod(a, m); b = mod(b, m);
    if (b == 0) return 0;
    ll res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  map<ll, ll> v = prime_factor(m);
  // v[1] = 1;
  COMBinit();
  ll result = 1;
  map<ll, ll>::iterator ite;
  for (ite = v.begin(); ite != v.end(); ++ite) {
    // cout << v[i] << endl;
    // cout << temp << endl;
    // temp = temp ? temp : 1;
    if(ite->second != 0) result = mul(result,COMB(ite->second + n -1, ite->second),MOD);
  }
  cout << result << endl;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);

  FOR(i,0,N) cin >> A[i];

  ll ans = 0;
  FOR(i,0,N){
    if(i%2) ans -= A[i];
    else ans += A[i];
  }

  FOR(i,0,N){
    if(i) cout << " ";
    cout << ans;
    ans = 2*A[i] - ans;
  }



}




Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	uint64_t A, B, K;
	cin >> A >> B >> K;
	for(auto i=A; i<=min(A+K-1, B); ++i){
		cout << i << endl;
	}
	for(auto i=max(B-K+1, A+K); i<=B; ++i){
		cout << i << endl;
	}
	
}


Measured memory_bytes: 256
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms=grep!$ls[$_-1]&&$ls[$_],1..$n-1;
	my@lms_map=(-1)x($n+1);
	my$m=@lms;
	for(0..$m-1){
		$lms_map[$lms[$_]]=$_;
	}
	@sa=$induce->(@lms);
	if($m){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 251852
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

  int u;
  int k;
  int v;
int Adj[101][101];
int color[101];
int d[101];
int f[101];
int time;

void visit(int u,int n){
  int i;
  color[u] = GRAY;
  d[u] = ++time;
  for(i=0;i<n;i++){
    if(Adj[u][i]==1){
    if(color[i] == WHITE){
      visit(i,n);
    }
    }
  }
  color[u] == BLACK;
  f[u]=++time;
}


void dfs(int n){
  int i;
  for(i=0;i<n;i++){
    color[i]=WHITE;
      }
  for(i=0;i<n;i++){
    if(color[i]==WHITE){
      visit(i,n);
    }
  }
}

int main(){
  int n,i,j;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      if(k!=0){
        Adj[i][v-1]=1;
    }
    }
  }

  dfs(n);
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    printf("%d ",d[i]);
    printf("%d",f[i]);
    printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2108
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
using namespace std;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double n, k;
	cin >> n >> k;
	vector<double> p(n);
	for (int i = 0; i < n; ++i) cin >> p[i];
	vector<double> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = p[i] * (p[i] + 1) / 2 / p[i];
	}

	double ans = -1, sum = 0;
	for (int i = 0; i < k; ++i) {
		sum += a[i];
	}
	ans = max(ans, sum);

	for (int i = k; i < n; ++i) {
		sum -= a[i - k];
		sum += a[i];
		ans = max(ans, sum);
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl







using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;


ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n;
vector<int> g[maxn];

int par[maxn];
int siz[maxn];
vector<int> subtrees[maxn];

void dfs(int at, int p=0) {
    siz[at]=1;
    for (int to: g[at]) {
	if (to == p) continue;
	dfs(to, at);
	par[to] = at;
	siz[at] += siz[to];
    }
}


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

    cin>>n;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    dfs(1);

    
    for (int at=1; at<=n; at++) {
	ll tot = 0;
	for (int to: g[at]) {
	    if (to==par[at]) continue;
	    tot += siz[to];
	    subtrees[at].push_back(siz[to]);
	}
	ll up = n-1-tot;
	if (up>0) subtrees[at].push_back(up);
    }


    ll res = 0;
    for (int i=1; i<=n; i++) {
	ll all = pw(2,n-1);
	all --;
	for (ll x: subtrees[i]) {
	    all -= (pw(2,x)-1);
	    all %= mod;
	}
	res += all;
	res %= mod;
    }

    res %= mod;
    res += mod;
    res %= mod;

    ll ans = res*pw(pw(2,n),mod-2)%mod;
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 75608
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	int n,m,k;
	cin>>n>>m>>k;
	cout<<(k+max(n,m)-1)/max(n,m)<<endl;
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



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

int n, d, ans;
int point[11][11];

bool get_dist(int x, int y) {
    int tmp = 0;
    for (int i = 1; i <= d; ++i) {
        tmp += pow(point[x][i] - point[y][i], 2);
    }
    if (int(sqrt(tmp)) == sqrt(tmp)) 
        return true;
    else 
        return false;
}

int main() {
    scanf("%d%d", &n, &d);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= d; ++j) {
            scanf("%d", &point[i][j]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            ans += get_dist(i, j);
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long hs[] = new long[N];
        for(int i = 0;i < N;i++)
            hs[i] = sc.nextLong();

        long dp[] = new long[N];
        dp[0] = 0;
        for(int i = 1;i < N;i++) {
            if (i == 1)
                dp[i] = dp[i - 1] + Math.abs(hs[i] - hs[i - 1]);
            else
                dp[i] = Math.min(dp[i - 1] + Math.abs(hs[i] - hs[i - 1]),dp[i - 2] + Math.abs(hs[i] - hs[i - 2]));
        }

        System.out.println(dp[N - 1]);

    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


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

int main() {
  double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
  while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
    if(xa1 < xb1) {
      swap(xa1,xb1);
      swap(ya1,yb1);
      swap(xa2,xb2);
      swap(ya2,yb2);
    }
    if(yb2 < ya1)
      cout << "NO" << endl;
    else if((xa1 <= xb2) && (yb1 <= ya2))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  if(n == 1)cout<<0<<endl;
  else cout<<1<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    double v = a * a * b;
    if(x >v/2){
        double ans = std::atan((a*b-x/a)*2/a/a);
        printf("%.10lf\n",(ans/M_PI)*180);
        
    }else if(x <=v/2) {
        double ans = std::atan(b/((x/a)*2/b));
        printf("%.10lf\n",(ans/M_PI)*180);
    }

    

    return 0;
}

Measured memory_bytes: 256
import sys

X = int(sys.stdin.readline())

n = 0
while True:
    if X - 500 >= 0:
        n += 1000
    else:
        break
    X -= 500
while True:
    if X - 5 >= 0:
        n += 5
    else:
        break
    X -= 5
print(n)


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
    int x, y, z;

    cin >> x >> y >>z;
    cout << z << " " <<  x << " " << y << endl;


    return 0;
}  


Measured memory_bytes: 256