akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;
map<ll,int> m;
ll ans = 0;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    m[0] = 1;
    cin >> n;
    ll csum = 0;
    F0R(i,n) {
        int x; cin >> x;
        csum += x;
        ans += m[csum];
        m[csum] ++;
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int data[4];

void string_to_int(string s){
  rep(i,4){
    char c=s[i];
    //cout<<c-'0'<<endl;
    data[i]=(c-'0');
  }
}

void solve(){
  int sum=0;
  rep(i,2){
    rep(j,2){
      rep(k,2){
	sum=data[0];
	string ans=to_string(data[0]);
	
	if(i==0){
	  sum+=data[1];
	  ans=ans+'+'+to_string(data[1]);
	}else{
	  sum-=data[1];
	  ans=ans+'-'+to_string(data[1]);
	}

	if(j==0){
	  sum+=data[2];
	  ans=ans+'+'+to_string(data[2]);
	}else{
	  sum-=data[2];
	  ans=ans+'-'+to_string(data[2]);
	}

	if(k==0){
	  sum+=data[3];
	  ans=ans+'+'+to_string(data[3]);
	}else{
	  sum-=data[3];
	  ans=ans+'-'+to_string(data[3]);
	}

	if(sum==7){
	  ans=ans+"=7";
	  cout<<ans<<endl;
	  return ;
	}
      }
    }
  }
}

int main(){
  string s;
  cin>>s;
  string_to_int(s);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    int i,j,l,m,n;
    string s;
    int h1,h2,m1,m2,k;

    cin>>h1>>m1>>h2>>m2>>k;
    cout<<h2*60+m2-(h1*60+m1)-k;

    return 0;
}


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

int main()
{
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  double D,T,S;
  cin>>D>>T>>S;

  double X = D/S;
  if(X<=T)
    cout<<"Yes";
  else
    cout<<"No";

  return 0;

}


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

int main(){
    const ll int MOD=1e+9+7;
    int n;
    cin>>n;
    ll int ans=1;
    for(int i=1;i<=n;++i){
        ans=((ans%MOD)*i)%MOD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>         vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)            for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

ll xp(ll b, ll e) {
  if (e == 0) return 1;
  ll c = xp(b, e >> 1);
  c = c * c % mod;
  if (e & 1) c = c * b % mod;
  return c;
}

ll inv(ll b) {
  return xp(b, mod - 2);
}

ll choose(ll n, ll k) {
  if (k > n / 2) k = n - k;
  ll a = 1, b = 1;
  loop(k) {
    a = a * (n - i) % mod;
    b = b * (i + 1) % mod;
  }
  return a * inv(b) % mod;
}

ll solve(ll s, int n) {
  s -= 3 * n;
  if (s < 0) return 0;
  return choose(s + n - 1, n - 1);
}

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

  int s;
  cin >> s;
  ll ans = 0;
  for (int i = 1;;i++) {
    ll x = solve(s, i);
    if (!x) break;
    ans += x;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long k;
    cin >> k;
    cout << 50 << endl;
    for(int i = 0; i < 50; ++i){
        long long a = k % 50, b = k / 50;
        long long d = i + b;
        if(i < a) d += 50 - a + 1;
        else d -= a;
        cout << d << " ";
    }
}

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

long long int gcd(long long int a,long long int b){
	if(b==0)	return a;
	return gcd(b,a%b);
}
	
int main(){
	long long int a,b,M,N;
	while(cin >> a>>b){
		long long int g = gcd(a,b);
		cout << g << ' ' << a/g*b << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
n,k=map(int,input().split())
line=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
    left,right=i,i+k-1
    ans=min(ans,
            abs(line[left])+abs(line[left]-line[right]),
            abs(line[right])+abs(line[right]-line[left])
            )
print(ans)

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

void dfs(int d, long long val, vector<long long> &all) {
    
    all.push_back(val);

    if(d == 10) return;
   for(int i = -1; i <= 1; i++) {
       int add = (val % 10) + i;
       if(add >= 0 && add <= 9) {
           dfs(d + 1, val * 10 + add, all);
       }
   }
}
int main(){
 int K;
 cin >> K;
 vector<long long> all;
 for(int v = 1; v < 10; v++) dfs(1, v, all);

    sort(all.begin(),all.end());

    cout << all[K - 1];
 return 0;
}

Measured memory_bytes: 2420
A = input()
B = input()
C = input()

cp = 'a'
winner = ''
while winner == '':
  if cp == 'a':
    if A == '':
      winner = 'A'
    else:
      cp = A[0]
      A = A[1:]
  elif cp == 'b':
    if B == '':
      winner = 'B'
    else:
      cp = B[0]
      B = B[1:]
  elif cp == 'c':
    if C == '':
      winner = 'C'
    else:
      cp = C[0]
      C = C[1:]


print(winner)

Measured memory_bytes: 3064
#!/usr/bin/env python3

def solve(s):
  l = []
  for c in s:
    if c == "0" or c == "1":
      l.append(str(c))
    elif len(l):
      l.pop()
  return "".join(l)




def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9048
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pii pair<int,int>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i);
#define int long long int

signed main()
{

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	int a,b;cin>>a>>b;
	cout<<a*b<<endll;


}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> s[i][j];
    }
  }

  int ans = 0;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      vector<vector<int>> d(h, vector<int>(w, -1));
      d[i][j] = 0;
      queue<pair<int, int>> q;
      q.push({i, j});
      while (!q.empty()) {
        pair<int, int> p = q.front();
        q.pop();
        rep(k, 4) {
          if (p.first + dy[k] < 0 || p.first + dy[k] >= h) continue;
          if (p.second + dx[k] < 0 || p.second + dx[k] >= w) continue;
          if (s[p.first + dy[k]][p.second + dx[k]] == '#') continue;
          if (d[p.first + dy[k]][p.second + dx[k]] != -1) continue;
          d[p.first + dy[k]][p.second + dx[k]] = d[p.first][p.second] + 1;
          q.push({p.first + dy[k], p.second + dx[k]});
        }
      }

      int res = 0;
      rep(k, h) {
        rep(l, w) {
          res = max(res, d[k][l]);
        }
      }
      ans = max(ans, res);
    }
  }
  cout << ans << endl;



  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;

