akhauriyash/Code-Regression huggingface dataset:
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=305;
int n,cnt[4];
db dp[maxn][maxn][maxn];

db go(int i,int j,int k){
	if(dp[i][j][k]>-0.5)return dp[i][j][k];
	if(!i&&!j&&!k)return 0;
	db cur=1.0;
	if(i)cur+=go(i-1,j,k)*(db(i)/db(n));
	if(j)cur+=go(i+1,j-1,k)*(db(j)/db(n));
	if(k)cur+=go(i,j+1,k-1)*(db(k)/db(n));
	dp[i][j][k]=cur*n/db(i+j+k);
	return dp[i][j][k];
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	REP(i,n){
		int x;
		scanf("%d",&x);
		cnt[x]++;
	}
	rep(i,n+1)rep(j,n+1)rep(k,n+1)dp[i][j][k]=-1;
	printf("%.10lf\n",go(cnt[1],cnt[2],cnt[3]));
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const int MAXN = 1e5 + 10;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && c != a) {
        cout << "Yes";
        return 0;
    }
    if (a == c && b != a) {
        cout << "Yes";
        return 0;
    }
    if (b == c && b != a) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#pragma G++ optimize(3)
using namespace std;
int main()
{
	int a,b,c,x,ans=0;
		cin>>a>>b>>c>>x;
			for(int i=0;i<=a;i++)
				for(int j=0;j<=b;j++)
					for(int k=0;k<=c;k++)
						if(i*500+j*100+k*50==x)
							ans++;
								cout<<ans;
									return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main(){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = x2;
	int y = y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	rep(i, 2) {
		swap(dx, dy);
		dx = -dx;
		x += dx;
		y += dy;
		cout << x << " " << y << " ";
	}
}

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

int main(){
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<s.size()/2;i++){
    if(s.at(i)!=s.at(s.size()-1-i)){
      cnt++;
    }
  }
  cout<<cnt;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll c[100][100];

int main() {
    int n;
    cin >> n;
    REP(i,n) REP(j,n) cin >> c[i][j];
    ll ans = 0;
    REP(i,n-1) FOR(j,i+1,n-1){
        ans += min(c[i][j], c[j][i]);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int A;
  cin>>A;
  int B=A/2;
  if(A%2==0){
    cout<<B*B<<endl;
  }
  else{
    int C=B+1;
    cout<<B*C<<endl;
  }
}

Measured memory_bytes: 256
A, B  = map(int, input().split())
grid = []
for h in range(100):
    str = "#"*50 + "."*50
    grid.append(list(str))
cntA = 0
while cntA < A - 1:
    w = cntA % 25
    h = cntA // 25
    grid[2*h][2*w] = "."
    cntA += 1
cntB = 0
while cntB < B - 1:
    w = cntB % 25 + 25
    h = cntB // 25  
    grid[2*h][2*w+1] = "#"
    cntB += 1

print(100,100)
for s in grid:
    print("".join(s))

Measured memory_bytes: 3444
def knapsack(n, W, w, v):
  dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
  for i in range(n+1):
    for j in range(W+1):
      if(i==0 or j==0):
        dp[i][j] = 0
      elif(w[i-1]<=j):
        dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]], dp[i-1][j])
      else:
        dp[i][j] = dp[i-1][j]
  return dp[n][W]


n, W = map(int, input().split())
we = []
va = []
for i in range(n):
  w, v = map(int, input().split())
  we.append(w)
  va.append(v)
print(knapsack(n, W, we, va))


