akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

int dist(int x1, int x2, int y1, int y2){
    return abs(x1 - x2) + abs(y1 - y2);
}

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

    int N;
    cin >> N;
    vector<int> t(N+1), x(N+1), y(N+1);
    t[0] = 0, x[0] = 0, y[0] = 0;
    FOR(i, 1, N+1) cin >> t[i] >> x[i] >> y[i];

    bool ans = true;
    FOR(i, 1, N+1){
        if(dist(x[i], x[i-1] , y[i], y[i-1]) > t[i] - t[i-1] 
        || (dist(x[i], x[i-1], y[i], y[i-1]) - t[i] + t[i-1]) % 2){
            ans = false;
        }
    }

    cout << (ans ? "Yes" : "No") << "\n";

    return 0;
}

Measured memory_bytes: 2560
s = input()

count=0
ans=0
if(s[0]=='A'):
    if(s[2:-1].count('C') == 1):
        for i in range(1, len(s)):
            if(97 <= ord(s[i]) <= 122):
                continue
            else:
                count+=1
            if(count>1):
                print("WA")
                ans+=1
                break
    else:
        print("WA")
        ans+=1
else:
    print("WA")
    ans+=1

if(ans==0):
    print('AC')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(s.size(), 0);
    int r = 0;
    rep(i, s.size()){
        if(s[i] == 'R') r++;
        else{
            ans[i] += r/2;
            r -= r/2;
            ans[i-1] += r;
            r = 0;
        }
    }
    int l = 0;
    rep(i, s.size()){
        if(s[n-1-i] == 'L') l++;
        else{
            ans[n-1-i] += l/2;
            l -= l/2;
            ans[n-i] += l;
            l = 0;
        }
    }
    rep(i, n) cout << ans[i] << (i == n-1 ? "\n" : " ");

}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val t = arrayOf(
        0, 2
        ,
        5
        ,
        5
        ,
        4
        ,
        5
        ,
        6
        ,
        3
        ,
        7
        ,
        6
    )

    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toInt()}

    val dp = Array<String?>(N + 1) { null }
    dp[0] = ""

    for (i in 1..N) {
        for (a in A) {
            if (t[a] > i) continue

            val s = dp[i - t[a]] ?: continue
            val nl = s.length + 1
            val ts = s + a.toString()
            if (dp[i] == null) {
                dp[i] = ts
            } else if (nl > dp[i]!!.length ||
                    nl == dp[i]!!.length && ts > dp[i]!!) {
                dp[i] = ts
            }
        }
    }

    println(dp[N])
}

Measured memory_bytes: 171428
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

ll N, A, B, C, D;
ll calc(ll N){
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> pque;
    pque.push(make_pair(0,N));
    map<ll,bool> m;
    while((int)pque.size()>0){
        ll cost, num;
        cost=pque.top().first;
        num=pque.top().second;
        pque.pop();
        if(m.count(num)){
            continue;
        }else{
            m[num]=true;
        }

        //cout << cost << ' ' << num << endl;
        if(num==0){
            return cost;
        }

        if(num%2+A/D+(A%D>0)<=(num-num/2)){
            pque.push(make_pair(cost+(num%2)*D+A,num/2));
        }else{
            pque.push(make_pair(cost+(num-num/2)*D,num/2));
        }

        if((2LL-(num%2))+A/D+(A%D>0)<=(num-num/2-1)){
            pque.push(make_pair(cost+(2LL-(num%2))*D+A,num/2+1));
        }else{
            pque.push(make_pair(cost+(num-num/2-1)*D,num/2+1));
        }

        if((num%3)+B/D+(B%D>0)<=(num-num/3)){
            pque.push(make_pair(cost+(num%3)*D+B,num/3));
        }else{
            pque.push(make_pair(cost+(num-num/3)*D,num/3));
        }
        
        if((3LL-(num%3))+B/D+(B%D>0)<=(num-num/3-1)){
            pque.push(make_pair(cost+(3LL-(num%3))*D+B,num/3+1));
        }else{
            pque.push(make_pair(cost+(num-num/3-1)*D,num/3+1));
        }

        if((num%5)+C/D+(C%D>0)<=(num-num/5)){
            pque.push(make_pair(cost+(num%5)*D+C,num/5));
        }else{
            pque.push(make_pair(cost+(num-num/5)*D,num/5));
        }

        if((5LL-(num%5))+C/D+(C%D>0)<=(num-num/5-1)){
            pque.push(make_pair(cost+(5LL-(num%5))*D+C,num/5+1));
        }else{
            pque.push(make_pair(cost+(num-num/5-1)*D,num/5+1));
        }
        
        if(num==1){
            pque.push(make_pair(cost+D,0));
        }
    }
}

