akhauriyash/Code-Regression huggingface dataset:
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int32_t main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << min(a,b) + min(c,d) << endl;
}
	

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#define KETA 10
using namespace std;

int main(){
	string str;
	int a[KETA], i, j, k;
	while(cin>>str){
		for(i=0;i<KETA;i++){
			a[i] = str[i] - '0';
		}
		for(i=KETA-1;i>0;i--){
			for(j=0;j<i;j++){
				k=j+1;
				a[j] = (a[j] + a[k]) % 10;
			//	cout<<a[j] << " ";
			}
			//cout<< endl;
		}
		cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>
int main(void){
   int n, hl[10];
   double h;
   for ( n = 0; n < 5; n++ ) {
      hl[n] = 0;
   }
   scanf("%d", &n);
   while (n != 0) {
      scanf("%lf", &h);
      if (165 > h) hl[0]++;
      else if ( 170 > h ) hl[1]++;
      else if ( 175 > h ) hl[2]++;
      else if ( 180 > h ) hl[3]++;
      else if ( 185 > h ) hl[4]++;
      else hl[5]++;
      n--;
   }
   for ( n = 0; n <= 5; n++ ) {
      printf("%d:", n + 1);
      while ( hl[n] != 0) {
         printf("*");
         hl[n]--;
      }
      printf("\n");
   }
   return 0;
}

Measured memory_bytes: 1800
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(r: int):
    return r*r


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    print(f'{solve(r)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75112
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as M




getBysplit = map read . words <$> getLine



count :: [String] -> [Int]
count lst = let
              xs = if (head . head) lst == '0' then [] : lst else lst
              ys = if (head . last) lst == '0' then xs ++ [] else xs
            in map length ys

solve :: Int -> M.Map Int Int -> Int -> Int
solve width mmap limit = foldl f 0 [0,2..limit]
      where
        f acc x = let
                    Just left = M.lookup x mmap
                    Just right = M.lookup (min (x + width) limit) mmap
                  in max (right - left) acc

main :: IO ()
main = do
  [n, k] <- getBysplit :: IO [Int]
  s <- getLine :: IO String
  let nums = (count . group) s --group 連続するものをリストに分割して二次元リストを返す
  let sums = scanl (+) 0 nums -- 累積和を作成する関数
  let width = 2 * k + 1
  let mmap = M.fromList $ zip [0..] sums
  let limit = length nums
  print $ solve width mmap limit


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

using namespace std;

void search(char map[14][14], int n, int m){
	
	if(map[n-1][m] == '1'){
		map[n-1][m] = '0';
		search(map, n-1, m);
	}
	if(map[n][m+1] == '1'){
		map[n][m+1] = '0';
		search(map, n, m+1);
	}
	if(map[n+1][m] == '1'){
		map[n+1][m] = '0';
		search(map, n+1, m);
	}
	if(map[n][m-1] == '1'){
		map[n][m-1] = '0';
		search(map, n, m-1);
	}
	
}

int main(){

	int cnt;
	char map[14][14];
	
	while(cin >> map[1][1]){
		cnt = 0;
		for(int i=2; i<13; i++){
			cin >> map[1][i];
		}
		for(int i=2; i<13; i++){
			for(int j=1; j<13; j++){
				cin >> map[i][j];
			}
		}
		
		for(int i=0; i<13; i++){
			for(int j=0; j<13; j++){
				if(map[i][j] == '1'){
					cnt++;
					map[i][j] = '0';
					search(map, i, j);
				}
			}
		}
		
		cout << cnt << endl;
	}

	return 0;

}

Measured memory_bytes: 1144
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y==NIL)root=z;
  else if(z->key < y->key)y->left = z;
  else y->right = z;
  
}

Node treeSearch(Node u, int k){

  while(u!=NIL && k != u->key){
    if(k < u->key)u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;

}


Node treeSuccessor(Node x){

  Node y;

  if(x->right != NIL)return treeMinimum(x->right);

  y = x->parent;
  while(y!=NIL && x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

 if(z->left == NIL || z->right == NIL) y=z;
 else y = treeSuccessor(z);

 if(y->left != NIL) x = y->left;
 else x = y->right;

 if(x!=NIL) x->parent = y->parent;
 
 if(y->parent==NIL)root = x;
 else if(y == y->parent->left)y->parent->left = x;
 else y->parent->right = x;

 if(y != z)z->key = y->key;

 free(y);
}


void inorder(Node u){
if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
 if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);

    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20612
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1e9 + 5
using namespace std;

int solve()
{
    int n;
    cin >> n;

    vector<int> dp(3);
    for (int day = 0; day < n; day++)
    {
        vector<int> new_dp(3);
        vector<int> a(3);
        for (int i = 0; i < 3; i++)
        {
            cin >> a[i];
        }

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (i != j)
                {
                    new_dp[j] = max(new_dp[j], dp[i] + a[j]);
                }
            }
        }
        dp = new_dp;
    }

    return max({dp[0], dp[1], dp[2]});
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    /*
    int t;
    cin >> t;

    while (t--)
    */
    cout << solve() << "\n";

    return 0;
}

Measured memory_bytes: 3664
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    aa = LI()
    a = [set([_]) for _ in aa]
    b = LI()

    e = [[None]*51 for _ in range(51)]
    for i in range(51):
        for j in range(i+1):
            if i == j:
                e[i][j] = 0
                continue
            if j == 0:
                e[i][0] = 1
                continue
            for k in range(1,i,1):
                ik = i % k
                if ik == j or ik > j*2:
                    e[i][j] = k
                    break

    for i in range(n):
        if e[aa[i]][b[i]] is None:
            return -1

    def f():
        r = -1
        for i in range(n):
            tr = inf
            for d in a[i]:
                if e[d][b[i]] < tr:
                    tr = e[d][b[i]]
            if r < tr:
                r = tr

        return r

    rr = 0

    while 1:
        k = f()
        if k == 0:
            break
        for i in range(n):
            for c in list(a[i]):
                at = c % k
                if e[at][b[i]] is not None:
                    a[i].add(at)
        rr |= 2**k


    return rr


print(main())




Measured memory_bytes: 6204
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

class UnionFind:
    def __init__(self, size, tb):
        self.table = tb

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    n,m = LI()
    x = LI()
    s = sum(x)
    t = []
    e = collections.defaultdict(list)
    for _ in range(m):
        a,b,y = LI()
        a -= 1
        b -= 1
        t.append((y,a,b))
        e[a].append((b,y))
        e[b].append((a,y))

    t = sorted(t)

    uf = UnionFind(n,[-c for c in x])
    ba = [None] * m
    for i in range(m):
        y,a,b = t[i]
        uf.union(a,b)
        k = -uf.table[uf.find(a)]
        if k >= y:
            ba[i] = 1


    uf2 = UnionFind(n,[-c for c in x])
    for i in range(m-1,-1,-1):
        if ba[i] is None:
            continue
        y,a,b = t[i]
        if not uf2.union(a,b):
            continue
        al = set([a,b])
        q = set([a,b])
        while q:
            nq = set()
            for o in q:
                for c,cy in e[o]:
                    if cy > y:
                        continue
                    if uf2.union(o,c):
                        nq.add(c)
            q = nq

    r = m
    for i in range(m):
        y,a,b = t[i]
        k = -uf2.table[uf2.find(a)]
        if k >= y:
            r -= 1

    return r



print(main())




Measured memory_bytes: 130244
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 1e5;
typedef long long ll;

int main(){
	ll x = 100;
	ll s;
	cin >> s;
	ll t = 0;
	while(x < s){
		x = x + x * 0.01;
		t++;
	} 
	cout << t << endl;	
	return 0;
}



Measured memory_bytes: 3632
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
alis = li()

blis = [0]*n
for i in reversed(range(1,n+1)):
    sums = 0
    for k in range(1,n+1):
        if k*i > n:
            break
        sums += blis[k*i - 1]
    if (sums % 2) != alis[i-1]:
        blis[i-1] = 1

ans = 0
anl = []
for i in range(n):
    if blis[i] == 1:
        ans += 1
        anl.append(i+1)
print(ans)
if len(anl) == 0 :
    exit()
print(*anl)

Measured memory_bytes: 14136
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*n
        self.rank=[-1]*n

    def Find_Root(self,x):
        if self.root[x]<0:return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)

        if x==y:return
        elif self.rank[x]>self.rank[y]:
            self.root[x] +=self.root[y]
            self.root[y]=x
        else:
            self.root[y] +=self.root[x]
            self.root[x]=y
            if self.rank[x]==self.rank[y]:
                self.rank[y] +=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def size(self,x):
        return -self.root[self.Find_Root(x)]

    def members(self,x):
        root=self.Find_Root(x)
        return [i for i in range(self.n) if self.Find_Root(i)==root]

    def roots(self):
        return[i for i,j in enumerate(self.root) if j<0]

    def group_members(self):
        return {i:self.members(i) for i in self.roots()}

    def group_count(self):
        return len(self.roots())


