akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    rep(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    rep(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};
int main(){
  long long a,b,q; cin>>a>>b>>q;
  vl s(a+2,0);
  vl t(b+2,0);
  vl x(q,0);
  repl(i,1,a+1) cin>>s[i];
  repl(i,1,b+1) cin>>t[i];
  rep(i,q) cin>>x[i];
  s[0] = -INF/10;
  s[a+1]=INF/10;
  t[0]=-INF/10;
  t[b+1]=INF/10;
  rep(i,q){
    ll xa,xb,ta,tb;
    xa = *(lower_bound(all(s),x[i])-1);
    ta = *(lower_bound(all(t),x[i])-1);
    xb = *upper_bound(all(s),x[i]);
    tb = *upper_bound(all(t),x[i]);
    //cout << xa << " " << ta << " " << xb << " " << tb << endl;
    ll ca = max(abs(xa-x[i]),abs(ta-x[i]));
    ll cb = max(abs(xb-x[i]),abs(tb-x[i]));
    ca = min(ca,cb);
    cb = 0;
    cb = min(abs(xa-x[i])+abs(x[i]-tb)+min(abs(xa-x[i]),abs(x[i]-tb)),abs(x[i]-ta)+abs(xb-x[i])+min(abs(ta-x[i]),abs(x[i]-xb)));
    ca = min(ca,cb);
    cout << ca << endl;}
  }


Measured memory_bytes: 5524
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n1=stoi(s)/100,n2=stoi(s)%100;
    n1=(n1<=12&&n1!=0);
    n2=(n2<=12&&n2!=0);
    cout<<(n1?n2?"AMBIGUOUS":"MMYY":n2?"YYMM":"NA")<<endl;
    return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, x; cin >> n >> x;
  int m[n];
  for (int i = 0; i < n; i++) cin >> m[i];
  int sum = accumulate(m, m + n, 0);
  sort(m, m + n);
  int res = (x - sum) / m[0] + n;
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp(a,b) make_pair(a,b)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
struct p3 {
	int a; int b; int c;
};

int a[500000], b[500000];
int grf[702][702];
vector<int>G[702];
int color[702];
int dp[2][702][702];
int R[702], B[702],ed[702];

int par[705], rnk[705],heavy[705];
void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rnk[i] = 0;
		heavy[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (heavy[x] < heavy[y])swap(x, y);
	par[y] = x;
	heavy[x] += heavy[y];
}
void initdp(int a, int n) {
	rep(i, n)rep(j, n)dp[a][i][j] = -1;
}
void dispdp(int a, int n) {
	rep(i, n) {
		rep(j, n) {
			if (j)cout << ' ';
			cout << dp[a][i][j];
		}cout << endl;
	}cout << endl;
}
bool dfs(int v, int c) {
	color[v] = c;
	rep(i, G[v].size()) {
		if (color[G[v][i]] == c)return false;
		if (color[G[v][i]] == 0 && !dfs(G[v][i], -c))return false;
	}
	return true;
}

signed main() {
	int n, m; cin >> n >> m;
	init(n);

	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		grf[a[i]][b[i]]++;
		grf[b[i]][a[i]]++;
	}
	rep(i, n)grf[i][i]++;
	rep(i, n) {
		rep(j, n) {
			if (!grf[i][j]) {
				G[i].push_back(j);
				unite(i, j);
			}
		}
	}
	rep(i, n) {
		if (!color[i]) {
			if (!dfs(i, 1)) {
				puts("-1");
				return 0;
			}
		}
	}
	rep(i, n) {
		if (color[i] == 1) {
			R[find(i)]++;
		}
		else B[find(i)]++;
	}
	rep(i, n) {
		ed[find(i)] += G[i].size();
	}
	rep(i, n)ed[i] /= 2;
	vector<p3>V;
	rep(i, n) {
		if (R[i] || B[i]) {
			V.push_back({ R[i],B[i],R[i] * B[i] - ed[i] });
		}
	}
	initdp(0, n+1);
	initdp(1, n + 1);
	dp[0][0][0] = 0;
	rep(k, V.size()) {
	rep(i,n+1){
		rep(j,n+1){
			if (dp[k & 1][i][j] == -1)continue;
			int na = V[k].a, nb = V[k].b;
			int ni = i + na, nj = j + nb, mi = i + nb, mj = j + na;
			dp[(k+1)&1][ni][nj] = max(dp[(k+1)&1][ni][nj], dp[k&1][i][j] + V[k].c + i*nb + j*na);
			dp[(k+1)&1][mi][mj] = max(dp[(k+1)&1][mi][mj], dp[k&1][i][j] + V[k].c + i*na + j*nb);
			}
		}
	//dispdp((k + 1) & 1, n + 1);
	initdp(k & 1, n+1);
	}
	int res = 0;
	rep(i, n + 1) {
		res = max(res, dp[1&V.size()][i][n - i]);
	}

	cout << m - res << endl;
}

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    if c>(a+b):
        ans=b+a+1+b
    else:
        ans=c+b
        
    print(ans)
        