int main(){
    int T;
    cin >> T;
    for(int i=0; i<T; i++){
        cin >> N >> A >> B >> C >> D;
        cout << calc(N) << endl;
    }
}

Measured memory_bytes: 4472
#include <stdio.h>

int main(void)
{
	while(1)
	{
		int a,b;
		char num[1000];
		int i=0;
		int count=0;
		
		for(i=0;i<1000;i++)
		{
			num[i] = 'a';
		}
		
		if(scanf("%d %d",&a,&b) == EOF)
		{
			goto finish;
		}
		
		snprintf(num,1000, "%d", a+b);
		
		for(i=0;i<1000;i++)
		{
			if(num[i] == 'a')
			{
				goto result;
			}
		}
		
		result:
		
		printf("%d\n",i-1);
	}
	
	finish:
	
	return 0;
	
}


Measured memory_bytes: 2036
import numpy as np
N,K= map(int,input().split())
H = np.array(list(map(int, input().split())))
 
dp = np.zeros(N, dtype=int)
 
for i in range(1,N):
  s=max(i-K,0)
  dp[i]=np.min(dp[s:i]+np.abs(H[s:i]-H[i]))
 
print(dp[-1])

Measured memory_bytes: 22904
#include"bits/stdc++.h"
#include<random>
using namespace std;
using ll = int64_t;