n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

UnionFind=UnionFind(n+1)
for a,b in AB:
    UnionFind.Unite(a,b)

length=UnionFind.group_count()-2
print(max(0,length))

Measured memory_bytes: 90648
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		ULL N, P; cin >> N >> P;
		if (N >= 50) { cout << 1 << endl; return; }
		if (N == 1) { cout << P << endl; return; }
		ULL ans = 1;
		for (ULL p = 2; p < P; p++) {
			ULL b = 1;
			rep(i, N) {
				b *= p; if (b > P) break;
			}
			if (b > P) break;
			if (P % b == 0) ans = p;
		}
		cout << ans << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	if(s.size()==2){
		if(s[0]==s[1]) cout << 1 << " " << 2 << endl;
		else cout << -1 << " " << -1 << endl;
		return 0;
	}
	rep(i,s.size()-2){
		if(s[i]==s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(s[i]==s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

ll n, res = 0;
vector<ll> a;
map<ll, ll> m1, m2;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    a.assign(n, 0);
    for(int i = 0; i < n; ++i){
        ll x;
        cin >> x;
        a[i] = x - i;
        m2[-x - i]++;
        // cout << x - i << " " << -x - i << "\n";

    }
    for(int i = 0; i < n; ++i){
        ll cnt = m2[a[i]];
        // if((-(a[i] + i) - i) == a[i]) cnt--;
        res += cnt;
        // cout << i << " " << cnt << "\n";
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 27372
from sys import stdin
import sys
import math

A, B = list(map(int, stdin.readline().rstrip().split()))

#x * 8 / 100 = A
#x * 10 / 100 = B

#xA = A * 100 / 8
#xB = B * 100 / 10


def tax(x,ratio):
    return math.floor(x * ratio / 100)


xA = int(A * 100 / 8)
xB = int(B * 100 / 10)

for i in range(max(0, xB-1), xA+10000):
    tax_a = tax(i, 8)
    tax_b = tax(i, 10)

    if tax_a == A and tax_b == B:
        print(i)
        sys.exit()

print(-1)


Measured memory_bytes: 3060
using System;
using System.Linq;

class Program {
    static void Main() {
        while (Console.ReadLine() != "0") {
            var counts = Array.ConvertAll(Console.ReadLine().Split(' '), str => int.Parse(str));
            if (counts.Any(n => n >= 2)) {
                Console.WriteLine(counts.Count(n => n != 0) + 1);
            }
            else {
                Console.WriteLine("NA");
            }
        }
    }
}

Measured memory_bytes: 10912
#include <iostream>

using namespace std;

int main()
{
	int K;
	for(;cin>>K, K;)
	{
		int sum = 0;
		for (int i = 0; i < K * (K - 1) / 2; i++)
		{
			int c;
			cin>>c;
			sum += c;
		}
		cout << (sum / (K - 1)) << endl;
	}
	return 0;
}

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


int main() {
	string s;
	cin >> s;
	int counter = 0;
	for (auto it = s.begin(); it != s.end(); it++)
	{
		if (*it == '1')
		{
			counter++;
		}
	}
	cout << counter;

}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  int cnt = 0;
  for (int i = A; i <= B; i++) {
    ostringstream os1;
    os1  << i;
    string sos1 = os1.str();

    ostringstream os2;
    os2 << i;
    string sos2 = os2.str();
    reverse(sos2.begin(), sos2.end());
    if (sos1 == sos2) {
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    
    int a, b;
    cin >> a >> b;
    
    if (a < b){
        cout << "a < b"<< endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1156
N, K = map(int, input().split())
S = list(input())

# 向かい合ってるor背を向けてる場所を検知
num_diff = 0
pre_s = S[0]
for cur_s in S[1:]:
    if pre_s != cur_s:
        num_diff += 1
    pre_s = cur_s

for i in range(K):
    if num_diff <= 1:
        num_diff = 0
        break
    num_diff -= 2

print(N-1-num_diff)

Measured memory_bytes: 4772
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;

#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 all(x) x.begin(), x.end()

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {cin >> a[i];}

    sort(all(a), greater<int>());

    ll sum = a[0];
    for(int i = 1; i <= (n - 2) / 2; i++) {
        sum += a[i] * 2;
    }

    if(n % 2 == 1) {
        sum += a[n / 2];
    }

    cout << sum << endl;
}


Measured memory_bytes: 3972
n = int(input())
s1 = input()
s2 = input()

ans = 0
tate = False
i = 0
if (s1[i] == s2[i]):
    ans = 3
    tate = True
    i = 1
else:
    ans = 6
    i = 2

while i < n:
    if (s1[i] == s2[i]):
        if tate:
            ans *= 2
            ans %= 1000000007
        tate = True
        i += 1
    else:
        if tate:
            ans *= 2
            ans %= 1000000007
        else:
            ans *= 3
            ans %= 1000000007
        tate = False
        i += 2

print(ans)

Measured memory_bytes: 3064
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
H = iil()
mh = 0
for i in H:
    if mh - 1 > i:
        print('No')
        exit()
    else:
        mh = max(mh,i)
print('Yes')

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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	string s;
	cin >> s;
	cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
}

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


int N,A[100000],B[100000],C[100000];
long long int b[100001],res;

int main(){
	cin>>N;
	for(int i=0;i!=N;++i)
		cin>>A[i];
	for(int i=0;i!=N;++i)
		cin>>B[i];
	for(int i=0;i!=N;++i)
		cin>>C[i];
	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);
	for(int i=0;i!=N;++i){
		int l=-1,r=N;
		while(l+1!=r){
			int k=(l+r)/2;
			if(C[k]>B[i])r=k;
			else l=k;
		}
		b[i]=N-r;
	}
	for(int i=N-2;i!=-1;--i)
		b[i]+=b[i+1];
	for(int i=0;i!=N;++i){
		int l=-1,r=N;
		while(l+1!=r){
			int k=(l+r)/2;
			if(B[k]>A[i])r=k;
			else l=k;
		}
		res+=b[r];
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
    int n, building, floor, roomNum, people;
    int count[4][3][10]={{}};
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> building >> floor >> roomNum >> people;
        count[building-1][floor-1][roomNum-1]+=people;
    }

    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){         
           cout << " " << count[0][i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){         
           cout << " " << count[1][i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){         
           cout << " " << count[2][i][j];
        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i=0; i<3; i++){
        for(int j=0; j<10; j++){         
           cout << " " << count[3][i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
r, c = map(int, input().split())
arr = []
for i in range(r):
    arr.append(list(map(int, input().split())))

for line in arr:
    line.append(sum(line))
    
arr.append([sum([line[i] for line in arr]) for i in range(c  + 1)])

for line in arr:
    print(*line)

Measured memory_bytes: 6844
package main

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

type stack struct {
	t   *node
	len int
}

type node struct {
	v    int
	prev *node
}

func (s *stack) Len() int {
	return s.len
}

func (s *stack) Peek() int {
	if s.len == 0 {
		return -1
	}
	return s.t.v
}

func (s *stack) Pop() int {
	if s.len == 0 {
		return -1
	}
	n := s.t
	s.t = n.prev
	s.len--
	return n.v
}

func (s *stack) Push(v int) {
	s.t = &node{v: v, prev: s.t}
	s.len++
}

func (s *stack) calc(op string) {
	l, r := s.Pop(), s.Pop()
	switch op {
	case "+":
		s.Push(l + r)
	case "-":
		s.Push(r - l)
	case "*":
		s.Push(l * r)
	}
}

func main() {
	s := bufio.NewScanner(os.Stdin)
	e := []string{}
	if s.Scan() {
		e = strings.Fields(s.Text())
	}
	f := &stack{nil, len(e)}
	for _, ele := range e {
		if num, err := strconv.Atoi(ele); err == nil {
			f.Push(num)
		} else {
			f.calc(ele)
		}
	}
	fmt.Println(f.Peek())
}



Measured memory_bytes: 1104
#include<stdio.h>
#include<string.h>
#define max 1000000
#define INF 1000000000

void merge(int [],int ,int ,int );
void mergeSort(int [],int ,int );


int count = 0;
int main(){
  int i,j,A[max],left,right,n;
 
  scanf("%d",&n);
   
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  left = 0;
  right = n;
  mergeSort(A,left,right);
   
   for(i = 0;i < n-1;i++){
    printf("%d ",A[i]);
  }
   printf("%d\n",A[n-1]);
   printf("%d\n",count);
  return 0;
}
 
void mergeSort(int A[],int left, int right){
  int mid = 0;
 
  if((left + 1) < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}
 
void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
   
  n1 = mid - left;
  n2 = right - mid;
 
  int L[n1+1],R[n2+1];
 
  for(i = 0;i < n1;i++){
    L[i] = A[left+i];
  }
 
  for(i = 0;i < n2;i++){
    R[i] = A[mid+i];
  }
  L[n1] = INF;
  R[n2] = INF;
  i = 0;
  j = 0;
   
  for(k = left;k < right;k++){
    if(L[i] <= R[j]){
     A[k] = L[i];
     i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
    count++;
  }
}
 
 

Measured memory_bytes: 6624
require 'set'
Move = [ [2, -1, -1, -1],
         [2, 5, -1, -1], [0, 1, 3, 6], [2, 7, -1, -1],
         [5, -1, -1, -1], [1, 4, 6, 9], [2, 5, 7, 10], [3, 6, 8, 11], [7, -1, -1, -1],
         [5, 10, -1, -1], [6, 9, 11, 12], [7, 10, -1, -1],
         [10, -1, -1, -1] ]
R = [0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4]
C = [2, 1, 2, 3, 0, 1, 2, 3, 4, 1, 2, 3, 2]
 

while n = gets.to_i
  break if n == -1
  brd = [n, 4.times.map{ gets.split.map(&:to_i) } ].flatten
  q = [[brd, 0]]
  ans = -1
  set = Set.new([])
  set.add(brd)
  until q.empty?
    b, d = q.shift
    if (1..11).all?{ |v| b[v] == v }
      ans = d
      break
    end
    x = d
    13.times do |i|
      if b[i] > 0
        [R, C].each do |a|
          x += (a[i] - a[b[i]]).abs
        end
      end
    end
    unless x > 20
      13.times do |i|
        if b[i] == 0
          4.times do |j|
            unless Move[i][j] == -1
              b[i], b[Move[i][j]] = b[Move[i][j]], b[i]
              unless set.include?(b)
                set.add(nb = b.dup)
                q << [nb, d + 1]
              end
              b[i], b[Move[i][j]] = b[Move[i][j]], b[i]
            end
          end
        end
      end
    end
  end
  puts ans == -1 ? 'NA' : ans
end

Measured memory_bytes: 12528
#include <stdio.h>

int n,A[100000];
int partition(int,int);

int main(){
    int i,p;
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++){
        scanf("%d",&A[i]);
    }
    p = partition(0,n-1);
    for(i = 0 ; i < n ; i++){
        if(i == p) printf("[");
        printf("%d",A[i]);
        if(i == p) printf("]");
        if(i!=n-1) printf(" ");
    }
    printf("\n");
}

int partition(int p,int r){
    int x = A[r];
    int i = p-1,j,y;
    for(j = p ; j <= r-1 ; j++){
        if(A[j] <= x){
            i = i+1;
            y = A[i];
            A[i] = A[j];
            A[j] = y;
        }
    }
    y = A[i+1];
    A[i+1] = A[r];
    A[r] = y;
    return i+1;
}



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

int main() {
  int N;cin>>N;
  long ans=0;
 // vector<int> P(N);
  if(N==1) goto shutsuryoku;
  //この下はN>=2で考えていい
//  for(int i=0;i<N-1;i++) P.at(i)=i+2;
//  P.at(N-1)=1;
//  for(int i=0;i<N;i++) ans += i%P.at(i);
  for(int i=1;i<N;i++) ans +=i;
shutsuryoku:
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
n=int(input())
s = []
for _ in range(n):
    s.append(input())
cnt={"AC": 0, "WA": 0, "TLE": 0,"RE":0}
for i in s:
    cnt[i] += 1

for i in ["AC","WA","TLE","RE"]:
    print(i,"x",cnt[i])

Measured memory_bytes: 16320
<?php
fscanf(STDIN, '%d %d %d', $a, $b, $c);

$bucket = [];

$bucket[$a] = 1;
$bucket[$b] = 1;
$bucket[$c] = 1;



if (count($bucket) === 2) {
    echo 'Yes'.PHP_EOL;
} else {
    echo 'No'.PHP_EOL;
}


Measured memory_bytes: 4856
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static IEnumerable<int[]> Read()
        {
            string line;
            while(!string.IsNullOrEmpty(line = Console.ReadLine()))
                yield return line.Split(',').Select(int.Parse).ToArray();
        }

        static void Main(string[] args)
        {
            var a = Read().ToLookup(x => x[0]);
            var b = Read().ToLookup(x => x[0]);
            foreach (var item in a
                .Where(item => b.Contains(item.Key))
                .ToDictionary(x => x.Key, x => b[x.Key].Count() + x.Count())
                .OrderBy(x => x.Key))
            {
                Console.WriteLine(item.Key + " " + item.Value);
            }
        }
    }
}

Measured memory_bytes: 6892
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    int n;
    int a[MAX];
    int b[MAX];
    int c[MAX];

    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];

    int manzok;
    int au;
    au = -5;
    manzok = 0;
  
    rep(i, n){
        manzok += b[a[i] - 1];
		if(au == a[i] - 1) manzok += c[a[i] - 2];
        au = a[i];
    }
    cout << manzok << endl;

}



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

using namespace std;

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 T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int memo[110];

int a[110];
int b[110];
int l[110];
int r[110];

int gcd(int a,int b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}

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

int rec(int i){
	if(memo[i]>=0)
		return memo[i];
	int aa=a[i]*rec(l[i]);
	int bb=b[i]*rec(r[i]);
	int gg=gcd(aa,bb);
	aa/=gg;
	bb/=gg;
	return memo[i]=rec(l[i])*bb+rec(r[i])*aa;
}

int main(void){
	int n;
	while(cin >> n,n){
		for(int i=1;i<=n;++i) cin >> a[i] >> b[i] >> l[i] >> r[i];
		memo[0]=1;
		for(int i=1;i<=n;++i) memo[i]=-1;

		int ans=0;
		for(int i=1;i<=n;++i) ans=max(ans,rec(i));
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  long long k, a, b;
  cin >> k >> a >> b;
  long long c = 1;
  c += min(k, a - 1);
  k -= min(k, a - 1);
  if (b - a <= 2) {
	  c += k;
	  cout << c << endl;
	} else {
	  c += (k / 2) * (b - a);
	  c += k % 2;
	  cout << c << endl;
	}
  return 0;
}


Measured memory_bytes: 256
<?php
while ($line = trim(fgets(STDIN))) {
  list($N, $K) = explode(' ', $line);
  if ($N == 0 && $K == 0) {
    break;
  }
  $S = explode(' ', trim(fgets(STDIN)));
  $yes = true;
  for ($i=0; $i<$N; ++$i) {
    $B = explode(' ', trim(fgets(STDIN)));
    for ($j=0; $j<$K; ++$j) {
      $S[$j] -= $B[$j];
      if ($S[$j] < 0) {
        $yes = false;
      }
    }
  }
  if ($yes) echo "Yes\n";
  else echo "No\n";
}

Measured memory_bytes: 15364
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	long long A, B;
	cin >> N >> A >> B;
	vector<long long> h(N);
	auto maxH = 0ll;
	for (auto i = 0; i < N; ++i)
	{
		cin >> h[i];
		maxH = max(maxH, h[i]);
	}

	auto func = [&](long long x)
	{
		auto count = 0ll;
		for (auto i = 0; i < N; ++i)
		{
			auto temp = h[i] - B * x;
			if (temp > 0)
			{
				count += temp / (A - B);
				if (temp % (A - B) > 0)
				{
					++count;
				}
			}
		}

		return count <= x;
	};

	auto low = 0ll;
	auto high = maxH / B + 1;
	while (high >= low)
	{
		auto mid = (high + low) / 2;
		auto result = func(mid);
		if (result)
		{
			high = mid - 1;
		}
		else
		{
			low = mid + 1;
		}
	}

	cout << low << endl;

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  sort(a, a+n);
  cout << a[n-1] - a[0] << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <limits.h>

int main(void){
    int n;
    scanf("%d",&n);
    for (int i=0; i<30; i++){
        for (int j=0; j<30; j++){
            if (i*4+j*7==n){
                printf("Yes\n");
                return 0 ;
            }
        }
    }
    printf("No\n");
	return 0 ;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
 
using namespace std;


	
int main()
{ 
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	if((a+d-1)/d<(c+b-1)/b)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}
	
	


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

int main(){
  int h,w; //flag=1の時、一致している状態。loop中にflag=0となったらすぐにbreakする。
  cin >> h >> w;
  int flag1=0;
  vector<int> flag2(w,0); //縦の重複
  vector<string> lines(h);
  //入力
  for(int i=0;i<h;i++){
    cin >> lines.at(i);
  }
  //縦の重複の判断
  for(int i=0;i<w;i++){
    for(int j=0;j<h;j++){
      if(lines.at(j).at(i)=='.')flag1=1;
      else{
      	flag1=0;
      	break;
      }
    }
    if(flag1==1)flag2.at(i)=1;
    flag1=0;
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(lines.at(i).at(j)!='.'){
      	flag1=0;
        break;
      }
      else flag1=1;
    }
    //出力フェーズ
    if(flag1!=1){
      for(int j=0;j<w;j++){
        if(flag2.at(j)!=1)cout << lines.at(i).at(j);
      }
    }
    flag1=0;
    cout << endl;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,i,a[100009];
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];

sort(a,a+n);
double ans=(a[0]+a[1])/2.0;

for(i=2;i<n;i++)
{

 ans=(ans+a[i])/2.0;

}

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




Measured memory_bytes: 256
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
//#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    ll n, k;
    cin >> n >> k;
    arri a(n);
    arri inv(n);
    arri inv2(n);
    ll ans = 0;

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

    for (int i = 0; i < n; i++)
    {
        inv[i] = 0;
        for (int j = (i + 1); j < n; j++)
        {
            if (a[i] > a[j])
            {
                inv[i]++;
            }
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        inv2[i] = 0;
        for (int j = i - 1; j >= 0; j--)
        {
            if (a[i] > a[j])
            {
                inv2[i]++;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        unsigned long long int aux = k * k;
        aux += k;
        aux /= 2;
        aux %= mod;
        aux *= inv[i];
        aux %= mod;

        //ll aux = (inv[i] * (k * k - k + 1)) % mod;
        ans = (ans + aux) % mod;
    }
    k--;
    for (int i = 0; i < n; i++)
    {
        unsigned long long int aux = k * k;
        aux += k;
        aux /= 2;
        aux %= mod;
        aux *= inv2[i];
        aux %= mod;

        //ll aux = (inv[i] * (k * k - k + 1)) % mod;
        ans = (ans + aux) % mod;
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main (void) {
    ll N;
    ll A;
    ll B;

    cin >> N >> A >> B;

    if (A > B || (N == 1 && A != B)) {
        cout << 0 << endl;
    } else {
        ll ma = A + B * (N - 1);
        ll mi = A * (N - 1) + B;
        cout << ma - mi + 1 << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

int main(){
    ll n;
    cin >> n;
    vecll b(n - 1);
    for(auto& i : b) cin >> i;
    
    ll ans = b.at(0) + b.at(n - 2);
    for(ll i = 0; i < n - 2; i++){
        if(b.at(i) < b.at(i + 1)) ans += b.at(i);
        else ans += b.at(i + 1);
    }

    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

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

	auto s1 = s.substr(0, 2), s2 = s.substr(2, 2);
	auto a1 = std::stoi(s1), a2 = std::stoi(s2);

	bool b1 = a1 > 0 && a1 <= 12, b2 = a2 > 0 && a2 <= 12;

	if (b1 && b2)
		std::cout << "AMBIGUOUS" << std::endl;
	if (b1 && !b2)
		std::cout << "MMYY" << std::endl;
	if (!b1 && b2)
		std::cout << "YYMM" << std::endl;
	if (!b1 && !b2)
		std::cout << "NA" << std::endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-c)<=d) || (abs(a-b)<=d && abs(c-b)<=d)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main()
{  int n,a[200],x=0,y=101,ans=9999999999;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {scanf("%d",&a[i]);
    x=min(x,a[i]);
    y=max(y,a[i]);
  }
  for(int i=x;i<=y;i++)
  {   int sum=0;
      for(int j=1;j<=n;j++)
       {   int cur=abs(a[j]-i);
           sum+=cur*cur;
       }
       if(sum<ans)ans=sum;
  }
  printf("%d",ans);

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




ll f(ll b, ll n){
    if(n < b) return n;
    return f(b, n / b) + (n % b);
}

int main() {
    ll n, s;
    cin >> n >> s;
    
    if(s == n){
        cout << n + 1 << endl;
        return 0;
    }
    
    for(ll b = 2; b <= sqrt(n) + 1; b++){
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }
    
    for(ll p = sqrt(n) + 1; p >= 1; p--){
        ll b = (n - s) / p + 1;
        if(b < 2 || s - p < 0)continue;
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  double ans = 0;
  for (const auto i : a) {
    ans += 1 / static_cast<double>(i);
  }

  std::cout << std::fixed << std::setprecision(15) << 1 / ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = [[0] * 2 for i in range(n)]
for i in range(n):
    d[i][0], d[i][1] = map(int, input().split())

d = sorted(d)
s = 0
ans = 0
for a, b in d:
    s += b
    ans = a
    if (s >= k):
        break


print(ans)


Measured memory_bytes: 20804
from heapq import*
def D(s,e):
 g=10**6;d=[10**18]*n;f=[1]*n;d[s]=f[s]=0;q=[]
 for a,b in e[s]:heappush(q,a*g+b)
 while q:
  m=heappop(q)
  if f[m%g]:
   v=m%g;x=d[v]=m//g;f[v]=0
   for y,w in e[v]:
    if f[w]:heappush(q,(x+y)*g+w)
 return d
(n,m,s,t),*z=[map(int,t.split())for t in open(0)];e,f=eval('[[]for _ in"_"*n],'*2)
for u,v,a,b in z:u-=1;v-=1;e[u]+=(a,v),;e[v]+=(a,u),;f[u]+=(b,v),;f[v]+=(b,u),
a,m=[],0
for y,s in zip(D(s-1,e)[::-1],D(t-1,f)[::-1]):m=max(m,10**15-y-s);a+=m,
print(*a[::-1])

Measured memory_bytes: 131976
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */


#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CAXBC {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      ll ret = 0;
      for(ll a=1; a<n; a++) {
        for(ll b=1; a*b<n; b++) {
          ret += 1;
        }
      }
      cout << ret << endl;


    }
};

signed main() {
  CAXBC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3652
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int n,m,x,y,a,i,j;
  vector<int> u(100010),to;
  vector<vector<int> > g(100010);
  scanf("%d %d\n",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d\n",&x,&y);
    x--,y--;
    g[x].push_back(y);
    u[y]++;
  }
  queue<int> que;
  for(i=0;i<n;i++){
    if(u[i]==0){
      que.push(i);
    }
  }
  while(!que.empty()){
    a=que.front();
    que.pop();
    for(i=0;i<g[a].size();i++){
      int us=g[a][i];
      u[us]--;
      if(u[us]==0){
        que.push(us);
      }
    }
    to.push_back(a);
  }
  vector<int> dp(100010);
  for(i=0;i<to.size()-1;i++){
    for(j=0;j<g[to[i]].size();j++){
      if(dp[g[to[i]][j]]<dp[to[i]]+1){
        dp[g[to[i]][j]]=dp[to[i]]+1;
      }
    }
  }
  int ans=0;
  for(i=0;i<to.size();i++){
    if(ans<dp[i]){
      ans=dp[i];
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 7032
#include <stdio.h>
 
int main(){
    int s,m,h,inp;
    scanf("%d",&inp);
    h=inp/3600;
    m=(inp-h*3600)/60;
    s=inp-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = n;
		for (int i = 1 ; i <= n / 2 ; i++) {
			int tmp = cal(i,0) + cal(n-i,0);
			if (cnt > tmp) cnt = tmp;
		}
		System.out.println(cnt);
	}

	private static int cal (int n, int m) {
		if (n <= 9) return n + m;
		else return cal((n - n % 10) / 10 , m + n % 10);
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int n = in.nextInt();
            int ans = 0;
            for(int i = 0; i < 10; i++){
                for(int j = 0; j < 10; j++){
                    for(int k = 0; k < 10; k++){
                        for(int l = 0; l < 10; l++){
                            if(i + j + k + l == n){
                                ans++;
                            }
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 26196
#include "bits/stdc++.h"

using namespace std;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define INF LLONG_MAX
#define EPS 1e-9
#define all(v) (v).begin(),(v).end()
#define sq(x) ((x)*(x))
#define foreach(it, v) for(auto it=(v).begin(); it != (v).end(); ++it)
#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)


#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
 
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}
 
typedef long double dbl;
bool codejam = 0;

const int MOD = 1000*1000*1000 + 7;
const int NMAX = 1000*1000 + 11;

int arr[NMAX];
int n,m,p,q,k,a,b,c,ans;
string s,str;
char ch;
vector<int> v;

void solve()
{
    cin>>n;
    unordered_map<int,int > s;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(s.find(i-arr[i]) != s.end())
            ans += s[i-arr[i]];
        s[i+arr[i]]+=1;
    }
    cout<<ans<<"\n";
}

int32_t main(){ fio;
    int t = 1;
    int cs = 1;
    // cin>>t;
    while(t--){
        if(codejam){
            cout<<"Case #"<<cs<<": ";
        }
        cs++;
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 12892