akhauriyash/Code-Regression huggingface dataset:
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	vector<ll> v(n);
	for(int i=0;i<n;++i) cin >> v[i];
	ll ans=0;
	for(int i=0;i<n-1;++i)
	{
		if(v[i]>=v[i+1])
		{
			ans+=v[i]-v[i+1];
			v[i+1]=v[i];
		}
	}
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

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

int main(){
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

int main() {
	in(int, x1, y1, x2, y2);
	int x3, y3, x4, y4;
	int x1x2 = x2-x1;
	int y1y2 = y2-y1;
	//out(x1x2, y1y2);
	x3 = x2 - y1y2;
	y3 = y2 + x1x2;
	x4 = x3 - x1x2;
	y4 = y3 - y1y2;
	out(x3, y3, x4, y4);
}



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

int main() {
  string s;
  cin >> s;
  ll res = 0;
  rep(i, s.size()) {
    if (i%2) {
      if (s.at(i) == 'g') res++;
    } else {
      if (s.at(i) == 'p') res--;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int k,s;cin >> k >> s;
  int ans = 0;
  for(int x=0;x<=k;++x){
    for(int y=0;y<=k;++y){
      int z = s-(x+y);
      if(z<=k && z >= 0)ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; 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 MODNUM 1000000007

using ll = long long;
using namespace std;

int main(){
    string S;
    cin >> S;

    ll ans = 0;
    int N = (int)S.size()-1;

    //R個の全探索(2^R通り)
    for (int bit = 0; bit < (1 << N); bit++) {
        int tmp = -1;
        for (int i = 0; i < N; i++) {
            //i番目のビットが立っていた時の処理
            if (bit & (1<<i)) {
                string subS = S.substr(tmp+1, i-tmp);
                ll t = 0;
                rep(j,subS.size()) {
                    t += (subS[j] - '0');
                    if(j != (int)subS.size()-1) t *=10;
                }
                ans += t;
                tmp = i;
            }
        }
        
        string subS = S.substr(tmp+1);
        ll t = 0;
        rep(j,subS.size()) {
            t += (subS[j] - '0');
            if(j != (int)subS.size()-1) t *=10;
        }
        ans += t;
    }
    
    cout << ans << endl;
    return 0;
}


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

void copyStringArray(char **, char **, int);

main() {

  int n;
  char **o; //入力された配列
  char **b; //BubbleSort
  char **s; //SelectionSort
  char *tmp;

  int i, j, minj;



  scanf("%d", &n);

  o = (char **)malloc(sizeof(char *) *n);
  for( i=0; i<n; i++) {
    o[i] = (char *)malloc(sizeof(char) *3);
  }
  b = (char **)malloc(sizeof(char *) *n);
  for( i=0; i<n; i++) {
    b[i] = (char *)malloc(sizeof(char) *3);
  }
  s = (char **)malloc(sizeof(char *) *n);
  for( i=0; i<n; i++) {
    s[i] = (char *)malloc(sizeof(char) *3);
  }

  for( i=0; i<n; i++) {
    scanf("%s", o[i]);
  }

  for( i=0; i<n; i++) { 
    strcpy(b[i], o[i]);
    strcpy(s[i], o[i]);
  }

  
  //BubbleSort
  for( i=0; i<n; i++) {
    for( j=n-1; j>i; j--) {
      if( b[j][1] < b[j-1][1] ) {
	tmp = b[j];
	b[j] = b[j-1];
	b[j-1] = tmp;
      }
    }
  }
  
  //SelectionSort
  for( i=0; i<n; i++) {
    minj = i;
    for( j=i; j<n; j++) {
      if( s[j][1] < s[minj][1] ) {
	minj = j;
      }
    }
    if(s[i][1] != s[minj][1]) {
      tmp = s[i];
      s[i] = s[minj];
      s[minj] = tmp;
    }
  }


  for( i=0; i<n-1; i++) {
    printf("%s ", b[i]);
  }
  printf("%s\nStable\n", b[n-1]);


  for( i=0; i<n-1; i++) {
    printf("%s ", s[i]);
  }
  printf("%s\n", s[n-1]);
  for( i=0; i<n; i++) {
    if(strcmp(b[i], s[i]) != 0) {
      printf("Not stable\n");
      break;
    }
  }
  if(i == n){
    printf("Stable\n");
  }
      
  return 0;

}

Measured memory_bytes: 624
<?php
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($N,$D) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$ans=1;
switch($S) {
case "SSS":
  $ans=0;
  break;
case "RRS":
case "SRR":
  $ans=2;
  break;
 case "RRR":
   $ans=3;
   break;
}
printf("%d\n",$ans);

Measured memory_bytes: 15968
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define NIL -1
#define LENGTH 500005

typedef struct node{
  int key;
  struct node *p;
  struct node *l;
  struct node *r;
} Tree;

Tree *root = NULL;
void insert(int key){
  Tree *z = (Tree*)malloc(sizeof(Tree));
  z -> key = key;
  z -> l = NULL;
  z -> r = NULL;
  Tree *x, *y;
  x = root;
  y = NULL;
  while(x != NULL){
    y = x;
    if(z -> key < x -> key)
      x = x -> l;
    else
      x = x -> r;
  }
  z -> p = y;
  if(y == NULL)
    root = z;
  else if(z -> key < y -> key)
    y -> l = z;
  else
    y -> r = z;
}
void printInorder(Tree *u){
  if(u == NULL)
    return;
  printInorder(u -> l);
  printf(" %d", u -> key);
  printInorder(u -> r);
}
void printPreorder(Tree *u){
  if(u == NULL)
    return;
  printf(" %d", u -> key);
  printPreorder(u -> l);
  printPreorder(u -> r);

}
Tree* find(Tree *u, int key){
  while(u != NULL && u -> key != key){
    if(key < u -> key)
      u = u -> l;
    else
      u = u -> r;
  }
  return u;
}
int main(){
  int n, key;
  char line[100];
  char *str_ptr;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &n);
  for(int i = 0; i < n; ++i){
    fgets(line, sizeof(line), stdin);
    if(strcmp(line, "print") == 0 || strcmp(line, "print\n") == 0){
      printInorder(root);
      printf("\n");
      printPreorder(root);
      printf("\n");
    }else{
      str_ptr = strtok(line, " ");
      if(strcmp(str_ptr, "insert") == 0){
        str_ptr = strtok(NULL, " ");
        sscanf(str_ptr, "%d", &key);
        insert(key);
      }else if(strcmp(str_ptr, "find") == 0){
        str_ptr = strtok(NULL, " ");
        sscanf(str_ptr, "%d", &key);
        Tree *tmp = find(root, key);
        if(tmp != NULL)
          printf("yes\n");
        else
          printf("no\n");
      }
    }
  }
  return 0;
}



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

#define sz(a) (int)a.size()
#define re return
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define gr greater <int>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

using namespace std;

typedef long long ll;
typedef string str;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;

ll n, k, a[200001], ans = 1, b[200001];
vll v;
set <ll> s;

///!!!<3<3<3<3<3!!!
void ProdamGaraje () {
   cin >> n >> k;
   for (ll i = 0; i < n; ++i)
      cin >> a[i];
   if (n >= k) {
      for (ll i = 0; i < k; ++i)
         ans = a[ans - 1];
      cout << ans;
      re;
   }
   v.pb(1);
   while (1) {
      s.insert(a[ans - 1]);
      ans = a[ans - 1];
      v.pb(ans);
      if (s.find(a[ans - 1]) != s.end())
         break;
   }
   for (ll i = 0; i < sz(v); ++i) {
      b[i] = a[ans - 1];
      ans = a[ans - 1];
   }
   ll d = sz(v) - 1;
   while (b[d] != b[0])
      d--;
   ans = 1;
   while (b[0] != ans) {
      k--;
      ans = a[ans - 1];
   }
   cout << b[k % d];
}
///!!!<3<3<3<3<3!!!
int main () {
   //freopen ("input.txt", "r", stdin);
   //freopen ("output.txt", "w", stdout);
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int tt = 1;
   //cin >> tt;
   while (tt--)
      ProdamGaraje ();
}
///GOOOOOOSE!!!!
/*
     ▄▀▀▀▄
▄███▀░0░░░▌
    ▌░░░░░▐
    ▌░░░░░▐
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
   ▄▄▌▌▄▌▌        */


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if(x<a)
        cout << 0 << endl;
        else
            cout << 10 << endl;
        return 0;

}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

        Scanner scan = new Scanner(System.in);
        Map<Integer, Integer> map = new HashMap<>();

        for(int i = 0; i < 3;i++){
            int k = scan.nextInt();
            map.put(k, map.getOrDefault(k,0)+1);
        }

        if(map.get(5) == 2 && map.get(7) ==1){
            System.out.println("YES");
            return;
        }

        System.out.println("NO");
    }
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS


const int maxn=2e6;
const ll mod=1e9+7;
ll fact[maxn],inv[maxn],ifact[maxn];

void calcInv(){
    for(int i=0;i<2;i++){
        fact[i]=1;
        ifact[i]=1;
        inv[i]=1;
    }
    for(int i=2;i<maxn;i++){
        fact[i]=(i*fact[i-1])%mod;
        ll q=mod/i,r=mod%i;
        inv[i]=(-q*inv[r])%mod;
        inv[i]=(inv[i]+mod)%mod;
        ifact[i]=(inv[i]*ifact[i-1])%mod;
    }
}

ll ncr(int n, int r){
	if(n<r){
		return 0;
	}
	ll tmp = (fact[n]*ifact[n-r])%mod;
	return (tmp*ifact[r])%mod;
}

int main(){
	fastread;
	calcInv();
	ll h,w,a,b;
	cin>>h>>w>>a>>b;

	ll ans = 0;
	for(ll i=b;i<w+h-2;i++){
		if(i-b >= h-a) break;
		ans += (ncr(i-1,b-1) * ncr(h+w-2-i,w-1-b))%mod;
		ans %= mod;
		// cout<<(ncr(i-1,b-1) * ncr(h+w-2-i,w-1-b))%mod<<endl;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 47104
n = int(input())
p = list(map(int,input().split()))

ans = 1
dotira = False
s = 10**18

if 0 in p :
  print(0)

else:
  
  for x in p:
    ans = ans * x
    if ans > s:
      dotira = True
      break
  if dotira:
    print(-1)
  else:
    print(ans)

    


Measured memory_bytes: 21592
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    // 2要素変換
    let element1: i32 = iter.next().unwrap().parse().unwrap();
    let element2: i32 = iter.next().unwrap().parse().unwrap();
    let element3: i32 = iter.next().unwrap().parse().unwrap();

    let mut counter = 0;
    for num in element1..(element2 + 1) {
        if element3 % num == 0 {
            counter += 1
        };
    }
    println!("{}", counter);
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll N =3003;
string s,t;
ll dp[N][N],x[N][N],n,k;
pair<ll,ll> p[N][N];
vector<char> ans;

void solve(ll u, ll v)
{
	if(u+v==0)return;
	if(x[u][v]==1)ans.pb(s[u]);
	solve(p[u][v].F,p[u][v].S);
}

int main()
{
    ios_base::sync_with_stdio(false);

    clr(dp);clr(x);
	cin>>s>>t;s="*"+s;t="#"+t;n=sz(s);k=sz(t);
	forn(i,n){if(i!=0)dp[i][0]=dp[i-1][0],p[i][0]=mp(i-1,0);if(s[i]==t[0])dp[i][0]=x[i][0]=1;}
	forn(j,k){if(j!=0)dp[0][j]=dp[0][j-1],p[0][j]=mp(0,j-1);if(t[j]==s[0])dp[0][j]=x[0][j]=1;}

	for(int i=1;i<n;i++)for(int j=1;j<k;j++)
	{
		if(dp[i-1][j]>dp[i][j] ) dp[i][j] = dp[i-1][j],p[i][j]=mp(i-1,j);
		if(dp[i][j-1]>dp[i][j] ) dp[i][j] = dp[i][j-1],p[i][j]=mp(i,j-1);
		if(dp[i-1][j-1] + (s[i]==t[j]) > dp[i][j]){dp[i][j]=dp[i-1][j-1] + (s[i]==t[j]);p[i][j]=mp(i-1,j-1);x[i][j]=1;}
	}
	solve(n-1,k-1);
	//cout<<dp[n-1][k-1]<<endl;
	reverse(all(ans));
	for(char c:ans)cout<<c;
}


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

int main(){
  char c;
  string s;
  cin >> c;
  if (islower(c)) cout << 'a' << endl;
  else cout << 'A' << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	char s[N+1];
	int cnt=0;
	scanf("%s",s);
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') cnt++;
	}
	if (cnt > N/2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}	
vector<int> getPrimes(int n){
	vector<int> res;
	bool isPrime[n+1];
	for(int i=0;i<=n;i++)isPrime[i]=1;
	isPrime[0]=isPrime[1]=0;
	for(int i=2;i<=sqrt(n);i++){
		if(isPrime[i]&&(i*i)<=n){
			for(int j=i*i;j<=n;j+=i){
				isPrime[j]=0;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(isPrime[i])res.p_b(i);
	}
	return res;
}
int32_t main(){
 	fastIO;
 	int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
 	int r[a],g[b],no[c];
 	for(int i=0;i<a;i++)cin>>r[i];
 	for(int i=0;i<b;i++)cin>>g[i];
 	for(int i=0;i<c;i++)cin>>no[i];
 	sort(r,r+a);sort(g,g+b);
 	vector<int> tot;
 	for(int i=a-1;i>=a-x;i--)tot.p_b(r[i]);
 	for(int i=b-1;i>=b-y;i--)tot.p_b(g[i]);
 	for(int i=0;i<c;i++)tot.p_b(no[i]);
 	sort(tot.begin(),tot.end());
 	int sum=0;
 	for(int i=tot.size()-1;i>=tot.size()-x-y;i--)sum+=tot[i];
 	cout<<sum<<endl;
} 	

Measured memory_bytes: 8688
N = int(input())
g = [[-1]*N for i in range(N)] #何も証言していないのを-1。i番目の人がj番目の人を正直ものといっているか、不親切といっているか、なにもいってないか。

for i in range(N):
    A = int(input())
    for j in range(A):
        a,x = map(int, input().split())
        a -= 1
        g[i][a] = x
ans = 0
for i in range(1 << N):
    d=[0]*N
    for j in range(N):
        if (i>>j & 1):
            d[j] = 1
    ok = True
    for j in range(N):
        if d[j]: #正直者だと割り当てをした人を見る
            for k in range(N):
                if g[j][k] == -1: continue
                if g[j][k] != d[k]: ok = False #jの人の証言が、実際の割り当てとあっているかどうかを判断
    if ok:
        ans = max(ans, bin(i).count("1"))
print(ans)

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_H = (int)(1e2 + 5);
const int MAX_W = (int)(1e2 + 5);

int a, b;

int h = 100;
int w = 100;
char white = '.';
char black = '#';
char field[MAX_H][MAX_W];

void coloring(char color, int begin_h, int num) {
  if (num == 0) return;

  int cnt = 0;
  for (int i = begin_h; i < h; i += 2) {
    for (int j = 0; j < w; j += 2) {
      field[i][j] = color;
      cnt += 1;
      if (cnt >= num) return;
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d", &a, &b);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      field[i][j] = (i < h / 2) ? black : white;
    }
  }

  coloring(white, 0, a - 1);

  coloring(black, h / 2 + 1, b - 1);

  printf("%d %d\n", h, w);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      printf("%c", field[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int i,a=0;
    for (i=1; i<=s.size(); i++)
    {
        a++;
    }
    cout << s[0] << a-2 << s[s.size()-1] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e10
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {
  vector<int> a(5);
  rep(i, 5) cin >> a[i];
  int k;
  cin >> k;
  rep(i, 5) {
    rep(j, 5) {
      if (i == j) continue;
      if (abs(a[i] - a[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;

  return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    map<lint, lint> cnt;

    lint sum = 0;
    for_(i,0,N) {
        lint A;
        cin >> A;
        ++cnt[A];
        sum += A;
    }

    int Q;
    cin >> Q;
    for_(i,0,Q) {
        lint B, C;
        cin >> B >> C;

        sum -= cnt[B] * B;
        sum += cnt[B] * C;

        cnt[C] += cnt[B];
        cnt[B] = 0;

        cout << sum << endl;
    }
}

Measured memory_bytes: 9560
package main

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

func main() {
	n := nextInt()
	m := nextInt()
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = nextInt()
	}
	ys := make([]int, m)
	for i := 0; i < m; i++ {
		ys[i] = nextInt()
	}
	p := int(math.Pow10(9)) + 7

	var X, Y int
	for i, x := range xs {
		X += i*x - (n-(i+1))*x
	}
	for i, y := range ys {
		Y += i*y - (m-(i+1))*y
	}

	fmt.Println((X % p) * (Y % p) % p)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 5120
#pragma region header
#define _GLIBCXX_DEBUG 
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int A;
    cin >> A;
    cout << 1 - A << endl;
}








Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Printer{
    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T>
    void print(vector<T> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class T>
    void print(vector<vector<T> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};
using namespace Printer;

//--global--//

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

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, m;
    cin >> n >> m;
    ll res = 0;
    ll start = m / n;
    for(ll i = start; i>0; i--){
        if(m % i == 0){
            res = i;
            break;
        }
    }
    
    cout << res << endl;
    
    return 0;
}


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

class dice{
public:
    vector<int> me = {1, 2, 3, 4, 5, 6};
    void N(){
        vector<int> tmp(6);
        tmp[0] = me[1]; tmp[1] = me[5]; tmp[2] = me[2];
        tmp[3] = me[3]; tmp[4] = me[0]; tmp[5] = me[4];
        me = tmp;
    }
    void E(){
        vector<int> tmp(6);
        tmp[0] = me[3]; tmp[1] = me[1]; tmp[2] = me[0];
        tmp[3] = me[5]; tmp[4] = me[4]; tmp[5] = me[2];
        me = tmp;
    }
    void S(){
        vector<int> tmp(6);
        tmp[0] = me[4]; tmp[1] = me[0]; tmp[2] = me[2];
        tmp[3] = me[3]; tmp[4] = me[5]; tmp[5] = me[1];
        me = tmp;
    }
    void W(){
        vector<int> tmp(6);
        tmp[0] = me[2]; tmp[1] = me[1]; tmp[2] = me[5];
        tmp[3] = me[0]; tmp[4] = me[4]; tmp[5] = me[3];
        me = tmp;
    }
    int TOP(){
        return me[0];
    }
};

int main(void){
    dice d;
    rep(i, 6) cin >> d.me[i];
    string q;
    cin >> q;
    rep(i, q.size()){
        switch (q[i]){
            case 'N':
                d.N();
                break;
            case 'E':
                d.E();
                break;
            case 'S':
                d.S();
                break;
            case 'W':
                d.W();
                break;
        }
    }
    cout << d.TOP() << endl;
    return 0;
}


Measured memory_bytes: 3216
from collections import Counter
s = raw_input()
hist = Counter(s)

min_count = 1000
for alpha in hist.keys():
    count = 0
    tmp = s[:]
    while(tmp != alpha * len(tmp)):
        tmp2 = ''
        for i in range(len(tmp) - 1):
            if tmp[i] == alpha or tmp[i+1] == alpha:
                tmp2 += alpha
            else:
                tmp2 += tmp[i]
        tmp = tmp2
        count += 1
    min_count = min(count, min_count)
print min_count

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < N; i++) {
    int K;
    cin >> K;
    for (int j = 0; j < K; j++) {
      int A;
      cin >> A;
      X.at(A - 1) += 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    if (X.at(i) == N) ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

namespace tree {
struct union_find {
  vector<int> par, rank, size;
  int compnum;

  union_find(int N) {
    compnum = N;
    par.resize(N), rank.resize(N), size.resize(N);
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int main() {
  int N, M, K; cin >> N >> M >> K;
  tree::union_find uf(N);
  vector<int> no_count(N);
  rep(i, M) {
    int a, b; cin >> a >> b; a--, b--;
    uf.unite(a, b);
    no_count[a]++;
    no_count[b]++;
  }
  rep(i, K) {
    int a, b; cin >> a >> b; a--, b--;
    if (uf.same(a, b)) {
      no_count[a]++;
      no_count[b]++;
    }
  }
  rep(i, N) {
    if (i) cout << " ";
    cout << uf.size_of(i) - no_count[i] - 1;
  }
  cout << "\n";
}


Measured memory_bytes: 2432
/*RMQ????????°???????????¨??§?§£???*/
/*?§????O(n)??§?????¨??????????????????O(logn)*/
#include <vector>
#include <iostream>
#include <algorithm>

#define RMQ_MAX ((1LL<<31) - 1)
template <typename T>
class SegmentTree{

public:
  int size;//????´?????????????
  SegmentTree(){}
  SegmentTree(int size){
    int n = 1;
    while (n < size){
      n *= 2;
    }
    this->size = n;
    data.assign(2 * n - 1, RMQ_MAX);
  }
  void init(int size){
    int n = 1;
    /*????´????2????????????*/
    while (n < size){
      n *= 2;
    }
    this->size = n;
    data.assign(2 * n - 1, RMQ_MAX);
  }
  /*data[node] = val????????´*/
  /*O(logn)*/
  void update(int node, T val){
    node += size - 1;
    data[node] = val;
    while (node > 0){
      node = (node - 1) / 2;
      data[node] = std::min(data[2 * node + 1], data[2 * node + 2]);
    }
    return ;
  }
  /*data[left] ~ data[right - 1]?????§???????°?????????????*/
  /*O(logn)*/
  /*range_minimum(left, right, 0, 0, size)*/
  T range_minimum(int left, int right, int node, int most_left, int most_right){

    if (most_right <= left || right <= most_left){
      return RMQ_MAX;
    }
    if (left <= most_left && most_right <= right){
      return data[node];
    }else{
      T left_value = range_minimum(left, right, 2 * node + 1, most_left , (most_left + most_right) / 2);
      T right_value = range_minimum(left, right, 2 * node + 2, (most_left +  most_right) / 2, most_right);
      return std::min(left_value, right_value);
    }
  }
  /*Debug*/
  void show(){
    std::cerr << "--show--" << std::endl;
    for (const auto &val : data){
      std::cerr << val << std::endl;
    }
    std::cerr << "--end--" << std::endl;
  }

private:
  std::vector<T> data;//??????????????????
};

int N,Q;
int main(){
  std::cin >> N >> Q;
  SegmentTree<long long> RMQ(N);
  for (int i = 0; i < Q; i++){
    long long com,x,y;
    std::cin >> com >> x >> y;
    if (com == 0){
      RMQ.update(x, y);
    }else{
      std::cout << RMQ.range_minimum(x, y + 1, 0, 0, RMQ.size) << std::endl;
    }
  }

  return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=1;
    for(int i=1;i<=n;i++){
        if(ans*2<=ans+k)ans=ans*2;
        else ans=ans+k;
        //cout<<ans<<endl;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
const int64_t MOD = 1e9 + 7;

int n;
vector<int> v;

int solve(int i, int m) {
	if (m == 0) return 1;
	if (i >= n) return 0;
	int res = solve(i + 1, m) || solve(i + 1, m - v.at(i));
	return res;
}

int main() {
	int q, m;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		v.push_back(x);
	}

	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		if (solve(0, m)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


Measured memory_bytes: 3108
// https://atcoder.jp/contests/practice2/tasks/practice2_a
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, Q;
    cin >> N >> Q;
    dsu d(N);
    while (Q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        } else {
            cout << d.same(u, v) << "\n";
        }
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3992
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#include <map>
#include <queue>

#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;
const int INF = 2e9;

int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        int n,m;
        cin >> n >> m;
        vector<vector<int>> g(n+1,vector<int>());
        REP(i,m) {
                int a,b;
                cin >> a >> b;
                g[a].EB(b);
                g[b].EB(a);
        }
        vector<int> d(n+1,INF);
        vector<int> fa(n+1,INF);

        d[1] = 0;
        fa[1] = 1;

        priority_queue<int, vector<int>, greater<int>> q;  // priority queue 
        q.push(1); // source node , time 0 , node 1 , remain silver : s
        while(!q.empty()) { // dijkstras round
                int t = q.top();
                q.pop();
                for(int i = 0; i < g[t].size(); i++) { 
                        int v = g[t][i];
                        if(d[v] > d[t] + 1) {  // relax condition : enough silver w >= a , with less time 
                                d[v] = d[t] + 1;
                                fa[v] = t;
                                q.push(v);
                        }
                }
        }
        int flag = 1;
        for( int i = 2 ; i <= n ; ++i) {
          if( d[i] == INF ) {
            flag = -1;
            break;
          }
        }
        if( flag == -1 ) {
          cout << "No" << endl;
        }
        else {
          cout << "Yes" << endl;
          for(int i = 2; i <= n; ++i) {
            cout << fa[i] << endl;
          }
        }
        return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),W=in();
	map<char,int> C;
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			C[S[j]]++;
		}
	}
	int one=0,two=0,four=0;
	if((H%2) && (W%2)){
		one = 1;
		two = H/2+W/2;
		four = (H/2)*(W/2);
	}
	else if((H%2)){
		two = W/2;
		four = (H/2)*(W/2);
	}
	else if(W%2){
		two = H/2;
		four = (H/2)*(W/2);
	}
	else{
		four = (H/2)*(W/2);
	}

	for(auto& x:C){
		if((x.second%4)==1 || (x.second%4)==3){
			one--;
			x.second--;
		}
	}
	if(one){
		out("No");
		return 0;
	}

	for(auto& x:C){
		if((x.second%4)==2){
			two--;
			x.second-=2;
		}
	}
	if(two){
		if(two>0 && !(two%2)){
			for(auto& x:C){
				while(two>0 && x.second){
					two-=2;
					x.second-=4;
				}
				if(!two) break;
			}
		}
		else{
			out("No");
			return 0;
		}
	}

	for(auto& x:C){
		while(x.second){
			four--;
			x.second-=4;
		}
	}
	if(four){
		out("No");
		return 0;
	}
	out("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 10000000


int main()
{
	int n;
	cin>>n;
	vector<int> v(n);
	int prev,curr;
	long int ans=0;
	for(int i=0;i<n;i++)
	  {
	      cin>>v[i];
	      if(i==0){prev=v[i];}
	      else
           {
               curr=v[i];
               if(curr<prev){ans+=prev-curr;}
               else
                prev=curr;
          }
	  }
	  cout<<ans;
}


Measured memory_bytes: 4024
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, a[1010];

int main(){
	cin >> n;
	double cnt = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		cnt += 1.0 / a[i];
	}
	printf("%.10f\n", 1.0 / cnt);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
pair<int,int>pz[100001],po[100001];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
bool visited[100001]={false};

//void dfs(int x){
//	visited[x]=true;
//	//ans.push_back(x);
//	//c[x]=1;
//	for(auto &child:graph[x]){
//		if(!visited[child]){
//			dfs(child);	
//			//c[x]+=c[child];
//		}
//	}
//}
signed main(){
	FAST
	int n;
	//int arr[n][3];
	cin>>n;
	int arr[n][3];
	cin>>arr[0][0]>>arr[0][1]>>arr[0][2];
	for(int i=1;i<n;i++){
		int x,y,z;
		cin>>x>>y>>z;
		arr[i][0]=x+max(arr[i-1][1],arr[i-1][2]);
		arr[i][1]=y+max(arr[i-1][0],arr[i-1][2]);
		arr[i][2]=z+max(arr[i-1][0],arr[i-1][1]);
	}
	cout<<max({arr[n-1][0],arr[n-1][1],arr[n-1][2]});
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vector<tuple<string, int, int>> vp(n);
    REP(i, n) {
        string s;
        int p;
        cin >> s >> p;
        vp[i] = make_tuple(s, p, i + 1);
    }

    sort(all(vp), [](const tuple<string, int, int> &a,
                     const tuple<string, int, int> &b) {
        if(get<0>(a) == get<0>(b)) {
            return get<1>(a) > get<1>(b);
        } else {
            return get<0>(a) < get<0>(b);
        }
    });

    for(auto p : vp) {
        cout << get<2>(p) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

N, W = map(int, input().split())
wl = [0]*N
vl = [0]*N
for i in range(N):
  wl[i], vl[i] = map(int, input().split())

dp = {}
for i in range(len(wl)):
  w, v = wl[i], vl[i]

  newdp = {}
  
  # copy
  for ew, ev in dp.items():
    if ew not in newdp:
      newdp[ew] = ev
    else:
      newdp[ew] = max(newdp[ew], ev)

    if ew + w not in newdp:
      newdp[ew+w] = ev+v
    else:
      newdp[ew+w] = max(newdp[ew+w], ev + v)

  
  if w not in newdp:
    newdp[w] = v
  else:
    newdp[w] = max(newdp[w], v)
    
  dp = newdp

ans = 0
for w, v in dp.items():
  if w <= W:
    ans = max(ans, v)
print(ans)
#print(sorted(list(dp.items())))



Measured memory_bytes: 4900
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=2e5+5;
int n, n2[N], n5[N], f[64][64];
int main() {
	scanf("%d", &n);
	long long ans=0;
	for(int i=1; i<=n; ++i) {
		long double a;
		scanf("%Lf", &a);
		long long b=roundl(a*1e9L);
		int n2=0, n5=0;
		while(b%2==0) b/=2, ++n2;
		while(b%5==0) b/=5, ++n5;
		++f[n2][n5];
		if(n2>=9 && n5>=9) --ans;
	}
	for(int i=0; i<64; ++i) {
		for(int j=0; j<64; ++j) {
			for(int k=0; k<64; ++k) {
				for(int l=0; l<64; ++l) {
					if(i+k>=18 && j+l>=18) ans+=1ll*f[i][j]*f[k][l];
				}
			}
		}
	}
	printf("%lld\n", ans/2);
	return 0;
}


Measured memory_bytes: 3880
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

#ifdef LOCALCODE
signed solve()
#else
signed main()
#endif
{
	auto N = IN();
	auto M = IN();
	auto X = IN();
	X--;
	vector<int> v(N+1);
	REP(i, M)
	{
		int a;
		cin >> a;
		a--;
		v[a] = 1;
	}
	int l = accumulate(v.begin(), v.begin() + X, 0);
	int r = accumulate(v.begin() + X, v.end(), 0);
	print(min(l, r));
	return 0;
}


Measured memory_bytes: 256