int main() {
    string S, T;
    cin >> S >> T;
    ll ans = 0;
    for (ll i = 0; i < S.size(); i++) {
        ans += (S[i] == T[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
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 (0 <= z && z <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//file_name:ABC46_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    ll ans = -1*((s.size()+1)/2);
    rep(i,s.size()){
        if(s[i]=='g')ans++;
    }


    

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



Measured memory_bytes: 512
import sys
input = sys.stdin.readline
N = int(input())
nes = [list(map(int,input().split())) for i in range(N)]
A = [0]
B = [0]
C = [0]
for i in range(N) :
    a = nes[i][0] + max(B[-1],C[-1])
    b = nes[i][1] + max(A[-1],C[-1])
    c = nes[i][2] + max(B[-1],A[-1])
    A += [a]
    B += [b]
    C += [c]
print(max(A[-1],B[-1],C[-1]))

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

int main() {
    int X, sum = 0;
    cin >> X;
    while (X / 500 != 0) {
        sum += 1000;
        X -= 500;
    }
    while (X / 5 != 0) {
        sum += 5;
        X -= 5;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input! {
        h: usize,
        n: usize,
        m: [(usize, usize); n],
    }
    let mut dp = vec![usize::max_value(); h + 1];
    dp[0] = 0;
    for (ai, bi) in m.into_iter() {
        for j in 0..h {
            let nj = min(j + ai, h);
            dp[nj] = if dp[j] == usize::max_value() {
                dp[nj]
            } else {
                min(dp[nj], dp[j] + bi)
            };
        }
    }
    println!("{}", dp[h]);
}


Measured memory_bytes: 4352
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

$nums = explode(" ", $stdin[1]);

$max = max($nums);

sort($nums);

#var_dump($nums);

#誤差？対策
foreach($nums as $v){
  $nums2[] = $v * 100000000;
}

#var_dump($nums2);

//if(count($nums2) == 2){
//  $temp = array_sum($nums) / count($nums);
//}else{
  
  $temp=$nums2[0]; 
  for($i = 1; $i < count($nums2); $i++){
	//var_dump($temp);
    $temp = ($temp + $nums2[$i]) / 2;
    //unset($nums2[$i]);
    //$nums2[$i + 1] = $temp;

  }
  
  //var_dump($temp);
  
  //$ans = (array_sum($nums2) / count($nums2)) / 100000000;
//}

  
echo $temp/ 100000000 . PHP_EOL;
//echo $ans . PHP_EOL;





Measured memory_bytes: 3828
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(lst[k-1])

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	string s1,s2;
	cin>>s1>>s2;
	int n=s1.length();
	int cou=0;
	for(int i=0;i<n;i++){
		if(s1[i]!=s2[i])
			cou++;
	}
	cout<<cou<<endl;
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll mod = 1e9 + 7;
ll Z[10][10];
int main() {
	ll N;
	cin >> N;
	for (ll i = 1; i <= N; i++) {
		ll a = i % 10;
		ll k = i;
		while (k >= 10) {
			k /= 10;

		}
		Z[a][k]++;
	}
	ll an = 0;
	rep(i, 10) {
		rep(j, 10) {
			an += Z[i][j] * Z[j][i];
		}
	}
	cout << an << endl;
}

Measured memory_bytes: 3628
import fractions

N,K=map(int,input().split())
A=list(map(int,input().split()))

g=A[0]
for i in range(1,N):
    g=fractions.gcd(g,A[i])

if K%g==0 and K<=max(A):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 88364
<?php
//$S = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($a,$b,$c,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$l = substr($S,-1);
if ($l=='s') {
  echo $S."es";
}
else {
  echo $S."s";
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;
class DSumOfDivisors {

public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        vector<int> f(N+1);
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <= N; j += i) {
                f[j]++;
            }
        }

        int res = 0;
        for (int i = 1; i <= N; i++) {
            res += i * f[i];
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DSumOfDivisors solver;
    solver.solve(in, out);
    return 0;
}


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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false)

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

ll n,m,k;
string s;
int main() {
    INIT();

    cin >> n;
    n %= 10;
    if(
        n == 3
    ) {
        cout << "bon";
    } else if (
        n == 0 ||
        n == 1 ||
        n == 6 ||
        n == 8
    ) {
        
        cout << "pon";
    } else {
        cout << "hon";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

struct UnionFind {
   vector<int> d;
   UnionFind(int n = 0) : d(n, -1) {}
   int find(int x) {
      if (d[x] < 0) return x;
      return d[x] = find(d[x]);
   }
   bool unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return false;
      if (d[x] > d[y]) swap(x, y);
      d[x] += d[y];
      d[y] = x;
      return true;
   }
   bool same(int x, int y) { return find(x) == find(y); }
   int size(int x) { return -d[find(x)]; }
};
int deg[100005];
vector<int> to[100005];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, m, k;
   cin >> n >> m >> k;
   UnionFind uf(n);
   rep(i, 0, m) {
      int a, b;
      cin >> a >> b;
      deg[--a]++;
      deg[--b]++;
      uf.unite(a, b);
   }
   rep(i, 0, k) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      to[a].push_back(b);
      to[b].push_back(a);
   }
   rep(i, 0, n) {
      int ans = uf.size(i) - 1 - deg[i];
      for (auto u : to[i]) {
         if (uf.same(i, u)) ans--;
      }
      cout << ans << endl;
   }
   return 0;
}

Measured memory_bytes: 6784
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn readu() -> usize {
    read::<usize>()
}

#[allow(dead_code)]
fn readi() -> i32 {
    read::<i32>()
}

fn main() {
    input! {
        s: chars,
    }
    let mut v: Vec<char> = vec![];
    let mut ans = 0;
    for si in &s {
        if v.len() > 0 && Some(si) != v.last() {
            v.pop();
            ans += 2;
        } else {
            v.push(*si);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

template <class T>
void printVector(const vector<T>& v) {
    for (auto value : v) {
        cout << value << " ";
    }
    cout << endl;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<long double> a(n + 1, 0);
    vector<long double> csum(n + 1, 0);
    reps(i, n) cin >> a[i];
    reps(i, n) csum[i] = log10(a[i]) + csum[i - 1];
    // printVector(csum);

    long double pre = csum[k];
    for (int i = k + 1; i <= n; i++) {
        long double result = csum[i] - csum[i - k];
        // debug(pre, result);
        if (pre < result)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
        pre = result;
    }
    return 0;
}

Measured memory_bytes: 9112
from sys import stdin
input = stdin.readline
from collections import defaultdict, deque
h, w, m = map(int,input().split())
row = defaultdict(int)
col = defaultdict(int)
grid = defaultdict(int)
for _ in range(m):
    x,y = map(int,input().split())
    row[x]+=1
    col[y]+=1
    grid[(x,y)]=1


row = sorted(list(row.items()), key = lambda x: x[1], reverse = True)
col = sorted(list(col.items()), key = lambda x: x[1], reverse = True)


#print(row)
#print(col)

t = len(row)
for idx, ele in enumerate(row):
    i,j = ele
    if j!=row[0][1]:
        t = idx
        break
row = row[:t]
t = len(col)
for idx, ele in enumerate(col):
    i,j = ele
    if j!=col[0][1]:
        t = idx
        break
col = col[:t]

#print(row)
#print(col)
#print(grid)

ans = row[0][1]+col[0][1] + (-1 if grid[(row[0][0], col[0][0])] else 0)

i,j = 0,0
for r,cr in row:
    for c,cc in col:
        if not grid[(r,c)]:
            ans = cr+cc
            break
print(ans)


# dq = deque([(i,j)])
# while dq:
#     i,j = dq.popleft()
#     temp = row[i][1]+col[j][1] + (-1 if grid[(row[i][0], col[j][0])] else 0)
#     if ans<temp:
#         ans = temp
#         break
    
#     if i+1<len(row):dq.append((i+1,j))
#     if j+1<len(col):dq.append((i,j+1))

    
# print(ans)

Measured memory_bytes: 228876
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main() {

    string s;
    cin >> s;

    bool even_flag = (s.length() % 2 == 0) ? true : false;
 
    int length = s.length();
    if (!even_flag) {
        length -= 1;
    }

    bool difficulty = true;
    int i;
    for (i = 0; i < length; i=i+2) {
        if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D') ||
            !(s[i + 1] == 'L' || s[i + 1] == 'U' || s[i + 1] == 'D')) {
            difficulty = false;
            break;
        }
    }

    if (!even_flag) {
        if (!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
            difficulty = false;
        }
    }

    if (difficulty) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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


int main()
{
    int a, b, c;
    double pi = acos(-1.0);

    scanf("%d %d %d", &a, &b, &c);

    printf("%lf\n", 0.5*a*b*sin(c/180.0*pi));
    printf("%lf\n", a+b+sqrt(a*a + b*b - 2*a*b*cos(c/180.0*pi)));
    printf("%lf\n", 0.5*a*b*sin(c/180.0*pi)*2/a);


    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976


const int MAX_N = 1 << 17;
ll n, dat[2*MAX_N-1];       //SegmentTreeを持つグローバル配列

void init(int n_){
    n = 1;
    while(n < n_) n *= 2;
    for(int i = 0; i < 2 * n - 1; i++) dat[i] = (1LL << 31)-1;
}

void update(ll k,ll a){
    // k番目の値をaに変更
    k += n-1;
    dat[k] = a;
    while(k > 0){
        k = (k-1)/2;
        dat[k] = min(dat[k*2 + 1],dat[k*2 + 2]);
    }
}

// [a,b)の最小値を求める.

ll query_sub(ll a, ll b, ll k, ll l, ll r){
    // k:現在見てるノードの位置, [l,r):dat[k] が表してる区間
    if(r <= a || b <= l){
        return  (1LL << 31)-1;
    }else if(a <= l && r <= b){
        //すべての区間がかぶる時
        return dat[k];
    }else{
        //一部の区間がかぶる時
        ll vl = query_sub(a,b,2*k + 1,l,(r+l)/2);
        ll vr = query_sub(a,b,2*k + 2,(l+r)/2,r);
        return min(vl,vr);
    }
}
ll query(ll a,ll b) {return query_sub(a, b, 0, 0, n);}

int main()
{
    int q;
    cin >> n >> q;
    init(n);
    rep(i,q){
        ll c,x,y;
        cin >> c >> x >> y;
        if(c == 0){
            update(x,y);
        }else{
            cout << query(x,y+1) << endl;;
        }
    }
}



Measured memory_bytes: 5140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int cnt = 0;
            for (int i = 0; i < n; i++) {
                cnt += (Math.abs(in.nextInt() - in.nextInt()) + 1);
            }
            out.println(cnt);
        }

    }
}



Measured memory_bytes: 25712
import sys

input = sys.stdin.readline
S =  input()
S = S.replace("\n","")
s_list = list(S)
alpha_list = [chr(i) for i in range(97, 97+26)]
flag_list = [False for _ in range(26)]


if len(s_list) == 26:
    for i in range(25, 0, -1):
        if s_list[i - 1] < s_list[i]:
            c = 'ω'
            for j in range(i, 26):
                if s_list[i - 1] < s_list[j]:
                    c = min(c, s_list[j])
            print(S[:i-1] + c)
            exit(0)
    print(-1)

else:
    for i,alpha in enumerate(alpha_list):
        if alpha in s_list:
            flag_list[i] = True
    for i,flag in enumerate(flag_list):
        if not flag:
            print(S + alpha_list[i])
            break

Measured memory_bytes: 9072
#include<stdio.h>  
#include<string.h>  
int x[15],l[15],r[15];  
int kase;  
void dfs(int i,int j,int k) 
{  
    if(i>10)  
    {  
        kase=1;  
        return;  
    }  
    if(kase)  
    {  
        return;  
    }  
    if(x[i]>l[j-1])  
    {  
        l[j]=x[i];dfs(i+1,j+1,k);  
    }  
    if(x[i]>r[k-1])  
    {  
        r[k]=x[i];dfs(i+1,j,k+1);  
    }  
}  
int main()  
{  
    int t;     
    scanf("%d",&t);  
    while(t--)  
    {  
        for(int i=1;i<=10;++i)  
        {  
            scanf("%d",&x[i]);  
        }  
        kase=0;  
        dfs(1,1,1);  
        if(kase)  
        {  
            printf("YES\n");  
        }  
        else  
        {  
            printf("NO\n");  
        }  
    }  
    return 0;  
}   


Measured memory_bytes: 1916
/* Justin Choi */
#include <bits/stdc++.h>
using namespace std;

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;
#define qio ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forl(V, N) for(int V = 0; V < N; V++)
#define for1(V, N) for(int V = 1; V <= N; V++)
#define fore(E, X) for(auto &E:X)
#define newl cout << endl
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)

#define graph unordered_map<int, unordered_set<int>>
#define um unordered_map
#define us unordered_set
#define vi vector<int>
#define pi pair<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define ins insert

bool board[25][25];
int h, w;

int trav(int i, int j) {
    int loc = i*w+j;
    queue<pi> q; q.push(mp(loc, 0));
    us<int> VST; int md = 0;
    VST.ins(loc);
    while(!q.empty()) {
        pi val = q.front(); q.pop();
        md = val.second;
        int x = val.first / w, y = val.first % w;
        if(x+1 < h) {
            int id = (x+1)*w+y;
            if(VST.count(id) or !board[x+1][y]) { ; }
            else {
                q.push(mp(id, val.second+1));
                VST.ins(id);
            }
        }
        if(x-1 >= 0) {
            int id = (x-1)*w+y;
            if(VST.count(id) or !board[x-1][y]) { ; }
            else {
                q.push(mp(id, val.second+1));
                VST.ins(id);
            }
        }
        if(y+1 < w) {
            int id = x*w+y+1;
            if(VST.count(id) or !board[x][y+1]) { ; }
            else {
                q.push(mp(id, val.second+1));
                VST.ins(id);
            }
        }
        if(y-1 >= 0) {
            int id = x*w+y-1;
            if(VST.count(id) or !board[x][y-1]) { ; }
            else {
                q.push(mp(id, val.second+1));
                VST.ins(id);
            }
        }
    }
    return md;
}

int main() {
    qio; cin >> h >> w;
    forl(i, h) {
        forl(j, w) {
            char c; cin >> c;
            board[i][j] = c == '.';
        }
    }
    int mxcl=  0;
    forl(i, h) {
        forl(j, w) {
            if(board[i][j]) setmax(mxcl, trav(i, j));
        }
    }
    println(mxcl);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]){
    	Scanner s = new Scanner(System.in);
      	String s1 = s.next();
      	String s2 = s.next();
      	String ans = ans(s1,s2);
      	System.out.println(ans);
    }
  	public static String ans(String s1, String s2){
      	int M = s1.length(), N = s2.length();
      	if(N<=0 || M<=0)
          	return "";
      	char[] c1 = s1.toCharArray();
      	char[] c2 = s2.toCharArray();
      	int dp[][] = new int[M+1][N+1];
      	for(int i=1;i<=M;i++){
        	for(int j=1;j<=N;j++){
            	dp[i][j] = Math.max(dp[i][j-1],dp[i-1][j]);
              	if(c1[i-1]==c2[j-1]){
                	dp[i][j] = Math.max(dp[i][j],1+dp[i-1][j-1]);
                }
            }
        }
      	char[] result = new char[dp[M][N]];
      	int index = result.length-1,i=M,j=N;
      	while(i>0 && j>0){
        	if(c1[i-1]==c2[j-1]){
            	result[index--] = c1[i-1];
              	i--;
              	j--;
            } else if(dp[i-1][j]>dp[i][j-1]){
                i--;
            } else {
            	j--;
            }
        }
      	return new String(result);
    }
}

Measured memory_bytes: 80932
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,t;
	cin>>n>>t;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	ll ans=t;
	for(i=2;i<=n;i++){
		k=ar[i]-ar[i-1];
		if(k>t) ans+=t;
		else ans+=k;
	}

	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int now = a % b;
  vector<bool> chk(b, false);
  while(1){
    if(chk.at(now) == false){
      chk.at(now) = true;
      now = (now + a) % b;
    }else break;
  }
  if(chk.at(c) == true) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
public class Main{
    public static int check(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){
        if(x1 == x2){
            if(x3 == x4)
                return 2;
            else if(y3 == y4)
                return 1;
            else
                return 0;
        }
        else if(x3 == x4){
            if(y1 == y2)
                return 1;
            else
                return 0;
        }
        else{
            if((double)(y2 - y1)/(x2 - x1) == (double)(y4 - y3)/(x4 - x3))
                return 2;
            else if((y1 - y2)*(y4 - y3) == (x2 - x1)*(x4 - x3))
                return 1;
            else
                return 0;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        for(int i = 0 ; i < q ; i++){
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            int x3 = sc.nextInt();
            int y3 = sc.nextInt();
            int x4 = sc.nextInt();
            int y4 = sc.nextInt();
            System.out.println(check(x1, y1, x2, y2, x3, y3, x4, y4));
        }
    }
}


Measured memory_bytes: 39676
n, x = map(int, input().split())

pate, slice = [1], [1]
for _ in range(n + 1):
    pate.append(2 * pate[-1] + 1)
    slice.append(2 * slice[-1] + 3)

ans = 0
for i in range(n)[::-1]:
    if x >= slice[i] + 2:
        ans += pate[i] + 1
        x -= slice[i] + 2
    elif x < slice[i] + 2:
        x -= 1
print(ans + (x > 0))


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

int main(){
    string input;
    int n, ans = 0;
    cin >> input >> n;

    for(int i=0; i < n; i++){
        string ring;
        cin >> ring;
        ring += ring.substr(0,input.size()-1);
        if(ring.find(input) != string::npos) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1212
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

#[allow(unused_macros)]
macro_rules! put {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stdout(), "{}", $var);
    };
    ($var:expr, $($args:expr),*) => {
        let _ = write!(&mut std::io::stdout(), "{} ", $var);
        put!($($args),*);
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let x: usize = sc.cin();
    let y: usize = sc.cin();
    let z: usize = sc.cin();
    let m: usize = sc.cin();
    let mut xs: Vec<u64> = (0..x).map(|_| sc.cin()).collect();
    let mut ys: Vec<u64> = (0..y).map(|_| sc.cin()).collect();
    let mut zs: Vec<u64> = (0..z).map(|_| sc.cin()).collect();
        let mut xys = vec![];
        for i in 0..x{
            for j in 0..y {
                xys.push(xs[i] + ys[j]);
            }
        }
            xys.sort();
            xys.reverse();
                    let mut xyz = vec![];
for i in 0..min(3000, xys.len()) {
for j in 0..z {
xyz.push(xys[i] + zs[j]);
}
    }
xyz.sort();
xyz.reverse();
for k in 0..m {put!(xyz[k]);}


}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll x, n;
  cin >> x >> n;
  vll p(n);
  rep(i, n) {
    cin >> p[i];
  }

  vll table(102);
  rep(i, n) {
    table[p[i]] = 1;
  }
  ll idx = -1;
  ll v = INF;
  rep(i, 102) {
    if (table[i]) {
      continue;
    }
    ll diff = abs(x - i);
    if (diff < v) {
      v = diff;
      idx = i;
    }
  }

  cout << idx << endl;

  return 0;
}


Measured memory_bytes: 3616
import scala.io.StdIn.{readLine,readInt}

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val l = readLine.split(" ").map(_.toInt)
    printf("%d %d %d\n",l.min,l.max,l.foldLeft(0.toLong)(_+_))
  }
}

Measured memory_bytes: 49424
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	cin>>t;
	double a,b=0;
	for(int i=0;i<t;i++){
		cin>>a;
		b+=1.0/(a*1.0);
	}
	b=1/b;
	cout<<b;
}

