akhauriyash/Code-Regression huggingface dataset:
/// 11:59 AM 26/04/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll in = 0;
    bool f = 0;
    while(true) {
        if(in&1) {
            a-=d;
            if(a<=0) {
                f=1;
                break;
            }
        } else {
            c-=b;
            if(c<=0) {
                break;
            }
        }
        in++;
    }
    if(f) {
        cout<<"No";
    } else {
        cout<<"Yes";
    }
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

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



Measured memory_bytes: 3640
n, x = map(int,input().split())
li = list(map(int,input().split()))

li.sort()
ans = 0

for i in range(n):
    x = x-li[i]
    if x < 0:
        ans = i
        break
    ans = i+1

if x > 0:
    ans -=1

print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template <typename T>
class BIT
{
  private:
    vector<T> array;
    int N;

  public:
    BIT(int size) : array(size + 1, 0), N(size) {}

    T sum(int i)
    {
        T sum = 0;
        while (i > 0)
        {
            sum += array[i];
            i -= i & -i;
        }

        return sum;
    }

    T sum(int l, int r)
    {
        T res_l = sum(l - 1);
        T res_r = sum(r);

        return res_r - res_l;
    }

    void add(int i, T x)
    {
        while (i <= N)
        {
            array[i] += x;
            i += i & -i;
        }
    }

    int lower_bound(int w)
    {
        if (w <= 0)
        {
            return 0;
        }        

        int init = 1;
        while(init < N)
        {
            init *= 2;
        }

        int x = 0;
        for(int k = init; k > 0; k /= 2)
        {
            if(x + k <= N && array[x + k] < w)
            {
                w -= array[x + k];
                x += k;
            }
        }
        
        return x + 1;
    }
};

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

    int N, Q;
    cin >> N >> Q;
    BIT<int> bit(N);

    REP(i, Q)
    {
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0)
        {
            bit.add(x, y);
        }
        else
        {
            Cout(bit.sum(x, y));
        }
    }    

    return 0;
}


Measured memory_bytes: 3312
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    string s;
    cin >> s;
    int cnt0=0;
    int cnt1=0;
    
    REP(i,0,s.length()){
        if(s[i]=='0') cnt0++;
        if(s[i]=='1') cnt1++;
    }

    cout << min(cnt0,cnt1)*2 << ENT;
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;
 
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(non_snake_case, unused_variables)]
fn main() {
    let X: i64 = read();
    let Y: i64 = read();
    let ans: i64 =
        if X%Y==0 {
            -1
        } else { 
            X*(Y-1)
        };
    println!("{}", ans);
}



Measured memory_bytes: 4352
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local MOD = math.floor(10^9)+7

local tmp = read.l():totable()
local S = {}
for i=1,#tmp do
    if tmp[i] == '?' then
        S[i] = '?'
    else
        S[i] = tonumber(tmp[i])
    end
end

local map_newm = {}
local map_oldm = {}
for nd=0,9 do
    for oldm=0,12 do
        local x = oldm * 10 + nd
        local y = (oldm * 10 + nd) % 13
        map_newm[x] = y
        map_oldm[x] = oldm
    end
end
local N = #S
local ti = array(1, 0)
local tio = array(1, 0)
tio[0] = 1
for i=1,N do
    if S[i] == '?' then
        for m=0,12 do
            ti[m] = 0
        end
        for x=0,129 do
            local newm = map_newm[x]
            local oldm = map_oldm[x]
            ti[newm] = (ti[newm] + tio[oldm]) % MOD
        end
    else
        for oldm=0,12 do
            local newm = (oldm * 10 + S[i]) % 13
            ti[newm] = tio[oldm]
        end
    end
    tio, ti = ti, tio
end
print(tio[5])

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

const long long MOD = 2019;

