akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n, a, b;
    scan(n, a, b);

    writeln(min(n*a, b));
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 9120
N = int(input())
S = list(input())

v = []
tmp =[]

for s in S:
    if s == "(":
        tmp.append(")")
        v.append("(")
    else:
        if len(tmp) == 0:
            v.insert(0, "(")
            v.append(")")
        else:
            v.append(tmp.pop())

while tmp:
    v.append(tmp.pop())

print("".join(v))

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

constexpr int MAX_N = 8;

int N, A[3];
int l[MAX_N];

int dfs(int n, int a, int b, int c) {
  if (n == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 10000;
    }
    int abc[]{a, b, c};
    int mp{};
    for (int i{}; i < 3; ++i) {
      mp += abs(A[i] - abc[i]);
    }
    mp -= 30;
    return mp;
  }

  int ret[4];
  ret[0] = dfs(n + 1, a + l[n], b, c) + 10;
  ret[1] = dfs(n + 1, a, b + l[n], c) + 10;
  ret[2] = dfs(n + 1, a, b, c + l[n]) + 10;
  ret[3] = dfs(n + 1, a, b, c);
  sort(ret, ret + 4);

  return ret[0];
}

int main() {
  cin >> N;
  for (int i{}; i < 3; ++i)
    cin >> A[i];
  for (int i{}; i < N; ++i)
    cin >> l[i];

  array<int, 3> a{};
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    int s[10], n, b, c;
    bool flag;

    cin >> n;
    rep(i, n) {
        b = 0, c = 0, flag = true;
        rep(i, 10)
            cin >> s[i];
        rep(i, 10) {
            if (s[i] > b)
                b = s[i];
            else if (s[i] > c)
                c = s[i];
            else
                flag = false;
        }
        
        cout << (flag ? "YES" : "NO") << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

bool is_prime_number(int num) {
  if (num == 1) {
    return false;
  }

  for (int i = 2; i <= sqrt(num); i++) {
    if (!(num % i)) {
      return false;
    }
  }

  return true;
}

int main() {
  int n;
  deque<int> nums;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    nums.push_back(tmp);
  }

  int res = 0;
  for (int i = 0; i < n; i++) {
    if (is_prime_number(nums[i])) {
      res++;
    }
  }

  cout << res << endl;

  return 0;
}


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

int main(void){
	int h,w,i,j;
	
	while(scanf("%d %d", &h, &w),h || w){
		for(i=0; i<h; i++){
			for(j=0; j<w; j++){
				if((i+j)%2)
					printf(".");
				else
					printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <string>
#include <string.h>
#include <cstdio>
#include <cctype>
using namespace std;
int main(){
    string s,c; cin >> s >> c;
	for(int i=0; i<s.size(); i++){
		s.at(i) = toupper(s.at(i));
	}
    
    int cnt =0;
    while(c!="END_OF_TEXT"){
		for(int i=0; i<c.size(); i++){
			c.at(i) = toupper(c.at(i));
		}
        if(c==s) cnt++;
        cin >> c;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3212
N=input()
N=int(N)
d = [0 for i in range(N)]
#dの入力
for i in range(N):
    d[i]=input()
    d[i]=int(d[i])

#処理
d=sorted(d,reverse=True)

count=0
nowd=101

for i in range(N):
    if d[i]<nowd:
        count+=1
        nowd=d[i]

print(count)

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


typedef long long ll;
typedef vector <ll> vi;
typedef vector <vi> mat;

mat atvd;
mat memo;

ll dp(ll n, int m){
    if (n <= 0) return atvd[n][m];
    if (memo[n][m] != -1) return memo[n][m];
    if (m == 0) memo[n][m] = max(dp(n-1, 1) + atvd[n][m], dp(n-1, 2) + atvd[n][m]);
    if (m == 1) memo[n][m] = max(dp(n-1, 0) + atvd[n][m], dp(n-1, 2) + atvd[n][m]);
    if (m == 2) memo[n][m] = max(dp(n-1, 1) + atvd[n][m], dp(n-1, 0) + atvd[n][m]);

    return memo[n][m];

}


int main(){
    int n;
    cin >> n;
    atvd.assign(n, vi(3, 0));
    memo.assign(n, vi(3, -1));
    for (int i = 0; i < n; i++)
        for(int j = 0 ; j < 3; j++){
            ll a;
            scanf("%lld", &a);
            atvd[i][j] = a;
        }

    printf("%lld\n", max(dp(n-1, 2), max (dp(n-1, 0), dp(n-1, 1))));
    // for (int i = 0; i < n; i++){
    //     for(int j = 0 ; j < 3; j++){
    //         printf("%lld ", memo[i][j]);
    //     }
    //     printf("\n");
    // }
}


Measured memory_bytes: 15872
n, K = map(int,input().split())
A = list(map(int,input().split()))
b = [0 for _ in range(n+1)]

for _ in range(K):
    for i,a in enumerate(A):
        b[max(0, i-a)] += 1
        b[min(n, i+a+1)] -= 1

    for i in range(n):
        b[i+1] += b[i]
    A = b[:-1]
    b = [0 for _ in range(n+1)]
    if sum(A) == n*n:
        break
    
print(*A)

Measured memory_bytes: 170984
A,B,C,D = map(int,input().split())
count="senko"
while A>0 and C>0:
    if count == "senko":
        C = C-B
        count ="koko"
    else:
        A = A-D
        count="senko"
if A > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61664
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int main() {
    int n,m,num,rec,ans;
    cin>>n;
    vector<int>hp(n);
    rep(i,n)cin>>hp[i];
    ans=hp[0];
    for(int g=1;g<n;g++){
        if(ans!=1){
            ans=gcd(ans,hp[g]);
        }
    }
    
    cout<<ans;
    return 0;
}



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

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var t = int.Parse(line[1]);
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var pts = TimeSpan.Parse(line2[2]);
        var pst = line2[3];
        var stcount = 0;
        var anslist = new List<string>();
        for (int i = 1; i < n; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            var ts = TimeSpan.Parse(s[0]) - pts;
            var ts2 = ts.Hours * 60 + ts.Minutes;
            if (ts2 >= t)
            {
                anslist.Add(pst);
                anslist.Add(ts2.ToString());
                stcount++;
            }
            pts = TimeSpan.Parse(s[2]);
            pst = s[3];
        }
        Console.WriteLine(stcount);
        for (int i = 0; i < anslist.Count(); i += 2)
            Console.WriteLine("{0} {1}", anslist[i], anslist[i + 1]);
    }
}

Measured memory_bytes: 9656
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

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

ll d[40];
void solve(){

}
void show(){
  for(int i=0;i<40;i++){
    cout<<i<<":"<<d[i]<<endl;
  }
}
void init(){
  fill(d,d+40,0);
  d[1]=1;
  d[2]=2;
  d[3]=4;
  for(int i=4;i<31;i++){
    d[i]=d[i-3]+d[i-2]+d[i-1];
  }
}
int main(){
  int n;
  init();
  while(cin >> n,n){
    cout<<(d[n]/3650)+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    y, m, d = input().split('/')
    ymd = int(y + m + d)
    if ymd <= 20190430:
        print('Heisei')
    else:
        print('TBD')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<tuple>
#define FIRST (ll)(1e15)
#define MAX_N 110000
#define INF 10000000000000000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
typedef struct{
  ll to,cost;
}edge;
vector<edge> MG[MAX_N],SG[MAX_N];
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;
  t--;
  vector<ll> u(m),v(m),a(m),b(m),dbest(MAX_N,INF),sbest(MAX_N,INF);
  for(int i=0;i<m;i++){
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--;
    v[i]--;
    MG[u[i]].push_back({v[i],a[i]});
    MG[v[i]].push_back({u[i],a[i]});

    SG[u[i]].push_back({v[i],b[i]});
    SG[v[i]].push_back({u[i],b[i]});
  }
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(P(0,s));
  while(!que.empty()){
    P tmp = que.top();
    que.pop();
    ll d = tmp.first;
    ll v = tmp.second;
    if(dbest[v]<=d) continue;
    dbest[v] = d;
    for(auto nv:MG[v]){
      ll nd = nv.cost+d;
      if(dbest[nv.to]>nd){
        que.push(P(nv.cost+d,nv.to));
      }
    }
  }

  que.push(P(0,t));
  while(!que.empty()){
    P tmp = que.top();
    que.pop();
    ll d = tmp.first;
    ll v = tmp.second;
    if(sbest[v]<=d) continue;
    sbest[v] = d;
    for(auto nv:SG[v]){
      ll nd = nv.cost+d;
      if(sbest[nv.to]>nd){
        que.push(P(nv.cost+d,nv.to));
      }
    }
  }
  vector<ll> ans;
  ll best = 0;
  for(int i=n-1;i>=0;i--){
    best = max(best,FIRST-dbest[i]-sbest[i]);
    ans.push_back(best);
  }
  reverse(ans.begin(),ans.end());
  for(auto a:ans){
    cout << a<<endl;
  }
}


Measured memory_bytes: 23416
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;
const long long max_cache=1000000;
long long cache_fact[max_cache],cache_inv_fact[max_cache];
long long combination_cached(long long n,long long r){
  if(r<0||r>n)return 0;
  if(r==0||r==n)return 1;
  ll m=MOD;
  if(n>m){
    std::cerr<<"Combination Error: n is greater than m"<<std::endl;
    exit(1);
  }
  static bool cached=false;
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i < max_cache; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    for (long long i = 2; i < max_cache; i++){
      cache_inv_fact[i]=cache_inv_fact[i]*cache_inv_fact[i-1]%m;
    }
    cache_fact[0]=1;
    for (long long i = 1; i < max_cache; i++) {
      cache_fact[i]=cache_fact[i-1]*i%m;
    }
  }
  r=min(r,n-r);
  return cache_fact[n]*cache_inv_fact[r]%m*cache_inv_fact[n-r]%m;
}
template<typename T>
T modpow(T a,unsigned long long b){
  T base=a,ans=T(1LL);
  while(b){
    if(b&1){
      ans=ans*base%MOD;
    }
    base=base*base%MOD;
    b>>=1;
  }
  return ans;
}
void solve(long long N, long long M, long long K){
  ll ans=0;
  REP(K+1){
    ll cur=M*combination_cached(N-1,i)%MOD;
    cur=cur*modpow(M-1,N-1-i)%MOD;
    ans=(ans+cur)%MOD;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 19388
def main():
    n, m = map(int, input().split())
    p = []
    for i in range(m):
        p.append(input().split())

    if m == 0:
        print(0, 0)
        return 
    else:
        wa = [0 for i in range(n+1)]
        ac = [0 for i in range(n+1)]

        for pro, s in p:
            if ac[int(pro)] == 0:
                if s == 'WA':
                    wa[int(pro)] += 1
                elif s == 'AC':
                    ac[int(pro)] += 1
        
        sum_wa = 0
        for isac, iswa in zip(ac, wa):
            if isac == 1:
                sum_wa += iswa

        print(sum(ac), sum_wa)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 39872
s = input()
n = len(s)
count = 0
for l in range(0,n):
    for r in range(l,n):
        x = int(s[l:r+1])
        if l >= 2:
            ln = 2**(l-1)
        else:
            ln = 1
        if r <= n-3:
            rn = 2**(n-2-r)
        else:
            rn = 1
        count += rn*ln*x
print(count)

Measured memory_bytes: 38384
let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let f () = List.map int_of_string (split (read_line ()) ' ')

let dfs g n =
  let v = Array.make n (-1) in
  let rec dudu j = function
    | [] -> ()
    | hd :: tl when v.(hd) = (-1) -> (wa hd j; dudu j tl)
    | _ :: tl -> dudu j tl
  and wa i j = v.(i) <- j; dudu j g.(i)
  and doit i =
    if i < n then (if v.(i) = (-1) then wa i i; doit (i + 1))
  in
  doit 0;
  v

let () =
  match f () with
  | [n;m] -> begin
      let g = Array.make n [] in
      let rec read i =
        if i < m then
          match f () with
          | [s;t] -> begin
              g.(s) <- t :: g.(s);
              g.(t) <- s :: g.(t);
              read (i + 1)
            end
          | _ -> exit 1
      in
      read 0;
      let v = dfs g n in
      let q = read_int () in
      let rec read_q i =
        if i < q then begin
          match f () with
          | [s;t] -> begin
              print_endline (if v.(s) = v.(t) then "yes" else "no");
              read_q (i + 1)
            end
          | _ -> exit 1
        end
      in
      read_q 0
    end
  | _ -> exit 1

Measured memory_bytes: 14028
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

// Z-algorithm. O(|S|)
// sとs[i:|s|-1]の最長共通接頭辞の長さiを記録した配列．
// https://snuke.hatenablog.com/entry/2014/12/03/214243
vi z_algo(string s){
    vi A(s.size());
    A[0] = s.size();
    int i = 1, j = 0;
    while(i < s.size()){
        while(i+j < s.size() && s[j] == s[i+j]) j++;
        A[i] = j;
        if(j == 0){ i++; continue; }
        int k = 1;
        while(i+k < s.size() && k+A[k] < j) A[i+k] = A[k], k++;
        i += k, j -= k;
    }
    return A;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n;
    string s;
    cin >> n;
    cin >> s;

    int ans = 0;
    rep(i,n){
        vi A = z_algo(s.substr(i,s.size()));
        rep(j,A.size()){
            if(j+1 > A[j]) ans = max(ans, A[j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        
        String ans;

        var a = scaner.next();
        if (Character.isUpperCase(a.toCharArray()[0])) {
            ans = "A";
        } else {
            ans = "a";
        }

        System.out.println(ans);

        scaner.close();
    }

}


Measured memory_bytes: 35740
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<n+1; i++)
#define repr(i,n) for(ll i=n-1; i>=0; i--)
#define repr1(i,n) for(ll i=n; i>0; i--)
#define FOR(i,j,n) for(ll i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(ll i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<ll,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;
const string yes = "Yes";
const string no = "No";

//----------------------------------------------




int main(){
	ll n,m;
	cin >> n >> m;
	dsu d(n);

	rep(i,m){
		ll a,b;
		cin >> a >> b;
		a--;b--;
		d.merge(a,b);
	}
	vector<vector<int>> tmp = d.groups();
	prints(tmp.size()-1);


	return 0;
}




Measured memory_bytes: 8884
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

enum mod = 1_000_000_007L;




void main() {
    int W, H, N;
    scan(W, H, N);
    int l = 0, r = W;
    int d = 0, u = H;
    foreach (i ; 0 .. N) {
        int xi, yi, ai;
        scan(xi, yi, ai);
        if (ai == 1) {
            chmax(l, xi);
        }
        else if (ai == 2) {
            chmin(r, xi);
        }
        else if (ai == 3) {
            chmax(d, yi);
        }
        else {
            chmin(u, yi);
        }

        debug {
            writefln("%s, %s", l, r);
            writefln("%s, %s", d, u);
        }
    }

    auto ans = max(0, r - l) * max(0, u - d);
    writeln(ans);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	int selectionSort(int[] lst){
		int n=lst.length;
		int count=0;
		for(int i=0;i<n-1;i++){
			int min=Integer.MAX_VALUE;
			for(int j=i;j<n;j++){min=Math.min(min, lst[j]);}
			if(min==lst[i]){continue;}
			for(int j=i+1;j<n;j++){
				if(min==lst[j]){
					int x=lst[i];
					lst[i]=lst[j];lst[j]=x;
					count++;break;
				}
			}
		}
		return count;
	}
	
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    int n=sc.nextInt();
	    int[]x=new int[n];
	    for(int i=0;i<n;i++){x[i]=sc.nextInt();}
	    int c=new Main().selectionSort(x);
	    for(int i=0;i<n;i++){
	        if(i==0){System.out.printf("%d",x[i]);continue;}
	        System.out.printf(" %d",x[i]);
	    }
	    System.out.printf("\n%d\n",c);
	}
}


Measured memory_bytes: 26568
h, w = [int(i) for i in input().split()]
a = [["#" for _ in range(w+2)] for _ in range(h+2)]
print("".join(["#" for _ in range(w+2)]))
for _ in range(h):
    print("#{}#".format(input()))
print("".join(["#" for _ in range(w+2)]))


Measured memory_bytes: 3060
s=list(str(input()))

s1=(int("".join(s[:2])))
s2=(int("".join(s[2:])))

if 1<=s1<=12 and 1<=s2<=12:
            print('AMBIGUOUS')

elif  1<=s2<=12:
            print('YYMM')
elif  1<=s1<=12 :
            print('MMYY')
else:
            print('NA')
                 


      


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

const int MN = 410;
V<ll> sa;
ll dp[MN][MN];
bool vis[MN][MN];
ll solve(int l, int r) {
    if (l == r) return 0;
    if (vis[l][r]) return dp[l][r];
    vis[l][r] = true;
    ll ans = TEN(18);
    for (int m = l + 1; m <= r; m++) {
        ans = min(ans, solve(l, m-1) + solve(m, r));
    }
    ans += sa[r + 1] - sa[l];
    return dp[l][r] = ans;
}

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

    int n;
    cin >> n;
    V<ll> a(n);
    sa = V<ll>(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sa[i + 1] = sa[i] + a[i];
    }
    cout << solve(0, n-1) << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i=0;i<n;i++) {
			h[i]=sc.nextInt();
		}
		long[] cost = new long[n];
		cost[0]=0;
		cost[1]=Math.abs(h[1]-h[0]);
		for (int i=2;i<n;i++) {
			cost[i]=Math.min(cost[i-1]+Math.abs(h[i]-h[i-1]), cost[i-2]+Math.abs(h[i]-h[i-2]));
		}
		System.out.println(cost[n-1]);
	}

}

Measured memory_bytes: 50000
#include <stdio.h>

int main(void) {
  int a;
  int b;
  int c;
  char buf1[20];
  fgets(buf1, 20, stdin);
  sscanf(buf1, "%d" "%d"" %d" , &a, &b, &c);
  
  if(a <= c && b >= c){
  printf("Yes \n");
  }
  else{
  printf("No \n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int k = 0;
    int cur = 1;
    for (int i = 0; i < n; i++){
        if (a[i] == cur){
            cur++;
        }
    }
    int ans;
    if (cur == 1) ans = -1;
    else ans = n-cur+1;
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3988
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(int[]);
    auto N = nx[0];
    auto x = nx[1];

    auto as = readln.split.to!(int[]);
    sort(as);
    int cnt;
    foreach (a; as) {
        if (a <= x) {
            ++cnt;
            x -= a;
        } else {
            writeln(cnt);
            return;
        }
    }
    if (x) --cnt;
    writeln(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
 string S;
 cin >> S;
 int K;
 cin >> K;
  vector<string> a;
  for(int i = 0;i<S.size();i++){
    for(int j = 1;j<=5 && j<=S.size()-i;j++){
      a.push_back(S.substr(i,j));
    }
  }
  
  sort(a.begin(),a.end());
  unique(a.begin(),a.end());

  cout << a[K-1] << endl;
 }


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  long long int i=0;
  cin >> a >> b;
  for(i=0;i<(a>b?a:b);i++){
    if(abs(a-i)==abs(b-i)){
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 384
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 7 * 17 * (1 << 23) + 1;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string s, t;
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	map<string, int> a;
	a["SUN"]=7, a["MON"]=6, a["TUE"]=5, a["WED"]=4, a["THU"]=3, a["FRI"]=2, a["SAT"]=1;
	string t;
	cin>>t;
	cout << a[t];
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// void initiate_random() { mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count()); }

// /mnt/c/Users/vince/Desktop/POST-IOI/Codeforces/Regular/670

const long MOD = 1e9+7;
long dp[2003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int s; scanf("%d", &s);
	
	dp[0] = 1;
	for(int j = 3; j <= s; j++)
	{
		for(int k = 3; k <= j; k++)
		{
			dp[j] += dp[j-k];
			dp[j] %= MOD;
		}
	}
	printf("%lld\n", dp[s]);
	
}

Measured memory_bytes: 3820
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc068.contest.atcoder.jp/tasks/arc068_c>
 問題文============================================================
 すぬけくんは鉄道会社を運営するゲームで遊ぶことにしました。
 すぬけ鉄道には M+1 個の駅があり、 0 から M までの番号がついています。
 すぬけ鉄道の列車は駅 0 から d 駅ごとに停車します。 例えば d=3 のとき駅 0,駅 3,駅 6,駅 9, … に停車します。
 
 すぬけ鉄道が走っている地域には N 種類の名産品があり、
 種類 i の名産品は 駅 li,駅 li+1,駅 li+2, …, 駅 ri のいずれかに列車が停車したとき購入することが可能です。
 
 列車が停車する間隔 d は 1,2,3,…,M の M 種類が存在しています。
 M 種類の列車それぞれについて、その列車に駅 0 で乗車した場合に購入可能な名産品の種類数を求めなさい。
 なお、列車から別の列車への乗り換えは許されないものとします。
 
 =================================================================
 解説=============================================================
 ================================================================
 */

struct BIT {
    ll N;
    vector<ll> bit;
    BIT(ll N):N(N) {
        /* BITは[1..N]で扱う */
        bit.resize(N + 1, 0);
    }
    
    void add(int x, int val){
        while (x <= N) {
            bit[x] += val;
            x += x & -x;
        }
    }
    
    int sum(int x){
        int ret = 0;
        while (x) {
            ret += bit[x];
            x &= (x - 1);
        }
        return (ret);
    }
};

void solve(){
    int N,M; cin >> N >> M;
    vector<pii> lr(N);
    for(auto& in:lr) cin >> in.first >> in.second;
    vector<vector<pii>> sec(M+2);
    for(auto& p:lr){
        sec[p.second-p.first+1].push_back(p);
    }
    BIT bit(M+2);
    ll incl = 0;
    for(int d = 1; d <= M;d++){
        for(auto p:sec[d-1]){
            bit.add(p.first,1);
            bit.add(p.second+1,-1);
        }
        incl += sec[d-1].size();
        ll out = N - incl;
        for(int x = d; x <= M; x += d){
            out += bit.sum(x);
        }
        cout << out << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;

    ll A[N];
    ll B[N];
    for (ll i = 0; i < N; i++)
    {
        cin >> A[i] >> B[i];
    }

    map<pair<ll, ll>, ll> mp;
    for (ll i = 0; i < N; i++)
    {
        for (ll k = -1; k <= 1; k++)
        {
            for (ll j = -1; j <= 1; j++)
            {
                if (2 <= k + A[i] && k + A[i] <= H - 1 && 2 <= j + B[i] && j + B[i] <= W - 1)
                {
                    mp[make_pair(k + A[i], j + B[i])]++;
                }
            }
        }
    }

    vector<ll> ans(10);
    ll sum = 0;
    for (auto p : mp)
    {
        ans[p.second]++;
        sum++;
    }

    ans[0] = (H - 2) * (W - 2) - sum;

    for (ll i = 0; i < 10; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

int N, Y, x = -1, y = -1, z = -1;

int main() {
    cin >> N >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; i + j <= N; j++) {
            if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
                x = i, y = j, z = (N - i - j);
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

// snukeさんのmodint
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// mint N;
//cout << N.x << endl;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vector<ll> A(5);
    for(int i=0; i<5; i++){
        cin >> A[i];
    }
    ll mx = 0;
    for(int i=0; i<5; i++){
        chmax(mx,(N+A[i]-1LL)/A[i]);
    }
    cout << 4 + mx << enld;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

int main(void){
    int n;
    string s = "";
    cin >> n;
    
    if (n == 0) s = "0";
    
    while (n != 0) {
        if (n % 2 != 0) s += "1";
        else s += "0";
        if (n < 0) {
            if (n % 2 == 0) n = (-n) / 2;
            else n = (-n) / 2 + 1;
        }
        else n = - n / 2;
    }
    
    for (int i = 0; i < s.size(); i++) {
        cout << s[s.size() - 1 - i];
    }
    cout << endl;
    
    
}


Measured memory_bytes: 384
int main(int argc, const char * argv[]) {
    int i,j,num;
    int y=0;
    int trump[4][13]={0};
    char c;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%c %d",&c,&y);
        if(c=='\n'){
            scanf("%c %d",&c,&y);
        }
        if(c=='S'){
            trump[0][y-1]=1;
        }else if(c=='H'){
            trump[1][y-1]=1;
        }else if(c=='C'){
            trump[2][y-1]=1;
        }else if(c=='D'){
            trump[3][y-1]=1;
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(trump[i][j]==0){
                switch(i){
                    case 0:
                        printf("S %d\n",j+1);
                        break;
                    case 1:
                        printf("H %d\n",j+1);
                        break;
                    case 2:
                        printf("C %d\n",j+1);
                        break;
                    case 3:
                        printf("D %d\n",j+1);
                        break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    if(n<b) cout<<(a*n)/b<<endl;
    else cout<<(a*(b-1))/b<<endl;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long gcd( long a, long b )
{
	long tmp;

	if ( a <= b )
	{
		tmp = a;
		a = b;
		b = tmp;
	}

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

long lcm( long a, long b, long GCD )
{

	return ( a * b )/GCD;
}

int main()
{
	long tmp;
	long a, b;

	while ( scanf( "%ld %ld", &a, &b ) != EOF )
	{

		tmp = gcd( a, b );
		fprintf( stdout, "%ld ", tmp );
		fprintf( stdout, "%ld\n", lcm( a, b, tmp ) );	
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=2e3+10;
int A[MAX];
int main (){
    int N,x;cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
    }
    sort(A+1,A+1+N);
    ll res = 0;
    for(int i=1;i<=N-2;i++){
            for(int j=i+1;j<=N-1;j++){
                bool f=0;
                for(int k=j+1;k<=N;k++){
                    if(A[i]+A[j]>A[k]){
                        res++;
                    }
                }
            }
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    long long N,i;
    scanf("%lld",&N);
    long long a[N];
    long long b[N+1];
    for(i=1;i<=N;i++)
      b[i]=0;
    for(i=0;i<N-1;i++)
    {
      scanf("%lld",&a[i]);
      b[a[i]]++;
    }
    for(i=1;i<=N;i++)
    {
      printf("%lld\n",b[i]);
    }
    return 0;
}

Measured memory_bytes: 4736
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n; cin >> n;
  double s = 0;
  for (int i = 1; i <= n; i++) {
    double t; cin >> t;
    s += 1 / t;
  }
  cout << fixed << setprecision(10);
  cout << 1 / s << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3820
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int main() {
    int N;cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++)cin >>retu.at(i);
    int ans = 0;
    for(int i = 0;i<N;i++){
        int A = retu.at(i);
        while(A%2 == 0){
            ans++;
            A /= 2;
        }
    }

    cout << ans << endl;


    

    // PLEASE GIVE ME THE "ACCEPTED" !
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, a, b, c, k);
  rep(ai, k + 1) rep(bi, k + 1) rep(ci, k + 1) if (ai + bi + ci <= k) {
    int A = a << ai, B = b << bi, C = c << ci;
    if (A < B && B < C) {
      out("Yes");
      return 0;
    }
  }
  out("No");
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    
    int n, k;
    cin >> n >> k;

    long double ans = 0.0;

    FOR(i, 1, n + 1)
    {
        long double tmp = 1.0 / n;

        int cnt = 0;
        while(i * pow(2, cnt) < k)
        {
            tmp /= 2.0;
            cnt++;
        }
        ans += tmp;
    }

    cout << ans << endl;
}

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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n,m;
vector<int> v[100005];
int dp[100005];

int f(int idx){
    int &ret=dp[idx];
    if(ret!=-1)
        return ret;
    ret=0;
    for(int i=0;i<v[idx].size();i++){
        ret=max(ret,f(v[idx][i])+1);
    }
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>m;
        for(int i=0;i<m;i++){
            int x,y;
            cin>>x>>y;
            v[x].push_back(y);
        }
        memset(dp,-1,sizeof dp);
        int ans=1;
        for(int i=1;i<=n;i++){
            ans=max(ans,f(i));
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 11728
#include <iostream>
using namespace std;
int main()
{
	int n,a,b,maxs=0,y=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		if(maxs<=a)
		{
			maxs=a;y=b;
		}
	} 
	printf("%d\n",maxs+y);
	return 0;
}

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


int main(){



    long long int a[4];
    for(int i=0; i<4; i++){
        cin >> a[i];
    }
    long long int m=a[0]*a[2];
    for(int i=0; i<2; i++){
        for(int j=2; j<4; j++){
            m = max(m,a[i]*a[j]);
        }
    }

    cout << m <<endl;
}

Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

import bisect
a.sort()
b.sort()
c.sort()
ans = 0
for i in range(len(b)):
    ab = bisect.bisect_right(a,b[i]-1) # b[i]より真に小さいaの要素数
    bc = len(c) - bisect.bisect_left(c,b[i]+1) # b[i]より真に大きいcの要素数
    ans += ab*bc
print(ans)

Measured memory_bytes: 23328
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
long long a,b,c;
int main()
{
	cin>>a>>b>>c;
	cout<<(a+b)*c/2<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
*l, = map(int, input().split())

ans = []
for _ in range(N):
    for i in range(len(l))[::-1]:
        if l[i]==(i+1):
            ans.append(l[i])
            del l[i]
            break
        
if l:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)


Measured memory_bytes: 3060