akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<int> v(3); cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if (v[0]+v[1]==v[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Map;
import java.util.TreeMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer,Long> a = new TreeMap<>();
        for(int i = 0;i < n;i++){
            int x = sc.nextInt();
            if(a.get(x) != null){
                a.put(x,a.get(x)+1L);
                continue;
            }
            a.put(x,1L);
        }
        List <Integer> list = new ArrayList<>(a.keySet());
        Collections.sort(list,Collections.reverseOrder());
        //System.out.println(list);
        long edge1 = 0;
        long edge2 = 0;
        for(Integer it : list){
            //System.out.println("it = " + it);
            if(a.get(it) < 2){
                continue;
            }
            else if(a.get(it) >= 2 && a.get(it) < 4){
                if(edge1 == 0){
                    edge1 = it;
                    continue;
                }
                edge2 = it;
                break;
            }
            else if(a.get(it) >= 4){
                if(edge1 != 0){
                    edge2 = it;
                    break;
                }
                edge1 = it;
                edge2 = it;
                break;
            }
        }
        System.out.println(edge1 * edge2);
    }
}


Measured memory_bytes: 61508
N,X,Y = map(int,input().split())
X -= 1
Y -= 1
data = [0]*N

for i in range(N-1):
    for j in range(i+1,N):
        data[min(j-i,abs(i-X)+1+abs(j-Y),abs(i-Y)+1+abs(j-X))] += 1

for k in range(1,N):
    print(data[k])

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<list>
using namespace std;
vector<int>G[1<<17];
int n;
list<int>ans;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	void unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(rank[a]<rank[b])
		{
			parent[a]=b;
		}
		else
		{
			parent[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
	}
};
main()
{
	int m;cin>>n>>m;
	int a,b;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	ans.push_back(a);
	ans.push_back(b);
	UF uf(n+1);
	uf.unite(a,b);
	while(1)
	{
		a=*ans.begin();
		bool f=0;
		for(int i=0;i<G[a].size();i++)
		{
			if(!uf.same(a,G[a][i]))
			{
				ans.push_front(G[a][i]);
				uf.unite(a,G[a][i]);
				f=1;
				break;
			}
		}
		if(!f)
		{
			b=ans.back();
			for(int i=0;i<G[b].size();i++)
			{
				if(!uf.same(b,G[b][i]))
				{
					ans.push_back(G[b][i]);
					uf.unite(b,G[b][i]);
					f=1;
					break;
				}
			}
		}
		if(!f)break;
	}
	cout<<ans.size()<<endl;
	a=0;
	for(int i:ans)cout<<(a++?" ":"")<<i;
	cout<<endl;
}


Measured memory_bytes: 10880
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
using System.IO.Pipes;

class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        //var S = Console.ReadLine();
        var N = long.Parse(Console.ReadLine());
        //var N = long.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

        long sum = 0;
        for (int i = 1; i < N; i++)
        {
            if(A[i] < A[i - 1])
            {
                sum += A[i - 1] - A[i];
                A[i] = A[i - 1];
            }
        }

        Console.WriteLine(sum);
        
    }



}


public class PriorityQueue<T> : IEnumerable<T>
{
    private readonly List<T> _data = new List<T>();
    private readonly IComparer<T> _comparer;
    private readonly bool _isDescending;

    public PriorityQueue(IComparer<T> comparer, bool isDescending = true)
    {
        _comparer = comparer;
        _isDescending = isDescending;
    }

    public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
        : this(Comparer<T>.Create(comparison), isDescending)
    {
    }

    public PriorityQueue(bool isDescending = true)
        : this(Comparer<T>.Default, isDescending)
    {
    }

    public void Enqueue(T item)
    {
        _data.Add(item);
        var childIndex = _data.Count - 1;
        while (childIndex > 0)
        {
            var parentIndex = (childIndex - 1) / 2;
            if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
                break;
            Swap(childIndex, parentIndex);
            childIndex = parentIndex;
        }
    }

    public T Dequeue()
    {
        var lastIndex = _data.Count - 1;
        var firstItem = _data[0];
        _data[0] = _data[lastIndex];
        _data.RemoveAt(lastIndex--);
        var parentIndex = 0;
        while (true)
        {
            var childIndex = parentIndex * 2 + 1;
            if (childIndex > lastIndex)
                break;
            var rightChild = childIndex + 1;
            if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0)
                childIndex = rightChild;
            if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
                break;
            Swap(parentIndex, childIndex);
            parentIndex = childIndex;
        }
        return firstItem;
    }

    public T Peek()
    {
        return _data[0];
    }

    private void Swap(int a, int b)
    {
        var tmp = _data[a];
        _data[a] = _data[b];
        _data[b] = tmp;
    }

    private int Compare(T a, T b)
    {
        return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
    }

    public int Count => _data.Count;

    public IEnumerator<T> GetEnumerator()
    {
        return _data.GetEnumerator();
    }

    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

