akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout << a+b+c<<endl;
    return 0;
}




Measured memory_bytes: 3236
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	ll k , a , b ; 
	cin >> k >> a >> b ; 
	if ( a+2 < b ){
		ll cur = 1 ; 
		ll t = min(a-cur,k) ;
		k -= t ; 
		cur+=t;
		cur += k/2*(b-a);
		if ( k % 2 != 0 ) cur++ ; 
		cout << cur << endl;
	}
	else {
		cout << 1 + k << endl;
	}
    return 0 ;
}


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

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

const ll DIVIDER = 1000000007;

int inv_mod(int a, int m) {
    int b, x, u, q, abs_m, tmp;
    abs_m = (m < 0) ? -m : m;
    b = m;
    x = 1;
    u = 0;
    while (b > 0) {
        q = a / b;
        tmp = u;
        u = x - q * u;
        x = tmp;
        tmp = b;
        b = a - q * b;
        a = tmp;
    }
    return (x < 0) ? abs_m + x : x;
}

int main() {
    iostream::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    int A[2 * N];
    rep(i, N) {
        cin >> A[i];
        A[N + i] = A[i];
    }
    ull scount1 = 0, scount2 = 0, lcount = 0, bcount = 0;
    rep(i, N - 1) {
        REP(j, i + 1, N) {
            if (A[i] > A[j]) {
                scount1++;
            }
        }
    }
    rep(i, 2 * N - 1) {
        REP(j, i + 1, 2 * N) {
            if (A[i] > A[j]) {
                scount2++;
            }
        }
    }

    lcount += scount1 * K;

    bcount = scount2 - 2 * scount1;
    lcount += ((bcount * (K * (K - 1) % DIVIDER) % DIVIDER)* inv_mod(2, DIVIDER)) % DIVIDER;

    cout << lcount % DIVIDER << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout<<"Yes\n";
    else cout<<"No\n"<<endl;
    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
a=list(map(int,[1,3,5,7,8,10,12]))
b=list(map(int,[4,6,9,11]))
c=list(map(int,[2]))
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")


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

int dp[100010][27];

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

	//連続した２文字を見る
	for (int i = 0; i < n - 1; ++i){
		if(s[i] == s[i + 1]){
			printf("%d %d\n", i + 1, i + 1 + 1); return 0;
		}
	}

	//a*aのような文字列
	for (int i = 1; i < n - 1; ++i){
		if(s[i - 1] == s[i + 1]){
			printf("%d %d\n", i - 1 + 1, i + 1 + 1); return 0;
		}
	}

	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;//
template <typename T>
T sq (T x) {
    return x * x;
}

signed main () {
    int N,L;
    cin >> N >> L;
    vector<string> s(N);
    rep(i,N) cin >> s.at(i);

    sort(all(s));
    rep(i,N) cout << s.at(i) ;
    cout << endl;
    return 0;
}



Measured memory_bytes: 384
a,b,k = map(int,input().split())
num=[]

if b-a >= k:
  for i in range(a,a+k):
    num.append(i)
  for i in range(b-k+1,b+1):
    num.append(i)
else:
  for i in range(a,b+1):
    num.append(i)

for i in sorted(set(num)):
  print(i)



Measured memory_bytes: 3060
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let ans = s.iter().zip(t.iter()).filter(|&(a, b)| a != b).count();

    println!("{}", ans);
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[(int)1e6+5];
int main(){
	int n;
	scanf("%d",&n);
	ll odd=0,even=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&arr[i]);
		if(arr[i]%2==0){
			even++;
		}
		
		else{
			odd++;
		}
	}
	even+=(odd/2);
	odd%=2;
	if(even>0) even=1;
	
	if(even+odd>1){
		printf("NO\n");
	}
	
	else{
		printf("YES\n");
	}
	
	
}

Measured memory_bytes: 1024
#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 int ll;
typedef unsigned long long int ull;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>s>>t;
  cout <<t<<s;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