Measured memory_bytes: 764
from collections import Counter

N = int(input())
S = input()
ans = 0

for i in range(1000):
    s = str(i).zfill(3)
    for i in range(N):
        if S[i]==s[0]:
            p = i
            break
    else:
        continue
    for i in range(p+1, N):
        if S[i]==s[1]:
            p = i
            break
    else:
        continue

    for i in range(p+1, N):
        if S[i]==s[2]:
            p = i
            break
    else:
        continue
    
    ans += 1

print(ans)


Measured memory_bytes: 42972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<int> cnt(N, 0);
    rep(i, N - 1 + M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        G[A].push_back(B);
        ++cnt[B];
    }
    
    vector<int> par(N, -1);
    queue<int> q;
    rep(i, N) {
        if (cnt[i] == 0) q.push(i);
    }
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v : G[u]) {
            --cnt[v];
            if (cnt[v] == 0) q.push(v);
            par[v] = u;
        }
    }
    rep(i, N) cout << par[i] + 1 << "\n";
    return 0;
}



Measured memory_bytes: 7040
import java.util.*
import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 998244353L

fun main() {
	abc000X()
}

fun abc000X() {
	val n=int()
	val a=list()
	println(a.withIndex().count{it.index%2==0&&it.value%2==1})
}


Measured memory_bytes: 36616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int H, W, x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool ans = true;
    if (x - r < 0) ans = false;
    if (y - r < 0) ans = false;
    if (x + r > W) ans = false;
    if (y + r > H) ans = false;

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