Measured memory_bytes: 47916
function Main(input) {
	var data = input.split(/\a\n|\a|\n/)
	var n = data[0]
	var a = data.slice(1).map(function(s) { return parseInt(s); });
		
	for (var i = 0; i < n; ++i) {
		var b = []
		for (var j = 0; j < a.length; j += 2) {
			if (a[j] > a[j + 1]) {
				b.push(a[j] - a[j + 1])
			} else if (a[j] == a[j + 1]) {
				b.push(a[j])
			} else {
				b.push(a[j + 1] - a[j])
			}
		}
		a = b
	}
	
	console.log(a[0])
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 51464
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second



int dijkstra(int n,int s,vector<mp>* vs,int* dist,int g=-1){
	memset(dist,-1,sizeof(int)*n);
	//rep(i,n)dist[i]=-1;
	priority_queue<mp,vector<mp>,greater<mp> > que;
	que.push(mp(0,s));
	while(!que.empty()){
		mp pa=que.top();
		que.pop();
		int co=pa.fir,
			no=pa.sec;
		if(dist[no]!=-1 && dist[no]<co)continue;
		dist[no]=co;
		if(no==g)return co;
		rep(i,vs[no].size()){
			mp pb=vs[no][i];
			int to=pb.fir,
				tc=co+pb.sec;
			if(dist[to]!=-1 && dist[to]<=tc)continue;
			dist[to]=tc;
			que.push(mp(tc,to));
		}
	}
	return -1;
}


int n,m;

vector<mp> vs[100005];


int dist[100005];




int main(void){
	int n,m,s;
	scanf("%d%d%d",&n,&m,&s);
	rep(i,m){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		vs[a].push_back(mp(b,c));
		//vs[b].push_back(mp(a,c));
	}
	dijkstra(n,s,vs,dist);
	rep(i,n){
		if(dist[i]!=-1)printf("%d\n",dist[i]);
		else printf("INF\n");
	}
	return 0;
	
}

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

int main(void)
{
    int n, k, h, count;
    count = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> h;
        if(k <= h)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int f(double x){
  if(x < 0){int c = x - 0.5; return c;}
  else{
  int c = x + 0.5;
  return c;
  }
}

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  double sum = 0;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    sum += v[i];
  }
  int d = f(sum / n);
  //cout << d << endl;

  int res = 0;
  for(int i = 0; i < n; i++){
    res += pow(d - v[i], 2);
  }
  cout << res << endl;

}

Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> v(200010, 0);
  rep(i, N) {
    int num;
    cin >> num;
    v[num]++;
  }

  sort(v.begin(), v.end());
  int count = 0;
  rep(i, v.size()) if (v[i] != 0) count++;
  if (count <= K) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  count -= K;
  rep(i, v.size()) {
    if (v[i] != 0) {
      ans += v[i];
      --count;
    }
    if (count == 0) break;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4028
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

//解説をみましたところ、根付き木でできるとのことなので書き直します。

pair<int, int> E[200000];
int he[100001], A[100001];
int OK = 1;
int dfs(int p, int mae) {
	ll goukei = 0;
	int saidai = -1;
	for (int q = he[p]; q; q = E[q].second) {
		int to = E[q].first;
		if (to != mae) {
			int tmp = dfs(to, p);
			goukei += tmp;
			chmax(saidai, tmp);
		}
	}
	if (saidai == -1) return A[p];
	ll kari = A[p] * 2 - goukei;
	chmax(saidai, int(kari));
	if (kari < 0 || saidai > A[p]) OK = 0;
	return kari;
}

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


	int N = getint();
	rep1(i, N) A[i] = getint();
	int k = 1;
	rep(i, N - 1) {
		int a = getint(), b = getint();
		E[k] = mp(b, he[a]);
		he[a] = k++;
		E[k] = mp(a, he[b]);
		he[b] = k++;
	}
	if (E[he[1]].second) {
		if (dfs(1, 0)) OK = 0;
	}
	else {
		if (dfs(1, 0) != A[1]) OK = 0;
	}
	if (OK) printf("YES");
	else printf("NO");

	Would you please return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n,k;cin>>n>>k;
    int a[114514];
    vector<int> mi;
    rep(i,0,n){
        cin>>a[i];
    }
    if(n==1){
        cout<<abs(a[0])<<endl;
        return 0;
    }
    int ans=inf;
    rep(i,0,n-k+1){
        int h=a[i+k-1]-a[i];
        if(a[i]>=0)ans=min(ans,a[i+k-1]);
        else if(a[i+k-1]<=0)ans=min(ans,-1*a[i]);
        else {
           ans=min(ans,h+min(abs(a[i]),abs(a[i+k-1])));
            //cout<<h<<"fdsf"<<endl;
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

void solve()
{
    vector <int> a(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= 5; i++)
    {
        bool ok = 0;
        for (int j = 0; j < 5; j++)
            if (a[j] == i) ok = 1;
        if (!ok) cout << i << endl;
    }
}

int main()
{
    int tt = 1;
    //cin >> tt;
    while (tt--) solve();
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
const ll INF = 1000000000000007;

using namespace std;

int main(){
  ll N;
  cin >> N;
  vector <ll> A(N+2,0);
  
  for(ll i = 1; i<=N; ++i)
  {
    cin >> A[i];
  }
  A[0] = 0;
  A[N+1] = 0;

  //訪れるのをやめたとき
  // 3, 5 , -1   
  // 3,   , -1  
  //総和から、abs(A[i-1] - A[i]) と abs(A[i] - A[i+1]) を引く
  //総和に、 abs(A[i-1] - A[i+1])を足す
  ll wa = 0;
  REP(i,N + 1)
  {
    wa += abs(A[i] - A[i+1]);
  }

  ll res;
  for(ll i = 1; i <= N; ++i)
  {
    res = wa - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]) + abs(A[i-1] - A[i+1]);
    cout << res << endl;
  }

  return 0;

}

Measured memory_bytes: 2048
def main():
    K, T = map( int, input().split())
    A = list( map( int, input().split()))
    A.sort(reverse=True)
    if A[0] <= (K+1)//2:
        print(0)
    else:
        print((A[0] - (K+1)//2)*2 - (K+1)%2)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1e18 : 1e9;
const int MOD = 1000000007;
const long double EPS = 1e-8;

int n;
string s[110];
int main() {
	cin >> n;
	rep (i, n) cin >> s[i];
	int cnt = 0;
	rep (i, n) {
		cnt += s[i] == "A";
		cnt -= s[i] != "A";
		if (cnt < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << (cnt ? "NO" : "YES") << endl;
	return 0;
}



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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    if (k > a + b) {
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    else if (a >= k) {
        cout << a-k << " " << b << endl;
        return 0;
    }
    else if (k > a) {
        cout << 0 << " " << b - (k - a) << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
import math
import numpy as np


def inputs(): return list(map(int, input().split()))


def main():
    _, A, B, C, D = inputs()
    S = input()
    ans = []
    if '##' in S[A:C]:
        ans.append(False)
    else:
        ans.append(True)
    if '##' in S[B:D]:
        ans.append(False)
    else:
        ans.append(True)
    if D < C:
        if '...' in S[B-2: D+1]:
            ans.append(True)
        else:
            ans.append(False)

    if all(ans):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12896
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 
void solve() {
    ll x, y;
    cin >> x >> y;
    int c = 0;
    while (x <= y) {
        x *= 2LL;
        c++;
    }
    cout << c << EOL;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    
    if(c <= a + b + 1)
        cout << b + c << endl;
    else{
        cout << a + 2 * b + 1 << endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> num = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    int N, M;
    cin >> N >> M;
    auto A = make_vec<int>(M);
    REP(i, M) { cin >> A.at(i); }
    sort(ALL(A), greater<int>());

    vector<int> dp(N + 4, -INF);
    dp[0] = 0;
    REP(i, N + 1) {
        REP(j, M) {
            if (i >= num[A[j]]) {
                dp[i] = max(dp[i], dp[i - num[A[j]]] + 1);
            }
        };
    }

    int cur = N;
    string S = "";
    while (cur > 0) {
        for (auto a : A) {
            // cout << "cur:" << cur << " a:" << a << endl;
            if (cur - num[a] >= 0) {
                if (dp[cur - num[a]] == dp[cur] - 1) {
                    cur = cur - num[a];
                    S.push_back(a + '0');
                    break;
                }
            }
        }
    }
    cout << S << endl;

    return 0;
}


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

int main(int argc, char const *argv[])
{
    string a;
    cin >> a;
    if (a == "SSS")
    {
        cout << 0 << endl;
        return 0;
    }
    if (a == "SRS")
    {
        cout << 1 << endl;
        return 0;
    }
    if (a == "RSS")
    {
        cout << 1 << endl;
        return 0;
    }
    if (a == "SSR")
    {
        cout << 1 << endl;
        return 0;
    }
    if (a == "RRS")
    {
        cout << 2 << endl;
        return 0;
    }
    if (a == "SRR")
    {
        cout << 2 << endl;
        return 0;
    }
    if (a == "RSR")
    {
        cout << 1 << endl;
        return 0;
    }
    if (a == "RRR")
    {
        cout << 3 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3624
alphabet_lowercase = [chr(i) for i in range(97, 97 + 26)]
alphabet_uppercase = [chr(i) for i in range(65, 65 + 26)]

input_string = input()
output_string = ""
for s in input_string:
    if s in alphabet_lowercase:
        output_string += alphabet_uppercase[alphabet_lowercase.index(s)]
    elif s in alphabet_uppercase:
        output_string += alphabet_lowercase[alphabet_uppercase.index(s)]
    else:
        output_string += s

print(output_string)



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

using namespace std;

int main(void) {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}


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

typedef long long ll;
using namespace std;

//int main() {
//    vector<int> n(3);
//    cin >> n[0] >> n[1] >> n[2];
//    sort(n.begin(), n.end());
//
//    cout << n[2] * 10 + n[0] + n[1];
//    return 0;
//}
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int maxv = max({a, b, c});
    cout << a + b + c + 9 * maxv;
    return 0;
}


Measured memory_bytes: 256
//123 A
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  cout<<(e-a<=k ? "Yay!" : ":(")<<endl;
  return 0;
}

Measured memory_bytes: 256
(defun count-to-break-all (count)
  (if (zerop count)
      0
      (1+ (loop with i = 1
                repeat (1- count)
                sum (setf i (* i 2))))))

(defun solve (h)
  (let ((count (loop for count from 0
                     until (= h 1)
                     do (setf h (floor h 2))
                     finally (return count))))
    (+ (count-to-break-all count)
       ;; The number of the HP=1 monsters
       (expt 2 count))))

#-swank
(let* ((h (read)))
  (format t "~A~%" (solve h)))


Measured memory_bytes: 16484
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+5;
ll a[N];
void solve(){
	int n,x; 
	cin>>n>>x; 
	ll ans = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	if(a[1]>=x){
		ans+=a[1]-x;
		a[1] = x;
	}
	for(int i=2;i<=n;i++){
		assert(a[i-1]<=x);
		ll dis = x-a[i-1];
		if(a[i]>=dis){
			ans+=a[i]-dis;
			a[i] = dis;
		}
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	ll i, n, ans;
	cin >> n;
	for (i = sqrt(n); i > 0; i--) {
		if (i * (n / i) == n) {
			ans = i + (n / i) - 2;
			break;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;
int main(){

  stack<int> stack;
  string s;
  int firstnum;
  int secondnum;
  int sum;

  while ( cin >> s )
  {
	  int tempstr = s[0];

	  if (tempstr == '+' || tempstr == '-' || tempstr == '*' || tempstr == '/')
	  {
		  secondnum = stack.top();
		  stack.pop();
		  firstnum = stack.top();
		  stack.pop();
		  if (tempstr == '+')
		  {
			  sum = firstnum + secondnum;
			  stack.push(sum);
		  }
		  if (tempstr == '-')
		  {
			  sum = firstnum - secondnum;
			  stack.push(sum);
		  }
		  		  if (tempstr == '*')
		  {
			  sum = firstnum * secondnum;
			  stack.push(sum);
		  }		  if (tempstr == '/')
		  {
			  sum = firstnum / secondnum;
			  stack.push(sum);
		  }
	  }
	  else
	  {
		  
		  int num = atoi(s.c_str());
		  stack.push(num);
	  }
  }

  cout << stack.top() <<endl;
  return 0;
}


Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{
    int x,y;
    bool operator<(const P &a)const{
        if(y!=a.y)
        return y>a.y;
        return x>a.x;
    }
};
vector<int> v[200456];
int a,b,c,n,m,i,k,o[513][666],d,e,dy[5]={0,0,-1,1,0},dx[5]={0,1,1,1,2};
int l[300];
long long x,y,z[1111][33];
P u1[100100],u2[100100];
int j[200][10200];
priority_queue<P> q;
//long long x=0,y=0,z[99];

//deque<int> d;
//'1'==49;
map<int,int > p;
string r,r1;
//char r[1000];
bool asd(P a,P b)
{
   if(a.x-a.y!=b.x-b.y)
    return a.y-a.x<b.y-b.x;
   return a.x<b.x;
}



int main()
{
    scanf("%d %d %d",&a,&b,&c);
    for(int t=1;t<=a;t++)
        for(int w=1;w<=b;w++)
    {
        o[t][w]+=((t+w)/c%2);
    }
    for(int t=1;t<=a;t++)
        for(int w=1;w<=b;w++)
    {
        o[t][w]+=((1+(t-w+b)/c)%2*2);
    }

    for(int t=1;t<=a;t++,puts(""))
        for(int w=1;w<=b;w++)
    {
        if(o[t][w]==0) printf("R");
        if(o[t][w]==1) printf("Y");
        if(o[t][w]==2) printf("G");
        if(o[t][w]==3) printf("B");
    }
}


Measured memory_bytes: 8192
import sys
n=int(input())
s=[list(input()) for i in range(n)]
L1=[]
L2=[]
ct1=0;ct2=0
for i in range(n):
  ct3=0
  l=[0]
  for j in range(len(s[i])):
    if s[i][j]=='(':
      ct1+=1
      ct3+=1
      l.append(ct3)
    else:
      ct2+=1
      ct3-=1
      l.append(ct3)
  if l[-1]>=0:
    L1.append((min(l),l[-1]))
  else:
    L2.append((min(l)-l[-1],-l[-1]))
if ct1!=ct2:
  print('No')
  sys.exit()

L1.sort()
L1.reverse()
ct4=0
for i in range(len(L1)):
  if ct4+L1[i][0]<0:
    print('No')
    sys.exit()
  ct4+=L1[i][1]

L2.sort()
L2.reverse()
ct5=0
for i in range(len(L2)):
  if ct5+L2[i][0]<0:
    print('No')
    sys.exit()
  ct5+=L2[i][1]

print('Yes')

Measured memory_bytes: 264096
import java.util.*;

class Main {

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

    String s = sc.next();
    String t = sc.next();
    int count = 0;
    for (int i = 0; i < 3; i++) {
      if (s.charAt(i) == t.charAt(i)) count++;
    }
    System.out.println(count);

  }
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

string IntToString(int number)
{
	stringstream ss;
	ss << number;
	return ss.str();
}

int need[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int n, m;
int a[10];
vi v;
string memo[10001] = {};

string dfs(int unused)
{
    if(unused == 0) return "";
    if(memo[unused] != "") return memo[unused];
    string rec = "";

    for(int i = 0; i < v.size(); i++) {

	if(unused - need[v[i]] < 0) continue;

	string tmp = dfs(unused - need[v[i]]);
	if(tmp == "X") continue;
	    
	tmp = (char)('0' + v[i]) + tmp;

	if(rec.size() == tmp.size()) {
	    if(rec < tmp) rec = tmp;
	} else {
	    if(rec.size() < tmp.size()) rec = tmp;
	}
	
    }
    
    if(rec == "")
	return memo[unused] = "X";
    else
	return memo[unused] = rec;
}

int main()
{
    ci >> n >> m;
    rep(i, m) ci >> a[i];

    sort(a, a + m, greater<int>());

    bool exist[10] = {};
    rep(i, m) {
	if(exist[need[a[i]]]) continue;
	v.pb(a[i]);
    }
    
    co << dfs(n) << en;

    return 0;
}





Measured memory_bytes: 32768
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        int[] c = new int[4];
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'E') {
                c[0]++;
            }
            if (s.charAt(i) == 'W') {
                c[1]++;
            }
            if (s.charAt(i) == 'S') {
                c[2]++;
            }
            if (s.charAt(i) == 'N') {
                c[3]++;
            }
        }

        if ( (c[0] != 0 && c[1] != 0) || (c[0] == 0 && c[1] == 0) ) {
            if ( (c[2] != 0 && c[3] != 0) || (c[2] == 0 && c[3] == 0) ) {
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }

        sc.close();
    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
vector<int>vect[100001];
vector<int>block[100001];
set<int>r;

void dfs(bool visited[],int src)
{
       r.insert(src);
      visited[src]=true;

       for(int i=0;i<vect[src].size();i++)
       {
           if(visited[vect[src][i]]==false)
                dfs(visited,vect[src][i]);
       }
 }
int main()
{
    int n,m,k;
     cin>>n>>m>>k;

       for(int i=1;i<=m;i++)
       {
        int u,v;
         cin>>u>>v;

           vect[u].push_back(v);
           vect[v].push_back(u);
       }
       for(int i=1;i<=k;i++)
        {
           int u,v;
            cin>>u>>v;

            block[u].push_back(v);
            block[v].push_back(u);
        }

        bool visited[n+1]={false};

        int arr[n+1];

    for(int i=1;i<=n;i++)
    {
       if(visited[i]==false)
       {
          r.clear();
         dfs(visited,i);

          for(auto itr = r.begin();itr!=r.end();itr++)
          {
            int x = (*itr);

             arr[x] = r.size()-vect[x].size()-1;

               for(int j=0;j<block[x].size();j++)
                 if(r.find(block[x][j])!=r.end()) arr[x]--;
           }
       }
    }
      for(int i=1;i<=n;i++)
        cout<<arr[i]<<" ";
}


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

int main(){
  string s;
  cin >> s;
  int ans =0;
  int cnt =0;
  bool r = false;
  bool rr = false;
  
  for(int i=0;i<2;i++){
    if(s[i]=='R'&&s[i+1]=='R'){
      cnt++;
      r = true;
    }
    if(s[i]=='R'||s[i+1]=='R') rr = true;
  }
  if(rr) ans++;
  
  if(r) cout << cnt + 1 << endl;
  else cout << ans << endl;
}
  
  

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

using namespace std;

int main() {
  int n, k; cin >> n >> k;
  vector<int>h(n); for (int i = 0; i < n; i++) cin >> h[i];
  vector<int>dp(n + 1, 1e9);
  dp[1] = 0;
  for (int i = 2; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      if (i - j >= 0)
        dp[i] = min(dp[i], dp[i-j] + abs(h[i-1] - h[i-1-j]));
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  int p[n];
  for(int i = 0; i < n; i++){
    cin>>p[i];
  }
  int c = 0;
  for(int i = 0; i < n-2; i++){
    if(p[i]<p[i+1]&&p[i+1]<p[i+2]){
      c++;
    }
    else if(p[i]>p[i+1]&&p[i+1]>p[i+2]){
      c++;
    }
  }
  cout<<c<<endl;
  return 0;
}




Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]

ans = 'Yes'
for i in range(2):
  for j in range(2):
    if c[i][j] - c[i][j + 1] != c[i + 1][j] - c[i + 1][j + 1]:
      ans = 'No'
      break
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//modint
template<typename T> T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		T t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
template<typename T> T modpow(T x, int k) {
	if (k == 0)return 1;
	if (k % 2 == 0) return modpow(x * x, k / 2);
	else return x * modpow(x, k - 1);
}

template<int mod> class modint {
public:
	ll val;
	modint(ll a) {
		val = a % mod;
	}
	modint operator+(const modint& r) {
		return modint((this->val + r.val) % mod);
	}
	modint operator-(const modint& r) {
		return modint((this->val - r.val) % mod + ((this->val - r.val) % mod < 0) * mod);
	}
	modint operator*(const modint& r) {
		return modint((((this->val % mod) * (r.val % mod))) % mod);
	}
	modint operator/(const modint& r) {
		return modint(this->val * modinv<ll>(r.val, mod) % mod);
	}
	modint& operator+=(const modint& r) {
		*this = *this + r;
		return *this;
	}
	modint& operator-=(const modint& r) {
		*this = *this - r;
		return *this;
	}
	modint& operator*=(const modint& r) {
		*this = *this * r;
		return *this;
	}
	modint& operator/=(const modint& r) {
		*this = *this / r;
		return *this;
	}

};

//X = A+2B
//Y = 2A+B
//X+Y = 3A + 3B
//2X - Y = 3B
//2Y - X = 3A
int main() {
	int X, Y;
	cin >> X >> Y;
	int B = 2 * X - Y;
	int A = 2 * Y - X;
	if (B % 3 != 0 || A % 3 != 0 || A < 0 || B < 0) {
		cout << 0 << endl;
		return 0;
	}
	B /= 3; A /= 3;
	modint<MOD> ans = 0;
	vector<modint<MOD>> frac(1e7,1);
	for (int i = 1; i < 1e7; i++)frac[i] = frac[i - 1] * modint<MOD>(i);
	ans = frac[A + B] / frac[A] / frac[B];
	cout << ans.val << endl;
}

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

int n, m, s, t;
class Edge{
public:
	long long cost;
	int from, to;
	Edge(long long c, int f, int t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
constexpr long long INF = 1e18+9;
bool operator < (const Edge &e, const Edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
void dijkstra(int s, const Graph &g, vector<long long> &dist){
	int V = g.size();
	dist = vector<long long>(V, INF);
	dist[s] = 0;
	priority_queue<Edge> q;
	q.push(Edge(0, s, s));
	while(!q.empty()){
		Edge e = q.top();
		q.pop();
		if(dist[e.to] < e.cost) continue;
		for(int i=0; i<(int)g[e.to].size(); ++i){
			Edge f = g[e.to][i];
			if(dist[f.to] > dist[e.to] + f.cost){
				dist[f.to] = dist[e.to] + f.cost;
				q.push(Edge(dist[f.to], s, f.to));
			}
		}
	}
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m >> s >> t;
	--s;
	--t;
	Graph ga(n), gb(n);
	for(int i=0; i<m; ++i){
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		--u;
		--v;
		ga[u].push_back(Edge(c, u, v));
		ga[v].push_back(Edge(c, v, u));
		gb[u].push_back(Edge(d, u, v));
		gb[v].push_back(Edge(d, v, u));
	}
	vector<long long> da, db;
	dijkstra(s, ga, da);
	dijkstra(t, gb, db);
	vector<long long> ans(n, INF);
	for(int i=0; i<n; ++i){
		ans[i] = da[i] + db[i];
	}
	for(int i=n-2; i>=0; --i){
		ans[i] = min(ans[i], ans[i+1]);
	}
	for(int i=0; i<n; ++i){
		cout << (long long)1e15 - ans[i] << "\n";
	}
}

Measured memory_bytes: 19012
#include <bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

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

  int x[N], l[N];
  pair<int, int> A[N];

  for (int i = 0; i < N; i++)
  {
    cin >> x[i] >> l[i];
    A[i].first = x[i] + l[i];
    A[i].second = x[i] - l[i];
  }
  sort(A, A + N);
  int ans = 1;
  int tmp = A[0].first;

  for (int i = 1; i < N; i++)
  {
    if (tmp <= A[i].second)
    {
      ans++;
      tmp = A[i].first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5176
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <vector>
#include <math.h>

typedef long long int LLI;

int main()
{
	LLI a,b,c,d,n,t;
	bool state = false;
	scanf("%lld %lld %lld %lld %lld",&n, &a, &b, &c, &d);
	n--;
	t = b - a;
	for(LLI i = 0; i <= n; ++i)
		if((i * c - (n - i) * d) <= t && (i * d - (n - i) * c) >= t)
			state = true;
	printf(state ? "YES" : "NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  string S,T;cin>>S>>T;
  vector<string>dp(S.length(),"");
  for(int i=0;i<T.length();i++){
    vector<string>dp2(S.length());
    for(int j=0;j<S.length();j++){
      if(j==0)
        dp2[j]=dp[j];
      else
        if(dp2[j-1].length()<dp[j].length())
          dp2[j]=dp[j];
        else
          dp2[j]=dp2[j-1];
      
      if(T[i]==S[j] && (j==0 ? 0 : dp[j-1].length())+1>dp2[j].length())
        dp2[j]=(j==0 ? "" : dp[j-1]),
        dp2[j].push_back(T[i]);
    }
    dp=dp2;
  }
  cout<<dp.back()<<endl;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;
int a[200000];
vi b[2];
int n;

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

  cin >> n;
  int d;
  FOR(i, 0, n){
    cin >> d;
    b[(i+1)%2].pb(d);
  }
  reverse(b[n%2].begin(), b[n%2].end());
  for(vi::iterator itr=b[n%2].begin(); itr != b[n%2].end(); itr++){
    cout << (*itr) << " ";
  }
  int s = b[(n+1)%2].size();
  FOR(i, 0, s){
    cout << b[(n+1)%2][i];
    cout << (i < s - 1 ? " " : "\n");
  }
}


Measured memory_bytes: 3188
#include<stdio.h>
int main() {
	int i;
	char ch;
	char st[1200] = {0};
	for (i = 0;i < 1200;i++) {
		scanf("%c", &ch);
		if (65 <= ch&&ch <= 90) ch += 32;
		else if (97 <= ch&&ch <= 122)ch -= 32;
		st[i] = ch;
		if (ch == '\n') {
			st[i + 1] = '\0';
			break;
		}
	}
	printf("%s", st);
	return 0;
}

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

using namespace std;

int main(){

    int N = 0;
    int M = 0;
    int in = 0;
    cin >> N >> M;



    std::vector<int> X(M,0);

    for(int i = 0; i < M; i++){
        cin >> in;
        X[i] = in;
        //std::cout << X[i] << std::endl;
    }

    if(N >= M){
        std::cout << "0" << std::endl;
        return 0;
    }

    std::sort(X.begin(), X.end());

    std::vector<int> sa(M-1,0);

    for(int i = 1; i < M; i++){
        sa[i - 1] = X[i] - X[i-1];
        //std::cout << sa[i - 1] << " ";
    }
    //std::cout << std::endl;

    std::sort(sa.begin(), sa.end());

    int total = 0;
    for(int i = 0; i < (M - 1) - (N - 1); i++){
        total += sa[i];
    }

    std::cout << total << std::endl;


}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    char a, b;
    cin >> a >> b;
    if( a < b ) cout << '<';
    else if( a > b ) cout << '>';
    else cout << '=';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib> //abs(int)
using namespace std;
int main(void){
  string A;
  int count = 0;
  cin >> A;
  for(int i = 0 ; i < 3; i++){
    if(A.at(i) == '1'){
      count++;
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC99();
}

void ABC99(){
    int n,i,a,b,sum=0;
    cin>>a>>b;
    for(i=1;i<b-a;i++){
        sum+=i;
    }
    cout<<sum-a<<endl;
}

Measured memory_bytes: 256
MyString=Union{String,SubString{String},Char}
MyStringArray=Union{Array{String,1},Array{SubString{String},1},Array{Char,1}}
parseInt(x::MyString) = parse(Int, x)
parseInt(x::Real) = trunc(Int, x)
parseBigInt(x::MyString) = parse(BigInt, x)
parseBigInt(x::Real) = trunc(BigInt, x)
parseFloat(x::MyString) = parse(Float64, x)
parseFloat(x::Real) = trunc(Float64, x)
parseBigFloat(x::MyString) = parse(BigFloat, x)
parseBigFloat(x::Real) = trunc(BigFloat, x)
parseMap(x::MyStringArray) = map(parseInt, x)
parseMapBig(x::MyStringArray) = map(parseBigInt, x)

function main()
    n,k,x,y=[parseInt(readline()) for i in 1:4]
    if k<n
        println(k*x+(n-k)*y)
    else
        println(n*x)
    end
end
main()

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll dp[10005], prevmax[10005];

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);

	int c, n, m; cin >> c >> n >> m;

	rep(i, 1, 10005) dp[i] = -1;
	
	rep(i, 0, n) {
		int s, p; cin >> s >> p;
		for (int j = c - s; j >= 0; j--) if (dp[j] != -1) {
			dp[j + s] = max(dp[j + s], dp[j] + p);
		}
	}

	//rep(i, 0, c + 1) if (dp[i] != -1) printf("%d: %lld\n", i, dp[i]);
	rep(i, 1, c + 1) prevmax[i] = max(prevmax[i - 1], dp[i]);

	for (ll i = 1; i <= m; i++) {
		cout << i * prevmax[c / i] << '\n';
	}
}



Measured memory_bytes: 3348
#include<stdio.h>

int serch(int A[],int n,int key){
  int c=0;
  A[n]=key;
  while(A[c]!=key){
    c++;
  }
  return c!=n;
}

int main(){
  int i,n,A[10001],q,key,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(serch(A,n,key))sum++;
  }

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

  return 0;

}



Measured memory_bytes: 2140
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int32_t N;
  cin >> N;
  vector<int32_t> A(N + 1);
  vector<bool> touched(N + 1, false);
  for (int32_t i = 1; i <= N; ++i) {
    cin >> A[i];
  }
  int32_t c_pos = 1;
  int32_t count;
  for (int32_t i = 1; i <= N; ++i) {
    c_pos = A[c_pos];
    if (c_pos == 2) {
      count = i;
      break;
    } else if (touched[c_pos]) {
      count = -1;
      break;
    } else {
      touched[c_pos] = true;
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
<?php
  fscanf(STDIN, "%d", $n);
  $ac = 0;
  $wa = 0;
  $tle = 0;
  $re = 0;



  for($i=0;$i<$n;$i++) {
    fscanf(STDIN, "%s", $s);
    if($s === "AC") {
      $ac++;
    }
    if($s === "WA") {
      $wa++;
    }
    if($s === "TLE") {
      $tle++;
    }
    if($s === "RE") {
      $re++;
    }
  }

  echo "AC x $ac".PHP_EOL;
  echo "WA x $wa".PHP_EOL;
  echo "TLE x $tle".PHP_EOL;
  echo "RE x $re".PHP_EOL;

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

using namespace std;


const int maxn = 3333;
double dp[maxn][maxn];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    dp[0][0] = 1.0;
    int n; cin >> n;
    for (int i = 1; i <= n; i++) {
        double p; cin >> p;
        if (i == 1) dp[i][1] = p, dp[i][0] = 1 - p;
        else {
            for (int j = 0; j <= i; j++) {
                if (j == 0) {
                    dp[i][j] = dp[i-1][j] * (1 - p);
                } else {
                    dp[i][j] = dp[i - 1][j] * (1 - p) + dp[i - 1][j - 1] * p;
                }
            }
        }
    }
    double ans = 0.0;
    for (int i = n; i > n / 2; i--) ans += dp[n][i];
    printf("%.10lf\n", ans);
}


Measured memory_bytes: 78592
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np
 
K = INT()
sum = 0
 
for n in range(1, K+1):
  for m in range(1, K+1):
    sum1 = gcd(n, m)
    for l in range(1, K+1):
      sum += gcd(l, sum1)
 
print(sum)

Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int exgcd(int a,int b,int &x,int &y){
  while(b){
    int t{a/b};
    swap(a-=t*b, b);
    swap(x-=t*y, y);
  }
  return a;
}
int exgcd(int a,int b){
  int x{1},y{0};
  return exgcd(a,b,x,y);
}
int inverse(int a,int mod){
  int x{1},y{0};
  exgcd(a,mod,x,y);
  return (x%mod+mod)%mod;
}

int main(){
  
  int n; cin>>n;
  vector<int> a(n);
  ll s{};
  for(auto &i:a) {
    cin>>i;
    s += i;
  }
  ll sum{};
  for(int i=0; i<n; i++){
    ll b = s - a.at(i);
    b %= MOD;
    sum += (b*a.at(i))%MOD;
    sum %= MOD;
  }
  cout << (sum * inverse(2,MOD))%MOD<<endl;
  
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X, A;
  
  cin >> X;
  cin >> A;
  
  if( X < A){
   
    cout << "0" << endl;
  }
  else if( X >= A ){
        cout << "10" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	ll N, K, ans;
	cin >> N >> K;
	ans = (N - 2) / 11 * 5;
	for (int i = 0; i < (N - 2) % 11; ++i) {
		for(int j = 0; j < 5; ++j){
			if (((9 + i * 7 + j) * 9) % 11 == K)ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256