akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int swap(int *, int *);
int partition(int *, int, int);

int main() {
  int A[100001];
  int n, i, split;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  
  split = partition(A, 0, n - 1);

  for (i = 0; i < split; i++) {
    printf("%d ", A[i]);
  }
  printf("[%d] ", A[i]);

  split = i + 1;
  for (i = split; i < n; i++) {
    if(i != n - 1)printf("%d ", A[i]);
    else printf("%d\n", A[i]);
  }
  
  return 0;
}

int swap(int *a, int *b) {
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

int partition(int *A, int p, int r) {
  int x = A[r];
  int i = p - 1;
  int j;

  for (j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i + 1], &A[r]);

  return i + 1;
}



Measured memory_bytes: 2108
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
int main(){
      int N,K;
      cin>>N>>K;
      int h[N];
      rep0(i,N) cin>>h[i];
      sort(h,h+N);
      ll ans=longinf;
      rep0(i,N-K+1){
            ans=min(ans,(ll)(h[i+K-1]-h[i]));
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{

  int i, j, N, c=0, flag =1, temp;
  int A[100];

  scanf ("%d\n", &N);


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

 i = 0;
   while (flag) {
    flag = 0;
    for (j = N-1; j >= i+1; j--) {
      if (A[j] < A[j-1]) {
       temp = A[j];
       A[j] = A[j-1];
       A[j-1] = temp;
       c++;
       flag = 1;
      }
    }
   }

   for (i =0; i < N-1; i++) {
      printf("%d ", A[i]);
   }
   printf("%d\n%d\n", A[N-1], c);
   return 0;
}

Measured memory_bytes: 604
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    var d = new List<int>();
    Func<int, int> A = x => (x + 9) / 10 * 10;
    Func<int, int> B = x => A(x) - x;
    var s = "";
    while ((s = Console.ReadLine()) != null) d.Add(int.Parse(s));
    Console.WriteLine(d.Select(A).Sum() - d.Select(B).Max());
  }
}

Measured memory_bytes: 13396
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int k,a[50];
	cin >> k;
	cout << 50 << endl;
	for(int i = 0;i < 50;i++){
		a[i] = 49 + (int)(k / 50);
	}
	for(int i = 0;i < k % 50;i++){
		for(int j = 0;j < 50;j++){
			if(i == j) a[j] += 50;
			else a[j]--;
		}
	}
	for(int i = 0;i < 50;i++) cout << (i ? " " : "") << a[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<math.h>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	string str;
	int i;
	getline(cin,str);
	transform(str.begin(),str.end(),str.begin(),::toupper);
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 1176
//7-12-19
#include<bits/stdc++.h>

#define Pi acos(-1.0)
#define ll long long
#define uu first
#define vv second
#define scl(n) scanf("%d",&n)
#define scll(n) scanf("%lld",&n)

//Vector Macros
#define pb push_back
#define eb emplace_back
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end())
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c),0)

//Loop Macros
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define For(i,n) for(int i=0;i<n;i++)

//Debug Macros
#define deb(a) cout << #a << " : " << a << " ";
#define debln(a) cout<< #a <<" : " << a << endl;
#define open  freopen("input.txt","r",stdin);
#define close freopen ("output.txt","w",stdout);

#define fastio ios::sync_with_stdio(false);cin.tie(nullptr);

//Print Macros
#define print(v)  for(auto x : v) {  cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v) { cout<<x.uu<<" "<<x.vv<<endl; }

using namespace std;



int main()
{
    //open
    //close
    //fastio
    
   int a,b,c;
   cin>>a>>b>>c;
   
   puts ((a+b+c) >= 22 ? "bust" : "win");
    
    return 0;
}




Measured memory_bytes: 256
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let A = cin.getInt(), B = cin.getInt(), C = cin.getInt(), X = cin.getInt(), Y = cin.getInt();
    let p1 = A * X + B * Y, p2, p3, p4;
    p2 = p3 = p4 = Number.MAX_SAFE_INTEGER
    if (X > Y) {
        p2 = Y * 2 * C + (X - Y) * A;
    } else if (X < Y) {
        p3 = X * 2 * C + (Y - X) * B;
    } else {
        p4 = (X + Y) * C;
    }
    let p5 = Math.max(X, Y) * 2 * C;
    console.log(Math.min(...[p1, p2, p3, p4, p5]));
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 100005;
const ll INF = 1e18;
ll A[MAX_N],L[MAX_N],R[MAX_N];