void solve(long long L, long long R){
    long long ans = 1e9;
    if(R - L > 2019){
        cout << 0 << endl;
        return;
    }

    for(long long i = L;i<=R-1;i++){
        for(long long j = i+1;j <= R;j++){
            if(ans > (i*j) % MOD) ans = (i*j) % MOD;
            if(ans == 0) break;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long L;
    scanf("%lld",&L);
    long long R;
    scanf("%lld",&R);
    solve(L, R);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] str=Console.ReadLine().Split(' ');
      int N=int.Parse(str[0]);
      int T=int.Parse(str[1]);
   int[][] input = new int[N][];
      for(int i=0;i<N;i++){
        string[] str2=Console.ReadLine().Split(' ');
        input[i]=str2.Select(int.Parse).ToArray();
      }
      int ans=1000;
      bool flg=false;
      for(int i=0;i<N;i++){
        if(input[i][1]<=T){
          flg=true;
         if(input[i][0]<ans){
          ans=input[i][0]; 
         }
           
        }
      }
   if(flg){
     Console.WriteLine(ans);
   }else{
     Console.WriteLine("TLE");
   }
    }
    
  }

}


Measured memory_bytes: 28324
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, d, x; cin >> n >> d >> x;
  int sum = 0;
  rep(i, n) {
    int ai; cin >> ai;
    sum += (d - 1) / ai + 1;
  }
  outl(sum + x);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

void solve()
{
    int n, m;
    cin >> n >> m;

    cout << n * m << endl;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int ret = 0;
    int A[N], B[N], C[N];
    REP(i, N) {
        cin >> A[i];
        --A[i];
    }
    REP(i, N) {
        cin >> B[i];
        ret += B[i];
    }
    REP(i, N) cin >> C[i];

    FOR(i, 1, N) {
        if(A[i] - A[i-1] == 1) {
            ret += C[A[i-1]];
        }
    }

    cout << ret << endl;

}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[10**9]*(n)
dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j<0:
            continue
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]))
print(dp[n-1])

Measured memory_bytes: 53624
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int a[5];
  for (int i = 0; i < 5; i++) scanf("%d", &a[i]);
  for (int i = 0; i < 5; i++) { if (a[i] == 0) { printf("%d\n", i + 1); break; } }
  return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int get(int x) {
    cout << x << endl;
    string ans;
    cin >> ans;
    if (ans == "Vacant") exit(0);
    return (ans == "Male");
}