ll cal(ll x)
{
	ll ans=0,plus=1,val=0;
	while(x>=val+plus)
	{
		ans++;
		val+=plus;
		plus++;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin>>x;
	if(x==1)
	{
		cout<<"0\n";
		return 0;
	}
	ll ans=0;
	for(ll i=2;i*i<x;i++)
	{
		if(x%i==0)
		{
			ll val=0;
			while(x%i==0)
			{
				val++;
				x/=i;
			}
			ans+=cal(val);
		}
	}
	if(x!=1) ans++;
	cout<<ans<<"\n";
	return 0;
}

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

string a,r;
int ans;

int main()
{
	cin>>a;

	r=a;
	reverse(r.begin(),r.end());
	for(int i=0;i<a.size()/2;i++)
		if(a[i]!=r[i]) ans++;
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    int a[n];
    a[0]=0;
    for(int i=1;i<n;i++) a[i]=a[i-1]+(s[i-1]=='A'&&s[i]=='C');
    for(int i=0;i<q;i++)
    {
        int l,r;
        cin >> l >> r;
        l--; r--;
        cout << a[r]-a[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)





const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

struct L : public vector<P> {
	L() {}
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;       // counter clockwise
	if (cross(b, c) < 0)   return -1;       // clockwise
	if (dot(b, c) < 0)     return +2;       // c--a--b on line
	if (norm(b) < norm(c)) return -2;       // a--b--c on line
	return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1]) <= 0 &&
		ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]) <= 0;
}

P crosspoint(const L &l, const L &m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
	if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
	return m[0] + B / A * (m[1] - m[0]);
}






L ab;
int n;
L st[100];
int o[100], l[100];

void init()
{
	double x, y;

	cin >> x >> y; P a(x, y);
	cin >> x >> y; P b(x, y);
	ab = L(a, b);

	cin >> n;

	rep(i, 0, n)
	{
		cin >> x >> y; P s(x, y);
		cin >> x >> y; P t(x, y);
		st[i] = L(s, t);
		cin >> o[i] >> l[i];
	}
}

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

	int dn; cin >> dn;
	rep(_dn, 0, dn)
	{
		init();
		
		vector<pair<double, int> > v;
		rep(i, 0, n)
		{
			if (!intersectSS(ab, st[i])) continue;
			
			P c = crosspoint(ab, st[i]);
			double d = abs(c - ab[0]);

			int p;
			if (o[i] == 0)
				p = 1 - l[i];
			else
				p = l[i];

			v.push_back(make_pair(d, p));
		}

		if (v.size() == 0)
		{
			cout << 0 << endl;
			continue;
		}

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

		int ans = 0;
		rep(i, 0, v.size() - 1)
		{
			if (v[i].second != v[i + 1].second) ans++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3260
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean ans = true;
        int[] a = new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        if(a[4] - a[0] <= k) System.out.println("Yay!");
        else System.out.println(":(");
        sc.close();
    }

}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, k; cin >> n >> k;
    ll cnt = 0;
    for(int b = k+1; b <= n; ++b) {
        cnt += (n/b) * (b-k);
        cnt += max(0, n%b-k+1);
        if(k==0) --cnt;
    }

    cout << cnt << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