Measured memory_bytes: 171528
function main(input) {
  input = input.trim();
  const a = input.split(" ").map(Number);
  if(a[0]+a[1]>a[2]+a[3]){
  	console.log('Left');
  }if(a[0]+a[1]<a[2]+a[3]){
  	console.log('Right');
  }if(a[0]+a[1]==a[2]+a[3]){
  	console.log('Balanced');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29528
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    rep(i,N-1){
        if(a[i] + a[i+1] >= K){
            cout<<"Possible"<<endl;
            rep(j, i) cout<<j + 1<<endl;
            Rreps(j, N - 1, i + 1) cout<<j + 1<<endl;
            cout<<i + 1<<endl;
            return 0;
        }
    }
    cout<<"Impossible"<<endl;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
    int a,b,t;
    cin>>a>>b;
    int d,e,f;
    d=a+b;
    e=a-b;
    f=a*b;
    d=d>e?d:e;
    f=d>f?d:f;
    cout<<f<<endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
 
const int N_MAX = 20000;
 
int arr[N_MAX];
 
int main() {
    for(;;) {
        int N, S;
        scanf("%d %d", &N, &S);
        if(N == 0 && S == 0) break;
        for(int i = 0; i < N; i++)
            scanf(" %d", arr + i);
        sort(arr, arr + N);
 
        int cnt = 0;
        for(int i = 0; i < N; i++) {
            cnt += (arr + N) - upper_bound(arr + i + 1, arr + N, S - arr[i]);
        }
 
        printf("%d\n", cnt);
 
    }
    return 0;
}

Measured memory_bytes: 1080
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Integer n = Integer.parseInt(br.readLine());
        String[] ta = br.readLine().split(" ");
        double t = Double.parseDouble(ta[0]);
        double a = Double.parseDouble(ta[1]);
        String[] str_hs = br.readLine().split(" ");
        int[] hs = new int[n];
        for (int i = 0; i < n; i++) {
            hs[i] = Integer.parseInt(str_hs[i]);
        }
        
        double min = 1000000;
        int index = 0;
        for (int i = 0; i < n; i++) {
            double avg = t - hs[i] * 0.006;
            double diff=a-avg;
            
            if (diff <0) diff = -1*diff;
            if (Math.abs(diff) < min) {
                min = diff;//Math.abs(a - avg);
                index = i+1;
            }
        }
        
        
        System.out.println(index);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll dp[2][100001];

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  int t=0;
  dp[t][0]=1;
  rep(i,n) {
    ll sum=0;
    rep(j,m+1) {
      sum+=dp[t][j];
      sum%=MAX;
      if(j-a[i]-1>=0) {
        sum-=dp[t][j-a[i]-1];
        sum+=MAX;
        sum%=MAX;
      }
      dp[t^1][j]+=sum;
      dp[t^1][j]%=MAX;
    }
    mem(dp[t]);
    t^=1;
  }
  pr(dp[t][m]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin >> n, n) {
		vi num(n);
		int s = 0, a = 0, c = 0;
		REP(i, n)
			cin >> num[i];
		double mi = 1e9;
		for(int i=15;i>=0;i--)
			for(int j = 15;j >= 0;j--)
			for(int k = 15; k >= 0;k--)
		{
			int r = i;
			int o[256] = {0};
			REP(m, n) {
				r = (r*j + k) % 256;
				o[(num[m] + r) % 256]++;
			}

			double h = 0;
			REP(m, 256)
				if (o[m] > 0)
					h += -((double)o[m] / (double)n)*log(((double)o[m] / (double)n)) / log(2);
			if (h <= mi) {
				mi = h;
				s = i;
				a = j;
				c = k;
			}
		}
		cout << s << " " << a << " " << c << endl;
	}
}

Measured memory_bytes: 3416
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

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

  if(A > B){
    b_min = B;
  }
  else{
  	b_min = A;
  }

  if(C > D){
    t_min = D;
  }
  else{
  	t_min = C;
  }
  
  cout << b_min + t_min << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long L = sc.nextLong();
    long R = sc.nextLong();

    sc.close();

    long r = Math.min(R, L+4038);

    long min = 2018;
    
    for (long i = L; i <= r; i++){
      for (long j = i + 1; j <= r; j++){
        long m = i*j%2019;
        min = Math.min(min, m);
      }
    }

    System.out.println(min);
    
  }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
  using namespace std;
  #define int long long int
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define hell 998244353
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
  int dp[405][405];
  int prefix[405];
  void solve()
  { 
     
     int n;
     cin>>n;
     vi v(n);
     rep(n)
     cin>>v[i];

     for(int i=0;i<n;i++)
     {
       
       if(i)
         prefix[i]=prefix[i-1]+v[i];
       else
         prefix[i]=v[i];
     }

     for(int l=n-1;l>=0;l--)
     {
       for(int r=l+1;r<n;r++)
       {

          int g=1e15;
           for(int i=l;i<r;i++)
           {
                int x=l>0?prefix[r]-prefix[l-1]:prefix[r];
                g=min(dp[l][i]+dp[i+1][r]+x,g);
           }
           dp[l][r]=g;
       }
     }
     cout<<dp[0][n-1];
      
   

   

  






  }



  signed main()
  {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   
    
    
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;

map<int, set<int>> table;
map<pair<int, int>, int> ans;
int h, w, n;

void add(int t, int l){
	if(l < 1 || t < 1 || l + 2 > w || t + 2 > h){ return; }
	int cnt = 0;
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(table.count(t + i) && table[t + i].count(l + j)){
				cnt++;
			}
		}
	}
	ans[{l, t}] = cnt;
	// cout<<l<<' '<<t<<' '<<cnt<<endl;
}