main()


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

using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<long long> A(N), cumsum(N + 1, 0);
  map<long long, long long> count;
  count[0]++;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    cumsum[i + 1] = cumsum[i] + A[i];
    count[cumsum[i + 1]] ++;
  }
  long long ans = 0;
  for(auto &e : count){
    //cout << e.first << " " << e.second << endl;
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,p;
    string s1,s2,s3,s4,s5,s6;
    cin>>s1;
    n=s1.length();
    m=(n+2)/2;
    p=(n-1)/2;
    s2=string(s1.rbegin(),s1.rend());
    if(s1.compare(s2)==0)
    {
        s4=string(s1.begin(),s1.begin()+p);
        s3=string(s1.rbegin()+m,s1.rend());

        if(s3.compare(s4)==0)
        {
            s5=string(s1.begin()+m,s1.end());
            s6=string(s1.rbegin(),s1.rbegin()+p);


            if(s5.compare(s6)==0)
            {
                cout<<"Yes"<<endl;
            }
            else
            {
                cout<<"No"<<endl;
            }
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}



Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int chcnt[] = new int[26];
        String str = "";
        while(sc.hasNext()){
            str = sc.nextLine();
            str = str.toLowerCase();
            for(int i = 0; i < str.length(); i++ ){
                char ch = str.charAt(i);
                if(ch <= 'z' && ch >= 'a') chcnt[ch - 'a']++;
            }
        }
        for(int i = 0; i < chcnt.length; i++){
            System.out.println((char)('a' + i) + " : " + chcnt[i]);
        }
    }
}


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


#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

class EMaxGCD {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    lint K, s = 0;
	    in>>N>>K;
	    vector<lint> A(N), div;
	    REP(i, N)in>>A[i], s+=A[i];
	    for(lint i=1;i*i<=s;i++){
	        if(s%i==0){
	            div.pb(i);
	            if(i*i<s) div.pb(s/i);
	        }
	    }
	    sort(RALL(div));
	    for(auto d : div){
	        lint p = 0, n = 0;
	        vector<lint> pos, neg;
	        REP(i, N){
	            lint x = A[i] % d;
	            if(x<d-x) neg.pb(x), n += x;
	            else pos.pb(d-x), p += d - x;
	        }
	        if(p<n) swap(p, n), swap(pos, neg);
	        sort(RALL(pos));
	        for(auto u : pos){
	            if(n==p) break;
	            p -= u, n += d - u;
	        }
	        if(p<=K){
	            out<<d<<endl;
                return;
	        }
	    }
	}
};