int main() {
    int n;
    cin >> n;
    int ls = get(0);
    int rs = get(n - 1);
    int l = 0, r = n - 1;
    while (1) {
        int m = (l + r) / 2;
        int ms = get(m);
        if ((ls == ms) ^ (l % 2 == m % 2)) {
            r = m;
            rs = ms;
        } else {
            l = m;
            ls = ms;
        }
    }
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 200010

// 中央値を O(1) で返し、動的に要素を追加できるデータ構造
// 要素数の合計が偶数なら、 2 つある中央値のうち小さい方を返す
class Median {
public:
    Median() : m_SumL(0), m_SumR(0) {}

    // 要素 x を追加
    void Add(ll x) {
        if(m_L.size() == 0 || x <= m_L.top()) {
            m_L.push(x);
            m_SumL += x;
        }
        else {
            m_R.push(x);
            m_SumR += x;
        }
        if((m_L.size() + m_R.size()) % 2 == 0) {
            // 要素数が偶数なら m_L と m_R の数は同じになるはず
            // (この時点で m_R の方が大きい状況はあり得ない)
            if(m_L.size() > m_R.size()) {
                m_SumL -= m_L.top();
                m_SumR += m_L.top();
                m_R.push(m_L.top());
                m_L.pop();
            }
            assert(m_L.size() == m_R.size());
        }
        else {
            // 要素数が奇数なら m_L の数が m_R より一つ多くなる
            if(m_L.size() < m_R.size()) {
                m_SumL += m_R.top();
                m_SumR -= m_R.top();
                m_L.push(m_R.top());
                m_R.pop();
            }
            assert(m_L.size() == m_R.size() + 1);
        }
    }

    // 中央値を返します
    // 要素数の合計が偶数なら、 2 つある中央値のうち小さい方を返す
    ll GetMedian() { return m_L.top(); }
    // 中央値含む左側の値の合計を返します
    ll GetLSum() { return m_SumL; }
    // 中央値より右側の値の合計を返します
    ll GetRSum() { return m_SumR; }
    // 中央値含む左側の要素数
    ll GetSizeL() { return m_L.size(); }
    // 中央値より右側の要素数
    ll GetSizeR() { return m_R.size(); }

private:
    priority_queue<ll> m_L;                                // 中央値より左側の数
    priority_queue<ll, vector<ll>, greater<ll> > m_R;
    ll m_SumL;                                              // 中央値より左側の数の和
    ll m_SumR;

};

ll Q;

signed main()
{
    cin >> Q;

    Median mset;

    ll sum_b = 0;

    REP(q, Q) {
        ll num;
        cin >> num;
        if(num == 1) {
            ll a, b;
            cin >> a >> b;

            sum_b += b;
            mset.Add(a);

        }
        else {
            // cand
            ll median = mset.GetMedian();
            ll ans = sum_b;
            ans += median * mset.GetSizeL() - mset.GetLSum();
            ans += mset.GetRSum() - median * mset.GetSizeR();
            printf("%lld %lld\n", median, ans);
        }
    }
    return 0;
}


Measured memory_bytes: 3828
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[[] for i in range(N+1)]

for i in range(M):
    x,y=map(int,input().split())
    E[x].append(y)
    E[y].append(x)

USE=[-1]*(N+1)
USE[0]=0
USE[1]=0

from collections import deque
Q=deque()
Q.append(1)
while Q:
    x=Q.pop()
    for to in E[x]:
        if USE[to]==-1:
            USE[to]=x
            Q.appendleft(to)

if -1 in USE:
    print("No")
else:
    print("Yes")
    print(*USE[2:])

Measured memory_bytes: 35168
#include <iostream>
using namespace std;
main () {
	int n, m;
	cin>>n>>m;
	int a[m], res = 0;
	for (int i=0;i<m;i++) {
		cin>>a[i];
		res+=a[i];
	}
	int hasil = n - res;
	if (hasil >= 0) {
		cout<<hasil<<endl;
	} else {
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 

 class Main{
             
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{
             String line;
             while((line=br.readLine())!= null){if(line.isEmpty())break;
                String[] spli=line.split(" ");
                double d=Double.parseDouble(line);
                
                double sum=d;
                for(int i=0;i<9;i++){
                    d=(i%2==0)? d*2 :d/3;sum+=d;
                }
                 System.out.println(sum);
                
                 
                 
             }
             
         }catch(Exception e){}         
     }
     
     
    
 }

Measured memory_bytes: 15088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
namespace Fact{
	long f[1000000];
	long rf[1000000];
	long pow(long N,long K){
		if(K == 0){
			return 1;
		}
		else if(K % 2 == 0){
			long t = pow(N,K/2);
			return t*t%mod;
		}
		else{
			return N*pow(N,K-1)%mod;
		}
	}
	void Fact(int N){
		for(int i=0;i<N+1;i++){
			if(i == 0){
				f[i] = 1;
			}
			else{
				f[i] = (f[i-1]*i)%mod;
			}
		}
		for(int i=N;i>=0;i--){
			if(i == N){
				rf[i] = pow(f[N],mod-2);
			}
			else{
				rf[i] = rf[i+1]*(i+1)%mod;
			}
		}
	}
	long GetFact(int N){
		return f[N];
	}
	long GetPerm(int N,int R){
		return f[N] * rf[N-R] % mod;
	}
	long GetConv(int N,int R){
		return ((f[N]*rf[R])%mod*rf[N-R])%mod;
	}
	long GetRev(int N){
		if(N == 0){
			return 1;
		}
		else{
			return rf[N] * f[N-1] % mod;
		}
	}
}
long DP[3002];
pair<int,int> Point[3002];
void Calc(){
	Fact::Fact(500000);
	int H = rei();
	int W = rei();
	int N = rei();
	for(int i=0;i<N;i++){
		int r = rei()-1;
		int c = rei()-1;
		Point[i] = {r,c};
	}
	Point[N] = {0,0};
	Point[N+1] = {H-1,W-1};
	N += 2;
	sort(Point,Point+N);
	DP[0] = mod-1;
	for(int i=1;i<N;i++){
		long ans = 0;
		for(int j=0;j<i;j++){
			if(Point[i].first >= Point[j].first && Point[i].second >= Point[j].second){
				ans += DP[j] * Fact::GetConv(Point[i].first - Point[j].first + Point[i].second - Point[j].second,Point[i].first - Point[j].first) % mod * (mod-1) % mod;
			}
		}
		DP[i] = ans % mod;
	}
	cout << DP[N-1] << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 10624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(All(A));
    using pll = pair<ll, ll>;
    vector<pll> chg(M);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        chg[i] = make_pair(b, a);
    }
    sort(All(chg));
    reverse(All(chg));
    vector<ll> chgll;
    rep(i, M) {
        ll a, b;
        tie(b, a) = chg[i];
        while(a > 0) {
            if(chgll.size() > N)
                break;
            chgll.push_back(b);
            a--;
        }
        if(chgll.size() > N)
            break;
    }
    sort(All(chgll));
    reverse(All(chgll));
    ll res = 0;
    int t = min(A.size(), chgll.size());
    rep(i, t) {
        if(A[i] < chgll[i])
            A[i] = chgll[i];
    }

    rep(i, N) { res += A[i]; }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n;
    int p;
    cin >> n;
    vector<int> range;
    vector<vector<int>> x(2, vector<int>(n, 0));
    for (int i = 0; i < 2; i++){
        for (int j = 1; j <= n; j++){
            range.push_back(j);
        }
        for (int j = 0; j < n; j++) {
            cin >> p;
            auto iter = find(range.begin(), range.end(), p);
            if (iter != range.end()){
                x[i][j] = iter - range.begin();
                range.erase(iter);
            }
        }
    }
    vector<int> f(n + 1, 1);
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i;

    int a = 0, b = 0;
    for (int i = 0; i < n; i++){
        a += max(0, x[0][n - i - 1]) * f[i];
        b += max(0, x[1][n - i - 1]) * f[i];
    }
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,t,a,m=0;
  cin>>k>>t;
  for(int i=0;i<t;++i){
    cin>>a;
    m=max(m,a);
  }
  cout << max(0,2*m-k-1) << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
cs = gets.chomp.chars
l = 0
r = n - 1
cnt = 0
while l != r
  if cs[l] == "W"
    if cs[r] == "R"
      cnt += 1
      cs[l] = "R"
      cs[r] = "W"
    else
      r -= 1
    end
  else
    l += 1
  end
end

puts cnt


Measured memory_bytes: 33488
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  cout << s[0] << (s.size() - 2) << s[s.size() - 1] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  ld A, B;
  cin >> A >> B;

  // main procedure

  // output
  WRITE_N((ll)(A * B));

  return 0;
}

Measured memory_bytes: 3764
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 5)