int main() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    int arr[3];
    arr[0] = a;
    arr[1] = arr[0] + b;
    arr[2] = arr[1] + c;

    if(arr[0] >= k) {
        cout << k;
    }else if(arr[1] >= k) {
        cout << a;
    }else{
        cout << a - (k - arr[1]);
    }
    
    return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  int m=1000;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    X -= a;
    if(m>a) m=a;
  }
  int a=X/m;
  cout << a+N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, q;
    cin >> n >> q;
    vector<vector<int>> Ai(n);
    for (int i=0; i<q; i++){
        int wh, t;
        cin >> wh >> t;
        if (wh == 0){
            int64_t x;
            cin >> x;
            Ai.at(t).push_back(x);
        }else if(wh == 1){
            for (int j=0; j<Ai.at(t).size(); j++){
                if (j == Ai.at(t).size() - 1){
                    cout << Ai.at(t).at(j);
                }else{
                    cout << Ai.at(t).at(j) << " ";
                }
            }
            cout << endl;
        }else{
            Ai.at(t).clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5740
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    a = int(input())
    b = int(input())
    if a>b:
        print("GREATER")
    elif a<b:
        print("LESS")
    else:
        print("EQUAL")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=2147483647;
const ll inf=1e16;
const ll ms=(1e5) +5;

int dad[ms];
int siz[ms];
int ar[ms]={0};
int br[ms]={0};


int findpar(int i)
{
    if(dad[i]==i)return i;
    return dad[i]=findpar(dad[i]);
}

void unionn(int u,int v)
{
    int a=findpar(u);
    int b=findpar(v);
    if(a!=b)
    {
        if(siz[b]>siz[a])swap(a,b);
        dad[b]=a;
        siz[a]+=siz[b];
    }
}

int main()
{
    idfc;

    int n,m,k;
    cin>>n>>m>>k;
    int i;
    for(i=1;i<=n;i++)
    {
        dad[i]=i;
        siz[i]=1;
    }
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        unionn(u,v);
        ar[u]++; ar[v]++;
    }
    int a,b;
    while (k--)
    {
        cin>>u>>v;
        a=findpar(u);
        b=findpar(v);
        if(a==b){
        br[u]++; br[v]++;}
    }
    int x;
    for(i=1;i<=n;i++)
    {
        x=siz[findpar(i)];
        //cout<<x<<" "<<ar[i]<<" "<<br[i]<<endl;
        x--;
        x-=ar[i];
        x-=br[i];
        cout<<x<<" ";
    }

    return 0;
}

Measured memory_bytes: 2432
def main():
    from bisect import bisect_left
    n, *A = map(int, open(0).read().split())
    length = 0
    lis = []
    for a in A:
        i = bisect_left(lis, a)
        if i == length:
            lis.append(a)
            length += 1
        else:
            lis[i] = a
    print(length)

if __name__ == '__main__':
    main()



Measured memory_bytes: 16632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

intt func(intt n) {
	intt r = 0;
	while (n > 0) {
		r += n;
		--n;
	}
	return r;
}

int main() {
	std::string s; std::cin >> s;
	for (int i = s.size() - 2; i >= 0; i -= 2) {
		if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
			std::cout << i << std::endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, G = I[:2]
G //= 100
p, c = I[2:].reshape(-1, 2).T
c //= 100

def main():
    v = np.arange(1, n+1)
    t = v * p + c
    combs = np.arange(2 ** n - 1)[:, None] >> np.arange(n) & 1
    res = p.sum()
    for comb in combs:
        s = t[comb == 1].sum()
        cnt = p[comb == 1].sum()
        if s - G < 0:
            m = np.amax(v[comb == 0])
            tmp = (G - s + m - 1) // m
            if tmp < p[m-1]:
                cnt += tmp
            else:
                continue
        res = min(res, cnt)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14548
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(k+1):
    for j in range(n):
        if i-a[j]<0:
            break
        if not dp[i-a[j]]:
            dp[i]=1
            break
print('First' if dp[k] else 'Second')

Measured memory_bytes: 43116
/*
    12/15はkyuridenamida啓発デー
*/

#include <cstdio>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

int r;
int w[2], h[2], x[2], y[2];
int l[2][500][500];
char has_reached[2][500][500];
vector<pair<int,int> > variation[2];

void input(int k) {
    int i;

    scanf("%d %d %d %d", w+k, h+k, x+k, y+k);
    x[k]--;
    y[k]--;

    variation[k].clear();

    for (i=0;i<h[k];i++) {
	int j;
        for (j=0;j<w[k];j++) {
	    has_reached[k][i][j] = 0;
	    scanf("%d", &l[k][i][j]);
	}
    }
}

void bfs(int k) {
    int i;
    int dx[] = {0,  0, 1, -1};
    int dy[] = {1, -1, 0,  0};
    int count = 0;
    int now_level = 0;
    priority_queue<pair<int, pair<int, int> >,  vector<pair<int, pair<int,int > > >, greater<pair<int, pair<int, int> > > > q;

    q.push(make_pair(l[k][y[k]][x[k]], make_pair(x[k], y[k])));

    while (!q.empty()) {
         pair<int, pair<int, int> > tmp = q.top();
	 q.pop();
	 int need_level = tmp.first;
         int x = tmp.second.first;
	 int y = tmp.second.second;

	 if (count > r) break;
         if (has_reached[k][y][x]) continue;
	 has_reached[k][y][x] = 1;

	 if (now_level < need_level) {
	     variation[k].push_back(make_pair(count, now_level));
	     now_level = need_level;
	 }

	 count++;

	 for (i=0;i<4;i++) {
	     int new_x = x + dx[i];
	     int new_y = y + dy[i];


	     if ( !(new_x < 0 || new_x >= w[k] || new_y < 0 || new_y >= h[k]) ) {
                 if (!has_reached[k][new_y][new_x]) q.push(make_pair(l[k][new_y][new_x], make_pair(new_x, new_y)));
	     }
	 }

    }
    
    variation[k].push_back(make_pair(count, now_level));
}

int main() {
    while (1) {
        int i;
	int min = 100000000;

	scanf("%d", &r);
	if (r == 0) return 0;

        input(0);
        input(1);
        bfs(0);
        bfs(1);

	vector<pair<int, int> >::iterator it1 = variation[0].begin();
	while (it1 != variation[0].end()) {
	    vector<pair<int, int> >::iterator it2 = lower_bound(variation[1].begin(), variation[1].end(), make_pair(r - it1->first, -1));

	    if (it2 == variation[1].end()) {
                ++it1;
		continue;
	    }

	    if (it1->second + it2->second < min)min = it1->second + it2->second;
	    ++it1;
	}

	printf("%d\n", min);
    }
}

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

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

using namespace std;

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

ll K;

ll i, j, k;

int main(){
    scanf("%lld", &K);
    if(K%2==0||K%5==0){
        printf("-1\n");
        return 0;
    }
    i = 0;
    do{
        (k = k * 10+7) %= K;
        ++i;
    } while (k);
    printf("%lld\n", i);
    return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); 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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll R,G,B,N;cin>>R>>G>>B>>N;
  ll ans=0;
  for(ll r=0;r*R<=N;r++)for(ll g=0;g*G<=N;g++){
    ll num=N-r*R-g*G;
    if(0<=num and num<=N and num%B==0)ans++;
  }
  cout<<ans<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 256
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)


// main code

Console.ReadLine() |> ignore
let s = Console.ReadLine()

let f (maxv, current) c =
    let next =
        match c with
        | 'I' -> current + 1
        | _ -> current - 1
    in (max maxv next, next)

List.fold f (0, 0) (Seq.toList s) |> fst |> Puts


Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[50],b[50];
	int c[50];
	for(int i=0;i<n;i++)c[i]=0;
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		c[a[i]-1]++;
		c[b[i]-1]++;
	}
	for(int i=0;i<n;i++)cout<<c[i]<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

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


Measured memory_bytes: 3672
import sys
N, K = map(int,input().split())
Alist = list(map(int,input().split()))
Flist = list(map(int,input().split()))
Alist.sort()
sum_Alist = 0
for i in range(N):
    sum_Alist += Alist[i]
print(Alist,Flist,file=sys.stderr)
if sum_Alist <= K:
    print(0)
    exit()
maxtime = max(Alist)*max(Flist)
mintime = -1
print(maxtime,mintime,file=sys.stderr)
midlist = [0 for i in range(N)]
while mintime+1 < maxtime:
    mid = (mintime+maxtime)//2
    sum_midlist = 0
    max_midlist = 0
    for i in range(N):
        midlist[i] = mid//Flist[i]
    midlist.sort()
    for i in range(N):
        if midlist[i] < Alist[i]:
            sum_midlist += Alist[i]-midlist[i]
    #print(maxtime,mintime,sum_midlist,file=sys.stderr)
    if sum_midlist <= K:
        maxtime = mid
    else:
        mintime = mid
print(maxtime)


Measured memory_bytes: 124844
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int cnt = 0;
    while(B > 0) {
        if(A > B) break;
        B -= A;
        ++cnt;
    }
    if(cnt > C) cout << C << endl;
    else cout << cnt << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n){
        cin >> a[i];
    }
    
    vector<vector<ll>> dp(n+1, vector<ll>(2, -1e18));
    dp[0][0] = 0;
    rep(i, n){
        dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]-a[i]);   //反転させない
        dp[i+1][1] = max(dp[i][0]-a[i], dp[i][1]+a[i]);   //反転
    }
    //最後は反転させることが出来ないのでdp[n-1][1]は考えない
    cout << dp[n][0] << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	long long int n, a[10000],x=-1000000,y=1000000;
	long long int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++){
		if (y>a[i])y = a[i];
		if (x<a[i])x = a[i];
	}
	printf("%lld %lld %lld\n", y, x, sum);
	return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;