typedef long long ll;
ll INF = 1LL << 60;
ll MAX = 100010;
ll MOD = 2019;

int
main() 
{
  ll l, r; cin >> l >> r;
  r = min(r, l + 2020);

  ll min = INF;
  rep(i, l, r){
    repe(k, i + 1, r){
      if((i * k % MOD) < min){
        min = i * k % MOD;
      }
    }
  }

  cout << min << endl;
}



Measured memory_bytes: 256
import Data.List
main = getLine >> getContents >>= print . uncurry (+) . foldl' ff (1, 1) . map (map read . words) . lines

ff :: (Int, Int) -> [Int] -> (Int, Int)
ff (a, b) [x, y] = (n * x, n * y)
    where
        n = max nx ny
        nx
            | a `mod` x == 0 = a `div` x
            | otherwise = a `div` x + 1
        ny
            | b `mod` y == 0 = b `div` y
            | otherwise = b `div` y + 1


Measured memory_bytes: 1532
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]
C = Counter(4 if a % 4 == 0 else 2 if a % 2 == 0 else 1 for a in A)

if C[2] == 0:
    print("Yes" if C[1] <= C[4] + 1 else "No")
else:
    print("Yes" if C[1] <= C[4] else "No")


Measured memory_bytes: 14636
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    H,N = LMIIS()
    AB = XLMIIS(N)
    #最小消費量[価値]
    inf_v = 20000
    inf_c = 10**8
    dp = [inf_c]*inf_v
    dp[0] = 0

    for i in range(H):
        if dp[i] == inf_c:
            continue
        for a,b in AB:
            dp[i+a] = min(dp[i+a], dp[i] + b)
    print(min(dp[H:]))

if __name__ == '__main__':
    main()

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

int V,E;
ll bitmasks[31];
ll sum_bitmasks[31];

void dfs(int cur,int cost,int &ans,ll mask){

  if( cost >= ans ) return;
  if( mask == (1LL<<V)-1LL ) {
    ans = min(ans,cost);
    return;
  }
  if( cur >= V ) return;
  if( (mask|(sum_bitmasks[cur])) != ((1LL<<V)-1LL) ) return;

  dfs(cur+1,cost,ans,mask); 
  dfs(cur+1,cost+1,ans,mask|bitmasks[cur]);

}