int main()
{
	int N;
	cin >> N;
	rep(i,N+1)
	{
		cin >> A[i];
	}

	L[N] = A[N];
	R[N] = A[N];
	for (int i = N-1; i >= 0; --i)
	{
		L[i] = A[i] + (L[i+1]+1) / 2;
		R[i] = A[i] + R[i+1];
	}
	if (L[0] > 1)
	{
		cout << -1 << endl;
		return 0;
	}
	ll ans = 0;
	ll temp = 1;
	rep(i,N+1)
	{
		ans += temp;
		temp -= A[i];
		temp = min(temp*2,R[i+1]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a % 2) == 0 || (b % 2) == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}

Measured memory_bytes: 256
import sys


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline


def solve():
    A, V = map(int, readline().split())
    B, W = map(int, readline().split())
    T = int(readline())

    if A < B:
        if A + V * T >= B + W * T:
            ans = 'YES'
        else:
            ans = 'NO'
    else:
        if A - V * T <= B - W * T:
            ans = 'YES'
        else:
            ans = 'NO'

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9248
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;

class Node {
  public int id;
  public Node from;
  public Node[] subNodes;

  public int count;

  this(int id) {
    this.id = id;
  }
}

class Nodes {
  public Node[] nodes;

  this(int size) {
    this.nodes = new Node[size];
    size.iota.each!(i => this.nodes[i] = new Node(i));
  }

  void setPath(int from, int to) {
    this.nodes[from].subNodes ~= this.nodes[to];
    this.nodes[to].from = this.nodes[from];
  }

  Node root() {
    return this.nodes[0];
  }

  void apply(int id, void delegate(Node) d) {
    d(this.nodes[id]);
  }

  void applyAllFromRoot(void delegate(Node) d) {
    auto cursors = [this.root()];
    while(!cursors.empty) {
      foreach(node; cursors) d(node);
      cursors = cursors.map!(node => node.subNodes).joiner.filter!(node => node !is null).array;
    }
  }
}

void main() {
  int N, Q; readf("%d %d\n", &N, &Q);

  auto nodes = new Nodes(N);
  foreach(i; 1..N) {
    int from, to; readf("%d %d\n", &from, &to);
    nodes.setPath(from - 1, to - 1);
  }
  
  foreach(i; 0..Q) {
    int nodeId, increments; readf("%d %d\n", &nodeId, &increments);
    nodes.apply(nodeId - 1, (node){ node.count += increments; });
  }

  int[] totals = new int[N];
  nodes.applyAllFromRoot((node) {
    totals[node.id] += node.count;
    if (node.from) totals[node.id] += totals[node.from.id];
  });

  totals.to!(string[]).join(" ").writeln;
}


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

int main() {
  int n;
  cin >> n;
  int k=0;
  rep(i,450){
    if(i*(i+1)/2==n){
      k=i;
    }
  }
  if(k==0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
    cout<<k+1<<endl;
    vector<int>ans[k+1];
    int now=0;
    int p=k;
    rep(i,k+1){
      rep(j,p){
        ans[i].push_back(now+j);
      }
      rep2(j,i+1,k+1){
        ans[j].push_back(now+j-i-1);
      }
      now+=p;
      p--;
    }   
    rep(i,k+1){
      cout<<k<<" ";
      rep(j,k){
        cout<<ans[i][j]+1<<" ";
      }
      cout<<endl;
    }
  }
}

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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	bool graph[n][n];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			graph[i][j] = false;
		}
	}
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a][b] = graph[b][a] = true;
	}
	
	int path[n];
	for (int i = 0; i < n; i++) {
		path[i] = i;
	}
	
	int ans = 0;
	do {
		if (path[0] == 0) {
			for (int i = 0; i < n - 1; i++) {
				if (graph[path[i]][path[i + 1]] == false) {
					break;
				}
				if (i == n - 2) {
					ans++;
				}
			}
		} else {
			break;
		}
	} while(next_permutation(path, path + n));
	
	cout << ans << endl;
	return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll r,g,b; cin>>r>>g>>b;
  ans2((b+10*g)%4==0);


  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

N,K,Q = list(map(int,input().split()))
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)
  
if K > Q:
  for i in range(N):
    print('Yes')
  sys.exit()
K_Q = K - Q
A_freq = Counter(A)
for i in range(1,N+1):
  if K_Q + A_freq[i] > 0:
    print('Yes')
  else:
    print('No')

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

string complete(int x)
{
    string s = to_string(x);
    string zero;
    for (int i=0; i<6-s.size(); i++)
        zero += "0";
    return zero+s;
}