int main(){
#define int long long int
    int N;
    cin >> N;
    int ans = 0;
    int prev = 0;
    for(int i=0;i<N;i++){
        int now;
        cin >> now;
        int d = min(now, prev);
        ans += d;
        now -= d;
        if(now >= 2){
            ans += now / 2;
            now = now % 2;
        }
        prev = now;
        //cout << i << ":" << prev << "-" << ans << endl;
    }
    cout << ans << endl;

}


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

using namespace std;
typedef vector<int> vec;

int n;
int d1[100001], d2[100001];
vec G[100001];

void bfs(int *d, int s, int t, int dis) {
  if (d[t] != 0 && d[t] != -1) return;
  d[t] = dis;

  for (int i = 0; i < G[t].size(); i++) {
    int v = G[t][i];
    if (v == s) continue;
    bfs(d, t, v, dis + 1);
  }
}

int main(void) {
  cin >> n;

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }

  memset(d1, -1, sizeof(d1));
  memset(d2, -1, sizeof(d2));
  d1[0] = 0, d2[n - 1] = 0;
  bfs(d1, -1, 0, 0);
  bfs(d2, -1, n - 1, 0);

  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    if (d1[i] <= d2[i]) cnt1++;
    else cnt2++;
  }

  cout << (cnt1 > cnt2 ? "Fennec" : "Snuke") << endl;
  
  return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+10;