int main(){
  while( cin >> V >> E, V|E ){
    rep(i,V) bitmasks[i] = 0LL;
    rep(i,E){
      int a,b;
      cin >> a >> b;
      bitmasks[a] |= (1LL<<a);
      bitmasks[a] |= (1LL<<b);
      bitmasks[b] |= (1LL<<a);
      bitmasks[b] |= (1LL<<b);
    }
    sum_bitmasks[V] = 0;
    for(int i=V-1;i>=0;i--){
      sum_bitmasks[i] = sum_bitmasks[i+1] | bitmasks[i];
    }
    int ans = V;
    dfs(0,0,ans,0);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/**
 * Created by hiramekun at 20:55 on 2019-09-07.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl p(n);
    unordered_map<ll, ll> mp;
    set<ll> s;
    rep(i, n) {
        cin >> p[i];
        mp[p[i]] = i;
        s.insert(p[i]);
    }

    set<ll> idx;
    ll ans = 0;
    while (!s.empty()) {
        ll now = *s.rbegin();
        s.erase(now);

        ll i = mp[now];
        vl l(2, -1), r(2, n);
        {
            auto itr = idx.lower_bound(i);
            // r
            rep(j, 2) {
                if (itr == idx.end()) break;
                r[j] = *itr;
                itr++;
            }
        }
        {
            auto itr = idx.lower_bound(i);
            rep(j, 2) {
                if (itr == idx.begin()) break;
                itr--;
                l[j] = *itr;
            }
        }

        ll l1 = i - l[0], l2 = l[0] - l[1];
        ll r1 = r[0] - i, r2 = r[1] - r[0];
        ans += (l1 * r2 + l2 * r1) * now;

        idx.insert(i);
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 9764
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N; cin >> N;
    vi U(N-1), V(N-1), W(N-1); 
    REP(i, N-1) {
        cin >> U[i] >> V[i] >> W[i];
        U[i]--; V[i]--;
    }

    vvi es(N);
    map<pii, int> len;
    REP(i,N-1) {
        es[U[i]].push_back(V[i]);
        es[V[i]].push_back(U[i]);
        len[pii(U[i], V[i])] = W[i];
        len[pii(V[i], U[i])] = W[i];
    }

    vi ans(N, 0);
    queue<int> que;
    vb vis(N, false);

    ans[U[0]] = 0;
    que.push(U[0]);
    while(!que.empty()) {
        int x = que.front(); que.pop();
        vis[x] = true;
        for(int i : es[x]) {
            if (!vis[i]) {
                que.push(i);
                if (len[pii(x, i)] % 2 == 0) ans[i] = ans[x];
                else ans[i] = 1 - ans[x];                
            }
        }
    }

    REP(i,N) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 20096
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> v;
    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        v.emplace_back(k);
    }
    int p = (lower_bound(v.begin(), v.end(), x)-v.begin());
    cout << min(p, m-p) << "\n";
    return 0;
}


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

string s;

int main()
{
  ios::sync_with_stdio(false);
  int i,j;
  cin>>s;

  for(i=0;i<s.size();i++)
  {
    if(s[i]=='C') break;
  }

  for(j=i;j<s.size();j++)
  {
    if(s[j]=='F'){cout<<"Yes";return 0;}
  }
  cout<<"No";
}


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

int main() {
    int h,w;
    cin >> h >> w;
    for(int i=0;i<=w+1;i++){
        cout << '#';
        if(i==w+1) cout << endl;
    }
    vector<char> a(w+2);
    for(int i=1;i<=h;i++){
        cout << '#';
        for(int i=0;i<w;i++){
            cin >> a.at(i);
            cout << a.at(i);
        }
        cout << '#' << endl;
    }
    for(int i=0;i<=w+1;i++){
        cout << '#';
        if(i==w+1) cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

vector<int> prime(int n){
    vector<int> res(100,0);
    for(int i=2; i*i<=n; i++){
        while(n%i == 0){ res[i]++; n /= i; }
    }
    if(n>1) res[n]++;
    return res;
}

int main(){
    int n; cin >> n;
    vector<int> data(100,0);
    loop(i,1,n+1) rep(j,101) data[j] += prime(i)[j];
    int a3 = 0, a5 = 0, a15 = 0, a25 = 0, a75 = 0;
    rep(i,101){
        if(2 <= data[i] && data[i] < 4) a3++;
        else if(4 <= data[i] && data[i] < 14) a5++;
        else if(14 <= data[i] && data[i] < 24) a15++;
        else if(24 <= data[i] && data[i] < 74) a25++;
        else if(74 <= data[i]) a75++;
    }
    int ans = a3*(a5+a15+a25+a75)*(a5+a15+a25+a75-1)/2;
    ans += (a5+a15+a25+a75)*(a5+a15+a25+a75-1)*(a5+a15+a25+a75-2)/2;
    ans += (a15+a25+a75)*(a5+a15+a25+a75-1);
    ans += (a25+a75)*(a3+a5+a15+a25+a75-1);
    ans += a75;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

int main(){
    string Sa,Sb,Sc; cin >> Sa >> Sb >> Sc;
    int cnta = 0, cntb = 0, cntc = 0;
    char now = 'a';
    rep(i,Sa.size()+Sb.size()+Sc.size()){
        if(now == 'a'){
            cnta++;
            if(cnta > Sa.size()){
                cout << "A" << endl;
                return 0;
            }
            now = Sa[cnta - 1];
            continue;
        }
        if(now == 'b'){
            cntb++;
            if(cntb > Sb.size()){
                cout << "B" << endl;
                return 0;
            }
            now = Sb[cntb - 1];
            continue;
        }
        if(now == 'c'){
            cntc++;
            if(cntc > Sc.size()){
                cout << "C" << endl;
                return 0;
            }
            now = Sc[cntc - 1];
            continue;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int h[100010];

int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&h[i]);
    h[0]=0;
    for (int i=1;i<=n;i++)
    {
        if (h[i]-1>=h[i-1]) h[i]--;
        if (h[i]<h[i-1]){
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(ll i=0; i<(n); i++)
#define FOR(i, a, n) for(ll i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(){
    ll L,R;cin>>L>>R;
    int ans = INT_MAX;
    if(R-L <= 2019){
        FOR(i, L, R+1){
            FOR(j, i+1, R+1){
                ans = (i*j)%2019 < ans ? (i*j)%2019 : ans;
            }
        }
    }else{
        FOR(i, L, L+2019){
            FOR(j, i+1, L+2019){
                ans = (i*j)%2019 < ans ? (i*j)%2019 : ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n,k;
    cin>>n>>k;
    ll ans=n%k==0?0:1;
    cout<<ans<<endl;
    return  0;
}


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

int main() {

    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    ll now = 0;
    ll repeatStartIndex;
    ll repeatCycle;
    vector<ll> firstVisitIndex(n, -1);
    firstVisitIndex[now] = 0;
    for (ll i = 1; i <= n; i++) {
        now = a[now];
        if (firstVisitIndex[now] == -1) {
            firstVisitIndex[now] = i;
        }
        else {
            repeatStartIndex = now;
            repeatCycle = i - firstVisitIndex[now];
            break;
        }
    }
    ll ans;
    ll mod;
    if (k < firstVisitIndex[repeatStartIndex]) {
        now = 0;
        for (ll i = 0; i < k ; i++) {
            now = a[now];
        }
        ans = now;
    }
    else { // firstVisitIndex[repeatStartIndex] <= k
        k -= firstVisitIndex[repeatStartIndex];
        now = repeatStartIndex;
        mod = k % repeatCycle;
        for (ll i = 0; i < mod; i++) {
            now = a[now];
        }
        ans = now;
    }
    cout << ans + 1<< endl;
    return 0;
}

Measured memory_bytes: 6412
n = int(input())
a = list(map(int, input().split()))
num = [0 for _ in range(10**6+1)]
for x in a:
	num[x] += 1

ok = [True for _ in range(10**6+1)]
ans = 0
for i in range(1, 10**6+1):
	if num[i] == 1 and ok[i] == True:
		ans += 1
	if num[i]:
		for j in range(i, 10**6+1, i):
			ok[j] = False
print(ans)

Measured memory_bytes: 217440
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==1) break;
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			int p;
			for(int i=1;;i++){
				p = 7*i-1;
				if(p>n) break;
				if(n%p==0) list.add(p);
				p += 2;
				if(p>n) break;
				if(n%p==0) list.add(p);
			}
			
			System.out.print(n + ":");
			boolean flag;
			for(int i=0;i<list.size();i++){
				p = list.get(i);
				flag = false;
				for(int j=i-1;j>=0;j--){
					if(p%list.get(j)==0){
						flag = true;
						break;
					}
				}
				if(flag==false) System.out.print(" " + p);
			}
			System.out.println();
			
		}	
	}	
}

Measured memory_bytes: 24068
import math
import collections
import heapq
from collections import defaultdict
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    maxv = n*(n-1)//2
    a = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1

    v = 0  # 頂点数
    # 頂点にIDをふる
    Id = [[-1 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(n):
            if i < j:  # 1-3 ,2-4など　3-1はダメ
                Id[i][j] = v
                v += 1

    def toId(i, j):
        if i > j:
            i, j = j, i
        return Id[i][j]



    e = [[] for i in range(maxv)]
    for i in range(n):
        for j in range(n - 1):
            # a[i][j]にIDを代入する Id[1][3]=1 => a[1][3] = a[3][1] = 1
            x = i
            y = a[i][j]
            if x > y:
                x, y = y, x
            a[i][j] = Id[x][y]  # toId(i, a[i][j])
        for j in range(n - 2):
            e[a[i][j + 1]].append(a[i][j])


    calculated = [False for i in range(maxv)]
    dp = [-1 for i in range(maxv)]

    def dfs(v):
        if dp[v] != -1:  # サイクル検知
            if not calculated[v]:
                return -1
            return dp[v]
        dp[v] = 1
        for u in e[v]:
            ret = dfs(u)
            if ret == -1:
                return -1
            dp[v] = max(dp[v], ret + 1)
        calculated[v] = True
        return dp[v]

    ans = 0
    for i in range(v):
        ret = dfs(i)
        if ret == -1:  # detected cycle
            print(-1)
            exit()
        ans = max(ans, ret)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 211376
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
struct edge {int to,cost;};
#define VMAX 51
typedef std::pair<int,int> P;

    ll N,M;
    ll ans;
    string S;
    int A[5];
    bool F=false;
    bool Q[5];
int main(){
    ios_base::sync_with_stdio(false);
    cin>>S;
    REP(i,4)A[i]=int(S[i]-'0');
    REP(Bit,1<<3){
        int sum=A[0];
        DEB(Bit)END
        REP(i,3){
            if(Bit&1<<i)sum+=A[i+1],Q[i]=true;
            else sum-=A[i+1],Q[i]=false;
        }
        if(sum==7){DEB(Bit);END;break;}
    }
    cout<<A[0];
    REP(i,3){
        cout<<(Q[i]?"+":"-")<<A[i+1];
    }
    cout<<"=7";
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
#define Graph vector<vector<int>>
using namespace std;

vi v;

main()
{
        v.assign(26,0);

        string s; cin>>s;
        each(it,s)v[it-'a']++;

        each(it,v)it%=2;

        int sum=0;
        each(it,v)sum+=it;
        cout<<(sum==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int n,a=0,w=0,t=0,r=0;
	cin>>n;
	string s;
	for (int i=1;i<=n;i++)
	{
		cin>>s;
		if (s=="AC")
		{
			a++;
		}
		if (s=="WA")
		{
			w++;
		}
		if (s=="TLE")
		{
			t++;
		}
		if (s=="RE")
		{
			r++;
		} 
	}
	cout<<"AC x "<<a<<endl;
	cout<<"WA x "<<w<<endl;
	cout<<"TLE x "<<t<<endl;
	cout<<"RE x "<<r<<endl;
	return 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef int def; //default parameter for loops

#define fori(a) for(def i=0; i<(a); i++)
#define fori1(a) for(def i=1; i<=(a); i++)
#define fori_(a) for(def i=(a)-1; i>=0; i--)
#define fori1_(a) for(def i=(a); i>0; i--)
#define forii(a, b) for(def i=(a); i<(b); i++)
#define forii_(a, b) for(def i=(b)-1; i>=(a); i--)

#define forj(a) for(def j=0; j<(a); j++)
#define forj1(a) for(def j=1; j<=(a); j++)
#define forj_(a) for(def j=(a)-1; j>=0; j--)
#define forj1_(a) for(def j=(a); j>0; j--)
#define forjj(a, b) for(def j=(a); j<(b); j++)
#define forjj_(a, b) for(def j=(b)-1; j>=(a); j--)

#define fork(a) for(def k=0; k<(a); k++)
#define fork1(a) for(def k=1; k<=(a); k++)
#define fork_(a) for(def k=(a)-1; k>=0; k--)
#define fork1_(a) for(def k=(a); k>0; k--)
#define forkk(a, b) for(def k=(a); k<(b); k++)
#define forkk_(a, b) for(def k=(b)-1; k>=(a); k--)

#define forl(a) for(def l=0; l<(a); l++)
#define forl1(a) for(def l=1; l<=(a); l++)
#define forl_(a) for(def l=(a)-1; l>=0; l--)
#define forl1_(a) for(def l=(a); l>0; l--)
#define forll(a, b) for(def l=(a); l<(b); l++)
#define forll_(a, b) for(def l=(b)-1; l>=(a); l--)

#define forg(a) for(def g=0; g<(a); g++)
#define forg1(a) for(def g=1; g<=(a); g++)
#define forg_(a) for(def g=(a)-1; g>=0; g--)
#define forg1_(a) for(def g=(a); g>0; g--)
#define forgg(a, b) for(def g=(a); g<(b); g++)
#define forgg_(a, b) for(def g=(b)-1; g>=(a); g--)

#define forf(a) for(def f=0; f<(a); f++)
#define forf1(a) for(def f=1; f<=(a); f++)
#define forf_(a) for(def f=(a)-1; f>=0; f--)
#define forf1_(a) for(def f=(a); f>0; f--)
#define forff(a, b) for(def f=(a); f<(b); f++)
#define forff_(a, b) for(def f=(b)-1; f>=(a); f--)

#define forh(a) for(def h=0; h<(a); h++)
#define forh1(a) for(def h=1; h<=(a); h++)
#define forh_(a) for(def h=(a)-1; h>=0; h--)
#define forh1_(a) for(def h=(a); h>0; h--)
#define forhh(a, b) for(def h=(a); h<(b); h++)
#define forhh_(a, b) for(def h=(b)-1; h>=(a); h--)

#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

template <typename T>
std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
  if ( !v.empty() ) {
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
  }
  return out;
}
template <typename T>
std::ostream& operator<< (std::ostream& out, const std::set<T>& v) {
  if ( !v.empty() ) {
    std::copy (v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
  }
  return out;
}

const int N = 1e5+10;
const ll M = 1e9+7;

int DP[501][501];

int main(){
	fastIO;
	int n, m, q;
	cin>>n>>m>>q;
	fori(m){
		int l, r;
		cin>>l>>r;
		DP[l][r]++;
	}
	fori1(n-1){
		forj1(n-i){
			DP[j][i+j]+=DP[j+1][i+j]+DP[j][i+j-1]-DP[j+1][i+j-1];
		}
	}
	fori(q){
		int a, b;
		cin>>a>>b;
		cout<<DP[a][b]<<endl;
	}
}


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

namespace ABC153
{
    class A
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int H = input[0];
            int A = input[1];

            if (H % A == 0) { Console.WriteLine(H / A); }
            else { Console.WriteLine(H / A + 1); }
        }
    }
}


Measured memory_bytes: 13268
# https://atcoder.jp/contests/abc103/tasks/abc103_c

import itertools
from collections import Counter
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = sum([a - 1 for a in A])
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  cin >> n;
  if (n % 4 == 0 || n % 7 == 0)
  {
    cout << "Yes" << endl;
    return 0;
  }
  
  for (int cake = 0; cake * 4 <= n; ++cake)
  {
    for (int donut = 0; donut * 7 <= n; ++donut)
    {
      if (n - donut * 7 - cake * 4 == 0)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,j,n,m,a[100][100],b[100],sum=0;

	scanf("%d%d", &n, &m);

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
			/* 空白区切りで入力は無理 */
		}
	}

	for (i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			sum += a[i][j] * b[j];
		}
		printf("%d\n", sum);
		sum = 0;
	}

	return 0;
}