typedef long long ll;
const int maxn = 55, mod = 1e9 + 7;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int add(int x, int y) {return x + y < mod ? x + y : x + y - mod;}

int n, f[maxn][maxn], C[maxn][maxn];

int main()
{
	n = gi();
	f[1][0] = f[1][1] = 1;
	for (int i = 0; i <= n; ++i) C[i][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = C[i][0] = 1; j <= i; ++j) C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);

	for (int i = 1; i < n; ++i)
		for (int j = 0; j <= i; ++j)
			if (f[i][j])
				for (int x = 0; x + i <= n; ++x)
					for (int y = 0; x + y + i <= n; ++y)
						if (x + y && x + y >= j && ((x + y - j) & 1) == 0)
							f[i + x + y][abs((x + y - j) / 2 + j - x)] = (f[i + x + y][abs((x + y - j) / 2 + j - x)] + (ll)f[i][j] * C[i + x + y][x + y] % mod * C[x + y][x]) % mod;

	printf("%d\n", f[n][0]);
	
	return 0;
}


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

Measured memory_bytes: 256
# include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std ;
int N = 3e5 + 7 ;
ll N1 = 1e9 + 7 ;
int main( ){
    speed ;
    ll TJK = 1 ;
    // cin >> TJK ;
    while( TJK -- ){
        int n ;
        cin >> n ;
        int a[n] ;
        for( int i = 0 ; i < n ; i ++ ){
            cin >> a[i] ;
        }
        ll ans = 0 ;
        for( int i = 1 ; i < n ; i ++ ){
            if( a[i] < a[i-1] ){
                ans += a[i-1] - a[i] ;
                a[i] += a[i-1] - a[i] ;
            }
        }
        cout << ans << endl ;
    }
}


Measured memory_bytes: 4388
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(a, b, c, d);
    while (a > 0 && c > 0)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
            return;
        }
    }
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3648