struct edge{
    int to,next,w;
}e[maxn*10];
int head[maxn],cnt;
void add(int u,int v,int w){
    e[cnt].to=v;e[cnt].next=head[u];e[cnt].w=w;head[u]=cnt++;
}
int dis[maxn];
int dij(int s){
    priority_queue<pair<int,int> >q;
    memset(dis,inf,sizeof(dis));dis[s]=0;
    q.push(make_pair(0,s));
    while(!q.empty()){
        int now=q.top().second;int d=q.top().first;q.pop();
        if(d>dis[now])continue;
        for(int i=head[now];~i;i=e[i].next){
            int v=e[i].to;
            if(dis[v]>dis[now]+e[i].w){
                dis[v]=dis[now]+e[i].w;
                q.push(make_pair(-dis[v],v));
            }
        }
    }
    return dis[0];
}
int main()
{
    int n;
    cin>>n;
    memset(head,-1,sizeof(head));
    for(int i=0;i<n;i++){
        add(i,(i+1)%n,1);
        add(i,(i*10)%n,0);
    }
    cout<<1+dij(1)<<endl;
}


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

int main() {
    int n,before;
    cin>>n;
    ll ans=1;
    set<int> st;
    vector<int> a(n+1);
    for (int i=1; i<n+1; i++) cin>>a[i];
    int res=a[1];
    st.insert(1);
    while(true) {
        if (res==2) {
            break;
        } else {
            before=st.size();
            st.insert(res);
            if (before==st.size()) {
                cout<<-1<<endl;
                return 0;
            }
            res=a[res];
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5376
//Created by:Coding_lover(17-06-2020 13:43:39)
#include <bits/stdc++.h>
#define ll long long
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define INF LLONG_MAX
#define f first
#define s second
#define LB lower_bound
#define UB upper_bound
#define pi pair<long long,long long>
#define pii pair<long long,pi>
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define vc vector
#define vll vector<long long>
#define rep(i, a, n) for (ll i = a; i < (long long)n; ++i)
#define repe(i, a, n) for (ll i = a; i <= (long long)n; ++i)
#define repr(i, n, a) for (ll i = n; i > (long long)a; --i)
#define repre(i, n, a) for (ll i = n; i >= (long long)a; --i)
using namespace std;
int main() {
  FASTER;
  ll t;
  t=1;
  //cin >> t;
  while (t--) {
  	ll n,w;
  	cin>>n>>w;
  	vll val(n),wt(n);
  	rep(i,0,n)cin>>wt[i]>>val[i];
  	vc<vc<ll>> dp;
  	dp.assign(n+1,vc<ll> (w+1,0));
  	repe(i,1,n)
  	{
  		repe(j,1,w)
  		{
  		    if(j<wt[i-1]) dp[i][j]=dp[i-1][j];
  			else dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
  		}
  	}
  	/*repe(i,1,n)
  	{
  		repe(j,1,w)cout<<dp[i][j]<<" ";
  		cout<<endl;
  	}*/
  	cout<<dp[n][w]<<endl;
  }
  return 0;
}


Measured memory_bytes: 80256
using System;
using System.Collections.Generic;

namespace abc163
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var aStrList = Console.ReadLine().Split(' ');
            var rest = n;
            foreach (var aStr in aStrList)
            {
                var a = int.Parse(aStr);
                rest -= a;
            }
            if (rest < 0)
            {
                rest = -1;
            }
            Console.WriteLine(rest);
        }
    }
}