Measured memory_bytes: 2100
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    h,w=map(int,input().split())
    grid=[0]*h
    for i in range(h):
        grid[i]=input()
    Sl=[[0]*w for _ in range(h)]
    Sr=[[0]*w for _ in range(h)]
    Su=[[0]*w for _ in range(h)]
    Sd=[[0]*w for _ in range(h)]

    # Sl
    for i in range(h):
        cnt=0
        for j in range(w):
            if(grid[i][j]=='.'):
                cnt+=1
                Sl[i][j]=cnt
            else:
                cnt=0
                Sl[i][j]=cnt

    # Sr
    for i in range(h):
        cnt=0
        for j in range(w-1,-1,-1):
            if(grid[i][j]=='.'):
                cnt+=1
                Sr[i][j]=cnt
            else:
                cnt=0
                Sr[i][j]=cnt

    # Su
    for j in range(w):
        cnt=0
        for i in range(h):
            if(grid[i][j]=='.'):
                cnt+=1
                Su[i][j]=cnt
            else:
                cnt=0
                Su[i][j]=cnt

    # Sd
    for j in range(w):
        cnt=0
        for i in range(h-1,-1,-1):
            if(grid[i][j]=='.'):
                cnt+=1
                Sd[i][j]=cnt
            else:
                cnt=0
                Sd[i][j]=cnt

    ans=0
    for i in range(h):
        for j in range(w):
            if(grid[i][j]=='#'): continue
            ans=max(Sl[i][j]+Sr[i][j]+Su[i][j]+Sd[i][j]-3,ans)
    print(ans)
