akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long int
using namespace std;


int32_t main(){
    int n;
    cin >> n;
    string res = "";
    while(n){
        n--;
        char ch = 97 + (char)(n % 26);
        string s(1, ch);
        res = s + res;
        n = n / 26;
    }
    cout << res << "\n";
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2==1) {
    cout << "No" << endl;
  }
  else {
    if(s.substr(0,s.size()/2)==s.substr(s.size()/2,s.size()/2)) {
      cout << "Yes" << endl;
      
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){

    int H,W,i,j;
    while(1){
    
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0)break;
        else{
          for(i=1;i<=H;i++){
              for(j=1;j<=W;j++){
                if(i == 1 || i == H || j==1 || j==W)  putchar('#');
                else putchar('.');
              }
            printf("\n"); 
          }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;
typedef long long int lli;

lli** memoTable;
lli* weight;
lli* value;

lli nItems;
lli capacity;

lli minCost(lli index, lli remCapacity){

    if(index == nItems){
        return 0;
    }
    if(remCapacity == 0){
        return 0;
    }


    if(memoTable[index][remCapacity] != -1){
        return memoTable[index][remCapacity];
    }

    lli op1 = INT_MIN;
    if(weight[index] <= remCapacity){
        op1 = minCost(index+1, remCapacity - weight[index])  + value[index];
    }
    
    lli op2 = minCost(index+1, remCapacity);

    memoTable[index][remCapacity] = max(op1, op2);
    return memoTable[index][remCapacity];

}

int main(){

    cin >> nItems >> capacity;
    weight = new lli[101];
    value = new lli[101];

    for(lli i=0; i<nItems; ++i){
        cin >> weight[i] >> value[i];
    }

    memoTable = new lli*[101];
    for(lli i=0; i<101; ++i){
        memoTable[i] = new lli[100001];
        memset(memoTable[i], -1, sizeof(lli) * 100001);
    }
    lli x = minCost(0, capacity);
    if(x == INT_MIN){
        cout<<0;
    }else{
        cout<<x;
    }

    return 0;
}

Measured memory_bytes: 79488
N, M = map(int, input().split())
H = list(map(int, input().split()))

A = [0]*M
B = [0]*M
for i in range(M):
    ta, tb = map(int, input().split())
    A[i] = ta - 1
    B[i] = tb - 1

ans = [True]*N
# v: Trueならいい展望台、Falseなら良くない展望台 
for i in range(M):
    ans[A[i]] = H[A[i]] > H[B[i]] and ans[A[i]]
    ans[B[i]] = H[B[i]] > H[A[i]] and ans[B[i]]

print(ans.count(True))

Measured memory_bytes: 21640
package main

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

var (
	N  string
	K  int
	dp [][5][2]int
)

func readVariables() {
	N, K = nextStr(), nextInt()
	dp = make([][5][2]int, len(N)+1)
}

func main() {
	readVariables()
	// fmt.Println(dp)
	dp[0][0][0] = 1
	for i := 0; i < len(N); i++ {
		//配るDP
		digit, _ := strconv.Atoi(string(N[i]))
		// fmt.Println(i, digit)
		for c := 0; c < 4; c++ {
			//Low -> Low
			dp[i+1][c+1][1] += dp[i][c][1] * 9
			dp[i+1][c][1] += dp[i][c][1]
			//Same -> Low
			if digit > 0 {
				dp[i+1][c+1][1] += dp[i][c][0] * (digit - 1)
				dp[i+1][c][1] += dp[i][c][0]
			}
			//Same -> Same
			if digit > 0 {
				dp[i+1][c+1][0] += dp[i][c][0]
			} else {
				dp[i+1][c][0] += dp[i][c][0]
			}
		}
	}
	answer := dp[len(N)][K][0] + dp[len(N)][K][1]
	// for _, v := range dp {
	// 	fmt.Println(v)
	// }
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >;
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
int n,k,q,a[100000],all[100000];
int main(){
	cin>>n>>k>>q;
	for(int i=0;i<q;i++)
	cin>>a[i];
	for(int i=0;i<q;i++){
		all[a[i]-1]++;
	}
	for(int i=0;i<n;i++){
		if(all[i]+k<=q)
		cout<<"No\n";
		else
		cout<<"Yes\n";
	}
	re 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(void)
{
	int a,b,c,i,j,k,cnt=0;
	char d[101][101];
	scanf("%d%d%d",&a,&b,&c);
	for(i=0;i<a;i++){
		scanf("%s",d[i]);
		for(j=0;j<=b-c;j++){
			k=0;
			while(k<c){
				if(d[i][j+k]!='.')break;
				k++;
			}
			if(k==c)cnt++;
		}
	}
	for(i=0;i<b;i++){
		for(j=0;j<=a-c;j++){
			k=0;
			while(k<c){
				if(d[j+k][i]!='.')break;
				k++;
			}
			if(k==c)cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2044
#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;
#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; }
#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;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字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;
}

// 桁和
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;
}

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



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    print(180 * (n - 2));


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


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 V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


int main() {

	int n;
	cin >> n;

	vector<int> cnt(105, 0);

	for (int i = 1; i <= n; i++)
	{
		int p;
		cin >> p;
		cnt[p]++;
	}

	int sum = 0;
	for (int i = cnt.size()-1; i >= 0; i--)
	{
		sum += cnt[i];
		if (sum >= i) {
			cout << i << endl;
			return 0;
		}
	}



	return 0;
}


Measured memory_bytes: 3116
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

string s, t;

int n, m;
int x, y;
int tmp;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> tmp;
	cin >> x >> y;
	--x, --y;
	cin >> s >> t;
	int l = 0;
	int r = m - 1;
	for (int i = s.size() - 1; i >= 0; --i) {
		if (l > r)
			break;
		if (t[i] == 'L') {
			r = min(m - 1, r + 1);
		}
		else if (t[i] == 'R') {
			l = max(0, l - 1);
		}
		if (s[i] == 'L') {
			++l;
		}
		else if (s[i] == 'R') {
			--r;
		}
	}
	if (y < l || y > r) {
		cout << "NO\n";
		return 0;
	}
	l = 0;
	r = n - 1;
	for (int i = s.size() - 1; i >= 0; --i) {
		if (l > r)
			break;
		if (t[i] == 'U') {
			r = min(n - 1, r + 1);
		}
		else if (t[i] == 'D') {
			l = max(0, l - 1);
		}
		if (s[i] == 'U') {
			++l;
		}
		else if (s[i] == 'D') {
			--r;
		}
	}
	if (x < l || x > r) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	return 0;
}





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

#define lli long long int
#define ld long double
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

////////////////////////////////////////////////////////    By: Umang Srivastava

/*
lli extgcd(lli a, lli b, lli *x , lli *y)
{
	if(a==0)
	{
		*x=0;
		*y=1;
		return b;
	}
	lli x1 , y1;
	lli gcd = extgcd(b%a , a , &x1 , &y1);
	*x=y-(b/a)*x1;
	*y=x1;
	return gcd;
}

lli modinv(lli a, lli m)
{
	lli x,y;
	lli g = extgcd(a,m,&x,&y);
	if(g!=1)
		return -1;
	return (x%m+m)%m;
}

lli moddiv(lli a, lli b, lli m)
{
	a=a%m;
	lli inv = modinv(b,m);
	if(inv!=-1)
		return ((a*inv + m)%m);
	else
		return -1;
}
*/
lli binpow(lli a, lli b, lli m)
{
	lli res=1;
	a=a%m;
	while(b>0)
	{
		if(b & 1)
		{
			res = (res * a)%m;
		}
		b=b>>1;
		a=(a*a)%m;
	}
	return res;
}
/*
lli gcd(lli a, lli b)
{
    // if(b<a)
    // {
    //     lli t=a;
    //     a=b;
    //     b=t;
    // }
    if(a==0)
        return b;
    return gcd(b%a,a);
}
*/
/////////////////////////////////////////////////////////

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,i,a,b;
    cin>>n;
    lli maxxysum,minxysum,minxydiff,maxxydiff;
    for(i=0;i<n;i++)
    {
        cin>>a>>b;
        if(i==0)
        {
            maxxysum = minxysum = a+b;
            minxydiff = maxxydiff = a-b;
            continue;
        }
        maxxysum = max(maxxysum, a+b);
        minxysum = min(minxysum, a+b);
        maxxydiff = max(maxxydiff, a-b);
        minxydiff = min(minxydiff, a-b);
    }
    cout<<max(maxxysum - minxysum, maxxydiff - minxydiff)<<endl;

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define sf1(a); scanf("%d",&a);
#define sf2(a,b); scanf("%d %d",&a, &b);
#define sf3(a,b,c); scanf("%d %d %d",&a, &b,&c);
#define sf4(a,b,c,d); scanf("%d %d %d %d",&a, &b,&c,&d);
#define pf1(a); printf("%d\n",a);
#define pf2(a,b); printf("%d %d\n",a,b);
#define pf3(a,b,c); printf("%d %d %d\n",a,b,c);
#define pf4(a,b,c,d); printf("%d %d %d %d\n",a,b,c,d);

using namespace std;

int main()
{
    int n;
    sf1(n);
    int o,e;
    if(n%2==1)
    {
        o=(n+1)/2;
        e=n/2;
    }
    else
    {
        o=n/2;
        e=n/2;
    }
    cout<<o*e<<endl;
    return 0;
}


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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;

int n;
int a[N];

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	ll res = 0;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		res += (y - x + 1);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
         
    using namespace std;
         
    int main(){
         
        int a, b, c, sum;
        cin >> a >> b >> c;
        sum = a+b+c;
        if (sum == 17) cout << "YES" << "\n";
        else cout << "NO" << "\n";
     
        return 0;
     
        }


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

#define INPUT1(n, a)                                                           \
    int n;                                                                     \
    std::cin >> n;                                                             \
    std::vector<int> a(n);                                                     \
    for(int i = 0; i < n; i++) {                                               \
        std::cin >> a[i];                                                      \
    }

#define INPUT2(x, y, field)                                                    \
    int x, y;                                                                  \
    std::cin >> x >> y;                                                        \
    std::vector<std::vector<int>> field(x, std::vector<int>(y));               \
    for(int i = 0; i < x; i++) {                                               \
        for(int j = 0; j < y; j++) {                                           \
            std::cin >> field[i][j];                                           \
        }                                                                      \
    }

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    long long l, r;
    cin >> l >> r;
    r = min(r, l + 2020);

    long long min = 2020;
    for(long long i = l; i < r; i++) {
        for(long long j = i + 1; j <= r; j++) {
            long long a = (i * j) % 2019;
            if(min > a) {
                min = a;
            }
        }
    }
    print(min);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
    int N;
    cin >> N;
    int sum = 0;
    int max = 0;
    for (int i = 0; i < N; ++i){
        int L;
        cin >> L;
        sum += L;
        if (max < L){
            max = L;
        }
    }
    if(sum-max > max){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007LL
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
typedef pair<int, pair<int,int> > E;
int vw[114514];
ll par[114514];
ll rankk[114514];
ll siz[114514];
int cand[114514];
int used[114514];
vector< pair<int,int> > nex[114514];
void init(int n){
	for(int i=1;i<=n;i++){
		par[i] = i;
		rankk[i]=0;
		siz[i] = vw[i];
	}
}
ll find(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(rankk[x]<rankk[y]){
		par[x]=y;
		siz[y] = siz[x] + siz[y];
	}else{
		par[y]=x;
		siz[x] = siz[x] + siz[y];
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>vw[i];
	}
	vector< E > ed;
	for(int i=0;i<m;i++){
		int ta,tb,ty;
		cin>>ta>>tb>>ty;
		ed.pb( mp( ty, mp(ta,tb) ) );
	}
	sort( ed.begin(), ed.end() );
	init(110000);
	for(int i=0;i<m;i++ ){
		int lef = ed[i].second.first;
		int rig = ed[i].second.second;
		//cout<<i<<" "<<lef<<" "<<rig<<endl;
		unite(lef,rig);
		if( siz[find(lef)] >= ed[i].first ){
			cand[i] = 1;
		}
	}
	reverse( ed.begin(), ed.end() );
	for(int i=0;i<m;i++){
		nex[ ed[i].second.first ].pb( mp( ed[i].second.second, i ) );
		nex[ ed[i].second.second ].pb( mp( ed[i].second.first, i ) );
	}
	int ans = 0;
	for(int i=0;i<m;i++){
		if( used[i] == 0 ){
			//cout<<i<<" "<<m-1-i<<" "<<cand[m-1-i]<<endl;
			if( cand[m-1-i] == 0 ) ans++;
			else{
				queue<int> que;
				int cw = ed[i].first;
				int lef = ed[i].second.first;
				int rig = ed[i].second.second;
				que.push(lef);
				que.push(rig);
				used[i] = 1;
				while(!que.empty()){
					int cur = que.front(); que.pop();
					for(int i=0;i<nex[cur].size();i++){
						pair<int,int> nx = nex[cur][i];
						int ew = ed[ nx.second ].first;
						if( used[ nx.second ] == 0 && ew <= cw ){
							used[ nx.second ] = 1;
							que.push( nx.first );
						}
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    int dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));
    for(int i = 0; i < n; i++)
        dp[i][m] = 0;
    for(int i = 0; i < m; i++)
        dp[n][i] = 0;
    for(int i = n-1; i >= 0; i--){
        for(int j = m-1; j >= 0; j--){
            if(s[i] == t[j]) {
                dp[i][j] = 1 + dp[i+1][j+1];
            }
            else {
                dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    //cout << dp[0][0] << endl;
    int i = 0, j = 0;
    string ans;
    while( i < n && j < m){
        if(s[i] == t[j]) {
            ans.push_back(s[i]);
            i++, j++;
        }
        else if(dp[i+1][j] >= dp[i][j+1]){
            i++;
        }
        else{
            j++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

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

	int n = s.size();
	int count0 = 0, count1 = 0;
	rep(i, 0, n) {
		if (s[i] == '0') count0++;
		else count1++;
	}
	int num = abs(count0 - count1);
	cout << n - num << endl;

	return 0;
}

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

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

    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i = 0; i < D; i++){
        cin >> p[i] >> c[i];
    }

    int mini = 1e9;
    for(int i = 0; i < (1 << D); i++){
        int total = 0, cnt = 0;
        for(int j = 0; j < D; j++){
            if((i >> j) & 1){
                total += p[j] * (j + 1) * 100 + c[j];
                cnt += p[j];
            }
        }
        if(total < G){
            bool f = false;
            for(int j = D - 1; j >= 0; j--){
                if((i >> j) & 1) continue;
                for(int k = 0; k < p[j]; k++){
                    total += (j + 1) * 100;
                    cnt++;
                    if(total >= G){
                        f = true;
                        break;
                    }
                }
                total += c[j];
                if(total >= G){
                    f = true;
                }
                if(f) break;
            }
        }
        mini = min(mini, cnt);
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{   int n,i,j,l,o=0;
   scanf("%d",&n);
   int a[n];
  for(i=0;i<n;i++)
  scanf("%d",&a[i]);
  sort(a,a+n);
  for(i=0;i<n;i++)
  for(j=i+1;j<n;j++)
  for(l=j+1;l<n;l++)
  if(a[i]+a[j]>a[l])
  o++;
  printf("%d",o);
}

Measured memory_bytes: 128
#include<cstdio>
#include<map>
#include<set>
using namespace std;

const int MAX = 1e5;
int par[MAX], r[MAX];

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

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (r[y] > r[x]) {
        par[x] = y;
    }
    else {
        if (r[x] == r[y]) r[x]++;
        par[y] = x;
    }
}


int n, m;
int p[MAX];
map<int, set<int>> g;

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) scanf("%d", &p[i]);
    init(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        unite(x - 1, y - 1);
    }

    for (int i = 0; i < n; i++) {
        g[find(i)].emplace(i);
    }

    int ans = 0;
    for (auto &i : g) {
        for (auto &j : i.second) {
            if (i.second.find(p[j] - 1) != i.second.end()) ans++;
        }
    }

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


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

int main() {
  int a,b;cin>>a>>b;
  string s;cin>>s;
  bool ok=true;
  for(int i=0;i<s.size();++i){
    if(i==a) ok &= (s[i]=='-');
    else ok &= ('0'<=s[i] && s[i]<='9');
  }
  cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	
	ll pos[N];
	
	F0R(i, N) {
		int cur; cin >> cur; cur--;
		pos[cur] = i;
		
	}
	
	ll ans = 0;
	
	multiset<ll> used;
	used.insert(-1); used.insert(-1); used.insert(N); used.insert(N);
	F0Rd(i, N) {
		
		used.insert(pos[i]);
		auto it = used.find(pos[i]);
		it--;
		ll s1 = *it;
		it--;
		ll s2 = *it;
		it++; it++; it++;
		ll e1 = *it;
		it++;
		ll e2 = *it; 
		ll curVal = i+1;
		ll numPos = 0;
		numPos += (e2 - e1) * (pos[i] - s1);
		numPos += (s1 - s2) * (e1 - pos[i]);
		//cout << numPos << endl;
		//cout << s1 << " " << s2 << " " << e1 << " " << e2 << endl;
		ans += curVal * numPos;
	}
	
	cout << ans << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 5760
import sys
import math
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
import itertools
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, H, M = MAP()

if abs(30 * H - 5.5 * M) % 360 <= 180:
    theta = abs(30 * H - 5.5 * M) % 360
else:
    theta = 360 - abs(30 * H - 5.5 * M) % 360

ans = sqrt(A ** 2 + B ** 2 - 2 * A * B * cos(math.radians(theta)))
print(ans)


Measured memory_bytes: 37740
import sys
d=sys.stdin.readline
p={'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),
   'S':(4,0,2,3,5,1),'R':(0,2,4,1,3,5),'L':(0,3,1,4,2,5)}
while 1:
 n=int(d())
 if n==0:break
 a=[1];s='123456'
 for _ in[0]*n:
  s=[s[e]for e in p[d()[0]]]
  a+=[s[0]]
 print(sum(map(int,a)))


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 1LL << 60;

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    if(n<m){
        for(int i=0;i<m;i++) {
            cout << n;
        }
    }else{
        for(int i=0;i<n;i++) {
            cout << m;
        }
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
//複数の入力ケースの表示

#include <stdio.h>

int main(){

  int x = 0;        //初期化
  int i = 1;        //ケース1から

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

    if(x < 0 || x > 10000)
        {
            //エラーメッセージを表示して終了する
            printf("Invalid Input\n");
            return 0;
        }


    if(x != 0){
      printf("Case %d: %d\n", i, x);
      i += 1;
    }else{          //入力が0で終了
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>
#include<stdlib.h>
int compare(const void * a,const void *b){
  return *(int*)b -*(int*)a;
}
int main(){
  int n,i,r = 0,t=1;
  int arr[999];
  scanf("%d",&n);
  for(i = 0;i<n;i++)scanf("%d",&arr[i]);
  qsort(arr,n,sizeof(int),compare);
  for(i=0;i<n;i++){
    r += t*arr[i];
    t = -t;
  }
  printf("%d\n",r);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = 0;
        for(int i = k;i <= n+1;i++){
            //i個選ぶことを考える
            long tmp = n;
            tmp*=i;
            tmp++;
            long sub = i-1;
            sub*=i;
            tmp-=sub;
            tmp%=MOD;
            ans+=tmp;
            ans%=MOD;
            //System.out.println(tmp);
        } 
        System.out.println(ans%MOD);

    }

}


Measured memory_bytes: 35828
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		
		if(a>=30) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


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

int main() {

	int n; cin >> n;
	map<ll, ll> mp;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		ans += mp[i + 1 - a];
		mp[i + 1 + a]++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    for (auto& c : s)c = 'x';
    cout << s << endl;
    return 0;
}


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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int N, K;
        cin >>N >>K;
        vector<int> A(N+1, 0);
        Rep1(i, N)
                cin >>A.at(i);
        //
        for (auto i=K+1; i<=N; i++) {
                if (A.at(i)>A.at(i-K))
                        cout <<"Yes" <<endl;
                else
                        cout <<"No" <<endl;
        }
        return 0;
}

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

int main(){
    int N,M,L,R;
    cin>>N>>M;
    vector<int> ans(N+1,0);
    for(int i=0;i<M;++i){
        cin>>L>>R;
        ++ans[L];
        ++ans[R];
    }
    for(int i=1;i<=N;++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
 int n;
 cin>>n;
if(n==32)cout<<"51"<<endl;
else if(n==16)cout<<"14"<<endl;
else if(n==24)cout<<"15"<<endl;
else if(n==8||n==12||n==18||n==27||n==20)cout<<"5"<<endl;
else if(n==28||n==30)cout<<"4"<<endl;
else if(n==4||n==6||n==9||n==10||n==14||n==21||n==22||n==25||n==26)cout<<"2"<<endl;
else cout<<"1"<<endl;

}

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

int main()
{
  string s, ans="NO";
  cin >> s;
  reverse(s.begin(),s.end());
  while(true){
    if(s==""){
      ans = "YES";
      break;
    }else if(s.find("maerd")==0 || s.find("esare")==0){
      s.erase(0,5);
    }else if(s.find("remaerd")==0){
      s.erase(0,7);
    }else if(s.find("resare")==0){
      s.erase(0,6);
    }else{
      break;
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 512
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<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>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;
    Vector<Int> a(n);
    for (auto& x : a) {
        std::cin >> x;
    }
    a.insert(a.begin(), 0);

    Vector<Int> fore(n + 2), back(n + 2);
    for (Int i = 1; i <= n; ++i) {
        fore[i] = std::max(fore[i - 1], a[i]);
    }
    for (Int i = n; i >= 1; --i) {
        back[i] = std::max(back[i + 1], a[i]);
    }

    for (Int i = 1; i <= n; ++i) {
        std::cout << std::max(fore[i - 1], back[i + 1]) << std::endl;
    }
    return 0;
}


Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;

vector<int> g[maxn];
int dis1[maxn],dis2[maxn];

void init() {
    memset(dis1,0,sizeof(dis1));
    memset(dis2,0,sizeof(dis2));
    for(int i=0;i<maxn;i++)g[i].clear();
}

void dfs(int x,int f,int dis[],int dep){
    dis[x]=dep;
    for(int i=0;i<g[x].size();i++){
        if(g[x][i]!=f)dfs(g[x][i],x,dis,dep+1);
    }
}

int main() {
    int n,x,y;
    while(scanf("%d",&n)!=EOF) {
        init();
        for(int i=1; i<n; i++) {
            scanf("%d%d",&x,&y);
            g[x].push_back(y);
            g[y].push_back(x);
        }
        dfs(1,-1,dis1,0);
        dfs(n,-1,dis2,0);
        int cnt=0;
        for(int i=1; i<=n; i++) {
            if(dis1[i]<=dis2[i])cnt++;
            else cnt--;
        }
        if(cnt>0){
            puts("Fennec");
        }else{
            puts("Snuke");
        }
    }
    return 0;
}


Measured memory_bytes: 14336
n, m = gets.chomp.split(' ').map(&:to_i)

ids = []

l, r = gets.chomp.split(' ').map(&:to_i)
(m-1).times do
  l_i, r_i = gets.chomp.split(' ').map(&:to_i)
  if l < l_i
    l = l_i
  end
  
  if r_i < r
    r = r_i
  end
end

if r >= l
  puts r - l + 1
else
  puts 0
end

Measured memory_bytes: 1788
s = gets.chomp
if s == "SAT"
  puts 1
elsif s == "FRI"
  puts 2
elsif s == "THU"
  puts 3
elsif s == "WED"
  puts 4
elsif s == "TUE"
  puts 5
elsif s == "MON"
  puts 6
else
  puts 7
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

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

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		int i = 0;
		while ((y + z) * i + z <= x) {
			i++;
		}
		System.out.println(--i);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int binarySearch(int *,int,int);

int main(){
  int i ,S[100000],q,t,c=0,n;
  scanf("%d",&n);
  for(i=0 ; i<n ; i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&t);
    if(binarySearch(S,t,n)==1)c++;
  }
  printf("%d\n",c);
  return 0;
}

int binarySearch(int *S,int t,int n){
  int right = n,left = 0,mid;
  while(left < right){
    mid = (left+right) / 2;
    if(S[mid] == t)
      return 1;
    else if(t < S[mid])
      right = mid;
    else
      left = mid + 1;
  }
  return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;


ll N, A, B, C;
vector<ll> l;

ll dfs(ll num, ll a, ll b, ll c) {
	if (num == N) {
		if (a == 0 || b == 0 || c == 0) return INF;
		else return abs(a - A) + abs(b - B) + abs(c - C) - 30;
	}
	ll r1 = dfs(num + 1, a, b, c);
	ll r2 = dfs(num + 1, a + l[num], b, c) + 10;
	ll r3 = dfs(num + 1, a, b + l[num], c) + 10;
	ll r4 = dfs(num + 1, a, b, c + l[num]) + 10;
	return min({ r1, r2, r3, r4 });
}

int main() {
	cin >> N >> A >> B >> C;

	for (int i = 0; i < N; ++i) {
		ll tmp;
		cin >> tmp;
		l.push_back(tmp);
	}

	cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int N;

double dp[310][310][310];

double Solve(int i, int j, int k)
{
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += Solve(i - 1, j, k) * i;
    if (j > 0) res += Solve(i + 1, j - 1, k) * j;
    if (k > 0) res += Solve(i, j + 1, k - 1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

void _main()
{
    cin >> N;
    array<int, 3> counts = {0, 0, 0};
    rep(i, 0, N)
    {
        int a;
        cin >> a;
        ++counts[a - 1];
    }

    memset(dp, -1, sizeof(dp));

    printf("%.12lf\n", Solve(counts[0], counts[1], counts[2]));
}


Measured memory_bytes: 233088
N = int(input())
H = list(map(int, input().split()))

INF = 1e32
dp = [INF] * N

dp[0] = 0
dp[1] = abs(H[0]-H[1])

for hi in range(2, N):
    dp[hi] = min(dp[hi-1] + abs(H[hi]-H[hi-1]), dp[hi-2] + abs(H[hi]-H[hi-2]))

print(dp[N-1])

Measured memory_bytes: 13928
// ------------------------------------
// Date:2018/ 3/20
// Problem:A - AKIBA a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "YES" : "NO") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int main()
{
  SCIN(s);
  string memo = "AKIHABARA";
  bool ok = true;
  int cnt = 0;
  REP(i, memo.size()) {
    if (s[cnt] == memo[i]) cnt++;
    else if (memo[i] == 'A');
    else ok = false;
  }
  if (cnt != s.size()) ok = false;

  OK(ok);
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

int main()
{
  int N;
  std::cin >> N;
  bool flg = false;
  for (int i=1; i<=9; i++) {
    int M = N/i;
    if (M*i==N && 1 <= M && M <= 9) {
      flg = true; break;
    }
  }
  if (flg) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> G[300001];

    for (int i = 0; i < M; i++){
        int u, v; cin >> u >> v;
        G[u].emplace_back(N + v);
        G[N + u].emplace_back(2 * N + v);
        G[2 * N + u].emplace_back(v);
    }
    int S, T;
    cin >> S >> T;

    const int INF = INT_MAX;
    int d[N * 3 + 1];
    fill(d, d + N * 3 + 1, INF);
    d[S] = 0;
    queue<int> q;
    q.push(S);
    while(q.size() != 0){
        int x = q.front(); q.pop();
        if (x == T) break;
        for (auto& y : G[x]){
            if(d[y] != INF) continue;
            d[y] = d[x] + 1;
            q.push(y);
        }
    }

    if (d[T] == INF) d[T] = -1;
    else d[T] /= 3;

    cout << d[T] << endl;
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	string S, T;
	cin >> S >> T;

	int ans = 0;

	for (int i = 0; S[i]; ++i)
	{
		if (S[i] != T[i])
			++ans;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3860
#include <bits/stdc++.h>
#include <algorithm>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long 
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define endl "\n"
using namespace std;

ll gcd(ll a, ll b){
    return __gcd(a,b);
}

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

bool isPrime(ll n){
    if(n <= 1) return false;
    for(ll i=2; i<=sqrt(n); i++){
        if(n%i == 0){
            return false;
        }
    }
    return true;
}

void solve(){
    ll n;
    cin >> n;
    if(n%1000==0){
        cout << 0 << endl;
    }
    else{
        ll z = n%1000;
        cout << 1000-z << endl;
    }
}

int main() {
    fast;
    solve();
	//ll t; cin >> t; while(t--){ solve(); }
	return 0;
}

Measured memory_bytes: 3688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main{

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		int n 	     = Integer.parseInt(br.readLine());
		long max     = 0;
		long[] list  = new long[n];
		String[] tmp = br.readLine().split(" ");

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

			list[i] = Long.parseLong(tmp[i]);

		}

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

				max = Math.max(Math.abs(list[i] - list[j]), max);
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 32728
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MinimizeAbsoluteDifferenceDiv1
{
    public:
vector <int> findTuple(vector <int> x)
{


}
};

int main()
{
vector<int>ans;

for(int i=11;i<=55555;i++){
    int no=0;
    for(int j=2;j<=sqrt(i);j++){
        if(i%j==0)
            no=1;
    }
    if(!no&&i%10==1)
        ans.push_back(i);
}
int a;
while(cin>>a){
    
    
    for(int i=0;i<a;i++){
        cout<<ans[i]<<" ";
    }
    pt;
    
    
    
    
    
}

    return 0;
}


Measured memory_bytes: 256