Measured memory_bytes: 19332
N=int(input())
ans=0
mul=1
while ans<=N:
    ans=6*(mul**2)
    mul+=1
ANS={}
for i in range(1,101):
    for j in range(i,101):
        for k in range(j,101):
            if (i*i+j*j+k*k+i*j+j*k+i*k) not in ANS.keys():
                if i!=j and j!=k and k!=i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=6
                elif i==j and j==k and k==i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=1
                else:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]=3
            else:
                if i!=j and j!=k and k!=i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=6
                elif i==j and j==k and k==i:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=1
                else:
                    ANS[i*i+j*j+k*k+i*j+j*k+i*k]+=3
for Z in range(1,N+1):
    if Z in ANS.keys():
        print(ANS[Z])
    else:
        print(0)

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

int main(){
	int n;
	
	scanf("%d",&n);
	
	long long sum=0;
	
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	printf("%lld\n",sum);
	
	return 0;
}

Measured memory_bytes: 3828
S = input()

a = 0
b = 0
c = 0

for i in range(3):
	if (a == 0 and S[i] == 'a'):
		a = 1
	elif (b == 0 and S[i] == 'b'):
		b = 1
	elif (c == 0 and S[i] == 'c'):
		c = 1

if (a == 1 and b == 1 and c == 1):
	print("Yes")
else:
	print("No")


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