resolve()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S, T;
	cin >> S >> T;
	REP(i, S.size()){
		bool tmp = true;
		REP(j, S.size()){
			if(S[j] != T[(i+j)%S.size()]) tmp = false;
		}
		if(tmp){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt(); 
    int k = x;
    int tmp = 0;
    while (k > 0){
      tmp++;
      k = k/10;      
    }


    if(tmp == 1){
      if(x == 2||x == 4||x == 5 || x == 7 || x == 9){
        System.out.println("hon");
      }else if (x == 1 || x == 6 || x == 8){
        System.out.println("pon");
      }     else{
        System.out.println("bon");
      }
    }

    if(tmp == 2 || tmp == 3){
      x %= 10;
      if(x == 2||x == 4||x == 5 || x == 7 || x == 9){
        System.out.println("hon");
      }else if (x == 0||x == 1 || x == 6 || x == 8){
        System.out.println("pon");
      }     else{
        System.out.println("bon");
      }
    }

    
  }
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,B,C;
    double ans=0;
    cin>>N;
    double A[N];
    int S[N],D[N];

    rep(i,N){
        cin>>A[i];
    }
    double sum=0;
    rep(i,N){
        sum+=1.00/A[i];
    }
    ans=1.00/sum;

    printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max(x, y) ((x) > (y) ? (x) : (y))

int main(void)
{
  long a, b, k;
  
  scanf("%ld%ld%ld", &a, &b, &k);
  
  if (a > k)
    a -= k;
  else {
    b = max(0, a + b - k);
    a = 0;
  }
  
  printf("%ld %ld", a, b);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int n, cnt = 0;
vector<int> vec;

void insertionSort(int g){
	int v, j;
	for(int i = g;i < n; ++i){
		v = vec[i];
		j = i - g;
		while(j >= 0 && vec[j] > v){
			vec[j+g] = vec[j];
			j = j - g;
			cnt++;
		}
		vec[j+g] = v;
	}
}

void shellSort(){
	int m = 0, s = 1;
	while((n/s) > 0){
		s *= 2;
		m++;
	}

	int G[20];

	for(int k=0, t = 1; k<m; ++k){
		G[k] = n/t;
		t *= 2;
	}
	for(int i=0; i<m; ++i){
		insertionSort(G[i]);
	}

	cout << m << endl;
	for(int i=0; i < m; ++i){
		if(i != m-1) cout << G[i] << " ";
		else cout << G[i] << endl;
	}
	cout << cnt << endl;
	for(int i=0; i < n;++i){
		cout << vec[i] << endl;
	}
}

int main(){
	int num;
	cin >> n;
	for(int i=0; i<n; ++i){
		cin >> num;
		vec.push_back(num);
	}
	shellSort();

	return 0;
}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std; 

int main(void)
{
    int n;
    cin >> n; 
    
    v_int v(n);

    irep(i, n) {
        cin >> v[i];
    }
    int ans = INF;

    irep2(y, -100, 100) {
        int sum = 0;
        irep(i, n) {
            sum += (v[i] - y) * (v[i] - y);   
        }
        ans = min(sum, ans);
    }

    cout << ans;
    return 0;
}
/** tcoder **/


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

#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF=1l<<60;


signed main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
  vector<int>num,ans;
  int n,p,prime[1000001];

  for(int i=0;i<1000001;i++)prime[i]=0;
  prime[0]=prime[1]=1;

  for(int i=2;i*i<1000001;i++){
    if(prime[i]==0){
      for(int j=2*i;j<1000001;j+=i){
	prime[j]=1;
      }
    }
  }

  while(cin >> n >> p){
    if(n<0 && p<0)break;
    num.clear();
    ans.clear();

    for(int i=n+1;i<n+p+1000;i++)
      if(prime[i]==0)num.push_back(i);

    for(int i=0;i<num.size();i++){
      for(int j=i;j<num.size();j++){
	ans.push_back(num[i]+num[j]);
      }
    }
    sort(ans.begin(),ans.end());

    cout << ans[p-1] << endl;
  }

  return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N, M, S, T;
  vector< int > g[100000];

  cin >> N >> M >> S >> T;
  --S, --T;
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  int d[100000][2];
  memset(d, -1, sizeof(d));
  queue< pair< int, pair< int, int>> > que;
  que.emplace(0, make_pair(S, 0));
  d[S][0] = 0;
  while(que.size()) {
    int cost = que.front().first;
    auto p = que.front().second;
    que.pop();
    for(auto &to : g[p.first]) {
      if(d[to][p.second ^ 1] == -1) {
        d[to][p.second ^ 1] = cost + 1;
        que.emplace(cost + 1, make_pair(to, p.second ^ 1));
      }
    }
  }

  if(d[T][0] == 2) {
    cout << 2 << endl;
    return 0;
  }

  if(d[T][1] == -1) {
    cout << -1 << endl;
    return 0;
  }

  bool primes[1010101] = {};
  for(int i = 2; i < 1010101; i++) {
    if(primes[i]) continue;
    if(d[T][1] <= i && i >= 3) {
      cout << i << endl;
      return 0;
    }
    for(int j = i + i; j < 1010101; j += i) {
      primes[j] = true;
    }
  }
}



Measured memory_bytes: 10376
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	if n%10 == 0 {
		fmt.Printf("10\n")
		return
	}

	ans := 0
	for true {
		if n < 10 {
			ans += n
			break
		}
		ans += n % 10
		n = n / 10
	}

	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)

for i in range(min(len(s),len(t))):
    if s[i]==t[i]:
        count=1
        continue
    elif s[i]<t[i]:
        count=2
        break
    else:
        count=0
        break
if count==1:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')
elif count==2:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  int year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  int month = (s[5] - '0') * 10 + (s[6] - '0');
  int date = (s[8] - '0') * 10 + (s[9] - '0');
  if (year < 2019 || (year == 2019 && month < 4) || (month == 4 && date <= 30)) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A[5][4][11],n;
    for( int i=1; i<=4; i++)
    for( int j=1; j<=3; j++)
    for( int k=1; k<=10;k++) A[i][j][k]=0;
    
    cin >> n;
    for(int i=0; i<n; i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    
    for ( int f=1; f<=4; f++){
     if(f>1) cout << "####################\n";
     for(int b=1; b<=3; b++){
        for( int r=1; r<=10; r++){
        cout << " " << A[f][b][r];
    }
    cout << endl;
        }
}
        
        return 0;
}



Measured memory_bytes: 3112