int main() {
	EMaxGCD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
	int N; cin >> N;
  	int arr[N], dp[N];
  	
  	for(int i=0; i<N; i++){
      cin >> arr[i];
    }
  	
  	dp[N-1] = 0;
  	dp[N-2] = abs(arr[N-2] - arr[N-1]);
  
  	for (int i=N-3; i>=0; i--){
      dp[i] = min(abs(arr[i] - arr[i+1]) + dp[i+1], abs(arr[i] - arr[i+2]) + dp[i+2]);
       
    }
  	
  	cout << dp[0] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()

{
    int n;
    int m;
    cin>>n>>m;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    vector<int> adj[n+1];
    
    for(int i=0;i<m;i++)
    {
    	int u,v;
    	cin>>u>>v;
    	adj[u].push_back(v);
    	adj[v].push_back(u);
	}
	int res=0;
	for(int i=1;i<=n;i++)
	{
		//cout<<i<<" "<<adj[i].size()<<endl;
		if(adj[i].size()==0)res++;
		else
		{
			bool b=true;
			for(int j=0;j<adj[i].size();j++)
			{
				if(h[adj[i][j]-1]>=h[i-1])
				{
					b=false;
					break;
				}
			}
			res+=b;
		}
	}
	cout<<res;

}



Measured memory_bytes: 9116
from collections import deque

def Topologicalsort():
    for i in xrange(v):
        if indeg[i]==0 and color[i]==0:
            bfs(i)

def bfs(s):
    color[s]=2
    q.append(s)
    while len(q)>0:
        i=q.popleft()
        ans.append(i)
        for j in m[i]:
            indeg[j]-=1
            if indeg[j]==0  and color[j]==0:
                q.append(j)
                color[j]=1

v,e=map(int,raw_input().split())
m=[[]for i in xrange(v)]
indeg=[0]*v
color=[0]*v
ans=deque()
q=deque()
for i in xrange(e):
    s,t=map(int,raw_input().split())
    m[s].append(t)
    indeg[t]+=1
Topologicalsort()
for i in ans:
    print(i)

Measured memory_bytes: 9028
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
string s;

int main() {
	cin >> s;
	string t="";
	for (int i = s.length() - 1; i >= 0; i--) {
		t += s[i];
	}
	cout << t << endl;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> x(n), y(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i);
    y.at(i) = x.at(i);
  }
  
  sort(y.begin(), y.end());
  
  int a = y.at(n / 2 - 1), b = y.at(n / 2);
  for(int i = 0; i < n; i++){
    if(x.at(i) <= a) cout << b << endl;
    else cout << a << endl;
  }
}

