akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define HMAX 50
#define WMAX 50
#define INF 99999999

int H, W;
char s[HMAX][WMAX];

int whitecount;
int minDist;
int dist[HMAX][WMAX];

void SearchRoot() {


	vector< pair<int, int> > openList;
	int px, py;
	int ex, ey;

	for (int i = 0; i < HMAX; i++) {
		for (int j = 0; j < WMAX; j++) {
			dist[i][j] = INF;
		}
	}
	px = W - 1;
	py = H - 1;
	ex = 0;
	ey = 0;

	openList.push_back(make_pair(0, px * 100 + py));
	dist[py][px] = 0;
	while (!openList.empty()) {
		sort(openList.begin(), openList.end());
		int x = openList[0].second / 100;
		int y = openList[0].second % 100;
		int cost = openList[0].first;
		openList.erase(openList.begin());

		if (y > 0) {
			if (s[y - 1][x] == '.' && cost + 1 < dist[y - 1][x]) {
				dist[y - 1][x] = cost + 1;
				openList.push_back(make_pair(cost + 1, x * 100 + (y - 1)));
			}
		}
		if (y < H - 1) {
			if (s[y + 1][x] == '.' && cost + 1 < dist[y + 1][x]) {
				dist[y + 1][x] = cost + 1;
				openList.push_back(make_pair(cost + 1, x * 100 + (y + 1)));
			}
		}
		if (x > 0) {
			if (s[y][x - 1] == '.' && cost + 1 < dist[y][x - 1]) {
				dist[y][x - 1] = cost + 1;
				openList.push_back(make_pair(cost + 1, (x - 1) * 100 + y));
			}
		}
		if (x < W - 1) {
			if (s[y][x + 1] == '.' && cost + 1 < dist[y][x + 1]) {
				dist[y][x + 1] = cost + 1;
				openList.push_back(make_pair(cost + 1, (x + 1) * 100 + y));
			}
		}
	}
}