class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y

        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def check_same(self, x, y):
        return self.find(x) == self.find(y)


N, K, L = map(int, input().split())
r_union_find = UnionFind(N)
t_union_find = UnionFind(N)
for i in range(K):
    p, q = map(int, input().split())
    r_union_find.union(p, q)

for i in range(L):
    r, s = map(int, input().split())
    t_union_find.union(r, s)

pair = []

for i in range(1, N + 1):
    count = 0
    r_p = r_union_find.find(i)
    t_p = t_union_find.find(i)
    pair.append((r_p, t_p))

counter = Counter(pair)

answers = []
for p in pair:
    answers.append(counter[p])

answers = map(str, answers)
print(" ".join(answers))


Measured memory_bytes: 66548
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    vector<ll> cnt(3);
    ll n,a,b;cin>>n>>a>>b;
    for(ll i=0;i<n;i++){
        ll p;cin>>p;
        if(p<=a)cnt[0]++;
        else if(p<=b)cnt[1]++;
        else cnt[2]++;
    }
    cout<<(*min_element(cnt.begin(),cnt.end()));
}

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

int main()
{
    int n;
    cin>>n;
    int F[50];
    F[0]=1;
    F[1]=1;
    for(int i=2;i<=n;++i)F[i]=F[i-1]+F[i-2];
    cout<<F[n]<<endl;
 	return 0;
}


Measured memory_bytes: 3084
// https://atcoder.jp/contests/abc176/tasks/abc176_b
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	string n;
	cin >> n;
	long long ans = 0;
	for (auto x:n) {
		ans += (x-'0');
	}
	if (ans%9) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 3724
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n = int(input())
B = [int(input()) for _ in range(n)]