int main() 
{
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> v;
    for (int i=1; i<=m; i++)
    {
        int p, y;
        cin >> p >> y;
        v.emplace_back(p, y, i);
    }
    sort(v.begin(), v.end());
    vector<string> res(m+1);
    int old = get<0>(*v.begin());
    int i = 0;
    for(auto x: v)
    {
        // cout << get<0>(x) << " " << get<1>(x) << endl;
        if (old == get<0>(x))
            i++;
        else
            i = 1;
        old = get<0>(x);
        // cout << get<0>(x) << endl;
        string part2 = complete(i);
        int index = get<2>(x);
        string part1 = complete(get<0>(x));
        res[index] = part1 + part2;
    }
    for (int i=1; i<=m; i++)
        cout << res[i] << "\n";
    return 0;
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  bool a=true;
  string s;
  cin >> s;
  int k=s.size();
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(s[i]=='L'){
        a=false;
      }
    }
    else
      if(s[i]=='R'){
        a=false;
      }
  }
  if(a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := make([]string, N)
	for i := 0; i < N; i++ {
		s[i] = getString()
	}
	c := make([][2]int, N)
	for i := 0; i < N; i++ {
		for _, v := range s[i] {
			if v == '(' {
				c[i][0]++
			} else {
				if c[i][0] == 0 {
					c[i][1]++
				} else {
					c[i][0]--
				}
			}
		}
	}
	sort.Slice(c, func(i, j int) bool {
		if c[i][1] == 0 {
			return true
		}
		if c[j][1] == 0 {
			return false
		}
		if c[i][0] == 0 {
			return false
		}
		if c[j][0] == 0 {
			return true
		}
		di := c[i][0] - c[i][1]
		dj := c[j][0] - c[j][1]
		return di > dj
	})

	if c[0][1] != 0 {
		out("No")
		return
	}

	// out(c)

	l := c[0][0]
	r := c[0][1]
	// cntl := l
	// cntr := r
	for i := 1; i < N; i++ {
		// cntl += c[i][0]
		// cntr += c[i][1]
		x := min(l, c[i][1])
		y := min(r, c[i][0])
		l = l - x + c[i][0] - y
		r = r - y + c[i][1] - x
		if r > 0 {
			out("No")
			return
		}
		// out(c[i], x, y, l, r)
	}
	// if l == 0 && r == 0 && cntl == cntr {
	if l == 0 && r == 0 {
		out("Yes")
	} else {
		out("No")
	}
}


Measured memory_bytes: 34204
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100010];