int main() {
	minDist = HMAX * WMAX + 1;
	whitecount = 0;

	cin >> H >> W;
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> s[i][j];
			if (s[i][j] == '.') {
				whitecount++;
			}
		}
	}

	SearchRoot();
	minDist = dist[0][0];

	if (minDist == INF) {
		cout << -1 << endl;
	}
	else {
		cout << whitecount - minDist -1<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int d,e;
vector<vector<int>> g(100005);
vector<bool> done(100005,0);
vector<int> par(100005,-1);
void dfs(int s){
    done[s] = true;
    for(int v:g[s]){
        if (done[v]) continue;
        par[v] = s;
        dfs(v);
    }
}
ll c = 0;
void dfs2(int s){
    done[s] = true;
    for(int v:g[s]){
        if (done[v] || (s == d && v == e)) continue;
        //PRINT(v);
        c++;
        dfs2(v);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n;
    rep(i,n-1){
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    vector<ll> p;
    p.push_back(n-1);
    a = n-1;
    while(par[a] != 0){
        a = par[a];
        p.push_back(a);
    }
    p.push_back(0);
    reverse(all(p));
    //array_output(all(p));
    b = p.size();
    if (b%2){
        d = p[b/2];
        e = p[b/2+1];
    }
    else{
        d = p[b/2-1];
        e = p[b/2];
    }
    //cout << d << " " << e << endl;
    done.assign(n,0);
    dfs2(0);
    if (c != 0 && c > n-c-2) PRINT("Fennec");
    else PRINT("Snuke");
}




Measured memory_bytes: 12024
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 9;
using Graph = vector<vector<int>>;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

struct C {
    P p;
    double r;
    C(){}
    C(P _p, double _r) : p(_p), r(_r) {}
    C(double _x, double _y, double _r) : p(_x, _y), r(_r) {}
    void print() {
        cerr << p.real() << " " << p.imag() << " " << r << endl;
    }
};

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

C readC() {
    double x, y, r;
    cin >> x >> y >> r;
    return C(x, y, r);
}

int relationCC(C c1, C c2) {
    double d = abs(c1.p - c2.p);
    if (sgn(d, c1.r + c2.r) == 1)       return 4; // distant
    if (sgn(d, c1.r + c2.r) == 0)       return 3; // touch outside
    if (sgn(d, abs(c1.r - c2.r)) == -1) return 0; // c1 in c2
    if (sgn(d, abs(c1.r - c2.r)) == 0)  return 1; // c1 touches in c2
    return 2; // two crosspoints
}

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

    C c1 = readC();
    C c2 = readC();
    cout << relationCC(c1, c2) << endl;
}

Measured memory_bytes: 3284
#include <iostream>
#include <cmath>
using namespace std;
int height(int x, int y, int c_x, int c_y, int h){
    return max(0,h-abs(x-c_x)-abs(y-c_y));
}
int main() {
    int n=0;
    cin>> n;
    int d[1000];
    for (int i=0;i<3*n;i++){
        cin >> d[i];
    }
    for (int c_x = 0; c_x <= 100; c_x++) {
        for (int c_y = 0; c_y <= 100; c_y++) {
            int a=1;
            int k=0;
            for (int i=0;i<n;i++){
                if(d[3*i+2]>0){
                    k=i;
                    break;
                }
            }
            int h = d[3*k+2] + abs(d[3*k] - c_x) + abs(d[3*k+1] - c_y);
            for (int i = 0; i < n; i++) {
                if(d[3*i+2]!=height(d[3*i],d[3*i+1],c_x,c_y,h)){
                    a=0;
                    break;
                }
            }
            if(a==1){
                cout<<c_x<<" "<<c_y<<" "<<h;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

const int64_t MOD = 1000000007;

int64_t N;
std::vector<int64_t> A;

void solve()
{
    std::cin >> N;
    A.resize(N);
    for (auto& v : A) std::cin >> v;
    std::sort(A.begin(), A.end());

    bool ok = true;
    if (N % 2 == 1)
    {
        if (A[0] != 0) ok = false;
        for (int64_t i = 2; i < N; i += 2)
        {
            if (A[i - 1] != i) ok = false;
            if (A[i] != i) ok = false;
        }
    }
    else
    {
        for (int64_t i = 1; i < N; i += 2)
        {
            if (A[i - 1] != i) ok = false;
            if (A[i] != i) ok = false;
        }
    }

    int64_t ans = 1;
    for (int64_t i = 0; i < N / 2; i++)
    {
        ans = ans * 2 % MOD;
    }
    ans = ok ? ans : 0;
    std::cout << ans << std::endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int x = 0;
  int answer = 0;
  for (char c : S) {
    if (c == 'I') {
      x++;
      answer = max(x, answer);
    } else {
      x--;
    }
  }
  cout << answer << "\n";

  return 0;
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((a (read))
         (b (read))
         (c (read)))
    (println (max 0 (- c (- a b))))))

#-swank (main)


;; For Test
#+swank
(defun io-equal (in-string out-string &optional (func #'main))
  "Passes IN-STRING to *STANDARD-INPUT*, executes FUNC, and returns true if the
string output to *STANDARD-OUTPUT* is equal to OUT-STRING."
  (labels ((ensure-last-lf (s)
             (if (eql (uiop:last-char s) #\Linefeed)
                 s
                 (uiop:strcat s uiop:+lf+))))
    (equal (ensure-last-lf out-string)
           (with-output-to-string (out)
             (let ((*standard-output* out))
               (with-input-from-string (*standard-input* (ensure-last-lf in-string))
                 (funcall func)))))))

#+swank
(defun get-clipbrd ()
  (with-output-to-string (out)
    (run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))

#+swank (defparameter *this-pathname* (uiop:current-lisp-file-pathname))
#+swank (defparameter *dat-pathname* (uiop:merge-pathnames* "test.dat" *this-pathname*))

#+swank
(defun run (&optional thing (out *standard-output*))
  (let ((*standard-output* out))
    (etypecase thing
      (null ; Runs #'MAIN with the string on clipboard
       (with-input-from-string (*standard-input* (delete #\Return (get-clipbrd)))
         (main)))
      (string
       (with-input-from-string (*standard-input* (delete #\Return thing))
         (main)))
      (symbol (5am:run! thing))
      (pathname ; Runs #'MAIN with the string in a text file
       (with-open-file (*standard-input* thing)
         (main))))))

#+swank
(defun gen-dat ()
  (uiop:with-output-file (out *dat-pathname* :if-exists :supersede)
    (format out "")))

#+swank
(defun bench (&optional (out (make-broadcast-stream)))
  (time (run *dat-pathname* out)))


Measured memory_bytes: 15204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int[] array = new int[5];
		for (int i = 0; i < 5; i++) {
			array[i] = sc.nextInt();
			if(array[i]==0) {
				System.out.println(i+1);
			}

		}
		sc.close();


	}
}


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

vector<vector<int> > edges;
vector<int> indeg;
vector<int> dist;
vector<int> vis;
void dfs(int s){
	vis[s] = 1;
	for(int i : edges[s]){
		dist[i] = max(dist[i], dist[s] + 1);
		indeg[i]--;
		if(indeg[i]==0) dfs(i);
	}
	
}

int main(){
int n,m;cin>>n>>m;
	edges.clear();
	indeg.clear();
	dist.clear();
	dist.resize(n+1,0);
	edges.resize(n+1);
	indeg.resize(n+1,0);
	vis.clear();
	vis.resize(n+1,-1);
	int aa,bb;
	for(int i=0;i<m;i++){
		cin>>aa>>bb;
		edges[aa].push_back(bb);
		indeg[bb]++;
	}
	for(int i=1;i<=n;i++){
		if(vis[i]==-1 && indeg[i]==0) {
			dfs(i);
			//vis[i] = 1;
		}
	}
	int ans =0;
	for(int i=1;i<=n;i++) ans = max(ans,dist[i]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int N = 0;
		int K = 0;
		String S;
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		K = Integer.parseInt(sc.next());
		S = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(S);
		char s;
		String lower;
		s = sb.charAt(K-1);
		lower=String.valueOf(s);
		sb.setCharAt(K-1, (lower.toLowerCase()).toCharArray()[0]);
		System.out.println(sb.toString());

	}

}

Measured memory_bytes: 21844
# B
T = str(input())
try:
    for i in range(T.count("?")):
        index = T.index("?")
        if T[index - 1] == "P":
            T = T.replace("?","D",1)
        elif T[index + 1] == "D":
            T = T.replace("?","P",1)
        elif T[index + 1] == "?":
            T = T.replace("?","P",1)
        else:
            T = T.replace("?","D",1)
    print(T)
except:
    print(T.replace("?","D"))

Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void) {
  int n, k, x, y;
  cin >> n >> k >> x >> y;

  if (n > k)
  cout << k * x + y * (n - k) << endl;
  else
  cout << n * x << endl;
  
}

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

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

    vector<int> count(26);
    for (auto c : s)
    {
        count.at(c - 'a')++;
    }
    string sp = "";
    for (char c = 'a'; c <= 'z'; c++)
    {
        for (int i = 0; i < count.at(c - 'a'); i++)
        {
            sp += c;
        }
    }

    count = vector<int>(26);
    for (auto c : t)
    {
        count.at(c - 'a')++;
    }
    string tp = "";
    for (char c = 'z'; c >= 'a'; c--)
    {
        for (int i = 0; i < count.at(c - 'a'); i++)
        {
            tp += c;
        }
    }
    cout << ((sp < tp) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
def Myne(N,K):
    Input1 = [str(input()) for i in range(1)]
    N,K = list(map(int,Input1[0].split()))
    ANS = []
    if N == K:
        ANS.append(1)
        print(1)
        for i in range(K-1):
            ANS.append(0)
            print(0)
    else:
        M = max(K,N-K)
        Mem = [[1 for j in range(i+1)] for i in range(M)]
        for j in range(M):
            I = len(Mem[j])
            for i in range(I):
                if j>0 and i!=0 and i!= I-1:
                    Mem[j][i] = int((Mem[j-1][i-1]+Mem[j-1][i])%(10**9+7))

        i = 0
        ANS.append(N-K+1)
        print(N-K+1)
        for i in range(1,K):
            if N-K-1 >= i+1:
                ans = Mem[K-1][i]*(Mem[N-K-1][i-1]+2*Mem[N-K-1][i]+Mem[N-K-1][i+1])
                ans = int(ans % (10**9+7))
                ANS.append(ans)
                print(ans)                
            elif N-K-1 >= i:
                ans = Mem[K-1][i]*(Mem[N-K-1][i-1]+2*Mem[N-K-1][i])
                ans = int(ans % (10**9+7))
                ANS.append(ans)
                print(ans)
            elif N-K-1 == i-1:
                ans = Mem[K-1][i]*Mem[N-K-1][i-1]
                ans = int(ans % (10**9+7))
                ANS.append(ans)
                print(ans)
            else:
                ANS.append(0)
                print(0)
    return ANS

if __name__ == '__main__':
    Myne(1,1)


Measured memory_bytes: 83024
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] line1 = br.readLine().split(" ");
    int n = Integer.parseInt(line1[0]);
    int m = Integer.parseInt(line1[1]);
    
    boolean[] red = new boolean[n];
    int[] num = new int[n];
    
    red[0] = true;
    
    for (int i=0; i<n; i++){
      num[i] = 1;
    }
    
    String[] data;
    int x;
    int y;
    
    for (int i=0; i<m; i++){
      data = br.readLine().split(" ");
      x = Integer.parseInt(data[0])-1;
      y = Integer.parseInt(data[1])-1;
      
      if (red[x]){
        red[y] = true;
      }
      num[x]--;
      num[y]++;
      if (num[x] == 0){
        red[x] = false;
      }
    }
    int result = 0;
    for (boolean b : red){
      if (b) result++;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 46272
s = input()

flag = 1

for i in range(len(s)):
  if i % 2 == 1:
    if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
      flag = 0
      break
  elif i % 2 == 0:
    if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
      flag = 0
      break
    
if flag == 1:
  print('Yes')
if flag == 0:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int N;
vector<string> S,T;

int main(void){
    GI(N);
    REP(i,N){
        string s;
        cin>>s;
        S.PB(s);
        T.PB(s);
    }
    int ans=0;
    REP(i,N){
        REP(j,N){
            REP(k,N){
                T[j][k] = S[j][(k+i)%N];
            }
        }
        bool flag = true;
        REP(j,N){
            REP(k,N){
                if(T[j][k] != T[k][j])
                    flag = false;
            }
        }
        if(flag)
            ans+=N;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H1 = sc.nextInt();
		int M1 = sc.nextInt();
		int H2 = sc.nextInt();
		int M2 = sc.nextInt();
		int K = sc.nextInt();
		System.out.println((H2*60+M2) - K - (H1*60+M1));
		
	}

}

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

using namespace std;

void divide2(long long h, long long w, long long* a, long long* b) {
    if (h % 2 == 0 || w % 2 == 0) {
        *a = *b = h * w / 2;
    } else if (h < w) {
        *a = (w / 2) * h;
        *b = (w / 2 + 1) * h;
    } else {
        *a = (h / 2) * w;
        *b = (h / 2 + 1) * w;
    }
}

long long range(long long a, long long b, long long c) {
    return max(max(a, b), c) - min(min(a, b), c);
}

long long check(long long h, long long w) {
    long long a, b;
    divide2(h, w - w / 3, &a, &b);
    long long hoge = range(a, b, h * (w / 3));
    divide2(h, w - w / 3 - 1, &a, &b);
    long long fuga = range(a, b, h * (w / 3 + 1));
    return min(hoge, fuga);
}

int main() {
    long long h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min(check(h, w), check(w, h)) << endl;
}


Measured memory_bytes: 256
import math

while(1):
    try:
        thv = float(raw_input())
    except:
        break
    for i in range(1, 1000):
        y = 5 * (i-1)
        t = math.sqrt(y/4.9)
        v = 9.8 * t
        if v >= thv:
            print i
            break
            

Measured memory_bytes: 6348
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class NoChange {
public:
        void solve(std::istream &in, std::ostream &out) {
                long long n;
                in >> n;
                long long arr[n];
                long long dp[n];
                for (int i = 0; i < n; i++) {
                        in >> arr[i];
                        if (!i)
                                dp[i] = 0;
                        else if (i == 1)
                                dp[i] = abs(arr[i] - arr[i - 1]);
                        else
                                dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
                }
                out << dp[n - 1] << "\n";
        }
};

int main() {
        NoChange solver;
        std::ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        std::istream &in(std::cin);
        std::ostream &out(std::cout);
        int t = 1;
        for (int i = 0; i < t; ++i) {
                solver.solve(in, out);
        }
        return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 105

ll p[MAX], m[MAX][MAX];

int main(){
    int n; cin >> n;
    for(int i = 0; i <= n; i++){
        int a,b; cin >> a >> b;
        if(i == 0){
            p[i] = a; i++; p[i] = b;
        }else{
            p[i] = b;
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i == j) m[i][j] = 0;
            else m[i][j] = INT_MAX;
        }
    }

    for(int len = 2; len <= n; len++){ //計算する行列の個数
        for(int i = 1; i <= n-len+1; i++){ //左端
            int j = i + len -1; //右端
            for(int k = i; k < j; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
                
            }
        }
    }

    // for(int i = 1; i <= n; i++){
    //     for(int j = 1; j <= n; j++){
    //         cout << m[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    cout << m[1][n] << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
   
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s,t;
  cin>>s>>t;
  cout<<t<<s<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  int A,B;
  string S;
  cin >> A >> B;
  int C = A*1.25;
  int D = B*0.8;
  // cout << C << endl;
  // cout << D << endl;
  if(C==B && D==A){
    cout << max((int)(A/0.08),(int)(B/0.1)) << endl;
    return 0;
  }
  if(C==B){
    cout << (round)(A/0.08) << endl;
    return 0;
  }
  if(D==A){
    cout << (int)(B/0.1) << endl;
    return 0;
  }
  cout << "-1" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 225;

int n, m;
char s[N][N];
int f[N][N][N], g[N][N][N];

int main() {
	scanf("%d %d", &n, &m);
	fo(i, 1, n) scanf("%s", s[i] + 1);
	fd(k, m, 1) {
		fo(i, 1, n) {
			int ky = 1;
			fo(j, i, n) {
				if(j > i && s[j][k] != s[j - 1][k]) ky = 0;
				if(!ky) f[i][j][k] = 0; else {
					f[i][j][k] = k;
					if(k < m && s[i][k] == s[i][k + 1]) {
						f[i][j][k] = max(f[i][j][k], f[i][j][k + 1]);
					}
				}
			}
		}
	}
	fo(ans, 0, 16) {
		if(f[1][n][1] == m) {
			pp("%d\n", ans);
			return 0;
		}
		fo(i, 1, n) fo(j, i, n) fo(k, 1, m)
			g[i][j][k] = f[i][j][k];
		fo(i, 1, n) fo(j, i, n) fo(k, 1, m) {
			f[i][j][k] = max(f[i][j][k], g[i][j][g[i][j][k] + 1]);
			int as = i - 1;
			for(int l = i, r = j - 1; l <= r; ) {
				int m = l + r >> 1;
				if(g[i][m][k] >= g[m + 1][j][k])
					as = m, l = m + 1; else r = m - 1;
			}
			f[i][j][k] = max(f[i][j][k], min(g[i][as][k], g[as + 1][j][k])),
			f[i][j][k] = max(f[i][j][k], min(g[i][as + 1][k], g[as + 2][j][k]));
		}
	}
}

Measured memory_bytes: 75520
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N;
long long C[55];
string S[55];
long long dp[55][25][2];

bool ispal(string V) {
	for (int i = 0; i < V.size(); i++) {
		if (V[i] != V[V.size() - 1 - i]) return false;
	}
	return true;
}

int main() {
	// 入力
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> S[i] >> C[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= S[i].size(); j++) { dp[i][j][0] = (1LL << 60); dp[i][j][1] = (1LL << 60); }
	}

	// 前処理
	priority_queue<tuple<long long, int, int, int>, vector<tuple<long long, int, int, int>>, greater<tuple<long long, int, int, int>>> Q;
	long long Answer = (1LL << 60);
	for (int i = 1; i <= N; i++) {
		dp[i][S[i].size()][0] = C[i]; Q.push(make_tuple(dp[i][S[i].size()][0], i, S[i].size(), 0));
		dp[i][S[i].size()][1] = C[i]; Q.push(make_tuple(dp[i][S[i].size()][1], i, S[i].size(), 1));
		if (ispal(S[i]) == true) Answer = min(Answer, C[i]);
	}

	// DP の計算
	while (!Q.empty()) {
		long long cost = get<0>(Q.top());
		int a1 = get<1>(Q.top()), a2 = get<2>(Q.top()), a3 = get<3>(Q.top());
		Q.pop();

		// 左端
		if (a3 == 0) {
			string offset = S[a1].substr(S[a1].size() - a2, a2);
			for (int i = 1; i <= N; i++) {
				if (ispal(offset + S[i]) == true) Answer = min(Answer, cost + C[i]);
				if (offset.size() >= S[i].size()) {
					string v1 = offset.substr(0, S[i].size());
					string v2 = S[i]; reverse(v2.begin(), v2.end());
					if (dp[a1][a2 - S[i].size()][0] > cost + C[i] && v1 == v2) {
						dp[a1][a2 - S[i].size()][0] = cost + C[i];
						Q.push(make_tuple(dp[a1][a2 - S[i].size()][0], a1, a2 - S[i].size(), 0));
					}
				}
				else {
					string v1 = offset;
					string v2 = S[i].substr(S[i].size() - offset.size(), offset.size()); reverse(v2.begin(), v2.end());
					if (dp[i][S[i].size() - a2][1] > cost + C[i] && v1 == v2) {
						dp[i][S[i].size() - a2][1] = cost + C[i];
						Q.push(make_tuple(dp[i][S[i].size() - a2][1], i, S[i].size() - a2, 1));
					}
				}
			}
		}

		// 右端
		if (a3 == 1) {
			string offset = S[a1].substr(0, a2);
			for (int i = 1; i <= N; i++) {
				if (ispal(S[i] + offset) == true) Answer = min(Answer, cost + C[i]);
				if (offset.size() >= S[i].size()) {
					string v1 = offset.substr(offset.size() - S[i].size(), S[i].size());
					string v2 = S[i]; reverse(v2.begin(), v2.end());
					if (dp[a1][a2 - S[i].size()][1] > cost + C[i] && v1 == v2) {
						dp[a1][a2 - S[i].size()][1] = cost + C[i];
						Q.push(make_tuple(dp[a1][a2 - S[i].size()][1], a1, a2 - S[i].size(), 1));
					}
				}
				else {
					string v1 = offset;
					string v2 = S[i].substr(0, offset.size()); reverse(v2.begin(), v2.end());
					if (dp[i][S[i].size() - a2][0] > cost + C[i] && v1 == v2) {
						dp[i][S[i].size() - a2][0] = cost + C[i];
						Q.push(make_tuple(dp[i][S[i].size() - a2][0], i, S[i].size() - a2, 0));
					}
				}
			}
		}
	}

	// 出力
	if (Answer == (1LL << 60)) cout << "-1" << endl;
	else cout << Answer << endl;
	return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, d1, d2;
  Solver(LL n) : n(n){};
  using Graph = vector<vector<vector<pair<int, int>>>>;
  Graph makeGraph(int d) {
    Graph ret(2 * n, vector<vector<pair<int, int>>>(2 * n));
    for (int a = -2 * n; a < 2 * n; ++a) {
      for (int b = -2 * n; b < 2 * n; ++b) {
        if (a * a + b * b == d) {
          for (int i = 0; i < 2 * n; ++i) {
            for (int j = 0; j < 2 * n; ++j) {
              int nx = i + a, ny = j + b;
              if (0 <= nx and nx < 2 * n and 0 <= ny and ny < 2 * n) {
                ret[i][j].emplace_back(nx, ny);
              }
            }
          }
        }
      }
    }
    return ret;
  }
  vector<vector<int>> divide(const Graph& g) {
    vector<vector<int>> ret(2 * n, vector<int>(2 * n, -1));
    for (int i = 0; i < 2 * n; ++i) {
      for (int j = 0; j < 2 * n; ++j) {
        if (ret[i][j] >= 0) continue;
        ret[i][j] = 0;
        dfs(i, j, g, ret);
      }
    }
    return ret;
  }
  void dfs(int x, int y, const Graph& g, vector<vector<int>>& b) {
    for (auto&& p : g[x][y]) {
      if (b[p.first][p.second] == -1) {
        b[p.first][p.second] = !b[x][y];
        dfs(p.first, p.second, g, b);
      }
    }
  }
  void solve() {
    cin >> d1 >> d2;
    Graph g1 = makeGraph(d1);
    Graph g2 = makeGraph(d2);
    auto res1 = divide(g1);
    auto res2 = divide(g2);
    vector<vector<pair<int, int>>> ans(4);
    for (int i = 0; i < 2 * n; ++i) {
      for (int j = 0; j < 2 * n; ++j) {
        ans[res1[i][j] * 2 + res2[i][j]].emplace_back(i, j);
      }
    }
    DBG(ans)
    for (int i = 0; i < 4; ++i) {
      if (ans[i].size() >= n * n) {
        for (int j = 0; j < n * n; ++j) {
          cout << ans[i][j].first << ' ' << ans[i][j].second << endl;
        }
        break;
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 178940
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {

    ll h, w, d;
    cin >> h >> w >> d;
    ll a[302][302];
    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
        }
    }
    ll q;
    ll l[100002];
    ll r[100002];
    cin >> q;
    REP(i, q)cin >> l[i] >> r[i];
    vector<V> v;
    v.push_back(make_pair(0, make_pair(-1, -1)));
    REP(i, h){
        REP(j, w){
            v.push_back(make_pair(a[i][j], make_pair(i, j)));
        }
    }
    sort(v.begin(), v.end());
    ll cnt[90002];
    REP(i, d){
        cnt[h * w - i] = 0;
        ll j = 1;
        while(h * w - i - d * j > 0){
            int px, py, nx, ny;
            ny = v[h * w - i - d * j].second.first;
            nx = v[h * w - i - d * j].second.second;
            py = v[h * w - i - d * (j - 1)].second.first;
            px = v[h * w - i - d * (j - 1)].second.second;
            cnt[h * w - i - d * j] = cnt[h * w - i - d * (j - 1)] + abs(ny - py) + abs(nx - px);
            j++;
        }
    }
    REP(i,q){
        print(cnt[l[i]] - cnt[r[i]]);
    }

}

Measured memory_bytes: 5236
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A, B = [], []
N.times do |i|
  A[i], B[i] = get_ints
end

A.sort!
B.sort!

if N % 2 == 0
  min_median = (A[N/2 - 1] + A[N/2]) / 2.0
  max_median = (B[N/2 - 1] + B[N/2]) / 2.0
  max_median_float = max_median == max_median.to_i ? 0 : 1
  min_median_float = min_median == min_median.to_i ? 0 : 1

  puts (max_median.floor - min_median.floor) * 2 + 1 + max_median_float - min_median_float
else
  min_median = A[N/2]
  max_median = B[N/2]
  puts max_median - min_median + 1
end


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

using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector<vector<int>> sw(m);
  for (int i = 0; i < m; i++) {
    int k; cin >> k;
    for (int j = 0; j < k; j++) {
      int s; cin >> s;
      sw[i].push_back(s-1);
    }
  }

  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for (int bit = 0; bit < (1<<n); bit++) {
    int cnt = 0;  // cnt: 点灯する電球の個数
    for (int i = 0; i < m; i++) {
      int on = 0;
      for (int j = 0; j < sw[i].size(); j++) {
        int ss = sw[i][j];
        if ((bit>>ss) & 1) { on++; }
      }
      if (on % 2 == p[i]) { cnt++; }
    }
    if (cnt == m) { ans++; }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
d=[]
if N>0:
  for i in range(N):
    city,score=input().split(" ")
    score=int(score)
    d.append([i+1,city,score])

d.sort(key=lambda x:x[2],reverse=True)
d.sort(key=lambda x:x[1])
for x in d:
  print(x[0])


Measured memory_bytes: 3060
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
using namespace std;


//---- Finding Missing Cards 2
int main(){
    int n, r, cards[4][13]={0};
    char m, marks[4]={'S', 'H', 'C', 'D'};
    cin >> n;
    for(int i=0; i<n; i++){
        scanf("%s %d", &m, &r);
        if(m==marks[0]){cards[0][r-1]=1;}
        if(m==marks[1]){cards[1][r-1]=1;}
        if(m==marks[2]){cards[2][r-1]=1;}
        if(m==marks[3]){cards[3][r-1]=1;}
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            if(cards[i][j]==0){
                cout << marks[i] << " " << j+1 <<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3152
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int n,w,h,x,y,tmp,i;
        w=scan.nextInt();
        h=scan.nextInt();
        n=scan.nextInt();
        x=Math.min(w,h);
        y=Math.max(w,h);
        tmp=0;
        for(i=1;i<=x;i++){
            tmp+=y;
            if(tmp>=n) break;
        }
        System.out.println(i);
    }
}

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

const int INF = 1000000000;
int main()
{
	int h,w;
	cin >> h >> w;
	int field[50][50];
	int dp[50][50];
	for(int i=0;i<50;i++){
		for(int j=0;j<50;j++){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			stringstream sst;
			sst << str[j];
			sst >> field[i][j];
		}
	}

	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(dp[i+1][j] > field[i+1][j]+dp[i][j] && i+1 < h)
				dp[i+1][j] = field[i+1][j]+dp[i][j];
			if(dp[i][j+1] > field[i][j+1]+dp[i][j] && j+1 < w)
				dp[i][j+1] = field[i][j+1]+dp[i][j];
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

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

int main(){
int x,y,w;
while(true){
cin >> x>>y;
if(x==0 && y==0) break;
if(x>y){
w=x;
x=y;
y=w;
}
cout << x<<" "<<y<<endl;
}
    return 0;
}

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

using namespace std;
typedef long long int ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;

int D;
int C[26];
std::vector<std::vector<int>> S;
const int INF = 1e9;

std::vector<int> T;

void init() {
  std::cin >> D;
  REP(i, 26) std::cin >> C[i];
  S.resize(D);
  REP(i, D) {
    S[i].resize(26);
    REP(j, 26) std::cin >> S[i][j];
  }

  T.resize(D, -1);
}

std::vector<int> prev_days;

int calc_score(std::vector<int> &contests, bool verbose = false) {
  int score = 0;
  prev_days.assign(26, -1);
  REP(i, contests.size()) {
    prev_days[contests[i]] = i;
    if (verbose) {
      for (int d : prev_days) std::cerr << d << ' ';
      std::cerr << endl;
    }
    REP(j, 26) {
      score -= C[j] * (i - prev_days[j]);
    }
    score += S[i][contests[i]];
    if (verbose) {
      std::cerr << score << std::endl;
    }
  }
  return score;
}

void output() {
  for (int t : T) std::cout << t + 1 << '\n';
}

void greedy() {
  std::vector<int> contests;
  REP(d, D) {
    int max_score = -INF, max_con = -1;
    REP(i, 26) {
      contests.emplace_back(i);
      int new_score = calc_score(contests);
      if (new_score > max_score) {
        max_score = new_score;
        max_con = i;
      }
      contests.pop_back();
    }
    contests.emplace_back(max_con);
  }
  T = contests;
  std::cerr << calc_score(T) << endl;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  init();

  greedy();

  output();

  return 0;
}


Measured memory_bytes: 3724
n,x = gets.strip.split.map(&:to_i)
as = gets.strip.split.map(&:to_i).sort
cnt = 0
n.times do |i|
    x -= as[i] 
  if x >= 0 

    cnt += 1
    # puts "x: #{x}, as[i]: #{as[i]}, cnt: #{cnt}"
  else
    break
  end
end
cnt -= 1 if x > 0
puts cnt

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		for(var i=0;i<N;i++){
			for(var j=i+1;j<N;j++){
				for(var k=j+1;k<N;k++){
					if(A[i]!=A[j] && A[i]!=A[k] && A[j]!=A[k] && A[i]+A[j]>A[k] && A[i]+A[k]>A[j] && A[j]+A[k]>A[i]){
						ans++;
					}
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17900
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
class Main{


	static final int MOD = 1000000007;


	static ArrayList<ArrayList<Pair>> map;
	static TreeMap<Integer,Integer> ans; 
	static int maxnum;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();

		int[] a = new int[n];
		double sum = 0;
		for(int i = 0;i < n;i++){
			sum += 1/sc.nextDouble();
		}
		System.out.println(1/sum);
		
		

	}





	static int upperbond(int k,int min,int[] data){		//kより小さい最大の値をdataの中から探し、返す二分探索
		int max = data.length;
		//		if(min == data.length-1){
		//			if(data[min] > k){
		//				return min;
		//			}
		//		}

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}

		return max;
	}

	static int lowerbond(int k,int min,int[] data){		//kより大きい最小の値をdataの中から探し、返す二分探索
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return min;
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}

class Town{
	int index;
	int x ;
	int y;
	public Town(int index,int x,int y) {
		this.index = index;
		this.x = x;
		this.y = y;
		// TODO 自動生成されたコンストラクター・スタブ
	}


}


class Edge  implements Comparable{

	int index;
	HashSet<Integer> hen;
	HashSet<Integer> used;
	HashMap<Integer, Integer> map;
	int size;


	public Edge(int index) {
		// TODO 自動生成されたコンストラクター・スタブ
		this.index = index;
		hen = new HashSet();
		used = new HashSet<Integer>();
		map = new HashMap<Integer,Integer>();
	}

	public int compareTo(Object other) {
		Edge otherpair = (Edge)other;

		return   otherpair.hen.size() - hen.size();
	}
}

class Food implements Comparable{

	int minits;
	int score;
	double cospa;

	public Food(int from,int end,double c) {
		this.minits = from;
		this.score = end;
		this.cospa = c;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Food otherpair = (Food)other;
		int dif = Double.compare(otherpair.cospa, cospa);
		return   dif;
	}

}

class Pair implements Comparable{
	int from;
	int end;
	public Pair(int from,int end) {
		this.from = from;
		this.end = end;
		// TODO 自動生成されたコンストラクター・スタブ
	}

	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  from - otherpair.from;
	}








}






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

using namespace std;
using ll=long long;

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

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int h,n,a,sum=0;
  cin>>h>>n;
  rep(i,0,n){
    cin>>a;
    sum+=a;
  }
  sum>=h ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

Measured memory_bytes: 256
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n = int(input())
  s,t = map(str,input().split())
  new = ""
  for i in range(n):
    new += s[i]
    new += t[i]
  print(*new,sep="")
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define maxn (200000+500)
#define int long long
using namespace std;
int a[maxn],n,now,ans,l,r;

signed main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&a[i]);
	for (l=r=1,now=ans=0;r<=n;)
	{
		while ((now^a[r])==(now+a[r]) && r<=n)
			now^=a[r],r++;
		if (r<=n) ans+=r-l;
		else ans+=(r-l)*(r-l+1)/2;
		now^=a[l],l++;
	}
	printf("%lld\n",ans);

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define all(x) (x).rbegin(), (x).rend()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<int,int>val;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        val[x]++;
        val[x-1]++;
        val[x+1]++;
    }
    int ans=0;
    for(auto t=val.begin();t!=val.end();t++){
        ans=max(ans,t->second);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7948
A,B,K = map(int, input().split())
 
 

 
 
ans = []
for x in range(A, min(A+K,B+1)):
    ans.append(x)
for x in range(max(A,B-K+1), B+1):
    ans.append(x)
for x in sorted(list(set(ans))):
    print(x)

Measured memory_bytes: 3060
/*
[agc010] F - Tree Game
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 3000;
const int INF = 1e9 + 1;

int N;
int A[MAX_N];
vector<int> g[MAX_N];

int dfs(int v, int par = -1) {
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        if (dfs(to, v) < A[v]) {
            return INF;
        }
    }
    return A[v];
}

void solve() {
    for (int i = 0; i < N; i++) {
        if (dfs(i) >= INF) {
            cout << i + 1 << " ";
        }
    }
    cout << endl;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }

    solve();

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int main(void)
{
    ll N;
    cin >> N;

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

    ll ans = 0;
    ll now = 0;
    REP(i,N) {
        now = A[now]-1;
        ans++;
        if (now == 1) {
            break;
        }
    }

    if (now != 1) ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

LL a, b;

int main() {
	read(a), read(b);
	if (2LL * a > b) {printf("%lld\n", b / 2); return 0;}
	LL k = (b - 2LL * a) / 4LL;
	printf("%lld\n", a + k);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  int n;

  cin>>n;

  vi v(n);

  for(int i=0; i<n; i++)

  cin>>v[i];

  int cnt=0;

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

  for(int i=0; i<n; i++){

    for(int j=0; j<i; j++){

      for(int k=0; k<j; k++){

      if(v[i]<v[k]+v[j] && v[i]!=v[j] && v[j]!=v[k] && v[i]!=v[k])

      cnt++;

    }

    }

  }

  cout<<cnt<<endl;

}

Measured memory_bytes: 3616
N,M=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
for i in range(N):
  a_i,b_i=map(int,input().split())
  a.append(a_i)
  b.append(b_i)
for i in range(M):
  c_i,d_i=map(int,input().split())
  c.append(c_i)
  d.append(d_i)
for i in range(N):
  x=[]
  for j in range(M):
    l=abs(a[i]-c[j])+abs(b[i]-d[j])
    x.append(l)
    u=min(x)
    w=x.index(u)+1
  y.append(w)
for k in range(N):
  print(y[k])       

Measured memory_bytes: 3064