for i in B:
    if i in l1:
        l1[l1.index(i)] = 0
    if i in l2:
        l2[l2.index(i)] = 0
    if i in l3:
        l3[l3.index(i)] = 0

l4 = [l1[0], l2[0], l3[0]]
l5 = [l1[1], l2[1], l3[1]]
l6 = [l1[2], l2[2], l3[2]]
l7 = [l1[0], l2[1], l3[2]]
l8 = [l1[2], l2[1], l3[0]]

ans=[l1, l2, l3, l4, l5, l6, l7, l8]

c = 0
for i in range(8):
    if ans[i] == [0, 0, 0]:
        c += 1

if c >= 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class APoor {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int or = 0;
            for (int i = 0; i < 3; i++) {
                or |= (1 << in.nextInt());
            }

            boolean answer = Integer.bitCount(or) == 2;
            out.println(answer ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using namespace std;
using namespace __gnu_pbds;

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimization("Ofast")
#pragma GCC optimization("unroll-loops")

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define print(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; i--)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e6 + 5, MOD = 998244353, SIZE = 2e7, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//

//<<-----Implement Functions Here---->>//
void solve()
{
    vin(a, 5)
    print(find(all(a), 0) - a.begin() + 1)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    solve();
    return 0;
}

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



int main(){
    int n;
    cin >> n;
    int data[n]; 
    for(int i=0; i<n; i++){
        cin >> data[i];
    }
    int count = 0;
    for(int i=1; i<n-1; i++){
        if( min(data[i], max(data[i-1], data[i+1])) == data[i]  && max(data[i], min(data[i-1], data[i+1]))== data[i] )  {
            count ++;
        }
    }

    cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
a=[]
tmp=0
ex=0
for i in range(1,N+1):
    x,y=map(int,input().split())
    a.append([x,y])
a.sort(key=lambda x: x[1])
for i in range(N):
    b=int(a[i][0])
    c=int(a[i][1])
    tmp=tmp+b
    if tmp>c:
        ex=1
        print("No")
        break
if ex==0:
    print("Yes")

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

#define      ll      long long int

vector<int> v;

int dp[13][100005];

int go(int at, int sum)
{
    if (at == (int) v.size() || sum <= 0) {
        return 0;
    }
    if (dp[at][sum] != -1) {
        return dp[at][sum];
    }
    int res = 1e9;
    for (int i = at; i < (int) v.size(); i++) {
        if (sum - v[i] >= 0) {
            res = min(res, 1 + go(i, sum - v[i]));
        }
    }
    dp[at][sum] = res;
    return res;
}

int main( )
{
    ll n, i, j, k;
    cin >> n;
    for (i = 6; i <= n; i = i * 6) {
        v.push_back(i);
    }
    for (i = 9; i <= n; i = i * 9) {
        v.push_back(i);
    }
    v.push_back(1);
    sort(v.begin(), v.end());
    memset(dp, -1, sizeof dp);
    cout << go(0, n) << '\n';
    return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

int main(void){
   string s;
   cin >> s;
   int ai=0,zi=0;
   for (int i=0; i<s.size(); i++) {
       if (s.at(i)=='A') {
           ai=i;
           break;
       }
   } 
   for (int i=0; i<s.size(); i++) {
       if (s.at(i)=='Z') zi=i;
   }
    cout << zi-ai+1 << endl;
}

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

int main(void){
  int n;
  while(1){
    int points = 0;
    std::cin >> n;
    if(n == 0)  return 0;
    for(int i=0; i < n/4; i++){
      int tmp; std::cin >> tmp;
      points += tmp;
    }
    std::cout << points << std::endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();		
        int b = sc.nextInt();
		int c = sc.nextInt();
        if(a+b+c>=22){System.out.println("bust");}
		else{System.out.println("win");}
	}
}		

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
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; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

ll cnt = 0; 

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 

int main(){
  ll n,k;
  cin>>n>>k;

  mint ans = 0;

  rep(i, n+1-k){
    ans += (n+1)*n/2 -(n+1-(k+i))*(n-(k+i))/2 - (k+i)*(k+i-1)/2 + 1;
    //cout <<(n+1)*n/2 <<" "<<(n+1-(k+i))*(n-(k+i))/2 <<" "<<(k+i-1)*(k+i-2)/2  <<endl;
  } 
  ans += 1;
  cout<<ans.x<<endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;cin >> S;string correct = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < 16; i++) {
    if (S.at(i) != correct.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
    TASK: Medians
    GRADER: codersclub.in.th/problem/10275
    LANG: CPP
    AUTHOR: Parnikkapore
*/
#include<bits/stdc++.h>
using namespace std;

#define repeat(n) for(int i=0; i<n; i++)
#define dRepeat(n) for(int i=1; i<=n; i++)
#define dRepeatRev(n) for(int i=n; i>=1; i--)
#define inf 1000000 //1 million

/*
1 2 3 4 5 6
2 3 4 5 6 - 4
1 3 4 5 6 - 4
1 2 4 5 6 - 4
1 2 3 5 6 - 3
1 2 3 4 6 - 3
1 2 3 4 5 - 3
*/

int n, x[200010], y[200010];
int i,j,k;

int main(){
    scanf(" %d", &n);
    for(i=1; i<=n; i++){
        scanf(" %d", &x[i]);
        y[i]=x[i];
    }
    sort(x, x+i);
    int rmed = x[n/2];

    for(i=1; i<=n; i++){
        if(y[i]>rmed) printf("%d\n", x[n/2]);
        else          printf("%d\n", x[(n/2)+1]);
    }
    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nhw = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
      
        var result = 0;
        for(var i = 0; i < nhw[0]; i++)
        {
            var ab = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            if (ab[0] >= nhw[1] && ab[1] >= nhw[2]) result++;
        }
        WriteLine(result);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

Measured memory_bytes: 11092
n,a,b=map(int,input().split())
p=10**9+7
q,res=divmod(n,10000)
n1=(2**10000)%p

total = 1
for i in range(q):
  total *= n1
  total %= p
total *= 2**res
total %= p

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n&1:res=res*a%mod
        a = a * a % mod
        n>>=1
    return res

def modinv(a, mod): return modpow(a,mod-2,mod)

A = 1
for i in range(a//3):
  A = A*modinv((a-3*i)*(a-3*i-1)*(a-3*i-2), p)
  A = A*(n-3*i)*(n-3*i-1)*(n-3*i-2) % p
for j in range(a%3):
  A = A*modinv(a-3*(a//3)-j,p)
  A = A*(n-3*(a//3)-j)%p

B = 1
for i in range(b//3):
  B = B*modinv((b-3*i)*(b-3*i-1)*(b-3*i-2), p)
  B = B*(n-3*i)*(n-3*i-1)*(n-3*i-2) % p
for j in range(b%3):
  B = B*modinv(b-3*(b//3)-j,p)
  B = B*(n-3*(b//3)-j)%p

print((total-A-B-1)%p)

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X;
	cin >> X;

	if(X == 3 || X == 5 || X == 7){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	return 0;
}



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

lint mod = 1e+9 + 7;
int n;
vector<lint> a;

// 素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long i = 2; i * i <= n; i++)
        while (n % i == 0) res[i]++, n /= i;
    if (n != 1) res[n]++;
    return res;
}

// a^n mod pを計算　O(log n)
long long int pow_mod(long long int a, long long int n, long long int p) {
    if (n == 0) return 1;
    long long int temp = pow_mod(a, n / 2, p);
    return n & 1 ? (((temp * temp) % p) * a) % p : (temp * temp) % p;
}

// Z_pでのaの逆元を計算 O(log p)
// depend:pow_mod
long long int inv_mod(long long int a, long long int p) {
    return pow_mod(a, p - 2, p);
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    unordered_map<lint, lint> lcm;
    for (int i = 0; i < n; i++) {
        unordered_map<lint, lint> pf = pf_um(a[i]);
        for (auto e : pf) {
            int fac = e.first;
            if (lcm[fac] < e.second) {
                lcm[fac] = e.second;
            }
        }
    }
    lint l = 1;
    for (auto e : lcm) {
        l = (l * pow_mod(e.first, e.second, mod)) % mod;
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint temp = l * inv_mod(a[i], mod);
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#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<int,int>;

int main(){
    char s[100];
    int l,k,k2;
    k=0;

    cin >> s;
    l=strlen(s);
    rep(i,(l-1)/2+1){
        if (s[i]!=s[l-1-i]){
            k=1;
            
        }

    }
    rep(i,(l-1)/2){
        if (s[i]!=s[(l-1)/2-i-1]){
            k=2;
        }

    }
    for (int j=(l+3)/2-1; j<l; ++j){
        if (s[j]!=s[l+(l+3)/2-j-2]){
            k=3;
        }
    }
    if (k==0){
        cout << "Yes" << endl;

    }
    else{
        cout << "No" << endl;
    }
    
    

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] arr = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			int h = arr[0];
			int n = arr[1];

			int[] arr2 = Console.ReadLine().Trim().Split(' ').Select(hogehoge => int.Parse(hogehoge)).ToArray<int>();

			long sum = 0;

			for (int i = 0; i < n; i++)
			{
				sum += arr2[i];
			}

			if (h <= sum)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}


		}

	}

}


Measured memory_bytes: 18144
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvpi vector<vpi>
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;
	
void solve(){
	fio;
  	int n;
  	cin>>n;
  	long double ar[n];
  	For(i,n)cin>>ar[i];
  	long double dp[n+1][n+1];
  	memset(dp,0,sizeof(dp));
  	dp[0][0]=1;
  	for(int i=1;i<=n;i++){
  		dp[i][0]=dp[i-1][0]*(1-ar[i-1]);
  	}
  	for(int i=1;i<=n;i++){
  		for(int j=1;j<=n;j++){
  			dp[i][j]=dp[i-1][j-1]*ar[i-1] + dp[i-1][j]*(1-ar[i-1]);
  		}
  	}
  	long double ans=0;
  	for(int i=(n+1)/2;i<=n;i++){
  		ans+=dp[n][i];
  	}
  	cout.precision(10);
  	cout<<fixed<<ans<<endl;
}

int32_t main(){
	fio;
	#ifndef ONLINE_JUDGE
  		freopen("input.txt", "r", stdin);
  		freopen("output.txt", "w", stdout);
  	#endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){ 
		//cout<<"Case #"<<i<<":\n";
		solve();
	}
	return 0;
}


Measured memory_bytes: 144472
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define vec_range(n1, n2) vec.begin() + n1, vec.begin() + n2

int main() {
	vector<int> vec; int an, tn, fn1, fn2; int set = 0;
	cin >> an; vec.resize(an);
	for (int i = 0; i < an; i++) cin >> vec[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> fn1 >> fn2; reverse(vec_range(fn1, fn2));
	}
	for (int i : vec) cout << (set++ ? " " : "") << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int A[N];
   int a;
   memset(A, 0, sizeof(A));
   for (int i = 0; i < N; i++) {
      cin >> a;
      A[a - 1] = i + 1;
   }
   for (int i = 0; i < N; i++) {
      cout << A[i] << " ";
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
	string a,b;
	int sum=0;
	cin>>a>>b;
	for (int i=0;i<3;i++){
		if(a[i]==b[i])
			sum+=1;
	}
	cout<<sum;
}

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

int main()
{
	int n[100], x[100];
	int i = 0;
	int cnt = 0;

	while (1)
	{
		cin >> n[i] >> x[i];

		if (n[i] == 0 && x[i] == 0)
		{
			break;
		}

		for (int j = 1; j <= n[i]; j++)
		{
			for (int k = 1; k <= n[i]; k++)
			{
				for (int l = 1; l <= n[i]; l++)
				{
					if (j < k && k < l)
					{
						if (j + k + l == x[i])
						{
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
		i++;
		cnt = 0;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int k, s, t;
	
	while(1){
		cin >> k;
		if(k == 0){
			break;
		} else if(k == 2){
			cin >> k;
			cout << k << endl;
			continue;
		}
		s = 0;
		for(int i = 0, n = k*(k-1)/2; i < n; i++){
			cin >> t;
			s += t;
		}
		cout << s/(k-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0