Measured memory_bytes: 3712
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
void solve(){
	cin>>n;
	VI a(n+1,0);
	rep(i,1,n+1)cin>>a[i];
	VI pat(n+1,0);
	rep(i,1,n+1)pat[i] = i;
	if(pat==a){
		cout<<"YES";
		return ;
	}
	rep(i,1,n+1)
	rep(j,i+1,n+1){
		swap(a[i],a[j]);
		if(a==pat){
			cout<<"YES";
			return ;
		}
		swap(a[i],a[j]);
	}
	cout<<"NO";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

ll dp[10010010];


int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    dp[1] = 0;
    rep(i,N) cin >> a[i];
    if(N == 2) dp[N] = abs(a[1]-a[0]);
    else{
        dp[2] = abs(a[1]-a[0]);
        for(int i = 2;i<N;i++){
            dp[i+1] = min(dp[i]+abs(a[i]-a[i-1]), dp[i-1]+abs(a[i]-a[i-2]));
            
        }
    }
    cout << dp[N] << endl;
  
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

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

    int N, T;
    i64 a[100010];

    cin >> N >> T;
    rep(i, N) {
        cin >> a[i];
    }

    i64 minv = a[0];
    i64 maxDiff = 0;

    rep(i, N) {
        chmin(minv, a[i]);
        chmax(maxDiff, a[i] - minv);
    }

    int ans = 0;
    minv = a[0];

    rep(i, N) {
        chmin(minv, a[i]);
        if (a[i] - minv == maxDiff) ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
//https://atcoder.jp/contests/caddi2018b/tasks/caddi2018b_a
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    string N; cin>>N;
    ll ans=0;
    for(auto c:N){
        if(c=='2')++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long

signed main() {
	int n;
	cin >> n;
	cout << n / 3 << endl;
}

Measured memory_bytes: 256
#include<iostream>

#define LIM 1000000
using namespace std;

int main(){
  bool num_map[LIM];
  int in_num,prime_count;
  for(int i=0;i<LIM;i++){
    num_map[i]=1;
  }
  
  for(int i=2;i<LIM;i++){
    if(num_map[i]==1)
      for(int j=i*2;j<LIM;j+=i){
	num_map[j]=0;
      }   
  }
  while(cin>>in_num){
    prime_count = 0;
    //    cin>>in_num;
    //cout<<in_num<<endl<<endl;
    for(int i=2;i<=in_num;i++){
      if(num_map[i]==1)
	prime_count++;
    }
    cout<<prime_count<<endl;  
  }
  
}

Measured memory_bytes: 2136
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

// void display_vector(vector<pair<int, int>> &information);

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> information;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        auto p = make_pair(b, a);
        information.push_back(p);
    }
    sort(information.begin(), information.end());
    // display_vector(information);

    string ans = "Yes";
    lli time_elapsed = 0;
    for(int i = 0; i < n; ++i){
        time_elapsed += information[i].second;
        // cout << "i = " << i << ": time_elapsed = " << time_elapsed << endl;
        if(time_elapsed > information[i].first){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

// void display_vector(vector<pair<int, int>> &information){
//     for(size_t i = 0; i < information.size(); ++i){
//         cout << "itr = " << i << ": (" << information[i].first << ", " << information[i].second << ")\n";
//     }
// }

Measured memory_bytes: 2420
N, M = map(int, input().split())

INF = 10**7
dp = [INF]*2**N
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    d = sum((1<< (i - 1)) for i in  map(int, input().split()))    
    for j in range(2**N):
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
        
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int bp(int pow, int n){
    int d = 1;
    while(n)
    {
        if(n%2==1)d=(d*pow)%mod;
        pow=(pow*pow)%mod;
        n/=2;
    }
    return d;
}
void solve(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int cnt = 0;
    while(1)
    {
        if(a<=0||c<=0)break;
        if(cnt%2==0)c-=b;
        else a-=d;
        cnt++;
    }
    if(a<=0)cout<<"No";
    else if(c<=0)cout<<"Yes";
    else{
        if(cnt%2==0)cout<<"Yes";
        else cout<<"No";
    }
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}


Measured memory_bytes: 3652
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  H, W = map(int, readline().split())
  h, w = map(int, readline().split())
  ans = H*W - h*W -H*w +h*w
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;

int a, b, c;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> c;
    cout << a * b / 2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
  int a, b, c, x=0;
  cin>>a>>b>>c;
  for(int i=a; i <= b; i++){
    if(c%i == 0){
      x++;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		boolean res = false;

		res = magic(a,b,c,k);

		if(res) {
			System.out.printf("Yes");
		} else {
			System.out.printf("No");
		}
	}

	static boolean magic(int a, int b, int c, int k) {
		int rd = a;
		int gr = b;
		int bl = c;
		int remain = k;

		while (gr <= rd) {
			gr *= 2;
			remain--;
			if(remain<0) {return false;}
		}

		while (bl <= gr) {
			bl *= 2;
			remain--;
			if(remain<0) {return false;}
		}
		return true;
	}
}


Measured memory_bytes: 35760
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, a;
	cin >> n >> a;
	Array x(n, 0);
	REP(i, n) {
		cin >> x[i];
		x[i] -= a;
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(5010,0));
	dp[0][2500] = 1;

	REP(i, n) {
		REP(j, 5010) {
			if (dp[i][j] !=0) {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j + x[i]] += dp[i][j];
				//cout << i + 1 << " " << j << ":" << dp[i + 1][j]<<endl;
				//cout << i + 1 << " " << j + x[i] << ":" << dp[i + 1][j + x[i]] << endl;;
			}
		}
	}

	cout << dp[n][2500]-1 << endl;

	return 0;
}

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

int main() {
  int N, n;
  cin >> N;
  n = N%10;
  
  if (n==2|| n==4 || n== 5 || n==7 || n==9){
  cout << "hon" << endl; 
  }
  else if (n==0 || n==1 || n==6 || n==8){
  cout << "pon" <<endl;
  }
  else {
  cout << "bon" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_bacm
#define mp mame_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    ll s = 0;
    for (int i = 1; i <= n; i++){
        if (i % 3 != 0 && i % 5 != 0) s += i;
    }
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
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<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    vii p(n+1);
    rep(i, 0, n) cin >> p[i]; 
    int ans = 0;
    rep(i, 0, n) {
      if (p[i] == i + 1) {
        ans++;
        swap(p[i], p[i+1]);
      }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>

using namespace std;

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

    int count = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) count++;
    }
    cout << count << endl;

    return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

int main(){
  string s,t;cin >> s >> t;
  
  rep(i,s.size()){  
    if(s==t){
      cout << "Yes" << endl;
      return 0;
    }
    char en=s.back();
    s.pop_back();
    s.insert(s.begin(),en);
  }
  cout << "No" << endl;
  return 0;
}


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

char s[101000];
int l,n,T,a[101000],x,y,used[101000];
vector<int>G[55555];

int dfs(int x){
	used[x]=1;
	int res=a[x];
	for (auto y:G[x]) if (!used[y])
		res+=dfs(y);
	return res;
}

int main(){
	scanf("%s",s+1); l=strlen(s+1); n=l>>1;
	for (int i=1;i<=n;++i) a[i]=s[i]-s[l-i+1];
	for (int i=n+1;i;--i) a[i]-=a[i-1];
	for (cin>>T;T--;){
		scanf("%d%d",&x,&y);
		if (x>n){
			x=l+1-x;
			y=l+1-y;
			swap(x,y);
		}else if (y>n){
			y=l+1-y;
			if (x>y) swap(x,y);
			--y;
		}
		if (x>n||x>y) continue;
		y=min(y,n);
		G[x].push_back(y+1);
		G[y+1].push_back(x);
	}
	for (int i=1;i<=n+1;++i) if (!used[i]){
		if (dfs(i)%26) return !puts("NO");
	}
	puts("YES");
}

Measured memory_bytes: 5120
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]

def bfs(y,x):
    a[y][x]='.'
    
    if y+1<h and x+1<w:
        if a[y+1][x]=='#' :
            bfs(y+1,x)
        elif a[y][x+1]=='#':
            bfs(y,x+1)
    elif x+1<w:
        if a[y][x+1]=='#':
            bfs(y,x+1)
    elif y+1<h:
        if a[y+1][x]=='#':
            bfs(y+1,x)
    
bfs(0,0)

ans='Possible'
for i in a:
    if '#' in i:
        ans='Impossible'
        
print(ans)
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long int n,w,dp[100005];
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n>>w;
	for(long long int i=0;i<100005;i++){
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	long long int we,val;
	for(long long int i=0;i<n;i++){
		cin>>we>>val;
		for(long long int i=100004;i>=0;i--){
			if(dp[i]!=INT_MAX){
				dp[i+val]=min(dp[i+val],dp[i]+we);
			}
		}
	}
	for(long long int i=100004;i>=0;i--){
		if(dp[i]<=w){
			cout<<i;
			return 0;
		}
	}
	cout<<"error";
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
h,w=map(int,input().split())
a=[list(map(str,input().split())) for _ in range(h)]
ans=[["#"]*(w+2)]
for i in range(h):
    b=["#"]
    b+=a[i]
    b+=["#"]
    ans.append(b)
ans.append(["#"]*(w+2))
for i in ans:
    print("".join(i))


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

using ll=long long;

int main() {
  int N; cin >>N;
  int temp=ceil(N/1.08);
  if ((int)(temp*1.08)==N) {
    cout <<temp <<endl;
  } else {
    cout <<":(" <<endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, k, a[MAX_N], m[MAX_N];

typedef long long ll;

ll modpow(ll x, ll n) {
    if (n == 0) return 1;
    return modpow(x * x % mod, n / 2) * (n & 1 ? x : 1) % mod;
}

ll modinv(ll a) {
    return modpow(a, mod - 2);
}

// assert m is prime
inline ll  inverse(ll  a, ll  m) {
    ll  b = m, x = 1, y = 0;
    // extgcd(a, m, x, y)
    while (b) {
        ll  t = a / b;
        swap(a -= t * b, b);
        swap(x -= t * y, y);
    }
    return (x % m + m) % m;
}


vector<ll> fact, inv_fact;
void init_fact(ll n) {
    fact.resize(n);
    fact[0] = 1;
    for (ll i = 1; i < n; i++) {
        fact[i] = i * fact[i - 1] % mod;
    }
    inv_fact.resize(n);
    inv_fact[n - 1] = inverse(fact[n - 1], mod);
    for (ll i = n - 2; i >= 0; i--) {
        inv_fact[i] = (i + 1) * inv_fact[i + 1] % mod;
    }
}

ll nPr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[n - r] % mod;
}

ll nCr(ll n, ll r) {
    if (n < r || n < 0 || r < 0) return 0;
    return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}

ll nHr(ll n, ll r) {
    if (n == 0 && r == 0) return 1;
    return nCr(n + r - 1, r);
}

signed main(){
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    sort(a, a+n);

    ll ret = 0;
    init_fact(n);

    // max
    for(ll i=k; i<=n; i++){
        ret += nCr(i-1, k-1) * a[i-1];
        ret %= mod;
    }

    // min
    m[n-k] = 1;
    for(ll i=k+1; i<=n; i++){
        m[n-i] += m[n-i+1] +  nCr(i-2, k-2);
        m[n-i] %= mod;
    }
    for(ll i=0; i<=n-k; i++){
        ret -= m[i] * a[i];
        ret %= mod;
        if(ret < 0) ret += mod;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2944
x=int(input())

for a in range(1000):
    for b in range(1000):
        if a**5 - b**5 == x:
            c=a
            d=b
        if a**5 + b**5 ==x:
          c=a
          d=-1*b
print(str(c)+" "+str(d)+"\n")

Measured memory_bytes: 67800
N,M = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]
INF = 10**5+1

small,big = 0,INF
for i in range(M):
    small = max(small,LR[i][0])
    big = min(big,LR[i][1])

if small <= big:
    print(big-small+1)
else:
    print(0)


Measured memory_bytes: 27332
/*
_________________________
|   LIVE FREE OR DIE     |
|       327 2153         |
|          New           |
|_______HAMPSHIRE________|

*/
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define MAX 20
#define int long long
#define MOD 998244353

int32_t main()
{
	IOS
	int n,k;cin>>n>>k;
	vector<int> cnt(n+1);
	for(int i=0;i<k;i++)
	{
		int p;cin>>p;
		for(int j=0;j<p;j++)
		{
			int x;cin>>x;
			cnt[x]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(cnt[i]==0)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

ll power(ll a, ll p)
{
	ll ans = 1;
	while(p)
	{
		if(p&1)
			ans = (ans*a)%mod;
		a = a*a%mod;
		p=p>>1;
	}
	return ans;
}

ll modInverse(ll a)
{
	return power(a,mod-2);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	ll fact[h+w+1];
	fact[0]=1;
	
	for(int i = 1; i<h+w+1; i++)
		fact[i]=fact[i-1]*i%mod;
	
	ll ans =0;
	for(int i = b;i<w; i++)
	{
		int n= h-a-1+i;
		ll k = ((fact[n]%mod*modInverse(fact[n-i])%mod)%mod*modInverse(fact[i])%mod)%mod;
		k = k*(fact[a+w-i-2]*modInverse(fact[a-1])%mod*modInverse(fact[w-i-1])%mod)%mod;
		ans = (ans+k)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;
#define N 200050
int n,a[N],b[N];
int check(int mid) {
	int i;
	for(i=1;i<=n;i++) b[i]=a[i]>=mid;
	int t=(n+1)>>1;
	for(i=1;t-i>=1;i++) {
		if(b[t-i]==b[t-i+1]) {
			return b[t-i];
		}
		if(b[t+i]==b[t+i-1]) {
			return b[t+i];
		}
	}return (!(t&1))^b[t];
}
int main() {
	scanf("%d",&n);n=n*2-1;
	int i;
	for(i=1;i<=n;i++) scanf("%d",&a[i]);
	int l=1,r=n+1;
	while(l<r) {
		int mid=(l+r)>>1;
		if(check(mid)==0) r=mid;
		else l=mid+1;
	}l--;
	printf("%d\n",l);
}

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

int main() {
	int e;
	while(cin >> e && e != 0) {
		int x,y,z;
		int ans = INT_MAX;
		for(z=0;z*z*z <= e;z++) {
			for(y=0;y*y<=e-z*z*z;y++) {
				x = e - z*z*z - y*y;
				if(x+y+z < ans)
					ans = x+y+z;
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3072
n = int(input())
a, b = map(int,input().split())
c = int(input())

ds = [int(input()) for i in range(n)]
ds.sort(reverse=True)

ans = c // a
for i in range(n):
  c += ds[i]
  ans = max(c // (a + b * (i + 1)), ans)

print(ans)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, d, x;
    cin>>n>>d>>x;
    int a[n];
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for (int i=0;i<n;i++)
    {
        ans++;
        for (int j=1;(a[i]*j+1)<=d;j++)
        {
            ans++;
        }
    }
    cout<<ans+x;
    return 0;
}

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

using namespace std;

int main() {
	int N;
	long long K;
	cin >> N >> K;
	vector< pair<int, int> > v(N);

	for(int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		v[i] = make_pair(a, b);
	}
	sort(v.begin(), v.end());

	int i = 0;
	long long cnt = 0LL;
	while(cnt < K) {
		cnt += v[i].second;
		i++;
	}
	cout << v[i-1].first << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

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

  int ws[n];
  
  FOR(i,0,1){
    FOR(j,0,1){
      ws[0] = i; ws[1] = j;

      FOR(k,1,n-2){
        if(s[k]=='o' && ws[k]==0) ws[k+1] = ws[k-1];
        else if(s[k]=='o' && ws[k]==1) ws[k+1] = (ws[k-1]+1) % 2;
        else if(s[k]=='x' && ws[k]==0) ws[k+1] = (ws[k-1]+1) % 2;
        else if(s[k]=='x' && ws[k]==1) ws[k+1] = ws[k-1];
      }

      bool ok = true;

      // cout << s[n-1] << " " << ws[n-1] << endl;
      // cout << ws[n-2] << " " << ws[0] << endl;
      // cout << "--------------" << endl;

      if(s[0]=='o' && ws[0]==0) {
        if(ws[n-1]!=ws[1]) ok = false;
      }
      else if(s[0]=='o' && ws[0]==1) {
        if(ws[n-1]==ws[1]) ok = false;
      }
      else if(s[0]=='x' && ws[0]==0) {
        if(ws[n-1]==ws[1]) ok = false;
      }
      else if(s[0]=='x' && ws[0]==1) {
        if(ws[n-1]!=ws[1]) ok = false;
      }

      // cout << ok << endl;

      if(s[n-1]=='o' && ws[n-1]==0) {
        if(ws[n-2]!=ws[0]) ok = false;
      }
      else if(s[n-1]=='o' && ws[n-1]==1) {
        if(ws[n-2]==ws[0]) ok = false;
      }
      else if(s[n-1]=='x' && ws[n-1]==0) {
        if(ws[n-2]==ws[0]) ok = false;
      }
      else if(s[n-1]=='x' && ws[n-1]==1) {
        if(ws[n-2]!=ws[0]) ok = false;
      }

      // cout << ok << endl;

      if(ok){
        FOR(i,0,n-1){
          if(ws[i]==0) cout << 'S';
          else cout << 'W';
        }
        cout << endl;
        return 0;
      }
    }
  }

  cout << -1 << endl;
  return 0;

  

}


Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define Abs(a) a>0?a:-a
char s[MAXN];
int n,ls,ans;
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		if(ls==0&&s[i]=='T')
			ans++;
		else if(s[i]=='T')
			ls++;
		else if(s[i]=='S')
			ls--;
	ans+=Abs(ls);
	printf("%d\n",ans);
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();

    	if ((A+B) % 2 == 0) {
    		int K = (A+B) / 2;
    		System.out.println(K);
    	} else {
    		System.out.println("IMPOSSIBLE");
    	}
   	}
}


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

ll gcd(ll a, ll b) { return b ? 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];
	// ll t = 1;
	// rep(i, n) {
	// 	t = lcm(t, a[i]);
	// }
	// // cout << t << endl;
	// t--;
	// ll ans = 0;
	// rep(i, n) {
	// 	ans += t%a[i];
	// }
	ll ans = 0;
	rep(i, n) ans += a[i]-1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define ff              first
#define ss              second
#define SZ(x)           ((int)(x).size())
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n+1);
    for(ll i=0; i<n; i++) cin>>v[i+1];
    ll l = v[1];
    ll r = v[v[1]];
    while(l!=r){
        l = v[l];
        r = v[v[r]];
    }
    l = 1;
    while(l!=r){
        l=v[l];
        r=v[r];
    }
    ll cycleStar = l;
    ll cnt = 0;
    l = 1;
    while(l!=cycleStar){
        cnt++;
        l = v[l];
    }
    ll eleBefore = cnt;
    ll lenn = 1;
    l = cycleStar;
    while(v[l]!=cycleStar){
        l=v[l];
        lenn++;
    }
    l = 1;
    while((eleBefore!=0)&&(k)){
        l=v[l];
        eleBefore--;
        k--;
    }
    if(k==0){
        cout<<l<<endl;
        return 0;
    }
    k=k%lenn;
    while(k){
        l=v[l];
        k--;
    }
    cout<<l<<endl;
    return 0;
}




Measured memory_bytes: 4820
h = int(input())
heap = list(map(int, input().split()))

for i, key in enumerate(heap):
    i += 1
    pi, cli = i // 2, i * 2
    rel_nodes = ''
    if pi:
        rel_nodes += 'parent key = {}, '.format(heap[pi - 1])
    if cli <= h:
        rel_nodes += 'left key = {}, '.format(heap[cli - 1])
        if cli < h:
            rel_nodes += 'right key = {}, '.format(heap[cli])

    print('node {}: key = {}, '.format(i, key) + rel_nodes)

Measured memory_bytes: 7692
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector< vector<int> > VVI;
typedef vector< vector<int> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int N;
  cin>>N;
  VI P(N);
  rep(i,N) cin>>P[i];
  int M=1e9;
  int ans=0;
  rep(i,N){
    if(M>P[i]){
      ans++;
      M=P[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

long long gcd(long long a, long long b){
    while(b != 0){
        long long tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

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

    long long ans = 0;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ans = gcd(ans, abs(x - a));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256