int main(){
	cin >> h >> w >> n;
	for(int i=0;i<n;i++){
		int a, b;
		cin >> a >> b;
		table[a].insert(b);
	}
	for(auto p : table){
		int a = p.first;
		for(auto b : p.second){
			// cout<<a<<' '<<b<<endl;
			add(a-2, b-2);
			add(a-2, b-1);
			add(a-2, b);
			add(a-1, b-2);
			add(a-1, b-1);
			add(a-1, b);
			add(a, b-2);
			add(a, b-1);
			add(a, b);
		}
	}
	
	vector<ll> ansv(10);
	for(auto p : ans){
		ansv[p.second]++;
	}
	// cout<<ansv[0]<<endl;
	ansv[0] = 1ll * (h - 2) * (w - 2) - accumulate(ansv.begin(), ansv.end(), 0);
	for(int i=0;i<10;i++){
		cout << ansv[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 54912
s = Array.new(13, false)
h = Array.new(13, false)
c = Array.new(13, false)
d = Array.new(13, false)

gets # ignore
while line = gets
  pattern, n = line.chomp.split
  i = n.to_i - 1
  case pattern
  when "S" then s[i] = true
  when "H" then h[i] = true
  when "C" then c[i] = true
  when "D" then d[i] = true
  end
end

s.each_with_index { |_, i| puts "S #{i+1}" unless s[i]}
h.each.with_index { |_, i| puts "H #{i+1}" unless h[i]}
c.each.with_index { |_, i| puts "C #{i+1}" unless c[i]}
d.each.with_index { |_, i| puts "D #{i+1}" unless d[i]}



Measured memory_bytes: 6884
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n, m;
  cin >> n >> m;

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

  vector<bool> t(n, true);
  for (int i = 0; i < m; i++) {
    if (h[a[i]] > h[b[i]]) {
      t[b[i]] = false;
    } else if (h[a[i]] < h[b[i]]) {
      t[a[i]] = false;
    } else if (h[a[i]] == h[b[i]]) {
      t[b[i]] = false;
      t[a[i]] = false;
    }
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (t[i]) {
      ans++;
      // cout << i << ln;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 5576
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] a = new long[3 * N];
		for (int i = 0; i < a.length; ++i) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		long sum = 0;
		int t = 3 * N;
		int s = 0;
		while (t - s > 0) {
			sum += a[t - 2];
			++s;
			t -= 2;
		}
		System.out.println(sum);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

    size_t N, W;
    cin >> N >> W;

    vector<intmax_t> w(N), v(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    const int max_value = int(1e5);
    vector<intmax_t> dp(max_value + 1, INF);
    dp[0] = 0;
    for (size_t i = 0; i < N; ++i) {
        for (int j = max_value; j >= 0; --j) {
            if (j - v[i] >= 0) {
                chmin(dp[j], dp[j - v[i]] + w[i]);
            }
        }
    }

    intmax_t res = 0;
    for (size_t value = 0; value <= max_value; ++value) {
        if (dp[value] <= W) {
            chmax(res, value);
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using Int = int64_t;

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

    vector<pair<Int, Int>> V;
    for (Int i = 1; i < N + 1; i++) {
        Int p;
        cin >> p;
        V.emplace_back(p, i);
    }

    sort(begin(V), end(V));
    reverse(begin(V), end(V));

    multiset<Int> S{0, 0, N + 1, N + 1};

    Int ans = 0;
    for (auto &v : V) {
        Int value = v.first;
        Int index = v.second;

        auto it = S.lower_bound(index);

        Int r1 = *it++;
        Int r2 = *it--;

        it--;

        Int l1 = *it--;
        Int l2 = *it;

        ans += 1l * value * (
            (r2 - r1) * (index - l1) +
            (l1 - l2) * (r1 - index)
        );

        S.insert(index);
    }

    cout << ans << '\n';
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n,a,b;cin>>n>>a>>b;
  if(abs(a-b)%2==1){
    P("Borys");
  }else{
    P("Alice");
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main( String args[] ) {

		int counter  = 0;
		int a;
		int b;
		int c;
		
		boolean isDoku;
		
		Scanner scan = new Scanner( System.in );
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		counter = 0;
		isDoku = true;
		
		
		if( a + b >= c ) {
			counter = c + b;
		}
		else {
			counter = b + a + b + 1;
		}
		
		
		System.out.println( counter );
		
		scan.close();
		
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;
unsigned long gcd(unsigned long m, unsigned long n) {
    while(1) {
        if(m < n) swap(m, n);
        if(!n) break;
        m %= n;
    }
    return m;
}

unsigned long lcm(unsigned long m, unsigned long n) {
    return (m*n)/gcd(m,n);
}
int main() {
    unsigned long a, b, c, d;
    cin >> a >> b >> c >> d;

    unsigned long inter = b - a + 1;
    unsigned long l = lcm(c, d);
    unsigned long sum_c, sum_d, sum_cd, ans;


    sum_c = b/c - (a-1)/c;
    sum_d = b/d - (a-1)/d;
    sum_cd = b/l - (a-1)/l;



    ans = inter - sum_c - sum_d + sum_cd;


    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double ax, ay, bx, by;
    int passed = h * 60 + m;
    double rada = M_PI / 2 - double(passed) / 720 * 2 * M_PI;
    double radb = M_PI / 2 - double(m) / 60 * 2 * M_PI;
    ax = a * cos(rada);
    ay = a * sin(rada);
    bx = b * cos(radb);
    by = b * sin(radb);
    cout << setprecision(15) << sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by)) << endl;
    return 0;
}


Measured memory_bytes: 4032
S=input()
List1=[]
for i in range(len(S)-1):
  if S[i]=='R' and S[i+1]=='L':
    List1.append(i)
List2=[]
for i in range(len(S)-1):
  if S[i]=='L' and S[i+1]=='R':
    List2.append(i)
List2.append(len(S)-1)
ans=[0 for i in range(len(S))]
def f(a,b):
  g=(a+1)//2+b//2
  return g
for i in range(len(List1)):
  if i==0:
    a=List1[i]+1
    b=List2[i]-List1[i]
    ans[List1[i]]=f(a,b)
    ans[List1[i]+1]=a+b-f(a,b)
  else:  
    a=List1[i]-List2[i-1]
    b=List2[i]-List1[i]
    ans[List1[i]]=f(a,b)
    ans[List1[i]+1]=a+b-f(a,b)

print(*ans)

Measured memory_bytes: 14608
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)
def knapsack(n, w):
    for _ in range(N):
        w, v = map(int, input().split())
        for wk in range(W, w-1, -1):
            tv = dp[wk - w] + v
            if tv > dp[wk]:
                dp[wk] = tv
    return dp[-1]
print(knapsack(N, W))

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

int main() {
long long k,s,sum=0;
cin>>k>>s;
long long a;
for (int i = 0; i <= k; ++i) {
	for (int j = 0; j <= k; ++j) {
		a=s-i-j;
		if(0<=a&&a<=k){
			sum++;
		}
	}

}
cout<<sum<<endl;
}


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

long long gcd(long long a,long long b){
	if(a>b) swap(a,b);
	while(a>0){
		b%=a;
		if(b==0) return a;
		a%=b;
	}
	return b;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a,b;
	cin >> a >> b;
	long long g=gcd(a,b);
	cout << (a*b/g) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;
typedef long long LL;
typedef double DB;
typedef pair <LL, LL> pLL;
const LL MOD = 1e9+7;
const LL NMAX = 1e6+7;
const string NAME = "test";

int n, m;
bool even;
LL pw[42];
pLL a[NMAX], mv[5];
char c_mv[5];

void init() {
    pw[0] = 1;
    for(int i = 1; i <= 41; ++i)
        pw[i] = pw[i-1] * 2;
    mv[1].fi = 1; mv[1].se = 0; c_mv[1] = 'L';
    mv[2].fi = -1; mv[2].se = 0; c_mv[2] = 'R';
    mv[3].fi = 0; mv[3].se = -1; c_mv[3] = 'U';
    mv[4].fi = 0; mv[4].se = 1; c_mv[4] = 'D';
}

bool enter() {
    cin >> n;
    int mod = -1;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i].fi >> a[i].se;
        if(mod == -1) mod = (abs(a[i].fi) + abs(a[i].se)) % 2;
        else {
            if(mod != (abs(a[i].fi) + abs(a[i].se)) % 2) return 0;
        }
        if((abs(a[i].fi) + abs(a[i].se)) % 2 == 0) a[i].fi++;
        while(pw[m]-1 < abs(a[i].fi) + abs(a[i].se)) m++;
    }
    m--;
    if(mod == 0) even = true;
    return 1;
}

bool check(LL x, LL y, int k) {
    return abs(x) + abs(y) <= pw[k+1] - 1;
}

bool trace(LL x, LL y, int k) {
    if(k == 0) {
        if(x == -1 && y == 0) {cout << 'L'; return 1;}
        if(x == 1 && y == 0) {cout << 'R'; return 1;}
        if(x == 0 && y == 1) {cout << 'U'; return 1;}
        if(x == 0 && y == -1) {cout << 'D'; return 1;}
        return 0;
    }
    for(int i = 1; i <= 4; ++i)
    if(check(x + mv[i].fi * pw[k], y + mv[i].se * pw[k], k-1) &&
       trace(x + mv[i].fi * pw[k], y + mv[i].se * pw[k], k-1)) {
        cout << c_mv[i];
        return 1;
    }
    return 0;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((NAME + ".inp").c_str(), "r", stdin);
    //freopen((NAME + ".out").c_str(), "w", stdout);
    init();
    if(!enter()) {
        cout << -1;
        return 0;
    }
    cout << m + 1 + even << '\n';
    if(even) cout << 1 << ' ';
    for(int i = 0; i <= m; ++i)
        cout << pw[i] << ' ';
    cout << '\n';
    for(int i = 1; i <= n; ++i) {
        if(even) cout << 'L';
        trace(a[i].fi, a[i].se, m);
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>

using namespace std;

int main() {
    int a; cin >> a;
    int* arr = new int[a];
    int sum = 0;
    int max = 1e9;
    for (int i = 0; i < a; i++) cin >> arr[i];
    sort(arr, arr + a);

    for (int i = 0; i <= 300; i++){
        for (int j = 0; j < a; j++) {
            sum += pow((arr[j] - i), 2); // 17
        }
    max = min(max, sum);//17 
    sum = 0; 
}
    cout << max; 

            return 0; 
 }
    
        

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

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    double c = x / (a * a);

    if(b <= 2 * c){
        double d = 2 * c - b;
        assert(d <= b);
        printf("%.8f\n", 90 - 180 * atan(a / (b - d)) / M_PI);
    }else{
        printf("%.8f\n", 90 - 180 * atan(2 * a * c / (b * b)) / M_PI);
    }
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int k, a, b;
    cin >> k >> a >> b;

    bool found = false;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            found = true;
            break;
        }
    }

    cout << (found ? "OK" : "NG") << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using std::cin; using std::string;
using std::cout; using std::endl;
using std::sort;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;
int main(){
    int a,b,c;
	while(cin>>a>>b){
	int co=1;
	c=a+b;
	while(1){
		if(c/10>=1){
			co+=1;
			c/=10;
		}
		else
			break;
	}
	cout<<co<<endl;
	co=1;
	}
	return 0;
}     

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
int main(){
    string s,t,a;
    int n;
    a="";
    cin>>n>>s>>t;
    REP(i,n){
        a+=s[i];
          a+=t[i];
    }
    cout<<a<<endl; 
}


Measured memory_bytes: 256
// #include "bits/stdc++.h"
#include <iostream>
#include <sstream>
#include <string>

namespace patch{
    template <typename T> std::string to_string(T value) {
        std::ostringstream os;
        os << value ;
        return os.str() ;
    }
}
/*
文字列を数値に変換
std::stoi(string型);
数値型を文字列に変換
to_string(数値型)
*/

std::string reverse_str(std::string);

int main(void) {
    int A, B;
    std::cin >> A >> B;

    int count = 0;
    for (int i = A; i <= B; i++) {
        std::string str = patch::to_string(i);
        std::string str_rev = reverse_str(str);

        if (str == str_rev) {
            count += 1;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

std::string reverse_str(std::string s) {
    std::string str_out = "";
    for (int i = s.length() - 1; i >= 0; i--) {
        str_out += patch::to_string(s[i]);
    }
    return str_out;
}


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

long long n,t[1005],a[1005];

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

    cin>>n;
    for(long long i=0;i<n;i++)
        cin>>t[i]>>a[i];
    for(long long i=1;i<n;i++)
    {
        long long d=max(t[i-1]/t[i],a[i-1]/a[i]);
        if(d*a[i]<a[i-1]||d*t[i]<t[i-1])
            d++;
        a[i]*=d;
        t[i]*=d;
    }

    cout<<t[n-1]+a[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 3612
#include<iostream>

using namespace std;

int main(){
	int x,y;
	for(int i=0;i<3000;i++){
		cin>>x>>y;
		if(x>y){
			swap(x,y);
		}
		if(x==0){
			if(y==0)break;
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 600010
using namespace std;
main(){
    int n,x;
    cin>>n>>x;
    int a[N];
    rep(i,n){
        cin>>a[i];
    }
    sort(a,a+n);
    int count=0;
    rep(i,n){
        if(x>=a[i]){
            x-=a[i];
            count++;
        }
    }
    if(count==n&&x){
        cout<<count-1;
    }
    else cout<<count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
int main(){
  double N,M;
  cin>>N>>M;
  vector<int>a(N);
  double sum=0;
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }

   sort(a.begin(),a.end());
   reverse(a.begin(),a.end());
 
  for(int i=0;i<M;i++){
  if(a[i]<sum/(4*M)){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

ll N;

int main() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    ll ans = (X - Z) / (Y + Z);
    cout << ans << endl;
    return 0;
}

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

int main () {
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(all(a)); sort(all(b));
    if (n%2 != 0) {
        int mn = a[(n-1)/2];
        int mx = b[(n-1)/2];
        cout << mx-mn+1 << endl;
    } else {
        double mn = ((double)a[n/2-1] + (double)a[n/2])/2;
        double mx = ((double)b[n/2-1] + (double)b[n/2])/2;
        cout << int(2*(mx-mn)) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 300005
#define endl "\n"

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

int n,a,b;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>a>>b;
    cout<<min(a*n,b)<<endl;
}

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

using namespace std;

typedef pair<int, int> P;
 
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}
 

int main() {
  int n;
  cin >> n;
  vector<P> a(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end(), pairCompare);
  long long int sum = 0;
  for (auto&& b: a) {
    sum += b.first;
    if (sum > b.second) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define ll long long
#define P pair<int,int>
#define MP(a,b) make_pair(a,b)
using namespace std;
bool vis[200005];
int n,m,dis[200005],t,h[200005];
priority_queue<P> q;
set<int> in[200005];
struct E{int v,c,next;}g[400005];
void ins(int u,int v,int c){g[++t].v=v,g[t].c=c,g[t].next=h[u],h[u]=t;}
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
	while(~scanf("%d%d",&n,&m))
	{
		memset(dis,0x3f,sizeof dis);
		memset(vis,0,sizeof vis);
		memset(h,0,sizeof h);
		memset(g,0,sizeof g);
		t=0;
		for(int i=1;i<200005;i++)
			in[i].clear();
		for(int i=1;i<=m;++i){
			int u,v,c;
			u=read(),v=read(),c=read();
			ins(u,v,c); ins(v,u,c);
		}
		q.push(MP(0,1)); dis[1]=0;
		while(!q.empty()){
			int u=q.top().second,cost=-q.top().first;
			q.pop();
			vis[u]=1;
			if(cost>dis[u]) continue;
			for(int j=h[u];j;j=g[j].next){
				if(vis[g[j].v]) continue;
				int v=g[j].v,c=g[j].c,d=dis[u]+(!in[u].count(c));
				if(d>dis[v]) continue;
				if(d<dis[v]){
					q.push(MP(-d,v));
					dis[v]=d;
					in[v].clear();
				}
				in[v].insert(c);
			}
		}
		printf("%d\n",dis[n]==1061109567?-1:dis[n]);
	}
}

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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    string s;
    int tx, ty, sx, sy;
    V x, y;

    cin >> s >> tx >> ty;

    bool isX = true;
    int i = 0;

    sx = 0;
    sy = 0;

    while (i < s.size())
    {
        if (s[i] == 'T')
        {
            isX = !isX;
            i++;
            continue;
        }

        int cnt = 0;

        while (i < s.size() && s[i] == 'F')
            cnt++, i++;

        if (cnt == 0)
            continue;

        if (isX)
        {
            x.push_back(cnt);
            sx += cnt;
        }
        else
        {
            y.push_back(cnt);
            sy += cnt;
        }
    }

    if (x.size() && s[0] == 'F')
    {
        tx -= x[0];
        sx -= x[0];

        x[0] = 0;
    }

    if (sx < abs(tx) || sy < abs(ty))
    {
        cout << "No" << endl;
        return 0;
    }

    if ((sx - abs(tx)) % 2 != 0 || (sy - abs(ty)) % 2 != 0)
    {
        cout << "No" << endl;
        return 0;
    }

    bool dpx[8010] = {false};
    bool dpy[8010] = {false};

    dpx[0] = true;
    dpy[0] = true;

    for (int i = 1; i <= (sx - abs(tx)) / 2; i++)
    {
        for (int j = 0; j < x.size(); j++)
        {
            if (i - x[j] >= 0)
                dpx[i] |= dpx[i - x[j]];
        }
    }

    for (int i = 1; i <= (sy - abs(ty)) / 2; i++)
    {
        for (int j = 0; j < y.size(); j++)
        {
            if (i - y[j] >= 0)
                dpy[i] |= dpy[i - y[j]];
        }
    }

    if (dpx[(sx - abs(tx)) / 2] && dpy[(sy - abs(ty)) / 2])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n, d;
    cin >> n >> d;

    d = 2 * d + 1;

    cout << (n + d - 1) / d << "\n";
    return 0;
}


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

int main(void){
  const int V = 10, W = 100, C = 10;
  // dp[j][k]: ??¢?????????i?????§??§???k????????¢?????????????????£????????????????¨????j??????????????????????????????????????°
  // (i????????????)
  vector<vector<int> > dp(W + 1, vector<int>(C + 1, 0));
  dp[0][1] = 1;
  for(int i = 1; i < V; i++){
    for(int j = W; j >= i; j--){
      for(int k = 1; k <= C; k++){
        dp[j][k] += dp[j - i][k - 1];
        if(j == i && k == 1){ ++dp[j][k]; }
      }
    }
  }

  while(true){
    int n, s;
    cin >> n >> s;
    if(n == 0 && s == 0){ break; }
    cout << dp[s][n] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3096
import numpy as np
from itertools import combinations
n, m , x = map(int, input().split())
skill_dic = {} 
for i in range(n):
    tmp = list(map(int, input().split()))
    skill_dic[i] = {'cost':tmp[0],'skills':tmp[1:]}

def calc_cost(skill_books, skill_dic,x):
    skill_nums = len(skill_dic[0]['skills'])
    skills = np.zeros(skill_nums)
    for i in skill_books:
        skills += skill_dic[i]['skills']
    skills = skills.reshape(-1, skill_nums)
    if np.all(skills >= x): return sum([ skill_dic[skill_book]['cost'] for skill_book in skill_books ])
    return None 

i = 1
cost_list = []
while i <= len(skill_dic.keys()):
    book_comb = combinations(skill_dic.keys(),i)
    for pattern in book_comb:
        cost = calc_cost(list(pattern),skill_dic, x)
        if cost is not None: cost_list.append(cost)
    i += 1
print(min(cost_list) if cost_list != [] else -1)

Measured memory_bytes: 27224
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll ans[110][110];
bool flag[2][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	string s1, s2;
	cin >> s1 >> s2;
	ll res = 0;
	ll target = 0;
	ll ans = 1;
	while (res < n) {
		if (s1[target] == s2[target]) {
			if (target == 0) {
				ans *= 3;
				ans %= MOD;
			}
			else {
				if (s1[target - 1] == s2[target - 1])ans *= 2;
				ans %= MOD;
			}
			res++;
			target++;
		}
		else {
			if (target == 0) {
				ans *= 6;
				ans %= MOD;
			}
			else {
				if (s1[target - 1] == s2[target - 1])ans *= 2;
				else {
					ans *= 3;
				}
				ans %= MOD;
			}
			res += 2;
			target += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

int main() {
    
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i % 3 == 0){
            cout << " " << i;
        }else{
            int x = i;
            while (x) {
                if(x % 10 == 3) {
                    cout << " " << i;
                    break;
                }else{
                    x /= 10;
                }
            }
        }
    }
    cout << endl;

}


Measured memory_bytes: 3096
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    int[] arr = {5,5,7};
    int[] arr2 = new int[3];
    for (int i = 0; i < 3; i++) {
      arr2[i] = in.nextInt();
    }
    Arrays.sort(arr2);
    out.println(Arrays.equals(arr,arr2) ? "YES" : "NO");

  }


  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    @Override
    public void close() {
    }
  }

}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    std::vector<long long> trips;
    int ans=0;
    cin>>n;
    trips.resize(n);
    for(auto &x:trips)
        cin>>x;
    n = trips.size();
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(trips[i]!=trips[j] && trips[i]!=trips[k] && trips[j]!=trips[k])
                    if(trips[i]+trips[j]>trips[k] && trips[i]+trips[k]>trips[j] && trips[j]+trips[k]>trips[i])
                        ans++;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3644
from collections import Counter as cnt
n =  int(input())
A = list(map(int, input().split()))
dic = cnt(A)
total = 0
for num in dic.values():
  if num >= 2:
    total += num * (num - 1) // 2
    
for num in A:
  target = dic[num]
  ans = total
  if target >= 2:
    ans -= target * (target - 1) // 2
    ans += (target - 1) * (target - 2) // 2
  print(ans)

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

 typedef long long ll;



 int main()
 {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    int flag = (w == 2 * x && h == 2 * y) ? 1:0;
    

    double ans = (double) w * h /2;

    printf("%.10f %d\n", ans, flag);
     return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define F first
#define S second
const int mod = 1e9+7;
int fac[100005];
//int inv[100005];

/*int pw(int base, int ex){
	base %= mod;
	if(ex==0){
		return 1;
	}
	int t = pw(base,ex/2);
	t=t*t;
	t%=mod;
	if(ex&1){
		return (t*base)%mod;
	}
	else {
		return t;
	}
}*/

int32_t main(){
	int a = 1;
	fac[0]=1;
	for(int i=1;i<=100005;i++){
		fac[i]=fac[i-1]*i;
		fac[i]%=mod;
	}
	int n,m;
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0;
		return 0;
	}
	int ans = fac[n]*fac[m];
	ans %= mod;
	if(n==m){
		ans *=2;
		ans %= mod;
	}
	cout<<ans;
}


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

using namespace std;

const int N = 123;

int n, a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  vector<int> answer;
  for (int i = 1; i <= n; ++i) {
    int p = -1;
    for (int j = n - i + 1; j; --j) {
      if (a[j] == j) {
        p = j;
        break;
      }
    }
    if (!~p) {
      cout << -1 << '\n';
      exit(0);
    }
    answer.push_back(p);
    for (int j = p; j <= n - i; ++j) {
      a[j] = a[j + 1];
    }
  }
  reverse(answer.begin(), answer.end());
  for (auto x : answer) {
    cout << x << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())

mypoint = [0 for i in range(N)]

#print(mypoint)


for i in range(Q):
    mypoint[int(input())-1] += 1
    

#print(mypoint)

#mymax = max(mypoint)


for i in range(N):
    if K + mypoint[i] - Q > 0 :
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4604
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
using namespace std;

int main()
{
	unsigned long long a = 100, b=0, c, X;
	cin >> X;
	while (1) {
		b++;
		a += a / 100;
		if (a >= X) {
			break;
		}
	}
	cout << b << endl;
}

Measured memory_bytes: 3636
//Heian-Kyo Walking
//????????????????´?2??????
//??????????????????????????¨??????????????§?????£???????§????????????§???????????¨?????¨????????????????????????????????£??????
//left[i][j]???????????¨????????????(i,j)????§???????????????¨?????§???????????¨???????????¨?????¨???????????????up[i][j]???????§????


#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	int counter;
	cin >> counter;
	for (int n = 0; n < counter; n++) {
		int gx, gy, p;
		cin >> gx >> gy;
		cin >> p;
		int x1, x2, y1, y2, t[16][16] = {}, up[16][16] = {} ,left[16][16] = {};
		for (int m = 1; m <= p; m++){
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 == x2)
				up[x1][max(y1, y2)] = 1;
			if (y1 == y2)
				left[max(x1, x2)][y1] = 1;
		}
		for (int j = 0; j <= 15; j++)
			left[0][j] = 1;
		for (int i = 0; i <= 15; i++)
			up[i][0] = 1;
		t[0][0] = 1;
		for (int j = 0; j <= gy; j++) {
			for (int i = 0; i <= gx; i++) {
				if (left[i][j] == 0 && i >= 0) 
					t[i][j] += t[i-1][j];
				if (up[i][j] == 0 && j >= 0) 
					t[i][j] += t[i][j-1];
			}
		}
		if (t[gx][gy] == 0)
			cout << "Miserable Hokusai!" << endl;
		else
			cout << t[gx][gy] << endl;
	}
}

Measured memory_bytes: 1164