akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <queue>
#include <algorithm>

using namespace std;

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

int main() {
    int N;
    vector<P> a;
    cin >> N;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        a.emplace_back(P(x, i+1));
    }

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

    for(int i = 0; i < N; i++){
        cout << a[i].second << " ";
    }

    cout << endl;


    return 0;
}

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

int A,B;

int sum_n(int n){
    int N[5];
    for(int i=0;i<5;i++){
      N[i] = n%10;
      n = n/10;
    }
    if(N[0] == N[4] && N[1] == N[3]) return 1;
    else return 0;
}

int main() {
    cin >> A >> B;
    int ans = 0;
    for(int i=A;i<=B;i++) ans += sum_n(i);

    cout << ans << endl;
}


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

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
			int N = vs[0];
			int M = vs[1];
			int min = 0, max = int.MaxValue;
			for (int i = 0; i < M; i++) {
				vs = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
				min = Math.Max(min, vs[0]);
				max = Math.Min(max, vs[1]);
			}
			if (min <= max) {
				Console.WriteLine(Math.Min(N, max) - min + 1);
			} else {
				Console.WriteLine(0);
			}
		}
	}
}


Measured memory_bytes: 17456
#coding:utf-8

class MakeTree():
    def __init__(self, key, p=None, l=None, r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r
 
def Insert(root,value):
    y = None
    x = root
    z = MakeTree(value)

    while x != None:
        y = x
        if x.key > z.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def inParse(u):
    if u == None:
        return
    inParse(u.l)
    global inParseList
    inParseList.append(u.key)
    inParse(u.r)

def preParse(u):
    if u == None:
        return
    global preParseList
    preParseList.append(u.key)
    preParse(u.l)
    preParse(u.r)


root = None       
n = int(input())
inParseList = []
preParseList = []
for i in range(n):
    order = list(input().split())
    if order[0] == "insert":
        root = Insert(root, int(order[1]))
    else:
        inParse(root)
        preParse(root)

        print(" " + " ".join([str(i) for i in inParseList]))
        print(" " + " ".join([str(i) for i in preParseList]))
        preParseList = []
        inParseList = []



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

int main() {
    string s; cin >> s;
    bool b1 = false, b2 = false, b3 = false;
    if (s[0] == 'A') b1 = true;
    for (int i=2; i<=s.size()-2; ++i) {
        if (s[i] == 'C') b2 = true;
    }
    int cnt = 0;
    for (int i=0; i<s.size(); ++i) {
        if (s[i] < 'a' || 'z' < s[i]) cnt++;
    }
    if (cnt == 2) b3 = true;
    cout <<  (b1 && b2 && b3 ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
    return b>0?gcd(b,a%b):a;
}
int main(){
	int n;
	cin >> n;
	long long sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=gcd(i,gcd(j,k));
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
long long MOD = 1e9+7;
long long INF = 1e15;
typedef pair<long long, long long> P;

int main(){
    int N, K;
    cin >> N >> K;
    int n = (N-1)*(N-2)/2;
    if(K > n) cout << -1 << endl;
    else{
        int M = (N-1) + (n-K);
        cout << M << endl;
        rep2(i, 1, N){
            cout << i << ' ' << N << endl;
        }
        int count = 0;
        rep2(i, 1, N){
            if(count == n-K) break;
            rep2(j, i+1, N){
                if(count == n-K) break;
                cout << i << ' ' << j << endl;
                count++;
            }
        }
    }  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double EPS = 1e-10;
const int INF = 2147483647;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

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

	if (s.size() < 4) {
		cout << "No" << endl;
	}
	else if (s.substr(0,4) == "YAKI"){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

long long n,d,a;
long long x,h;

void solve(){
    int i,j;
    string str;
    cin >> n >> d >> a;
    priority_queue<pair<long long,long long>,vector<pair<long long,long long> >,
    greater<pair<long long,long long> > > xh;
    for(i = 0;i < n;i++){
        cin >> x >> h;
        xh.push(make_pair(x,h));
    }
    long long ans = 0;
    long long dd = 0;
    while(!xh.empty()){
        x = xh.top().first;
        h = xh.top().second;
        xh.pop();
        if(h < 0){
            dd += h;
        }
        else if(h > dd){
            ans += (h-dd+a-1)/a;
            xh.push(make_pair(x+d+d+1,-((h-dd+a-1)/a*a)));
            dd += (h-dd+a-1)/a*a;
        }
    }
    cout << ans << endl;
}

int main(){
    solve();
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int a,b,c,d,e,k;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> a >> b >> c >> d >> e >> k;

  if (e - a > k)
    cout << ":(\n";
  else
    cout << "Yay!\n";


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b;
  scanf("%d%d",&a,&b);
  int sum=0;
  for(int i=0;i<2;i++){
	if(a>=b){sum+=a;
             a--;
            }
    else {sum+=b;
          b--;
         }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
from collections import deque

def main():
    n=int(input())
    l=[0]*n
    d={}
    for i in range(n-1):
        a,b,c=map(int,input().split())
        a-=1
        b-=1
        if a in d:
            d[a].add((b,c))
        else:
            d[a]={(b,c)}
        if b in d:
            d[b].add((a,c))
        else:
            d[b]={(a,c)}
    q,k=map(int,input().split())
    k-=1
    p=deque([k])
    while len(p):
        w=p.popleft()
        for i in d[w]:
            if (l[i[0]]==0 and i[0]!=k) or (l[i[0]]!=0 and l[i[0]]>l[w]+i[1]):
                l[i[0]]=l[w]+i[1]
                p.append(i[0])

    for i in range(q):
        x,y=map(int,input().split())
        print(l[x-1]+l[y-1])
if __name__ == '__main__':
    main()

Measured memory_bytes: 104584
from collections import deque


def CC():
    id=0
    color=["white" for i in range(n)]
    for j in range(n):
        if color[j]=="white":
            color[j]="gray"
            queue=deque([j])

            while len(queue)!=0:
                u=queue.popleft()
                for i in M[u]:
                    if color[i]=="white":
                        color[i]="gray"
                        queue.append(i)
                color[u]=str(id)
            id +=1

    return color


n,m=map(int,input().split())
M=[[] for i in range(n)]
for i in range(m):
    p,q=map(int,input().split())
    M[p].append(q)
    M[q].append(p)

color=CC()

for i in range(int(input())):
    a,b=map(int,input().split())
    print("yes" if color[a]==color[b] else "no")


Measured memory_bytes: 28936
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto v = prime_factor(n);
  ll res = 0;
  for(auto a : v){
    int count = 1;
    while(a.second >= count){
      res++;
      a.second -= count;
      count++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;

long long combination(int n){
    return n * (n - 1) / 2;
}

int main(){
    int n;
    cin >> n;
    unordered_map<string, int> c;
    string tmp;
    long long sum = 0;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        if (c.find(tmp) != c.end()){
            sum += c[tmp];
            c[tmp]++;
        }
        else{
            c[tmp] = 1;
        }
    }
//    for (auto itr = c.begin(); itr != c.end(); ++itr){
//        sum += combination(itr->second);
//    }
    cout << sum << endl;
    return 0;
}

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

int main () {
	
	std::vector<int> n(5);
	for(int i = 0; i < 5; i++){
		cin >> n[i];
	}
	sort(n.begin(),n.end());
	for(int i = 0; i < 5; i++){
		cout << n[4-i];
		if(i != 4){
			cout << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<string, pair<int, int>>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second.first;
        a[i].second.first *= -1;
        a[i].second.second = i + 1;
    }

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

    for (int i = 0; i < n; i++)
    {
        cout << a[i].second.second << endl;
    }

    return 0;
}

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

int main() {
    
    int a, b;
    cin >> a >> b;
    
    if(a<10 && a>0 && b<10 && b>0) cout << a*b << endl;
    else cout << "-1" << endl;
    
    
    
    
    
    
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define cc(a) cout << a << endl;
#define msg(a,b) cout << a << " : " << b << endl;
#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;
#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;



int main(){
    string str;
    long long int currSum = 0, k,c;
    cin >> str >> k;
    for(int i=0;i<str.size();i++){
        c= str[i]-'0';
        if(c == 1){
            k -= 1;
        }else{
            //k -= (c * 5* 1000000000000000);
            cout << c << endl;
            break;
        }
        if(k <= 0){
            cout << c << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
'use strict'
// T−x×0.006 度

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v)

  let n = input.shift()
  let T = input.shift()
  let A = input.shift()

  input = input.slice(0, n)

//   console.log(input)

  //   ;[n, T, A] = [input.shift(), input.shift(), input.shift()] //input.slice(0, 3)

  let tmp = new Array(n)
  for (let i in input) {
    tmp[i] = Math.abs(A - (T - input[i] * 0.006))
  }
//   console.log(tmp.length)
  // cosnt ans = Math.apply.max(null, tmp )
  //   const ans = Math.max(...tmp) + 1
  const ans = tmp.indexOf(Math.min(...tmp)) + 1
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main () {
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);
    //printf("%d, %d, %d\n", a,b,c);

    if(a == b){
        if(b == c){
            puts("1");
        }else{
            puts("2");
        }
    }else if(b == c){
        if(a == b){
            puts("1");
        }else{
            puts("2");
        }
    }else if(a == c){
        if(b == c){
            puts("1");
        }else{
            puts("2");
        }
    }else{
        puts("3");
    }

    return 0;
}


Measured memory_bytes: 128
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

one = S()
two = S()

if one[0] == two[2] and one[1] == two[1] and one[2] == two[0]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(string S) {
  int ans(0), n(0);
  REP(i, 3)
    if (S[i] == 'S')
      n = 0;
    else {
      n++;
      ans= max(ans, n);
    }
  cout << ans << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  solve(S);

  return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n;
  for (;;) {
    cin >> n;
    if (n == 0) {
      break;
    }

    int a[1000];
    double m = 0.0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      m += static_cast<double>(a[i]);
    }
    m /= static_cast<double>(n);

    double var = 0.0;
    for (int i = 0; i < n; ++i) {
      var += (static_cast<double>(a[i]) - m) * (static_cast<double>(a[i]) - m);
    }
    var /= static_cast<double>(n);
    printf("%f\n", sqrt(var));
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;
void solve(){
    if(a+b>n+1||a*b<n){
        puts("-1");
        return ;
    }
    while(n>0){
        ll x=min(a,n-b+1);
        for(ll i=n-x+1;i<=n;i++)
            cout<<i<<" ";
        n-=x;
        b--;
    }
}
int main(){
    while(cin>>n>>a>>b)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S[] = sc.next().split("/");

        int year = Integer.parseInt(S[0]);
        int month = Integer.parseInt(S[1]);

        String ans = "TBD";
        if(year < 2018 || (year == 2019 && month < 5)){
            ans = "Heisei";
        }

        out.println(ans);
    }
}


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

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

const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
int main()
{
  int i, m, d;
  
  while (cin >> m >> d, m){
    int cntdays = 0;
    for (i = 0; i < m; i++) cntdays += month[i];
    switch ((cntdays + d) % 7){
      case 0:
        cout << "Wednesday";
        break;
      case 1:
        cout << "Thursday";
        break;
      case 2:
        cout << "Friday";
        break;
      case 3:
        cout << "Saturday";
        break;
      case 4:
        cout << "Sunday";
        break;
      case 5:
        cout << "Monday";
        break;
      case 6:
        cout << "Tuesday";
        break;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
// F.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 660;

int head[MAX_N], current, n, m;
double dp[MAX_N];
bool vis[MAX_N];

struct edge
{
    int to, nxt;
    bool tag;
} edges[MAX_N * MAX_N << 1];

void addpath(int src, int dst)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    head[src] = current++;
}

void process(int block)
{
    for (int u = n - 1; u >= 1; u--)
    {
        int deg = 0;
        double max_son = 0, sum = 0;
        for (int i = head[u]; i != -1; i = edges[i].nxt)
            sum += dp[edges[i].to], max_son = max(max_son, dp[edges[i].to]), deg++;
        if (block == u && deg >= 2)
            deg--, sum -= max_son;
        dp[u] = sum / deg + 1;
    }
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d%d", &n, &m);
    for (int i = 1, u, v; i <= m; i++)
        scanf("%d%d", &u, &v), addpath(u, v);
    double ans = 0x3f3f3f3f;
    for (int i = 0; i <= n - 1; i++)
        process(i), ans = min(ans, dp[1]);
    printf("%.8lf", ans);
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string s,t; cin >> s >> t;
    cout << t + s << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second
namespace taolu
{
	const int N=201000;
	typedef long long ll;
	typedef std::pair<int,int> pii;
	struct disjoint_set_union
	{
		int q[N],w[N];
		void init(int n){for(int i=1;i<=n;i++)q[i]=i,w[i]=1;}
		int ask(int p){return p!=q[p]?q[p]=ask(q[p]):p;}
		void link(int u,int v){w[ask(v)]+=w[ask(u)];q[ask(u)]=ask(v);}
		bool uni(int u,int v){return ask(u)==ask(v);}
		int query(int p){return w[ask(p)];}
	}d;
	bool ex[N];
	pii s[N];
	int n;
	ll ans;
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1,x;i<=n;i++)
			scanf("%d",&x),s[i]=pii(x,i);
		std::sort(s+1,s+n+1);
	}
	void solve()
	{
		initialize();
		ans=0;
		d.init(n);
		for(int i=n;i;i--)
		{
			int p=s[i].y,x=0,y=0;
			if(ex[p-1])x=d.query(p-1),d.link(p,p-1);
			if(ex[p+1])y=d.query(p+1),d.link(p,p+1);
			ans+=(ll)(x+1)*(y+1)*s[i].x;
			ex[p]=1;
		}
		printf("%lld\n",ans);
	}
}
int main()
{
	taolu::solve();
	return 0;
}


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

int n, m;
vector<int> a;
vector<int> stars;

int sep(int x, int t) {
	x *= t;
	if (x < 10) return x;
	return x % 10 + 1;
}

unsigned solve(int i, int total) {
	if (i == stars.size()) {
		return (total % 10) == 0;
	}
	
	int res = 0;
	for (int ai : a) {
		res += solve(i + 1, total + sep(ai, stars[i]));
	}
	return res;
}

int main() {
	string id;
	cin >> n >> id >> m;
	a = vector<int>(m);
	for (int& ai : a) {
		cin >> ai;
	}
	
	int base = 0;
	for (int i = 0;  i < n; i++) {
		int t = 1 + ((n - i - 1) & 1);
		if (id[i] == '*') {
			stars.push_back(t);
		}
		else {
			base += sep(id[i] - '0', t);
			base %= 10;
		}
	}
	
	cout << solve(0, base) << endl;
	
	return 0;
}

Measured memory_bytes: 1352
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

   //int t; cin>>t; while(t--) 
	int n,k; cin>>n>>k;
	mii mp;
	f(i,0,n) mp[i]=0;
	f(i,0,k) {
		int d; cin>>d;
		f(j,0,d) {
			int x;
			cin>>x;
			mp[x-1]++;
		}
	}
	int sum=0;
	for(auto it:mp) {
		if(!it.sc) sum++;
	}
	cout<<sum;
	
    return 0 ;  
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
 
    void solve (){
        int n;
        n=5;
        vector<int>a(n);
        for(int i=0;i<n;i++)
            cin>>a[i];
        int k;
        cin>>k;
        int total=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(abs(a[i]-a[j])>k)
                    total++;
            }
        }
        if(total)
            cout<<":(";
        else{
            cout<<"Yay!";
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3588
n,*d=map(int,open(0).read().split())
f=[d[i]-d[n+i]for i in range(n)]
m=[v for v in f if v<0]
p=sorted(v for v in f if v>0)
c=len(m);s=sum(m)
while p and s<0:s+=p.pop();c+=1
print(-1if s<0else c)

Measured memory_bytes: 25076
n = gets.strip.to_i
data = n.times.map { gets.strip.split.map(&:to_i) }
pattern = data.permutation(n).to_a
sum_route = 0

pattern.each do |p|
  (0..p.length-2).each do |i|
    x = (p[i][0]-p[i+1][0])**2
    y = (p[i][1]-p[i+1][1])**2
    l = Math.sqrt(x+y)
    sum_route += l
  end
end
puts (sum_route / pattern.length).round(9)

Measured memory_bytes: 8316
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

ans=n
for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
      cnt+=1
  '''
  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  '''

  ans=min(ans,n-cnt)
print(ans)

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

vector<string>adj;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

int bfs(int rotx,int roty,int tox,int toy){
	vector<vector<int>>dist(h,vector<int>(w,1e7));
	dist[rotx][roty]=0;
	deque<pair<int,int>>q;
	q.push_front({rotx,roty});
	while(!q.empty()){
		int x = q.front().first;
		int y = q.front().second;
		q.pop_front();
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx>=0&&ny>=0&&nx<h&&ny<w && adj[nx][ny]=='.'){
				if(dist[nx][ny]>dist[x][y]){
					dist[nx][ny]=dist[x][y];
					q.push_front({nx,ny});
				}
			}
		}
		for(int i=x-2;i<=x+2;i++){
			for(int j=y-2;j<=y+2;j++){
				if(i>=0&&j>=0&&i<h&&j<w &&adj[i][j]=='.'){
					if(dist[i][j]>dist[x][y]+1){
						dist[i][j]=dist[x][y]+1;
						q.push_back({i,j});
					}
				}
			}
		}
	}

	return dist[tox][toy];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		adj.push_back(s);
	}
	int ans = bfs(ch,cw,dh,dw);
	if(ans>=1e7)ans=-1;
	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 8732
#include <stdio.h>

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



Measured memory_bytes: 2104
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

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




using namespace std;




int main(){
    ll N,K,C;
    cin>>N>>K>>C;
    string st;
    cin>>st;
    vector<ll> vec1,vec2;
    ll count=0;
    for(ll i=0;i<N;++i){
        if(count>K)break;
        if(st[i]=='o'){
            vec1.push_back(i);
            i=i+C;
            ++count;
        }
      
    }
    /*for(int i=0;i<vec1.size();++i){
        cout<<vec1[i]<<" ";
    }
    cout<<endl;
    */
    count=0;
    for(ll i=N-1;i>=0;--i){
        if(count>K)break;
        if(st[i]=='o'){
            vec2.push_back(i);
            i=i-C;
            ++count;
        }
        
     
    }
    sort(vec2.begin(),vec2.end());
   /*for(int i=0;i<vec2.size();++i){
        cout<<vec2[i]<<" ";
    }
    cout<<endl;
    */
    for(int i=0;i<vec1.size();++i){
        if(vec1[i]==vec2[i]){
            cout<<vec1[i]+1<<endl;
        }
    }
}





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

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >>d;
	int ans = 0;
	for(int i = 0;i <=100;i++){
		if (a<= i && b > i && c <= i && d > i){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
using namespace std; const int N=400010;
inline int read()
{
	int s=0, w=1; ri char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar(); return s*w;
}
void print(int x) {if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,k,c,x,wd,book[N],ot[N],cnt; char s[N];
signed main()
{
	scanf("%lld%lld%lld",&n,&k,&c);
	scanf("%s",s+1); 
	for(ri int i=1;i<=n;i++)
	{
		if(s[i]=='x'||i<=x) continue;
		if(wd>=k) {return 0; } x=i+c;
		wd++, book[i]=1;
	} x=n+1;
	for(ri int i=n;i;i--)
	{
		if(s[i]=='x'||i>=x) continue;
		x=i-c; if(book[i]) ot[++cnt]=i;
	}
	for(ri int i=cnt;i;i--) printf("%lld\n",ot[i]);
	return 0;
}

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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

ll n,x,t;

int main()
{
	io;
	cin >> n >> x >> t;
	ll ans = (n / x) * t;
	if(n%x)
		ans += t;
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector< pair<double, string> > mo(n);
    double sum=0.0;
    for(int i=0; i<n; i++){
        cin >> mo[i].first >> mo[i].second;
    }
    for(int i=0; i<n; i++){
        if(mo[i].second == "BTC"){
            sum += 380000.0 * mo[i].first;
            continue;
        }
        sum += mo[i].first;
    }
    cout << setprecision(15) << sum << endl;
    return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <cmath>
# include <tuple>
# include <vector>
# include <queue>
# include <string>
# include <map>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(3*n);
    for (int i = 0; i < 3*n; i++) cin >> a[i];
    vector<ll> plus(2*n, 0), minus(2*n, 0);
    priority_queue<ll, vector<ll>, greater<ll>> first;
    ll initialSum = 0;
    for (int i = 0; i < n; i++) {
        first.push(a[i]);
        initialSum+=a[i];
    }
    plus[n-1] = initialSum;
    for (int i = n; i < 2*n; i++) {
        ll tmp = plus[i-1];
        if (first.top() < a[i]) {
            tmp += a[i] - first.top();
            first.pop();
            first.push(a[i]);
        }
        plus[i] = tmp;
    }

    priority_queue<ll> second;
    initialSum = 0;
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        second.push(a[i]);
        initialSum+=a[i];
    }
    minus[n-1] = initialSum;
    for (int i = n; i < 2*n; i++) {
        ll tmp = minus[i-1];
        if (second.top() > a[i]) {
            tmp += a[i] - second.top();
            second.pop();
            second.push(a[i]);
        }
        minus[i] = tmp;
    }

    ll ans;
    for (int i = n-1; i < 2*n; i++) {
        if (i == n-1) ans = plus[i] - minus[3*n-i-2];
        else ans = max(ans, plus[i] - minus[3*n-i-2]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8052
package main

import (
	"fmt"
)

func main() {

	var X, Y int
	fmt.Scanf("%d %d", &X, &Y)

	flag := 0
	for i := 0; i <= X; i++ {
		j := X - i
		if Y == (2*i + 4*j) {
			flag = 1
		}
	}

	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1832
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    if(n == 0) puts("1");
    else if(n == 1) puts("2");
    else if(n == 2) puts("1");
    else puts("0");
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<ll, ll> ii;
ll n, v[100005], a[100005], b[100005], mi = 1e18, ma = -1e18;
vector<ii> od, ev;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> v[i];
        mi = min(mi, v[i]);
        ma = max(ma, v[i]);
        if (i & 1) a[v[i]]++;
        else b[v[i]]++;
    }
    for (int i = mi; i <= ma; i++) {
        if(a[i] != 0) od.push_back({a[i], i});
        if(b[i] != 0) ev.push_back({b[i], i});
    }
    sort(od.begin(), od.end());
    sort(ev.begin(), ev.end());
    if(od[od.size() - 1].se != ev[ev.size() - 1].se) {
        cout << n - od[od.size() - 1].fi - ev[ev.size() - 1].fi;
        return 0;
    }
    ll re = 1e9;
    if(ev.size() == 1 && od.size() == 1) {
        cout << n / 2;
        return 0;
    }
    if(ev.size()>=2)re = min(re, n-od[od.size() - 1].fi - ev[ev.size() - 2].fi);
    if(od.size()>=2)re = min(re, n-od[od.size() - 2].fi - ev[ev.size() - 1].fi);
    cout << re;
    return 0;
}


Measured memory_bytes: 4340
#include <set>
#include <cstdio>

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

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int g[100][100];
int gg[100][100];
int sign[100];
int maygo[100][100];

double A[100][100];
double B[100];

int n, s, t;

const double EPS = 1e-10;
inline bool isZero(double d){ return -EPS < d && d < EPS; }

void debug(){
  REP(i,n){
    REP(j,n) printf("%.1f ", A[i][j]);
    printf("%.1f\n", B[i]);
  }
  puts("");
}

int main(){
  const int MAX = 10000000;
  while(true){
    n = getInt();
    s = getInt() - 1;
    t = getInt() - 1;

    if(n + s + t == -2) break;

    REP(i,n) sign[i] = getInt();
    REP(i,n) REP(j,n){
      gg[i][j] = g[i][j] = getInt();
      if(i != j && gg[i][j] == 0) gg[i][j] = MAX;
    }

    REP(k,n) REP(i,n) REP(j,n)
      gg[i][j] = min(gg[i][j], gg[i][k] + gg[k][j]);

    REP(i,n){
      REP(j,n) maygo[i][j] = 0;
      if(sign[i]){
        // go minimum
        int mn = MAX;
        REP(j,n) if(g[i][j])
          mn = min(mn, g[i][j] + gg[j][t]);
        REP(j,n) if(g[i][j] && mn == g[i][j] + gg[j][t])
          maygo[i][j] = 1;
      }else{
        REP(j,n) if(g[i][j])
          maygo[i][j] = 1;
      }
    }

    if(gg[s][t] != MAX){
      REP(i,n) REP(j,n) A[i][j] = 0.0;
      REP(i,n) B[i] = 0.0;

      REP(i,n){
        if(i != t){
          int cnt = 0;
          REP(j,n) if(maygo[i][j]){
            A[i][j] = -1.0;
            B[i] += g[i][j];
            cnt++;
          }
          A[i][i] = cnt;
        }else{
          A[i][i] = 1.0;
        }
      }

      // hakidasi
      REP(i,n){
        // debug();

        if(isZero(A[i][i])){
          for(int j = i + 1; j < n; j++)
            if(!isZero(A[j][i])){
              REP(k,n) swap(A[i][k], A[j][k]);
              break;
            }
        }

        if(isZero(A[i][i])) printf("test: %d\n", i);

        REP(j,n) if(i != j && !isZero(A[j][i])){
          double div = A[j][i] / A[i][i];
          REP(k,n) A[j][k] -= div * A[i][k];
          B[j] -= div * B[i];
          if(!isZero(A[j][i])) puts("test2");
        }
      }

      // debug();

      printf("%.10f\n", B[s] / A[s][s]);
    }else{
      puts("impossible");
    }
  }

  return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    intl i,j,n;
    cin>>n;
    vector<intl> ar(n);
    intl sum=0;
    for(i=0;i<n;i++){
        cin>>ar[i];
        sum+=ar[i];
    }
    sort(ar.begin(),ar.end(),greater<intl>());
    intl val=2;
    intl ans=ar[0];
    for(i=1;i<n;i++){
        if(n==val){
            break;
        }
        else if(val==n-1){
            ans+=ar[i];
            val++;
        }
        else{
            ans+=(2*ar[i]);
            val+=2;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 4784
/*
Author : N_o_o_B
Created : April 22 2020 16:21:44 
*/
#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;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    int d,x;
    cin >> d >> x;
    vi a(n);
    int ans = x;
    fori(i,n){
        cin >> a[i];
        ans += (d-1)/a[i]+1;
    }
    cout << ans << endl;


    time_taken();
    return 0;
}

Measured memory_bytes: 256
//Wan Hong 2.2
//notebook
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
#define INF (1ll<<58)
ll read()
{
	ll x=0,f=1;
	char c;
	do
	{
		c=getchar();
		if(c=='-')f=-1;
	}while(c<'0'||c>'9');
	do
	{
		x=x*10+c-'0';
		c=getchar();
	}while(c>='0'&&c<='9');
	return f*x;
}
ll min(ll a,ll b)
{
	return a<b?a:b;
}
ll max(ll a,ll b)
{
	return a>b?a:b;
}

/**********/
#define MAXN 11
ll a[MAXN];
int main()
{
	ll ans=0,n=3;
	for(ll i=1;i<=n;++i)a[i]=read();
	std::sort(a+1,a+n+1);
	for(ll i=n;i>1;--i)ans=ans*10+a[i];
	printf("%lld\n",ans+a[1]);
	return 0;
}

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

int main() {
	int n, a, b;
	std::cin >> n >> a >> b;

	std::vector<int> p(n);
	for (auto &v : p) {
		std::cin >> v;
	}

	int x = 0, y = 0, z = 0;
	for (auto v: p) {
		x += v <= a;
		y += a < v && v <= b;
		z += b < v;
	}

	std::cout << std::min(x, std::min(y, z)) << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     debug       printf("\n<<CameHere<<\n")
#define     mem(x,y)    memset(x, y, sizeof(x))
#define     all(qz)     qz.begin(),qz.end()
#define     rall(qz)    qz.rbegin(),qz.rend()
#define     inf         LLONG_MIN
#define     INF         LLONG_MAX
#define     mod         1000000007
#define     Sqr(x)      ((x)*(x))
#define     ll          long long
#define     mk          make_pair
#define     pb          push_back
#define     pi          acos(-1.0)
#define     cos(a)      cos(a*pi/180)
#define     sin(a)      sin(a*pi/180)
#define     tan(a)      tan(a*pi/180)

ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}
/*---------AL ASAD NUR RIYAD------------*/


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    ll x=(n/1000)*1000;
    if(x==n) cout<<0<<endl;
    else cout<<(x+1000)-n<<endl;
    return 0;
}



















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

const int MAXN = 501000;
int t1[MAXN],t2[MAXN],c[MAXN];
int n;
char a[MAXN];
bool cmp(int *r,int a,int b,int l)
{
    return r[a]==r[b]&&r[a+l]==r[b+l];
}

void da(int str[],int sa[],int ra[],int height[],int n,int m)
{
    n++;
    int i,j,p,*x=t1,*y=t2;
    for(i=0; i<m; i++)
        c[i]=0;
    for(i=0; i<n; i++)
        c[x[i]=str[i]]++;
    for(i=1; i<m; i++)
        c[i]+=c[i-1];
    for(i=n-1; i>=0; i--)
        sa[--c[x[i]]]=i;
    for(j=1; j<=n; j<<=1)
    {
        p=0;
        for(i=n-j; i<n; i++)
            y[p++]=i;
        for(i=0; i<n; i++)
            if(sa[i]>=j)
                y[p++]=sa[i]-j;
        for(i=0; i<m; i++)
            c[i]=0;
        for(i=0; i<n; i++)
            c[x[y[i]]]++;
        for(i=1; i<m; i++)
            c[i]+=c[i-1];
        for(i=n-1; i>=0; i--)
            sa[--c[x[y[i]]]]=y[i];
        swap(x,y);
        p=1;
        x[sa[0]]=0;
        for(i=1; i<n; i++)
            x[sa[i]]=cmp(y,sa[i-1],sa[i],j)?p-1:p++;
        if(p>=n)
            break;
        m=p;
    }
    int k=0;
    n--;
    for(i=0; i<=n; i++)
        ra[sa[i]]=i;
    for(i=0; i<n; i++)
    {
        if(k)
            k--;
        j=sa[ra[i]-1];
        while(str[i+k]==str[j+k])
            k++;
        height[ra[i]]=k;
    }
}

int ra[MAXN],height[MAXN];
int sa[MAXN],num[MAXN];

bool ok(int k)
{
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        if(height[i]<k)
            continue;
        int maxx=max(sa[i-1],sa[i]),minn=min(sa[i-1],sa[i]);
        int j=i;
        while(height[j+1]>=k&&j<=n)
        {
            j++,maxx=max(maxx,sa[j]),minn=min(minn,sa[j]);
        }
        if(maxx-minn>=k)
            return 1;
    }
    return 0;
}



int main()
{
    scanf("%d",&n);
    scanf("%s",a);
    for(int i=0; a[i]!='\0'; i++)
        num[i]=a[i]-'a'+1;
    num[n]=0;
    da(num,sa,ra,height,n,27);
    int l=0,r=n;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        //printf("%d %d %d\n",mid,l,r);
        if(ok(mid))
            l=mid+1;
        else
            r=mid-1;
        //printf("%d %d %d\n",mid,l,r);
    }
    printf("%d",l-1 );
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi v(n);
    REP(i, n) cin >>v[i];
    set<int> s;
    bool f = false;
    REP(i, n) {
        if(s.count(v[i])) {
            f = true;
            break;
        }
        s.insert(v[i]);
    }
    if(f) cout << "NO" << endl;
    else cout << "YES" <<endl;


    return 0;
}

Measured memory_bytes: 10368
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{

    public static boolean[] isprime;
    public static List<Integer> prime;

    static void create()
    {
	prime = new LinkedList<Integer>();
	isprime = new boolean[1000010];
	int p = 0;
	for(int i=0;i<=1000009;i++)isprime[i] = true;
	isprime[0] = isprime[1] = false;
	for(int i = 2;i<=1000009;i++)
	    {
		if(isprime[i])
		    {
			prime.add(i);
			for(int j=2*i;j<=1000009;j+=i)
			    isprime[j] = false;
		    }
	    }
    }

    public static void main(String args[])throws IOException
    {
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	create();
	while(true)
	    {
		int n = Integer.parseInt(in.readLine());
		if(n == 0)
		    break;
		int cnt = 0;
		for(int i=1;i<=n;i++)
		    {
			if(i > n-i)
			    break;
			if(isprime[i] && isprime[n-i])
			    {
				cnt++;
			    }
		    }
		System.out.println(cnt);
	    }	

    }
    
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 600;
const int mod = 1e9 + 7;

int n, k;
int to[N + 1];
int f[N + 1][N + 1], g[N + 1];
int ans;

inline void dp()
{
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j += 2) {
			int sum1 = j - i + 1, sum2;
			bool flag = true;
			for (int k = i; k <= j; k++) {
				if (to[k]) {
					sum1--;
					if (to[k] < i || to[k] > j) {
						flag = false;
						break;
					}
				}
			}
			if (flag) {
				f[i][j] = g[sum1];
				sum2 = !to[j];
				for (int k = j - 1; k >= i; k--) {
					f[i][j] = (f[i][j] - 1ll * f[i][k] * g[sum2] + 1ll * mod) % mod;
					sum2 += !to[k];
				}
				ans = (ans + 1ll * f[i][j] * g[n - (k << 1) - sum1]) % mod;
			}
		}
	}
	return;
}
int main()
{
	n = read() << 1;
	k = read();
	for (int i = 1; i <= k; i++) {
		int x = read(), y = read();
		to[x] = y;
		to[y] = x;
	}
	g[0] = 1;
	for (int i = 2; i <= n; i += 2)
		g[i] = 1ll * g[i - 2] * (i - 1) % mod;

	dp();

	printf("%d\n", ans);
	return 0;
}


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

int main(){
	int a, b, c, num;
	cin >> num;
	for(int i=0; i < num; i++){
		cin >> a >> b >> c;
		if(a*a + b*b == c*c || b*b + c*c == a*a || c*c + a*a == b*b) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1152