akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
def i():
    return stdin.readline().rstrip()
def mi():
    return map(int(),stdin.readline().rstrip().split())
def li():
    return list(map(int,stdin.readline().rstrip()))
ans=10000
s=i()
t=i()
ls=len(s)
lt=len(t)
l=ls-lt
for i in range(l+1):
    cnt=0
    for j in range(lt):
        if s[i+j]!=t[j]:
            cnt+=1
    if cnt<ans:
        ans=cnt

print(ans)

Measured memory_bytes: 8976
#include<iostream>

using namespace std;

constexpr int MAX_LEN = 7368791;

bool seeBamboo[MAX_LEN + 20] = { true, true, };

int main()
{
    int m, n;
    while(cin >> m >> n, (m + n))
    {
        fill(seeBamboo + m, seeBamboo + MAX_LEN, false);

        int num = m;

        for(int i = 0; i < n; i++)
        {
            while(seeBamboo[num])num++;
            for(int j = num; j < MAX_LEN; j += num)
            {
                seeBamboo[j] = true;
            }
        }

        int ans = num;
        while(seeBamboo[ans])ans++;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10184
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,l = inpl()
mi = INF
a = [i+l for i in range(n)]
no = -1
for i in range(n):
    if abs(a[i]) < mi:
        no = i
        mi = abs(a[i])
# print(no)
print(sum(x for i,x in enumerate(a) if i != no))


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    REP(i, N + 1) cin >> A[i];
    REP(i, N) cin >> B[i];
    ll ans = 0;
    REP(i, N)
    {
        if (B[i] >= A[i])
        {
            ans += A[i];
            B[i] -= A[i];
            if (B[i] >= A[i + 1])
            {
                ans += A[i + 1];
                A[i + 1] = 0;
            }
            else
            {
                ans += B[i];
                A[i + 1] -= B[i];
            }
        }
        else
        {
            ans += B[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,t,min=1001;
  cin >> n >> t;
  vector<int>c(n),x(n);
  for(int i=0; i<n; i++){
    cin >> c.at(i) >> x.at(i);
    if(x.at(i)<=t){
      if(min>c.at(i)){
        min=c.at(i);
      }
    }
  }
  if(min==1001){
    cout << "TLE" << endl;
  }
  else{
    cout << min << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r;
    cin >> r;

  if (r < 1200) {
    cout << "ABC" << endl;
  }else if (r < 2800){
    cout << "ARC" << endl;
  }else {
    cout << "AGC " << endl;
  } 
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M, P = in.next().toInt
  val graph = Array.fill[List[(Int, Int)]](N+1)(Nil) // to, cost
  val graphRev = Array.fill[List[(Int, Int)]](N+1)(Nil) // to, cost
  for (i <- 0 until M) {
    val A, B, C = in.next().toInt
    graph(A) = (B, C) :: graph(A)
    graphRev(B) = (A, C) :: graphRev(B)
  }

  //
  val dpFor = new Array[Boolean](N+1)
  val q = Queue[Int](1)
  while (!q.isEmpty) {
    val now = q.dequeue()
    if (!dpFor(now)) {
      dpFor(now) = true
      for ((node, _) <- graph(now)) {
        q.enqueue(node)
      }
    }
  }

  val dpRev = new Array[Boolean](N+1)
  q.enqueue(N)
  while (!q.isEmpty) {
    val now = q.dequeue()
    if (!dpRev(now)) {
      dpRev(now) = true
      for ((node, _) <- graphRev(now)) {
        q.enqueue(node)
      }
    }
  }


  val dp = new Array[Boolean](N+1)
  for (i <- 1 to N)
    dp(i) = dpFor(i) && dpRev(i)

  var edges = List[Edge]()
  for (i <- 1 to N if dp(i)) {
    for ((node, cost) <- graph(i) if dp(node)) {
      edges = Edge(i, node, -(cost - P)) :: edges
    }
  }

  val bf = new BellmanFord(N+1, edges.length, edges.toArray)

  if (bf.findNegativeLoop)
    println(-1)
  else {
    bf.shortestPath(1)
    println(Math.max(0, -bf.d(N)))
  }
}

// O(|V|*|E|)
case class Edge(from: Int, to: Int, cost: Long)

// V: 頂点数, E: 辺数
// 0-based index
class BellmanFord(V: Int, E: Int, es: Array[Edge]) {

  val d = new Array[Long](V) // 最短距離

  private[this] val INF = Long.MaxValue

  // s番目の頂点から各頂点への最短距離を求める
  // 負のループがあると止まらない
  def shortestPath(s: Int): Unit = {
    for (i <- 0 until V)
      d(i) = INF

    d(s) = 0
    breakable {
      while (true) {
        var update = false
        for(i <- 0 until E) {
          val e = es(i)
          if (d(e.from) != INF && d(e.to) > d(e.from) + e.cost) {
            d(e.to) = d(e.from) + e.cost
            update = true
          }
        }

        if (!update)
          break
      }
    }
  }

  // true なら負の閉路が存在する
  def findNegativeLoop(): Boolean = {
    for (i <- 0 until V)
      d(i) = 0

    for (i <- 0 until V) {
      for (j <- 0 until E) {
        val e = es(j)
        if (d(e.to) > d(e.from) + e.cost) {
          d(e.to) = d(e.from) + e.cost

          // n 回目にも更新があるなら負の閉路が存在する
          if (i == V - 1)
            return true
        }
      }
    }

    false
  }

}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 34980
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

ll N, X;
ll ans = 0;
ll B[51];
ll P[51];
ll before;

int main(){
	
	cin>>N>>X;
	
	
	FOR( i, 1, N+1 ){
		B[i] = 2ll*(1ll<<(i-1))+(1ll<<i)-2;
		P[i] = 4ll*(1ll<<(i-1))-1;
	}
	
	before = N;
	
	while( X > 0 ){
		ll temp = before;
		while( temp ){
			ll sum = before-temp+B[temp]+P[temp];
			if( X >= sum ){
				before = temp;
				ans += P[temp];
				X -= sum;
				if( X > 0 ){
					ans++;
					X--;
				} 
				break;
			}
			temp--;
		}
		if( temp == 0 ) break;
	}
	
	X -= before;
	
	ans += max( 0ll, X );
	
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int n, r;
  cin >> n >> r;
  if (10 <= n) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

double Dist(double x1, double y1, double x2, double y2)
{
    return sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
}

long CGL_7_A()
{
    long iRcF = 0;
	double c1x = 0, c1y = 0, c1r = 0;
    cin >> c1x >> c1y >> c1r;
	double c2x = 0, c2y = 0, c2r = 0;
    cin >> c2x >> c2y >> c2r;
    double dTolCoinc = 0.000001;
    double dDist = Dist(c1x, c1y, c2x, c2y);
    if ( dDist - (c1r + c2r) > dTolCoinc ) {
        cout << 4 << endl;
    } else if ( fabs(dDist - (c1r + c2r)) <= dTolCoinc ) {
        cout << 3 << endl;
    } else if ( dDist - fabs(c1r - c2r) > dTolCoinc ) {
        cout << 2 << endl;
    } else if ( fabs(dDist - fabs(c1r - c2r)) <= dTolCoinc) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

#define AOJ_CGL_7_A

int main() {
#ifdef AOJ_CGL_1_A
    CGL_1_A();
#endif
#ifdef AOJ_CGL_1_B
    CGL_1_B();
#endif
#ifdef AOJ_CGL_4_A
    CGL_4_A();
#endif
#ifdef AOJ_CGL_7_A
    CGL_7_A();
#endif
    return 0;
}


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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    rep(i, ty - sy) cout << 'U';
    rep(i, tx - sx) cout << 'R';
    rep(i, ty - sy) cout << 'D';
    rep(i, tx - sx) cout << 'L';
    cout << 'L';
    rep(i, ty - sy + 1) cout << 'U';
    rep(i, tx - sx + 1) cout << 'R';
    cout << 'D';
    cout << 'R';
    rep(i, ty - sy + 1) cout << 'D';
    rep(i, tx - sx + 1) cout << 'L';
    cout << 'U';
    cout << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define f first
#define sc second
bool cmp(int a, int b) {
    return a < b;
}
void solve() {
    ll n;
    cin >> n;
    string s;
    while(n) {
        ll x = n % 26LL;
        if (x == 0) {
            s += 'z';
            n -= 26LL;
        }
        else {
            s += char('a' + x - 1);
        }
        n /= 26LL;
    }
    reverse(s.begin(), s.end());
    cout << s << "\n";
    return;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int t = 1;
    //cin >> t;
    while(t--)
    solve();
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    long long sum[n+1];
    sum[0] = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    long long ans = LLONG_MAX;
    for(int i=1;i<n;i++){
        long long tmp = abs(sum[n]-2*sum[i]);
        if(ans>tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ld l;
    cin>>l;
    ld a,b,c;
    a=ld(l/3),b=ld(l/3),c=ld(l/3);
    ld ans=a*b*c;
    cout<<fixed<<setprecision(10)<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
b = [0] * H
for i in range(H):
    b[i] = input()

c = [[0] * (W+2) for i in range(H+2)]
for i in range(H):
    for j in range(W):
        if b[i][j] == "#":
            c[i][j] += 1
            c[i+1][j] += 1
            c[i+2][j] += 1
            c[i][j+1] += 1
            # c[i+1][j+1] += 1
            c[i+2][j+1] += 1
            c[i][j+2] += 1
            c[i+1][j+2] += 1
            c[i+2][j+2] += 1
d = [""] * H
for i in range(H):
    for j in range(W):
        if b[i][j] == ".":
            d[i] += str(c[i+1][j+1])
        else: d[i] +="#"

for i in range(H):
        print(d[i])

Measured memory_bytes: 3064
package main

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

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	fmt.Printf("%d\n", A*B)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func getStdin() string {
	return readLine()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 1776
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll a, b, c; cin >> a >> b >> c;
  if(a == b && b != c) cout << "Yes\n";
  else if(b == c && c != a) cout << "Yes\n";
  else if(c == a && a != b) cout << "Yes\n";
  else cout << "No\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define fi first
#define se second
#define be begin()
#define en end()
#define reverse
const int mod=1000000007;
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
  return max(a,b)-min(a,b);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,s=100,sum=0;
  cin>>x;
  while(true){
    if(s>=x) break;
    sum++;
    s=s*(1.01);
  }
  cout<<sum<<"\n";
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i); 
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    long long sum=0;
    rep(i,n) sum +=a.at(i);
    if(a.at(m-1) * 4 * m >= sum){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3568
S = int(input())

x1 = 1000000000
if S % x1 == 0:
    y2 = S // x1
else:
    y2 = S // x1 + 1
    
x2 = 1
y1 = x1 * y2 - S
print(" ".join(map(str, [0, 0, x1, y1, x2, y2])))

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int d, n, s, t, sum;
int main() {
  
  while(cin>>d>>n, d) {sum=0;
    for(int i=0; i<n; i++) {
      cin >> s >> t;
      sum += t-s;
    }
    if(sum<d) cout << d-sum << endl;
    else cout << "OK" << endl;
  }
  
  return 0;
}

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

int main() {
  int n, m_w; cin >> n >> m_w;

  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++)
    cin >> w[i] >> v[i];

  vector<int64_t> max_val(m_w + 1, -1);
  max_val[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = m_w - w[i]; j >= 0 ; j--) {
      if (max_val[j] > - 1) {
        int new_w = j + w[i];
        int64_t new_val = max_val[j] + v[i];
        max_val[new_w] = max(max_val[new_w], new_val);
      }
    }
  }

  int64_t maxx = 0;
  for (int i = 0; i <= m_w; i++) {
    maxx = max(maxx, max_val[i]);
  }

  cout << maxx << "\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <queue>
#include <vector>
#include <array>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;

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

int main() {
	array<vector<int>, 26> d;
	string s, t;
	cin >> s >> t;
	int n = s.length();
	rep(i, n)d[s[i] - 'a'].push_back(i);
	for (auto& e : d)sort(e.begin(), e.end());
	ll r = 0;
	int c = 0;
	for (auto& e : t) {
		char u = e - 'a';
		if (d[u].empty()) {
			cout << -1 << endl;
			return 0;
		}
		auto i = lower_bound(d[u].begin(), d[u].end(), c);
		if (i == d[u].end()) {
			c = d[u][0] + 1;
			r += n;
		}
		else {
			c = *i + 1;
		}
	}
	r += c;
	cout << r << endl;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
  using namespace std;
  #define ll long long
  int main()
  {
      int n,m;
      cin>>n>>m;
      if(n==1)
      {
         n=14;
     }
     if(m==1)
     {
         m=14;
    }
     if(n==m)
     {
        cout<<"Draw";
    }
     else if(n<m)
     {
         cout<<"Bob";
     }
     else
     {
         cout<<"Alice";
     }
     return 0;
 }

Measured memory_bytes: 3584
N = int(input())
job = [[0]*2 for i in range(N)]
time = 0
for i in range(N):
    l = list(map(int, input().split()))
    job[i][0], job[i][1] = l[1], l[0]
job = sorted(job)
for i in range(N):
    time += job[i][1]
    if time > job[i][0]:
        print("No")
        break
    elif i == N-1:
        print("Yes")

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

public class Main {

	public static void main(String[] args)
	{
		FastReader in = new FastReader();
		int n = in.nextInt();
		int w = in.nextInt();
		int[][] wv = new int[n][2];
		for(int i = 0; i < n; i++)
		{
			wv[i][0] = in.nextInt();
			wv[i][1] = in.nextInt();
		}
		
		long[][] dp = new long[n+1][w+1];
		for(int i = 0; i < n+1; i++)
		{
			for(int j = 0; j < w+1; j++)
			{
				if(i == 0 || j == 0)
				{
					dp[i][j] = 0;
				}
				else if(wv[i-1][0] <= j)
				{
					dp[i][j] = Math.max(dp[i-1][j], wv[i-1][1] + dp[i-1][j-wv[i-1][0]]);
				}
				else
				{
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		System.out.println(dp[n][w]);
	}
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                }
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


Measured memory_bytes: 128340
#include <iostream>
using namespace std;
int main(void){
    int n; cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8){ ans++;}
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <complex>
using namespace std;

typedef long long ll;

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

bool isPrime(int x){
  if(x == 0 || x == 1) return false;

  for(int i = 2; i * i <= x; i++){
    if(x % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;

  while(cin >> n, n){
    for(int i = n; ; i--){
      if(isPrime(i) && isPrime(i - 2)){
        cout << i - 2 << " " << i << endl;
        break;
      }
    }
  }
}

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

int main(void) {
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);

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

  long long result = 0;
  for (int i = n - 1; i >= 0; i--) {
    int t = (result + a[i]) % b[i];
    result += (t == 0 ? 0 : b[i] - t);
  }

  cout << result << endl;
  return 0;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	vector<string> a(n), b(m);
	REPU(i, 0, n) cin >> a[i];
	REPU(i, 0, m) cin >> b[i];
	REPU(i, 0, n - m + 1) REPU(j, 0, n - m + 1) {
		bool good(true);
		REPU(l, 0, m) {
			if (b[l] != a[i + l].substr(j, m)) {
				good = false; break;
			}
		}
		if (good) {
			puts("Yes"); return 0;
		}
	}
	puts("No");

	return 0;
}


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

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

Measured memory_bytes: 256
#奇数だったら２が約数にない　その後もないので答えは０
#末尾５、０じゃなければ５が約数にない
#2を約数に持つことの方が圧倒的に多いので５を約数に持つときだけ数える、つまり末尾０の時

#2でわって
N=int(input())
count=0

for i in range(1,100000):
  if 5**i<=N//2:
    count+=1
  else:
    break
#print(count)

#//５**iすると


if N%2==1:
  print(0)
else:
  ans=0
  for i in range(1, count+1):
    ans+=N//((5**i)*2)
  print(ans)
  

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

// <set> ::= A | B | C | D | E
map<char, vector<int>> name2set;
// <op> ::= u | i | d | s
const string ops = "uids";

void unique(vector<int> &v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}

vector<int> set_oparate(vector<int> a, vector<int> b, char op) {
#define all(v) v.begin(), v.end()
    vector<int> ret(a.size() + b.size());
    vector<int>::iterator it;
    switch (op) {
    case 'u':
        it = set_union(all(a), all(b), ret.begin());
        break;
    case 'i':
        it = set_intersection(all(a), all(b), ret.begin());
        break;
    case 'd':
        it = set_difference(all(a), all(b), ret.begin());
        break;
    case 's':
        it = set_symmetric_difference(all(a), all(b), ret.begin());
        break;
    }
    ret.erase(it, ret.end());
    return ret;
#undef all
}

template<class T> struct Parser {
    typedef string::const_iterator State;

    T solve(const string &S) {
        State begin = S.begin();
        return expr(begin);
    }

    // <expr> ::= <term> <op> <term>
    // <op> ::= u | i | d | s
    T expr(State &begin) {
        T ret = term(begin);
        for (;;) {
            if (ops.find(*begin) != string::npos) {
                char op = *begin;
                begin++;
                ret = set_oparate(ret, term(begin), op);
            } else {
                break;
            }
        }
        return ret;
    }

    // <term> ::= c <factor> | <factor>
    T term(State &begin) {
        if (*begin == 'c') {
            begin++;
            return set_oparate(name2set['U'], factor(begin), 'd');
        } else {
            return factor(begin);
        }
    }

    // <factor> ::= ( <expr> ) | <set>
    T factor(State &begin) {
        if (*begin == '(') {
            begin++;    // skip '('
            T ret = expr(begin);
            begin++;    // skip ')'
            return ret;
        } else {
            return name2set[*begin++];
        }
    }
};

int main() {
    char name; int num;
    while (cin >> name >> num) {
        if (name == 'R') {
            unique(name2set['U']);
            for (auto &m : name2set) sort(m.second.begin(), m.second.end());
            string S; cin >> S;
            Parser<vector<int>> ps;
            vector<int> res = ps.solve(S);
            if (res.empty()) {
                cout << "NULL" << endl;
            } else {
                for (int i = 0; i < res.size(); i++) {
                    cout << res[i] << " \n"[i == res.size() - 1];
                }
            }
            name2set.clear();
        } else {
            for (int i = 0; i < num; i++) {
                int member; cin >> member;
                name2set[name].emplace_back(member);
                name2set['U'].emplace_back(member);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3192
import java.util.*;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d = sc.nextInt();

        int point[][] = new int[n][d];

        for (int i=0; i<n; i++){
            for(int j=0; j<d; j++){
                point[i][j] = sc.nextInt();
            }
        }

        int count = 0;

        for (int i=0; i<n; i++){
            for (int j=i+1; j<n; j++){
                double distance = 0;
                for (int k=0; k<d; k++){
                    distance += Math.pow((point[i][k]-point[j][k]), 2);
                }
                int a = (int)Math.sqrt(distance);
                if (a*a == distance){
                    count++;
                }
            }
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	string ans = s+t;
	for(int i = 0; i < n; i++){
		bool flag = true;
		for(int j = 0; j < n-i; j++){
			if(s[i+j] != t[j]) flag = false;
		}
		if(flag){
			ans = s;
			for(int j = n-i; j < n; j++){
				ans += t[j];
			}
			cout << ans.size() << endl; 
			return 0;
		}
	}
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        diff = A[i] + A[i+1] - x
        if A[i+1]>diff:
            A[i+1] -= diff
        else:
            A[i+1] = 0
        cnt += diff
print(cnt)

Measured memory_bytes: 14540
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string.h>
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    int h, w, k;
    cin >> h >> w >> k;

    int ans = 0;
    bool cIsBlack[h][w];
    // vector<vector<bool>> cIsBlack(h, vector<bool>(w, false));

    rep(i, h) {
        string s;
        cin >> s;

        rep(j, w) {
            if (s[j] == '#') {
                cIsBlack[i][j] = true;
            } else {
                cIsBlack[i][j] = false;
            }
        }
    }

    // rep(i, h) {
    //     rep(j, w) {
    //         cout << cIsBlack[i][j] << " ";
    //     }
    //     cout << endl;
    // }



    for (int iBit = 0; iBit < (1 << h); ++iBit) {   // 0 to 2^h - 1

        for (int jBit = 0; jBit < (1 << w); ++jBit) {   // 0 to 2^w -1

            bool tmpCIsBlack[h][w];
            memcpy(tmpCIsBlack, cIsBlack, sizeof(cIsBlack));
            // vector<vector<bool>> tmpCIsBlack(h, vector<bool>(w, false));
            // tmpCIsBlack = cIsBlack;

            rep(i, h) {
                if (iBit & (1 << i)) {
                    // i行をfalseに塗りつぶす
                    rep(j, w) {
                        tmpCIsBlack[i][j] = false;
                    }
                }
            }


            rep(j, w) {
                if (jBit & (1 << j)) {
                    // j列をfalseに塗りつぶす
                    rep(i, h) {
                        tmpCIsBlack[i][j] = false;
                    }
                }
            }


            // judge
            int count = 0;
            rep(i, h) {
                rep(j, w) {
                    if (tmpCIsBlack[i][j] == true){
                        count++;
                    }
                }
            }
            // cout << "count: " << count << endl;
            if (count == k) {
                ans++;
            }


        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef int64_t ll;

int main(){
  string s;
  cin>>s;
  vector<int> sa=atcoder::suffix_array(s);
  vector<int> lcp=atcoder::lcp_array(s,sa);
  ll ans=((ll)s.size()+1)*(ll)s.size()/2;
  for(int x : lcp)ans-=x;
  cout<<ans<<endl;
}


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

int main(){
  int a,b,c;
   int A;
cin>>A;
 a=A/100;
 b=A/10-a*10;
 c=A-a*100-b*10;
  
  if( a == 0 && b == 0 && c==0 ){
  cout << 0 << endl;
  }
  if ((a==1 && b==0 && c==0)||(a==0 && b==1 && c==0)||(a==0 && b==0 && c==1))
  {
  cout << 1 << endl;
  }  
  if ((a==1 && b==1 && c==0)||(a==0 && b==1 && c==1)||(a==1 && b==0 && c==1))
  {
  cout << 2 << endl;
  }
  if (a == 1 && b == 1 && c==1)
  {
    cout << 3 << endl;
   }
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int &a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,t,a; cin >> n >> t >> a;
    int ans = 0 , cc = INF;
    FOR(i,1,n+1){
        int h; cin >> h;
        int d = (t*1000-h*6)-a*1000;
        if(cc>abs(d)){cc = abs(d); ans = i;}
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
def moji(s):
    tmp = []
    for i in range(10):
        tmp.append(s[i])
    tmp.sort()
    new_s = ''
    for i in range(10):
        new_s += tmp[i]
    return new_s

N = int(input())
dic = {}
ans = 0
for i in range(N):
    tmp = moji(input())
    if tmp in dic:
        dic[tmp] += 1
    else:
        dic[tmp] = 1
for i in dic.values():
    if i == 1:
        continue
    ans += C(i,2)
print(ans)


Measured memory_bytes: 17932
#include<stdio.h>
int main(){
  int n,a,b;
  int d[n];
  int c=0,e=0;
  scanf("%d \n",&n);
  for(a=0;a<n;a++)
  {
    scanf("%d",&d[a]);
  }
  for(b=0;b<n-1;b++){
    c=b+1;
    while(c<n){
      e+=d[b]*d[c];
      c=c+1;
    }
  }
  printf("%d",e);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String s = sc.next();

   int sl =s.length()-2;
   
   String ans = s.substring(0,1)+sl+s.substring(sl+1,sl+2);
 
   System.out.println(ans);
 }
}

Measured memory_bytes: 23764
from bisect import bisect_right

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()

X = [x for x, _ in XH]

ans = 0
ims = [0] * (N + 1)
cnt = 0

for now, (x, h) in enumerate(XH):
    cnt += ims[now]
    if cnt * A >= h:
        continue
    ness = -(-(h - cnt * A) // A)
    cnt += ness

    i = bisect_right(X, x + D * 2)
    ims[now] += ness
    ims[i] -= ness
    ans += ness

print(ans)

Measured memory_bytes: 91352
#include <stdio.h>
#include <math.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  char s[n+1];
  scanf("%s", s);
  long mod = pow(10,9)+7;
  long alp[26];
  for (int i = 0; i < 26; i++) {
    alp[i] = 0;
  }
  for (long i = 0; i < n; i++) {
    alp[s[i]-'a']++;
  }
  long answer = 1;
  for (int i = 0; i < 26; i++) {
    answer *= alp[i]+1;
    answer %= mod;
  }
  answer--;
  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	int n, k, ans = 1;
	scanf("%d %d", &n, &k);

	for(int i = 0; i < n; i++) {
		if(ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 100005
using namespace std;
struct edge{
	int t,next;
}e[N*2];int ecnt,head[N];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;
}
int n,k,val[N];
priority_queue<pair<int,int> > pq;//Êµ¼ÊÉÏÊ¹ÓÃ¶ÓÁÐ¾Í¹»ÁË 
int main(){
	memset(val,0x3f,sizeof(val));
	scanf("%d",&n);
	for(int i=1,f,t;i<n;i++)
		scanf("%d%d",&f,&t),addedge(f,t);
	scanf("%d",&k);
	for(int i=1,v,p;i<=k;i++){
		scanf("%d%d",&v,&p);
		val[v]=p;
		pq.push(make_pair(p,v));
	}
	bool flag=true;
	while(!pq.empty()){
		int u=pq.top().second;pq.pop();
		for(int i=head[u];i;i=e[i].next){
			if(val[e[i].t]==0x3f3f3f3f){
				val[e[i].t]=val[u]-1;
				pq.push(make_pair(val[u]-1,e[i].t));
			}else if(abs(val[e[i].t]-val[u])!=1) flag=false;
		}
	}
	if(!flag) puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=n;i++) printf("%d\n",val[i]);
	}
	return 0;
} 

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define ba 47
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 +c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,H,D;
int fac[1000005],dp[1000006],sum[1000006];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
        if(c & 1) res = mul(res,t);
        t = mul(t,t);
        c >>= 1;
    }
    return res;
}
void Solve() {
    read(N);read(H);read(D);
    fac[0] = 1;
    int c = 0;
    for(int i = 1 ; i <= N ; ++i) {
        fac[i] = mul(fac[i - 1],i);
        update(c,fac[i]);
    }
    dp[0] = c;sum[0] = 1;
    for(int i = 1 ; i <= H ; ++i) {
        int t = sum[i - 1];
        if(i - D > 0) update(t,MOD - sum[i - D - 1]);
        dp[i] = mul(t,c);
        sum[i] = inc(sum[i - 1],dp[i]);
    }
    int ans = mul(dp[H],fac[N]);ans = mul(ans,fpow(c,MOD - 2));
    out(ans);enter;
}
int main(){
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	double A[N];double sum=0;
	rep(i,0,N){
		cin>>A[i];sum+=1/A[i];
	}cout<<setprecision(15)<<1/sum<<endl;
}

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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	int h, w;
	cin>>h>>w;
	vector<string> v(h);
	vi cnt(26, 0); int re1=0, re2=0, re4=0;
	F(h) {
		cin>>v[i];
		FF(w) cnt[v[i][j]-'a']++;
	}
	if(!(h&1) && !(w&1)) {
		re4 = (h*w-re2*2-re1)>>2;
	}
	else if(h&1 && w&1) {
		re1 = 1;
		re2 = h/2+w/2;
		re4 = (h*w-re2*2-re1)>>2;
	}
	else if(h&1) {
		re2 = w/2;
		re4 = (h*w-re2*2-re1)>>2;
	}
	else if(w&1) {
		re2 = h/2;
		re4 = (h*w-re2*2-re1)>>2;
	}
	sortv(cnt);
	int i=0; bool ans = true;
	/*while(re1>0) {
		while(cnt[i]==0) i++;
		cnt[i]-=re1;
	}
	while(re2>0) {
		while(cnt[i]==0) i++;
		if(cnt[i]<2) {ans=false; break;}
		cnt[i]-=2;
		re2--;
	}
	while(re4>0) {
		while(cnt[i]==0) i++;
		if(cnt[i]<4) {ans=false; break;}
		cnt[i]-=4;
		re4--;
	}*/
	while(re1>0 || re2>0 || re4>0) {
		while(cnt[i]==0) i++;
		if(re4>0 && cnt[i]>3) {
			cnt[i]-=4, re4--;
		}
		else if(re2>0 && cnt[i]>1) {
			cnt[i]-=2, re2--;
		}
		else if(re1>0 && cnt[i]) {
			cnt[i]-=1, re1--;
		}
		else {ans=false; break;}
	}
	cout<<(ans ? "Yes" : "No")<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;

int main() {
	int n, k; cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}

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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    string s; 
    read(s) ;
    if(s[sz(s)-1]!='s')
      s+='s';
    else
      {
        s.pb('e');
        s.pb('s');
      }

    cout<<s;
}

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
   // cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
	while(1){
		int x,h;
		cin>>x>>h;
		if(x==0&&h==0)break;
		printf("%f\n",x*x+2*x*sqrt(h*h+(double)x*x/4));
	}
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin >> s
#define pr(r) cout << r << endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout << a[j] << " "
#define wh(t) ll t; cin >> t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define arr(a,n) vl a(n, 0); fab(i, 0, n) cin >> a[i]
#define prs(u) cout << u << " "
#define fab(i,a,b) for(ll i = a; i < b; i++)
#define fba(i,b,a) for(ll i = b; i >= a; i--)
#define fa(i, x) for(auto i: x)
#define mem(s, j) memset(s, j, sizeof(s))
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pl>
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define vvl vector<vl>
#define vvpl vector<vpl>
#define mxe(x) *max_element(x)
#define mne(x) *min_element(x)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N = (ll)3e5;
const ll inf = (ll)1e18 + 7;
const ll mod = (ll)1e9 + 7;
const ll MX = (ll)1e9 + 7;
const ll MAX = (ll)1e12 + 7;
 
bool rsort1(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll, ll> &a,const pair<ll, ll> &b) { return (a.second > b.second);}
bool sort2(const pair<ll, ll> &a,const pair<ll, ll> &b){ return (a.second < b.second);}

vector<char> dir = {'L', 'R', 'U', 'D'};
vl dx = {-1, 1, 0, 0};
vl dy = {0, 0, -1, 1};

void add(ll &x, ll y){
    x = ((x % mod) + (y % mod)) % mod;
}

void mul(ll &x, ll y){
    x = ((x % mod) * (y % mod)) % mod;
}

ll sm(vl a) {
    ll sum = 0;
    for(auto i: a)
        sum += i;
    return sum;
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}
 
bool isPrime(ll p)
{
    for(ll i = 2;i * i <= p; i++)
        if(p % i == 0)
            rr false;
    rr true;
}

ll isPal(string s) {
    string k = s; 
    reverse(all(k));
    if(s == k)
        return 1;
    return 0;
}

int main()
{
	sup;
    
    string s;
    cin >> s;
    if(sz(s) % 2 == 1) {
        if(isPal(s) && isPal(s.substr(0, sz(s) / 2)) && isPal(s.substr((sz(s) + 3) / 2 - 1)))
            pr("Yes");
        else 
            pr("No");
    }
    else {
        pr("No");
    }
    return 0;
}

Measured memory_bytes: 256