int main(){
    ios_base::sync_with_stdio(false);
    int n,k,r,s,p,res=0;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    for(int i=0;i<k;i++){
        string q="";

        for(int j=i;j<n;j+=k)
            q+=t[j];
        q+='z';
        int c;
        for(int j=0;j<q.size()-1;j++){
            c=1;
            while(j+1<q.size()&&q[j]==q[j+1]){
                j++;
                c++;
            }
            c=(c+1)/2;
            if(q[j]=='r')
                res+=p*c;
            if(q[j]=='s')
                res+=r*c;
            if(q[j]=='p')
                res+=s*c;
            //cout<<c<<'\n';
        }

        //cout<<q<<' '<<res<<'\n';
    }
    cout<<res;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[5050];

ll ln[5050],aa[5050];
ll i, j, k, ans;

ll calc(ll b){
    ll i = 1;
    ll j = 0;
    ll ret = 0;
    while(i+b<N){
        aa[i] = 0;
        if(i+ln[i-j]<j+ln[j]){
            ln[i] = ln[i - j];
            if(ret<min(i,ln[i])){
                ret = min(i, ln[i]);
            }
        }else{
            ll k = j + ln[i] - i > 0 ? j + ln[i] - i : 0;
            while(i+k+b<N&&S[k+b]==S[i+k+b])
                k++;
            ln[i] = k;
            if(ret<min(i,ln[i])){
                ret = min(i, ln[i]);
            }
            j = i;
        }
        i++;
    }
    return ret;
}
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,0,N){
        ll a = calc(i);
        if(ans<a)
            ans = a;
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void swap(long long& r, long long& l){
    if (r > l) {
        return;
    } else {
        long long tmp = r;
        r = l;
        l = tmp;
        return;
    }
}

void solve(long long A, long long B, long long C){
    swap(A, B);
    swap(A, C);
    long long sAB = A - B;
    long long sAC = A - C;
    long long ret = sAB/2 + sAC/2;
    if ((sAB%2 == 0) && (sAC%2 == 0)) {
        
    } else if((sAB%2 == 1) && (sAC%2 == 0)) {
        ret += 2;
    } else if((sAB%2 == 0) && (sAC%2 == 1)) {
        ret += 2;
    } else if((sAB%2 == 1) && (sAC%2 == 1)) {
        ret += 1;
    }
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long A;
    long long B;
    long long C;
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&C);
    solve(A, B, C);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main(){
        int n,i;
        ll ans=0,sup=0;
        cin >> n;
        vector<ll> a(n+1);
        vector<ll> b(n);
        for(i=0;i<n+1;++i) cin >> a.at(i);
        for(i=0;i<n;++i) cin >> b.at(i);
        for(i=0;i<n;++i){
                ans += a.at(i)>=sup ? sup : a.at(i);
                a.at(i) -= sup;
                if(a.at(i)<=0) sup = b.at(i);
                else if(a.at(i)>=b.at(i)){
                        sup = 0;
                        ans += b.at(i);
                }else{
                        sup = b.at(i) - a.at(i);
                        ans += a.at(i);
                }
        }
        ans += a.at(n)>=sup ? sup : a.at(n);
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 4816
K = int(input())
A = list(map(int, input().split()))

ans1 = 2
ans2 = 2
for i in range(K - 1, 0, -1):
    if ans1 % A[i] != 0 or ans2 % A[i] != 0 or ans1 < 2 or ans2 < 2:
        print (-1)
        exit()
    ans1 = (ans1 + A[i] - 1) // A[i - 1] * A[i - 1] #最大
    ans2 = (ans2 + A[i - 1] - 1) // A[i - 1] * A[i - 1] #最小
    if ans2 > ans1:
        print (-1)
        exit()
    if ans2 == 0:
        ans2 = ans1

    # print (ans1, ans2)

if ans1 % A[0] != 0 or ans2 % A[0] != 0 or ans1 < 2 or ans2 < 2:
    print (-1)
    exit()

print (ans2, ans1 + A[0] - 1)    

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 100005;
constexpr int NIL = -1;
struct Node {
	int p, l, r;
	Node() : p{NIL}, l{NIL}, r{NIL} {}
};
Node T[MAX];
vi D(MAX);
inline void rec(int u, int p) {
	D[u] = p;
	if(T[u].r != NIL) rec(T[u].r, p);
	if(T[u].l != NIL) rec(T[u].l, p + 1);
}
int main() {
	int n; cin >> n;
	int v, d, c, l;
	rep(i, 0, n) {
		cin >> v >> d;
		rep(j, 0, d) {
			cin >> c;
			if(j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	int r;
	rrep(i, n - 1, -1) {
		if(T[i].p == NIL) { r = i; break; }
	}
	rec(r, 0);
	rep(u, 0, n) {
		cout << "node " << u << ": " << "parent = " << T[u].p << ", " << "depth = " << D[u] << ", ";
		if(T[u].p == NIL) p("root, [");
		else if(T[u].l == NIL) p("leaf, [");
		else p("internal node, [");
		for (int i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r) {
			if (i) p(", ");
			p(c);
		}
		P("]");
	}
	return 0;
}

Measured memory_bytes: 5840
#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 ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<int> p(n,0);
    vector<int> q(n,0);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    int a=0;
    int b=0;
    vector<int> count;
    rep(i,n) count.emplace_back(i+1);
    int cnt=0;
    do{
        bool ap=true;
        bool bq=true;
        for(int i=0; i<n; i++){
            if(count[i]!=p[i]) ap=false;
            if(count[i]!=q[i]) bq=false;
        }
        cnt++;
        if(ap) a=cnt;
        if(bq) b=cnt; 
    }
    while(next_permutation(count.begin(),count.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#define MAX 100
#define INF 1000000

void ssS(void);

int n;
int G[MAX][MAX];

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    
    for(j=0;j<n;j++) G[i][j]=INF;
  }
  
  for(i=0;i<n;i++){

    scanf("%d%d",&u,&k);
    
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      G[u][v]=c;
    }
    
  }

  ssS();
  
  return 0;
}

void ssS(){
  int i,min,u;
  int d[MAX],ch[MAX];

  for(i=0;i<n;i++){
    d[i]=INF;
    ch[i]=0;
  }

  d[0]=0;
  ch[0]=2;

  while(1){
    
    min=INF;
    u=-1;
    
    for(i=0;i<n;i++){
      
      if(ch[i]!=1 && d[i]<min){
	min=d[i];
	u=i;
      }

    }

    if(u==-1) break;
    
    ch[u]=1;

    for(i=0;i<n;i++){

      if(ch[i]!=1 && G[u][i]!=INF){

	if(G[u][i]+d[u]<d[i]){
	  d[i]=d[u]+G[u][i];
	  ch[i]=2;
	}

      }

    }

  }

  d[0]=0;
  for(i=0;i<n;i++){
    printf("%d",i);
    printf(" %d\n",d[i]);
  }
  
}



Measured memory_bytes: 2108
h, w = map(int, input().split())

ss = [[] for i in range(h)]

for i in range(h):
  ss[i] = list(str(input()))

s_h_l = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in range(w):
    s_h_l[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_l[i][j] = 0
      
s_h_r = [[0]*w for i in range(h)]
for i in range(h):
  light = 0
  for j in reversed(range(w)):
    s_h_r[i][j] = light
    if ss[i][j] == '.':
      light += 1
    else:
      light = 0
      s_h_r[i][j] = 0

s_w_u = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in range(h):
    s_w_u[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_u[j][i] = 0
      
s_w_d = [[0]*w for i in range(h)]
for i in range(w):
  light = 0
  for j in reversed(range(h)):
    s_w_d[j][i] = light
    if ss[j][i] == '.':
      light += 1
    else:
      light = 0
      s_w_d[j][i] = 0   

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, s_h_r[i][j]+s_h_l[i][j]+s_w_u[i][j]+s_w_d[i][j]+1)
print(ans)

Measured memory_bytes: 306996
#include <iostream>
#include <algorithm>

#define SIZE 1001

using namespace std;

int main() {
    long  long int B,i,j,k,M,K,Q;
    long  long int X,N,Y,Z;
    long  long int P[SIZE];

    cin >> N >> K;
    for (i=0;i<N;i++)
      cin >> P[i];
    sort(P,P+N);

    long long int S;
    S = 0;
    for (i=0;i<K;i++)
      S += P[i];
      cout << S << endl;
  return 0;

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
const int INF=10000000;

int main() {
    int a, b;
    cin >> a >> b;
    int ans=0;
    bool ok=false;
    for(int i=max(a,b);i<=1000;++i) {
        if(floor(0.08*i)==a && floor(0.1*i)==b) {
            ans=i;
            ok=true;
            break;
        }
    }
    if(ok) cout << ans << endl;
    else cout << -1 << endl;
}



Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] s = sc.next().split("");
    String[] t = sc.next().split("");
    
    int result = 0;
    for (int i = 0; i < s.length; i++) {
      if (s[i].equals(t[i])) result++;
    }
    
    System.out.println(result);
	}
}


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

int main() {

  int x, y;
  char op;
  
  while(1){
    cin >> x >> op >> y;

    if(op == '?') break;
    switch(op) {
      case '+':
        cout << x + y << endl;
        break;
      case '-':
        cout << x - y << endl;
        break;
      case '*':
        cout << x * y << endl;
        break;
      case '/':
        cout << x / y << endl;
        break;
      default:
        break;
    }
  }

   return 0;
}  

Measured memory_bytes: 1160
s=input()
s=list(s)
c=0
for i in range(0,len(s),2):
    if s[i]=='0':
        c+=1
for i in range(1,len(s),2):
    if s[i]=='1':
        c+=1
d=0
for i in range(0,len(s),2):
    if s[i]=='1':
        d+=1
for i in range(1,len(s),2):
    if s[i]=='0':
        d+=1
    
print(min(c,d))

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

ll diff(ll h, ll w, ll x) {
  ll res = w * x;
  ll s1, s2, s3, s_min, s_max;

  s1 = w * x; // 2
  s2 = w * ((h - x) / 2);
  s3 = w * h - s1 - s2;
  s_min = min({s1, s2, s3});
  s_max = max({s1, s2, s3});
  res = min(res, s_max - s_min);

  s1 = w * x;
  s2 = (h - x) * (w / 2);
  s3 = w * h - s1 - s2;
  s_min = min({s1, s2, s3});
  s_max = max({s1, s2, s3});
  res = min(res, s_max - s_min);

  return res;
}

int main() {
  ll H, W;
  cin >> H >> W;

  ll ans = H * W;
  ll s1, s2, s3, s_min, s_max;

  for (int h = 1; h <= H - 1; h++)
    ans = min(ans, diff(H, W, h));

  swap(H, W);

  for (int h = 1; h <= H - 1; h++)
    ans = min(ans, diff(H, W, h));

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second

using namespace std;
typedef long long ll;


int main()
{
    string s;
    cin >> s;
    fr(i, 0, s.size() - 1){
        if(s[i] == s[i + 1]){
            cout <<i +1  <<' '<<i + 2 << endl;
            return 0;
        }
        if(i + 2 < s.size() && s[i] == s[i + 2]){
            cout << i + 1 <<' '<<i + 3 << endl;
            return 0;
        }
    }

    cout << -1 <<' '<<-1 << endl;

    return 0;
}


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

int main(){
    long A, B, K;
    cin >> A >> B >> K;
    long g = __gcd(A, B);
    for(long i = 1, c = 0; i <= g; ++i){
        if(g % i == 0){
            ++c;
            if(c == K){
                cout << g / i << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[100010][2];
int main()
{
    string str;
    cin >> str;
    vector<int> l;
    int len = str.length();
    rep(i,(int)len)
    {
        l.push_back(str[i]-'0');
    }
    dp[0][0] = 1;    
    rep(i,len)
    {
        (dp[i+1][1] += dp[i][1]*3%MOD)%=MOD;
        if (l[i]==1)
        {
            (dp[i+1][1] += dp[i][0]%MOD)%=MOD;
            (dp[i+1][0] += dp[i][0]*2%MOD)%=MOD;
        }

        if (l[i]==0)
        {
            (dp[i+1][0] += dp[i][0]%MOD)%=MOD;
        }
    }
    cout << (dp[len][0]+dp[len][1])%MOD<< endl;
}

Measured memory_bytes: 2552
import numpy
N, W = map(int, input().split())
memo = numpy.array([[10**9+1 for i in range(10**5+1)] for j in range(N)])
memo[-1][0] = 0
for n in range(N):
    w, v = map(int, input().split())
    memo[n][:v] = memo[n-1][:v]
    memo[n][v:] = numpy.fmin(memo[n-1][v:], memo[n-1][:-v]+w)
a = numpy.where(memo[-1] <= W)
print(numpy.max(a[0]))

Measured memory_bytes: 169320
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7,N=1e5+99;
int n,m,phi[N][2],cnt,d[N];
ll ans;
map<int,int>f;
ll qpow(ll a,int b)
{
	ll ret=1;
	while(b){if(b%2)ret=ret*a%mod;a=a*a%mod;b/=2;}
	return ret;
}
int calc(int p,int q,int e)
{
	if(p>q)return f[e];
	int ans=calc(p+1,q,e);
	for(int i=1;i<=d[p];i++)ans=(ans+calc(p+1,q,e*=phi[p][0]))%mod;
	return ans;
}
void work(int p,int e)
{
	if(p>cnt)
	{
		ll tmp=(((n/e)%2?qpow(m,(e+1)/2):qpow(m,e))-calc(1,p,1)+mod)%mod;
		f[e]=tmp;
		ans=(ans+tmp*e)%mod;
		return;
	}
	d[p]=0;
	work(p+1,e);
	for(int i=1;i<=phi[p][1];i++)d[p]=i,work(p+1,(e*=phi[p][0]));
}
int main()
{
	cin>>n>>m;
	if(n==1){cout<<m;return 0;}
	int q=n;
	for(int i=2;i*i<=q;i++)
	if(q%i==0)
	{
		phi[++cnt][0]=i;
		while(q%i==0)q/=i,phi[cnt][1]++;
	}
	if(q>1)phi[++cnt][0]=q,phi[cnt][1]=1;
	work(1,1);
	cout<<(ans+mod)%mod;
}

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

using namespace std;
using ll = long long;

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

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

  for (int n = x; n <= 1e6; ++n) {
    bool isPrime = true;
    for (ll i = 2; i * i <= n; ++i) {
      if (n % i == 0) {
        isPrime = false;
        break;
      }
    }
    if (isPrime && n >= x) {
      cout << n << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import heapq
from operator import itemgetter
 
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y,A,B,C = IL()
p = IL()
q = IL()
r = IL()

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

d = []
heappop = heapq.heappop
heappush = heapq.heappush
for i in range(A):
  heappush(d, (-p[i],0))
for i in range(B):
  heappush(d, (-q[i],1))
for i in range(C):
  heappush(d, (-r[i],2))

acnt ,bcnt, ccnt = 0,0,0
cnt = 0
ans = 0
while acnt+bcnt+ccnt != X+Y:
  score,num = heappop(d)
  if num == 0:
    if acnt < X:
      acnt += 1
      ans -= score
  elif num == 1:
    if bcnt < Y:
      bcnt += 1
      ans -= score
  else:
    ccnt += 1
    ans -= score
print(ans)

Measured memory_bytes: 122988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int d1[120], d2[120];
int main() {
  int n;
  cin >> n;
  rep(i,n) {
    cin >> d1[i] >> d2[i];
  }

  rep(i,n-2) {
    if (d1[i]==d2[i]&&d1[i+1]==d2[i+1]&&d1[i+2]==d2[i+2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

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

int main(){
  char x[1000];
  int num,sum;

  for(;;){
    cin >> x;
    sum = 0;
    if (x[0] == '0') break;

    for (int i = 0; i<strlen(x); i++){
      num = 0;

      num = x[i] - '0';
      sum += num;
    }
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
#include<cstdio>
#define for(a,b,c) for(int a=b;a<=c;a++)
typedef long long ll;
ll abs(ll a){return a>0?a:-a;}
ll a[1<<19];
int n;
int main(){
    scanf("%d",&n);
    int t=1<<n;
    for (i,1,t) scanf("%lld",&a[i]);
    t>>=1;
    while (t){
        int tot=0;
        for (i,1,t) a[++tot]=a[i<<1]==a[(i<<1)-1]?a[i<<1]:abs(a[i<<1]-a[(i<<1)-1]);
        t>>=1;
    }
    printf("%lld",a[1]);
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

    int n;
    cin >> n;
    vector<ll> ab(n);
    ll res = 0;
    for(int i = 0; i < n; ++i){
        ll a, b;
        cin >> a >> b;
        ab[i] = a+b;
        res -= b;
    }

    sort(ab.begin(), ab.end(), greater<ll>());
    for(int i = 0; i < n; ++i){
        if(i%2 == 0) res += ab[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 3940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        int sum = 0;
        int eat = 1000;
        for (int i = 0; i < n; i++) {
            sum += l + i;
            if (Math.abs(l + i) < Math.abs(eat)) {
                eat = l + i;
            }
        }
        System.out.println(sum - eat);
    }
}


Measured memory_bytes: 23636
<?php
// 21:35
fscanf(STDIN, '%s', $b);

if ($b === 'A') $ans = 'T';
elseif ($b === 'T') $ans = 'A';
elseif ($b === 'C') $ans = 'G';
elseif ($b === 'G') $ans = 'C';

echo $ans . PHP_EOL;

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
const ll INF=1LL<<60;
vector<ll> DP;
vector<ll> h;
int main(){
  int N,K;
  cin>>N>>K;
  h.assign(N,0);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  DP.assign(N,INF);
  DP[0]=0;
  for(int i=0;i<N;i++){
    for(int j=1;j<=K;j++){
      chmin(DP[i+j],DP[i]+abs(h[i]-h[i+j]));
    }
  }
  cout<<DP[N-1]<<endl;
}

Measured memory_bytes: 1792
N = int(input())
X = list(map(int, input().split()))

save = X[:]

save.sort()

midL = save[int(N / 2 - 1)]
midR = save[int(N / 2)]

for i in X:
    if i <= midL:
        print(midR)
    else:
        print(midL)


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

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")

#define fi first
#define se second

using namespace std;

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

int main()
{
    int n;
    scanf("%d",&n);
    vector<vector<int>> x(n,vector<int>(3));
    for(auto &i:x)
        for(auto &j:i)
            scanf("%d",&j);
    vector<vector<int>> dp(n+1,vector<int>(3));
    for(int i=1;i<=n;++i)
        for(int j=0;j<3;++j)
            for(int k=0;k<3;++k)
                if(j!=k)
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+x[i-1][k]);
    int res=0;
    for(int i=0;i<3;++i)
        res=max(res,dp[n][i]);
    printf("%d\n",res);
}



Measured memory_bytes: 11136
import sys
n,k = map(int, sys.stdin.readline().split())
ans = 0
a = n//k
ans += a*(a-1)*(a-2)+a*(a-1)*3+a
if k %2 == 0:
    a = n//k
    if n %k >= k/2:
        a+=1
    ans += a*(a-1)*(a-2)+a*(a-1)*3+a
print(ans)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N,M = map(int, input().split())
abc = [[int(j) for j in input().split()] for _ in range(M)]
con=[[] for _ in range (N+1)]
inf = float("inf")

allcost = [ -inf] * (N+1)
allcost[1] = 0

for i in range(M):
    a,b,c = abc[i]
    con[a].append(b)

for n in range(1, N):
    for edge in range(M):
        a,b,c = abc[edge]
        if allcost[b] < allcost[a] + c:
            allcost[b] = allcost[a] + c
neg=[False]*(N+1)
for edge in range(M):
    a,b,c = abc[edge]
    if allcost[a] + c > allcost[b]:
        neg[b]=True
    if neg[a]==True:
      neg[b]=True
if neg[N]:
  print("inf")
  exit(0)
print(allcost[N])





Measured memory_bytes: 3572
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
ab = [inpl() for _ in range(n)]
ab.sort()
cnt = 0
for a,b in ab:
    cnt += b
    if cnt >= k:
        print(a)
        break


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

int main()
{
    int n,sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
D,X = map(int,input().split())
array_A = []
for I in range(N):
    array_A.append(int(input()))

if not ( 1 <= N and D and X <= 100):
    sys.exit()
for J in range(len(array_A)):
    if not ( 1 <= array_A[J] <= 100):
        sys.exit()

count = 0
for K in range(len(array_A)):
    day = 1
    while day <= D:
        count += 1
        day += array_A[K]

print(count+X)

Measured memory_bytes: 9160
<?php
 
	fscanf(STDIN, "%d", $N);

	$result = 0;

	$a = 1;
	$b = 1;
	while ($a <= $N - 1) {
      
      $b = 1;
      while ($b <= $N - 1) {
        if (($a * $b) < $N) {
          $result++;
        } else {
          break;
        }
        $b++;
      }
      $a++;
    }

	echo ($result);
?>

Measured memory_bytes: 16308
n,m = map(int,input().split())
lmax, rmin = 0, n

for _ in range(m):
  l,r = map(int,input().split())
  lmax = max(lmax, l)
  rmin = min(rmin, r)

print((rmin-lmax)+1 if (rmin-lmax)+1 > 0 else 0)

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
    int n;
    string s;

    cin >> n >> s;

    int cnt = 0;
    int pos = s.find("ABC");
    while (pos != string::npos) {
        cnt++;
        pos = s.find("ABC", pos+1);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
#A
def A():
    t,x = LI()
    print(t/x)
    return

#B
def B():
    n = I()
    a = LI()
    m = max(a)
    if m >= sum(a)-m:
        print("No")
    else:
        print("Yes")
    return

#C
def C():
    n,m = LI()
    x = LI()
    x.sort()
    l = [x[i+1]-x[i] for i in range(m-1)]
    l.sort()
    l = l[::-1]
    ans = sum(l[max(n-1,0):])
    print(ans)
    return

#D
def D():
    n,k = LI()
    a = LI()
    k = list(map(int,list(bin(k)[2:])))
    l = len(k)
    for i in range(n):
        a[i] = list(map(int,list(bin(a[i])[2:])))
        l = max(l,len(a[i]))
    for i in range(n):
        for j in range(l-len(a[i])):
            a[i].insert(0,0)
    for j in range(l-len(k)):
        k.insert(0,0)
    s = [[0,0] for i in range(l)]
    pow2 = [1 for i in range(l)]
    for i in range(l-1)[::-1]:
        pow2[i] = pow2[i+1]*2
    for i in a:
        for j in range(l):
            s[j][0] += pow2[j]*i[j]
            s[j][1] += pow2[j]*(not i[j])
    dp = [0 for i in range(l+1)]
    small = False
    for i in range(l):
        if not small:
            if not k[i]:
                dp[i+1] += dp[i]+s[i][0]
            else:
                if s[i][0] >= s[i][1]:
                    dp[i+1] += dp[i]+s[i][0]
                    small = True
                else:
                    dp[i+1] += dp[i]+s[i][1]
        else:
            dp[i+1] += dp[i]+max(s[i])
    print(dp[l])
    return
#E
if __name__ == "__main__":
    D()

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 116768
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;

const int MAX_N = 300000;

int par[MAX_N];
int Rank[MAX_N];


void init(int n){
    for (int i = 0; i < n; i++){
        par[i] = i;
        Rank[i] = 0;
    }
}

int find(int x){
    if(par[x] == x){
        return x;
    }
    else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y){
        return;
    }
    if (Rank[x] < Rank[y]){
        par[x] = y;
    }
    else {
        par[y] = x;
        if (Rank[x] == Rank[y]){
            Rank[x]++;
        }
    }
}
bool same(int x, int y){
    return find(x) == find(y);
}

int main() {
    int N, M;
    cin >> N >> M;
    init(N);
    for (int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        unite(a - 1, b - 1);
    }
    vector<int> T(N);
    for (int i = 0; i < N; i++){
        T.at(find(i))++;
    }
    int  most = 0;
    for (int i = 0; i < N; i++){

        most = max(most, T.at(i));
    }
    cout << most << endl;
}

Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=1;i<n-1;i++){
    if(a[i-1]<a[i] && a[i]<a[i+1]){
      ans++;
    }
    else if(a[i]>a[i+1] && a[i-1]>a[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

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


int main (){
    int a,b;
    cin >>a >> b;
    vector<int> ans;
    ans.push_back(a+b);
    ans.push_back(a-b);
    ans.push_back(a*b);
    //ans.push_back(a/b);
    sort(ans.begin(),ans.end());
    cout << ans.at(2) << endl;
    }



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

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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	
	
	int state = 0;	// 0:both, 1:<=, 2:>=
	ll ans = 1;
	for(int i = 0; i < n-1; ++i){
		switch(state){
		case 0:
			if(a[i] < a[i+1]){
				state = 1;
			}
			else if(a[i] > a[i+1]){
				state = 2;
			}
			else{
				state = 0;
			}
			break;
		case 1:
			if(a[i] > a[i+1]){
				ans++;
				state = 0;
			}
			break;
		case 2:
			if(a[i] < a[i+1]){
				ans++;
				state = 0;
			}
			break;
		default:
			break;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d,cnt=0,cnt2=0,pen1=0,pen2=0,cost=0;
	cin>>n>>a>>b>>c>>d;
	while(n>=pen1){
		pen1=pen1+a;
		cnt++;}
	while(n>pen2){
		pen2=pen2+c;
		cnt2++;}
	if(cnt2*d>cnt*b)
		cost=cnt*b;
	if(cnt*b>cnt2*d)
		cost=cnt2*d;
	if(cnt2*d==cnt*b)
		cost=cnt*b;
	cout<<cost<<endl;
	
	return 0;
}


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

int main(){
  int n;
  int a[9], b[11];
  for(int i=0;i<9;i++)cin >> a[i];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> b[i];
    for(int j=0;j<9;j++){
      if(b[i]==a[j])a[j]=0;  
    }
  }
  int flag=0;
  if(a[0]+a[1]+a[2]==0)flag=1;
  if(a[3]+a[4]+a[5]==0)flag=1;
  if(a[6]+a[7]+a[8]==0)flag=1;
  if(a[0]+a[3]+a[6]==0)flag=1;
  if(a[1]+a[4]+a[7]==0)flag=1;
  if(a[2]+a[5]+a[8]==0)flag=1;
  if(a[0]+a[4]+a[8]==0)flag=1;
  if(a[2]+a[4]+a[6]==0)flag=1;
  
  if(flag==1)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t

int main(){
    ll n;
    cin>>n;
    ll ans=1000*(n/500)+5*((n%500)/5);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
lst=[10001]*n
lst[0]=0
lst[1]=abs(h[1]-h[0])
for i in range(n-2):
  a=lst[i]+abs(h[i+2]-h[i])
  b=lst[i+1]+abs(h[i+2]-h[i+1])
  lst[i+2]=(a if b>a else b)
print(lst[n-1])
  


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

int main(){
  int N,A,B,a=0,b=0,c=0;
  cin>>N>>A>>B;
  for(int i=0;i<N;i++){
    int P;
    cin>>P;
    if(P<=A)
      a++;
    else if(P<=B)
      b++;
    else
      c++;
  }
  cout<<min({a,b,c})<<endl;
}

Measured memory_bytes: 256
import math
from functools import reduce

k=int(input())
sum = 0

for a in range(k+1):
    for b in range(k+1):
        tmp = math.gcd(a,b)
        for c in range(k+1):
            if a != 0 and b != 0 and c != 0:
                sum = sum + math.gcd(tmp,c)

print(sum)

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

int main(){
    int N = 0;
    std::cin >> N;
    
    std::vector<int> v, d;
  	int b, s;
    int tmp;
    while(std::cin >> tmp){v.push_back(tmp);};
    
    d.resize(N-1);
  
    int min = 1e9;
    int max = -1e9;
    int d_max = -1e9;
    for(int j=1; j<N; j++){
        min = v[j-1]>min ? min : v[j-1];
        max = v[j]-min>max ? v[j]-min : max;
    }
    std::cout << max << std::endl;
}


Measured memory_bytes: 4728
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;
	cin >> n >> a >> b;

	if(n==1 && a != b){
		cout << 0 << endl;
		return 0;
	}

	if(a > b){
		cout << 0 << endl;
		return 0;
	}

	ll min_num = a + b + a*(n-2);
	ll max_num = a + b + b*(n-2);

	cout << (max_num - min_num + 1) << endl;

	return 0;
}

Measured memory_bytes: 256