int main(void)
{
    int position[5];
    int max_distance;
    
    for(int i = 0;i < 5;i++)
    {
        cin >> position[i];
    }
    cin >>max_distance;

    bool communicate=true;

    for(int i = 0; i < 5;i++)
    {
        for(int j = i + 1; j < 5; j++)
        {
            int distance=abs(position[i]-position[j]);

            if (distance > max_distance)
            {
                communicate=false;
            }
        }
    }

    if(communicate)
    {
        cout << "Yay!" <<endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();

            Console.WriteLine(a-(b * 2) >= 0? a - (b * 2) : 0);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string ans2;
    int N,M;
    cin >> N;
    string a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    cin >> M;
    string b[M];
    for(int i = 0;i < M;i++){
        cin >> b[i];
    }
    string temp;
    int sum;
    for(int i = 0;i < N;i++){
        sum = 0;
        temp = a[i];
        for(int j = 0;j < N;j++){
            if(temp == a[j]){
                sum++;
            }
        }
        for(int j = 0;j < M;j++){
            if(temp == b[j]){
                sum--;
            }
        }
        if(sum > 0 && sum > ans)
            ans = sum;
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,l,r;
    cin>>n>>m;
    int ansl=1,ansr=n;
    while(cin>>l>>r){
        ansl=max(ansl,l);
        ansr=min(ansr,r);
    }
    cout<<max(0,ansr-ansl+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<vector<ll>> graph(N);
    vector<pair<int, int>> vp;
    rep(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
        vp.emplace_back(a, b);
    }

    ll k = 0;
    map<pair<ll, ll>, ll> mp; // 辺をキーにして,その色を値にしている
    vector<ll> c(N); // c[i]: iからの辺の色
    vector<bool> used(N); // iへ移動済みかどうか

    // 0からBFS
    queue<ll> que;
    used[0] = true;
    que.emplace(0);
    while (!que.empty()) {
        ll v = que.front();
        que.pop();
        // kは最大の次数
        k = max(k, (ll)graph[v].size());
        ll cur = 1; // 現在の色
        for (auto u : graph[v]) {
            // もし移動済みならスキップ
            if (used[u]) {
                continue;
            }
            // vからの辺の色が現在の色と同じなら色を変える
            if (cur == c[v]) {
                cur++;
            }
            c[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = cur++; // 辺の色を変える
            used[u] = true; // uは通った
            que.emplace(u); // 次はuから別の辺に行く
        }
    }
    cout << k << endl;
    for (auto k : vp) { // 辺から色を出力
        cout << mp[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 20600
#include <bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	#define PI 				acos(-1)
	#define mp				make_pair
	#define pb				push_back
	#define all(a)			(a).begin(), (a).end()
	#define srt(a)			sort(all(a))
	#define mem(a, h)		memset(a, (h), sizeof(a))
	#define f 				first
	#define s 				second
	#define MOD				1000000007
	#define MOD1			998244353
	#define EPS				1e-9
	#define fore(i, b, e)	for(int i = b; i < e; i++)
	#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
	int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

	using namespace std;
	using namespace __gnu_pbds;

	typedef long long 		ll;
	typedef unsigned long long 		ull;
	typedef pair<int, int>  ii;
	typedef vector<int>     vi;
	typedef vector<ii>      vii;
	typedef vector<ll>      vll;
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
	const int tam = 100010;
	int main()
	{
		ios::sync_with_stdio(0); cin.tie(0);
		//freopen("qwe.txt", "r", stdin);
		//freopen("asd.txt", "w", stdout);
		int n, m;
		cin>>n>>m;
		int res = 0;
		for(int i = sqrt(m) + 2; i > 0; i--)
		{
			if(m % i == 0)
			{
				if(m / i >= n)
				{
					res = max(res, i);
				}
				if(m / (m / i) >= n)
					res = max(res, m/i);
			}
		}
		cout<<res<<'\n';
		return 0;
	}

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

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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a[3] = {-n/3, -n/3, -n/3};
  for (int i = 0; i < n; i++) {
    a[s[i] - 'a']++;
  }
  bool f = true;
  for (int i = 0; i < 3; i++) {
    if (a[i] != 0 && a[i] != 1) {
      f = false;
    }
  }
  cout << (f ? "YES": "NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    if(a%x != 0) {
        ll tmp = x - (a%x);
        a += tmp;
    }
    if(b%x != 0){
        ll tmp = (b%x);
        b -= tmp;
    }
    ll ans = (b-a)/x + 1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
N=int(input())
mod=10**9+7
DP=[0]*(N*2+5)
X=[0]*(N*2+5)
Y=[0]*(N*2+5)
C=0
Y[0]=-1
for i in range(N):
  C=(C+X[i])%mod
  DP[i]=(C-Y[i])%mod
  Y[i+2]=DP[i]
  X[i+1]=(X[i+1]+DP[i])%mod
  X[i+N+2]=(X[i+N+2]-DP[i])%mod
for i in range(N,N*2+2):
  C=(C+X[i])%mod
  DP[i]=(C-Y[i])%mod
P=sum(DP[N:])
for i in range(N-1):
  P=(P+DP[i]*(N-1)*(N-1))%mod
print(P)

Measured memory_bytes: 127748
#include <stdio.h>

#define MIN(x,y) ((x)<(y)?(x):(y))

typedef long long int ll;

int x[100000];

int main(){
  int i, n, a, b;
  ll ans;
  scanf("%d%d%d", &n, &a, &b);
  for(i=0;i<n;i++) scanf("%d", x+i);
  ans=0;
  for(i=1;i<n;i++){
    ans += MIN((ll) a*(x[i]-x[i-1]), b);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}


// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
};

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}



// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[1100][1 << 12];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int s,w;
    cin >> s >> w;
    if(w >= s) print("unsafe");
    else print("safe");

}


Measured memory_bytes: 3656
#include<iostream>
#include<set>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string s;
    set<string> st;
    while(n>0)
    {
        cin>>s;
        st.insert(s);
        n--;
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 19204
use proconio::input;

fn main() {
  input! {
    n: usize,
    p: [usize; n],
  }
  // 自分の左側の値よりも小さい

  let mut ans = 0;
  let mut left_min = p[0];
  for &x in &p {
    if x <= left_min {
      ans += 1;
      left_min = x;
    }
  }
  println!("{}", ans);
}


Measured memory_bytes: 4728
implicit none
integer :: n,i,s,ss,sss
integer,allocatable,dimension(:):: a,b
s=0
ss=0
sss=0

read(5,*) n
allocate(a(n))
allocate(b(n))

read(5,*) (a(i),i=1,n)
read(5,*) (b(i),i=1,n)

do i=1,n
    s=s+a(i)
    a(i)=s
    ss=ss+b(n-i+1)
    b(n-i+1)=ss
enddo

do i=1,n
     sss=max(a(i)+b(i),sss)
enddo

write(6,*) sss
 
end

Measured memory_bytes: 256
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
  exit()
if m==1 and k==1:
  print(-1)
  exit()
if k==0:
  ans=[]
  for i in range(2**m):
    ans.append(i)
    ans.append(i)
else:
  ans=[k]
  for i in range(2**m):
    if i==k:continue
    ans.append(i)
  ans.append(k)
  for i in range(2**m-1,-1,-1):
    if i==k:continue
    ans.append(i)
print(*ans,sep=' ')

Measured memory_bytes: 100984
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll a,b,k;
	cin>>a>>b>>k;
	rep(i,k){
	    swap(a,b);
	    a+=b/=2;
	}
	if(k%2)swap(a,b);
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  int a, t = 1;
  rep(i,0,N-1) {
    cin >> a;
    if (a == t) t++;
  }

  if (t == 1) cout << -1 << endl;
  else cout << N - t + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
N,M,X = map(int,input().split())
C = [0] * N
A = [None] * N
for i in range(N):
  c,*a = map(int,input().split())
  C[i] = c
  A[i] = a

INF = 10 ** 9
ans = INF
import itertools
for i in range(2 ** N):
  cost = 0
  skills = [0] * M
  for j in range(N):
    if (i >> j) & 1:
      cost += C[j]
      for k in range(M):
        skills[k] += A[j][k]
    if cost >= ans:
      continue
    for s in skills:
      if s < X:
        break
    else:
      ans = cost

if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B;
    for (int i = 0; i < B; i++) {
        S += to_string(A);
    }
    for (int i = 0; i < A; i++) {
        T += to_string(B);
    }
    cout << min(S, T) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h> 
#include <stdlib.h>
int main() {
 int n, x, max;
 int a, b, c;
 int ans;

 while (1) {
  scanf("%d%d", &n, &x);

  if (n == 0 && x == 0)
    break;

  ans = 0;

  max = x;

  if (max > n)
    max = n;

  for (a = 1; a <= max; a++) {
   for (b = a + 1; b <= max; b++) {
    c = x - a - b;

   if (c > b && c <= n) 
     ans++;
   }
  } 

  printf("%d\n", ans);

  }

 return 0; 
} 


Measured memory_bytes: 2056