akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    int ans;
    int tap = 1;
    while (tap < B) {
        ans++;
        tap += A - 1;
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


Measured memory_bytes: 256
def partition(arr, p, r)
  x = arr[r]
  i = p - 1
  p.upto(r - 1) do |j|
    if arr[j] <= x
      i += 1
      arr[i], arr[j] = arr[j], arr[i]
    end
  end
  arr[i + 1], arr[r] = arr[r], arr[i + 1]
  return i + 1
end

if $PROGRAM_NAME == __FILE__
  n = gets.to_i
  arr = gets.split.map(&:to_i)
  q = partition(arr, 0, n - 1)
  n.times do |i|
    if i == q
      print "[#{arr[i]}]"
    else
      print arr[i]
    end
    print ' ' if i < n - 1
  end
  puts
end

Measured memory_bytes: 16752
#include<iostream>

#define endl '\n'

using namespace std;

const int MAXN=1e3+3,MOD=1e9+7;
long long dp[MAXN][MAXN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i){
        for(int i2=1;i2<=m;++i2){
            char curr;
            cin>>curr;
            if(curr=='.'){
                if(i==1 and i2==1){
                    dp[i][i2]=1;
                }else{
                    dp[i][i2]=(dp[i-1][i2]+dp[i][i2-1])%MOD;
                }
            }else{
                dp[i][i2]=0;
            }
        }
    }
    cout<<dp[n][m]<<endl;
return 0;
}

Measured memory_bytes: 8064
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    D=set(input().split())
    for i in range(N,10**7):
        if not set(str(i))&D:
            print(i)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 40172
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, last;
	cin >> n >> last;
	ll money = 1000;
	for (int i = 1; i < n; i++) {
		int cur;
		cin >> cur;
		if (cur >= last)
			money = money / last * cur + (money % last);
		last = cur;
	}
	cout << money << endl;
}


Measured memory_bytes: 3636
#include <iostream>

int main() {
  int N, K;
  std::cin >> N >> K;

  size_t count = 0;
  for (int i = 0; i < N; ++i) {
    int h;
    std::cin >> h;
    if (h >= K) count++;
  }

  std::cout << count;
  return 0;
}


Measured memory_bytes: 256
import fractions

def fnc(start, end, divisor):
  if start > end:
    return False
  return start % divisor > end % divisor

A, B, C, D = map(int, input().split())

rng = B - A + 1

Cmod = rng // C
if fnc(A+C*(rng // C), B, C):
  Cmod += 1

Dmod = rng // D
if fnc(A+D*(rng // D), B, D):
  Dmod += 1

lcm = C*D // fractions.gcd(C, D)
lcmod = rng // lcm
if fnc(A+lcm*(rng // lcm), B, lcm):
  lcmod += 1

print(rng - Cmod - Dmod+ lcmod)

Measured memory_bytes: 63980
import sys
import collections

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    sl = [''.join(sorted(input())) for i in range(n)]
    c = collections.Counter(sl)

    dict = collections.defaultdict(int)
    for v in c.values():
        if v == 1:
            continue

        dict[v] += 1

    ans = 0
    for k, v in dict.items():
        ans += sum([i for i in range(k)]) * v

    print(ans)


Measured memory_bytes: 64092
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=5e3+10;
int a[mx];
int pref[2][mx][mx];
int f[mx];
int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++)scanf("%d",a+i);
  for(int it=0;it<2;it++){
    for(int i=0;i<k;i++)f[i]=0;
    f[0]=1;
    for(int i=0;i<n;i++){
      int idx=(it==0?i:n-1-i);
      for(int j=0;j<k;j++)pref[it][idx][j]=f[j];
      for(int j=0;j+a[i]<k;j++)
        if(f[j]==1 && f[j+a[i]]==0)
          f[j+a[i]]=2;
      for(int j=0;j<k;j++)f[j]=min(f[j],1);
    }
    reverse(a,a+n);  
  }
  for(int i=0;i<n;i++){
    int bef=0;
    for(int j=1;j<=k;j++){
      int x=pref[1][i][j];
      pref[1][i][j]=bef;
      if(x==1)bef=j;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int maxi=0;
    for(int j=0;j<k;j++)if(pref[0][i][j]==1){
      int x=pref[1][i][k-j];
      maxi=max(maxi,x+j);
    }
//    cout<<"ai="<<a[i]<<" maxi="<<maxi<<endl;
    if(maxi<k-a[i])ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 196224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=3000;
LL n,mo,fac[N+10],inv[N+10],pw[N+10],f[N+10][N+10];
LL mul(LL x,LL y,LL mod=mo) {
    x%=mod;
    LL z=1;
    while (y) {
        if (y&1) z=z*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return z;
}
void prework() {
    fac[0]=1;
    for (int i=1;i<=N;i++) fac[i]=fac[i-1]*i%mo;
    inv[N]=mul(fac[N],mo-2);
    for (int i=N-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mo;
}
LL C(LL x,LL y) {
    if (y>x||y<0) return 0;
    return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
void work() {
    LL ans=0;
    for (int i=0;i<=n;i++) pw[i]=mul(2,mul(2,i,mo-1));
    f[0][0]=1;
    for (int i=1;i<=n;i++) {
        f[i][0]=1;
        for (int j=1;j<=i;j++)
            f[i][j]=(f[i-1][j-1]+f[i-1][j]*(j+1))%mo;
    }
    for (int i=0;i<=n;i++) {
        LL now=mul(mo-1,i)*C(n,i)%mo*pw[n-i]%mo;
        LL nowx=mul(2,n-i),sumx=0;
        for (LL j=0,sx=1;j<=i;j++,sx=sx*nowx%mo)
            sumx=(sumx+sx*f[i][j])%mo;
        now=now*sumx%mo;
        ans=(ans+now)%mo;
    }
    ans=(ans%mo+mo)%mo;
    printf("%lld\n",ans);
}
int main() {
    scanf("%lld%lld",&n,&mo);
    prework();
    work();
    return 0;
}


Measured memory_bytes: 69248
#include <bits/stdc++.h>
#define ll      	long long int
#define PI      	acos(-1)
#define read    	freopen("in.txt","r",stdin)
#define uu      	first
#define vv      	second
#define write   	freopen("out.txt","w",stdout)
#define pii     	pair<int,int>
#define pll         pair<ll,ll>
#define INF     	1e9
#define EPS     	1e-8
#define MAX     	1000006
#define MOD     	1000000007
#define fastRead 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int n , m , ans;
vector<int>edg[MAX];
int vis[MAX] , dist[MAX];
stack<int>s;


void dfs1(int node ) {

    vis[node] = 1;
    for(auto x : edg[node]) {
        if( vis[x]) continue;
        dfs1(x);
    }
    s.push(node);
}

void dfs2(int node ,int h) {
    vis[node] = 1;
    ans = max(h , ans);

    for(auto x : edg[node]) {
        if( vis[x]) continue;
        dfs2(x, h+1);
    }
}

int main()
{
    fastRead;
    cin>>n>>m;
    for(int i =0 ; i < m ; i++ ) {
        int u , v;
        cin>>u>>v;
        edg[u].push_back(v);
    }

    for(int i = 1;  i<= n ; i++ ) {
        if( vis[i] ==0 ) dfs1(i);
    }
    memset(vis, 0 , sizeof vis);
    for(int i =1 ; i<= n ; i++ ) dist[i] = -INF;

    while( !s.empty()) {

        int top = s.top();
        s.pop();
//        cout<<top<<endl;

        if( dist[top ]== -INF) dist[top] = 0;
        for(auto x : edg[top]) {

            dist[x] = max(dist[x] , dist[top] + 1);
        }
    }
    for(int i =1 ; i <= n ; i++ ) ans = max(ans , dist[i]);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 35456
N = int(input())

blue_dict = {}
red_dict = {}

for i in range(N):
  tmp = input()
  if tmp in blue_dict:
    blue_dict[tmp] += 1
  else:
    blue_dict[tmp] = 1
    
M = int(input())
for i in range(M):
  tmp = input()
  if tmp in red_dict:
    red_dict[tmp] += 1
  else:
    red_dict[tmp] = 1


blue_dict = sorted(blue_dict.items(), key = lambda x: x[1])
red_dict = sorted(red_dict.items(), key = lambda x: x[1])


def search_red(red_dict, word):
  for i in red_dict:
    if i[0] == word:
      return i[1]
  return 0

ans = 0
for i in blue_dict:
    ans = max(ans, i[1] - search_red(red_dict, i[0]))

print(ans)

Measured memory_bytes: 38256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : I - Tsundoku
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/6/2020
///****************************************************************************************************************************************///
#define ll   long long


int main()
{

    ll m,n,k;
	cin >> n >> m >> k;
	vector<ll> a(n);
	vector<ll> b(m);
	for(int i = 0; i<n; i++){
		cin >> a[i];
	}
	for(int i = 0; i<m; i++){
		cin >> b[i];
	}
	vector<ll> sumA(n+1);
	vector<ll> sumB(m+1);
	for(int i = 0; i<n; i++){
		sumA[i+1] = sumA[i] + a[i];
	}
	for(int i = 0; i<m; i++){
		sumB[i+1] = sumB[i] + b[i];
	}
	int total = 0;
	for(int i = 0; i<= n;i++){
		ll other = k-sumA[i];
		if(other < 0){
			continue;
		}
		int l = lower_bound(sumB.begin(), sumB.end(), other)-sumB.begin();
		if(l>m||sumB[l]>other){
			--l;
		}
		total = max(total, i+l);
	}
	cout << total;

 return 0;
}


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

int main()
{
  int H,W;scanf("%d %d",&H,&W);
  char a[H+2][W+2];
  for(int i=1;i<H+1;i++)for(int j=1;j<W+1;j++)cin>>a[i][j];
  for(int i=0;i<H+2;i++)for(int j=0;j<W+2;j++)if(i==0||i==H+1||j==0||j==W+1)a[i][j]='#';
  for(int i=0;i<H+2;i++){for(int j=0;j<W+2;j++)cout<<a[i][j];cout<<endl;}
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */


void solve() {
	ll n, m, sum = 0, count = 0;
	cin >> n >> m;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		sum += arr[i];
	}
	double res = (sum * (1 / (4.0 * m)));

	for (int i = 0; i < n; i++) {
		if(arr[i] >= res) {
			count++;
		}
	}
	if(count >= m) {
		cout << "Yes\n";
		return;
	}
	cout << "No\n";
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int r; cin >> r;
  cout << r * r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); i++)
#define Rep(i, n) for (int (i) = (n); (i) > 0; i--)

int main() {
  int n,a=0,b=0;
  vector<int> card(100);

  cin >> n;
  rep(i,n)
    cin >> card[i];

  rep(i,n){
    for(int j = i+1; j<n; j++){
      if(card[i]<card[j])
        swap(card[i],card[j]);
    }
    if(i%2)
      b+=card[i];
    else
      a+=card[i];
  }

  cout << a-b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

double dp[3100][3100];

int main(){
    int n; cin >> n;
    vector<double> p(n);
    rep(i,n) cin >> p[i];
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);
        }
    }
    double ans = 0;//注意 
    for(int j = (n+1)/2; j <= n; j++) ans += dp[n][j];
    cout << fixed << setprecision(10) << ans << endl;
}

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

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
using namespace std;

signed main() {
  double n, x, t;
  cin >> n >> x >> t;
  int ans = ceil(n / x) * t;
    cout << ans;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int a, b;
    cin >> a >> b;
    string s1="", s2="";
    rep(i, b){
        s1 += (char)('0'+a);
    }
    rep(i, a){
        s2 += (char)('0'+b);
    }
    
    cout << min(s1, s2) << endl;
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

int total_pares(int n)
{
    int total = 0;
    for(int i = 2; i <= n; ++i)
    {
        if(n % 2 == 0)
            total++;
    }

    return total;
}
int total_impares(int n)
{
    int total = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(n % 2 != 0)
            total++;
    }

    return total;
}
int main(void)
{
    int K; cin >> K;

    int total = 0;
    int total_impares;
    int total_pares;

    if(K % 2 == 0)
    {
        total_impares = K / 2;
        total_pares = K / 2;
    }
    else
    {
        total_impares = K / 2 + 1;
        total_pares = K / 2;
    }
    
    total = total_impares * total_pares;
    cout << total << endl;


    return 0;
}

Measured memory_bytes: 256
n = int(input())
data = list(map(int,input().split()))
point = 0
i = 1
while i <= len(data) - 2:
    if data[i-1] < data[i] and data[i] < data[i+1]:
        point += 1
    if data[i - 1] > data[i] and data[i] > data[i + 1]:
        point += 1
    i += 1

print(point)

Measured memory_bytes: 9052
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,*A = get_all_int()

# dp[i][j] = 活発度高い順のi人目まで処理し、左にjに置いた場合のうれしさの最大
dp = [ [0] * (n+1) for _ in range(n+1) ]

AA = list(enumerate(A))
AA.sort(key=(lambda t: t[1]), reverse=True)

for i, t in enumerate(AA):
    # k 移動前の位置
    # a 活発度
    k,a = t
    for j in range(i+1):
        # 左に置く (すでに左端にj人居る)
        move = abs(k - j)
        dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + a*move)

        # 右に置く (すでに右端にi-j人居る)
        move = abs(k - (n-(i-j)-1))
        dp[i+1][j] =   max(dp[i+1][j],   dp[i][j] + a*move)

ans = 0

for j in range(n+1):
    ans = max(ans, dp[n][j])

# left = 0
# right = n-1

# AA = list(enumerate(A))
# AA.sort(key=(lambda t: t[1]), reverse=True)
# ans = 0
# for i,a in AA:
#     log(i,a)
#     l = abs(left-i)
#     r = abs(right-i)

#     if l > r:
#         log(f"  {i}->{left}, ", a*l)
#         ans += a * l
#         left += 1
#     else:
#         log(f"  {i}->{right}, ", a*r)
#         ans += a * r
#         right -= 1

print(ans)


Measured memory_bytes: 106772
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct Graph{
    struct Node{
        vector<int> dests;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void add1Edge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void add2Edge2(int from, int dest){
        add1Edge(from, dest);
        add1Edge(dest, from);
    }
    // void dfs(int idx, int from = -1){
    //     for(int didx : nodes[idx].dests){
    //         if(didx == from){ continue; }
    //         dfs(didx, idx);
    //     }
    // }
    ll dijkstra(int start, int goal){
        struct DElem{
            ll cost, dest;
            bool operator < (const DElem& e) const { return cost > e.cost; }
        };
        priority_queue<DElem> pq;
        pq.push({0, start});
        vector<vector<char>> visited(nodes.size(), vector<char>(3));
        // vector<char> visited(nodes.size());
        while(pq.size()){
            auto e = pq.top(); pq.pop();
            int rem = e.cost % 3;
            if(visited[e.dest][rem]){ continue; }
            visited[e.dest][rem] = true;
            if(e.dest == goal){
                if(rem == 0){
                    return e.cost / 3;
                }
                // if(rem != 2){
                //     return e.cost / 3 + rem;
                // }else if(visited[e.dest].size() == 2){
                //     return visited[e.dest][0] / 3 + 2;
                // }
                // return e.cost;
            }
            for(int didx : nodes[e.dest].dests){
                pq.push({e.cost + 1, didx});
            }
        }
        return -1;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g.add1Edge(u, v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;
    cout << g.dijkstra(s, t) << '\n';
}


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

using namespace std;

int main() {
    long long int n,i,j,k;
    cin>>n;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        b[i]=min(b[i-1]+abs(a[i-1]-a[i]),b[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<b[n-1];
    
}

Measured memory_bytes: 5060
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

int main(){
  int n,x,t;
  cin >> n >> x >> t;
  int ans = 0;
  ans += (n/x)*t;
  if(n%x != 0)ans += t;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		double x[3], y[3];
		for (int j = 0; j < 3; ++j)
			scanf("%lf %lf", x+j, y+j);
		
		double a[2], b[2];
		for (int j = 0, c = 0; j < 3 && c < 2; ++j)
		{
			for (int k = j+1; k < 3 && c < 2; ++k)
			{
				if (y[j] == y[k])
					continue;

				a[c] = -(x[k]-x[j])/(y[k]-y[j]);
				b[c] = (y[k]+y[j] - (x[k]+x[j])*a[c])/2;
				++c;
			}
		}
		double px = (b[0]-b[1])/(a[1]-a[0]);
		double py = a[0] * px + b[0];
		double r = sqrt((px-x[0])*(px-x[0])+(py-y[0])*(py-y[0]));
		printf("%.3f %.3f %.3f\n", px, py, r);
	}

	return 0;
}

Measured memory_bytes: 0
let () =
  let open Hashtbl in
  let n = read_int () in
  let tbl = create ~random:true n in
  let rec doit i =
    if i < n then begin
      match Scanf.scanf "%s %s\n" (fun x y -> x, y) with
      | ("insert", x) -> (add tbl x true; doit (i + 1))
      | ("find", x) -> (print_endline (if mem tbl x then "yes" else "no"); doit (i + 1))
      | _ -> exit 1
    end
  in
  doit 0

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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int m;
  cin>>m;
  vector<int> b(m);
  for(auto& bi:b)cin>>bi;

  cout<< includes(a.begin(),a.end(),b.begin(),b.end()) <<endl;

}


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

#define ft first
#define sd second
#define sz(x) ((int)x.size())

using namespace std;

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

const int MAXN = 100 * 1000 + 213;





int n, m, a[MAXN], num = 1;
bool c[MAXN];


int main() {
	c[1] = true;
	cin >> n >> m;
	fill(a + 1, a + n + 1, 1);
	int x, y;
	while (m--) {
		cin >> x >> y;
		if (c[x])
			if (!c[y])
				c[y] = true, num++;
		if (a[x] == 1)
			if (c[x])
				c[x] = false, num--;
		a[x]--;
		a[y]++;
	}
	cout << num;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <regex>
#include <set>
#include <cmath>
#include <sstream>
#include <numeric>
#include <set>

using namespace std;

int main()
{
    int n;
    std::string a, b;
    std::cin >> n >> a >> b;

    std::stringstream ss;
    int i = 0;
    while(true)
    {
        if(i < a.size())
        ss << a[i];
        if(i < b.size())
        ss << b[i];
        i++;
        if(i >= a.size() && i >= b.size())
            break;
    }
    std::cout << ss.str();
    return EXIT_SUCCESS;
}


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

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var dict = new Dictionary<string, int>();
        dict["AC"] = 0;
        dict["WA"] = 0;
        dict["TLE"] = 0;
        dict["RE"] = 0;
        for (int i = 0; i < N; i++)
        {
            var s = Console.ReadLine();
            dict[s]++;
        }

        foreach (var kv in dict)
        {
            Console.WriteLine($"{kv.Key} x {kv.Value}");
        }
    }
}

Measured memory_bytes: 31064
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int x = scan!int, y = scan!int, a = scan!int, b = scan!int, c = scan!int;
    long[] ps = scan!long(a);
    long[] qs = scan!long(b);
    long[] rs = scan!long(c);

    S[] us;
    foreach(p; ps) us ~= S(1, p);
    foreach(q; qs) us ~= S(2, q);
    foreach(r; rs) us ~= S(0, r);

    us.sort!"a.value>b.value"();

    int cnt1, cnt2, cntall;
    long ans;
    foreach(u; us){
        if(u.color == 0){
            ans += u.value;
            cntall += 1;
        }
        if(u.color == 1){
            if(cnt1 < x){
                ans += u.value;
                cnt1 += 1, cntall += 1;
            }
        }
        if(u.color == 2){
            if(cnt2 < y){
                ans += u.value;
                cnt2 += 1, cntall += 1;
            }
        }
        if(cntall >= x + y) break;
    }

    ans.writeln;
}

struct S{
    int color;
    long value;
}

Measured memory_bytes: 18804
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),

int n;
string s;
int dp[100000][13];

int f(int i,int sum){
    if(i==n)return sum==5;
    int &ans=dp[i][sum];
    if(ans!=-1)return ans;
    ans=0;
    if(s[i]!='?'){
        ans=f(i+1,(sum*10+s[i]-'0')%13);
    }else{
        for(int j=0;j<10;j++)ans=(ans+f(i+1,(sum*10+j)%13))%MOD;
    }
    return ans;
}

signed main(){
    FASTER;
    cin>>s;
    n=s.size();
    memset(dp,-1,sizeof dp);
    cout<<f(0,0);
}



Measured memory_bytes: 20076
N, W = list(map(int,input().split()))
v = []
w = []
C = list([0 for i in range(W + 1)] for j in range(N + 1))
for i in range(N):
    n, m = list(map(int,input().split()))
    v.append(n)
    w.append(m)
for i in range(1, N + 1):
    for j in range(1, W + 1):
        if j - w[i - 1] < 0:
            C[i][j] = C[i-1][j]
        else:
            C[i][j] = max(int(C[i-1][j]),int(C[i-1][j-w[i - 1]]+v[i - 1]))
print(int(C[N][W]))

Measured memory_bytes: 27904
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n;
    ll m;
    while(cin >> n >> m, n){
        n++;
        vector<ll> p(n,0);
        for(int i = 1; i < n; i++)  cin >> p[i];
        vector<ll> a;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                a.push_back(p[i]+p[j]);
            }
        }
        sort(a.begin(), a.end());
        ll ans = 0;
        for(int i = 0; i < n*n; i++){
            if(a[i] > m)    break;
            ans = max(ans, a[i] + *(--upper_bound(a.begin(),a.end(),m-a[i])));
        }
        cout << ans << endl;
    }
    return 0;
}


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

acc = [i for i in range(N+1)]
for i in range(N): acc[i+1] += acc[i]

ans = 0
for i in range(K,N+2):
    ma = acc[-1] - acc[max(-len(acc),-1-i)]
    mi = acc[i-1]
    ans += ma - mi + 1
    ans %= 10**9+7

print(ans)

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

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

        int d = 0;
        for (int a = 1; a <= k; a++) {
                for (int b = 1; b <= k; b++) {
                        for (int c = 1; c <= k; c++) {
                                d += __gcd(a, __gcd(b, c));
                        }
                }
        }

        cout << d << endl;

        return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int H,N;
    cin>>H>>N;
    int A[N];
    
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    bool judge=false;
    for(int i=0;i<N;i++){
        H=H-A[i];
        if(H<=0){
            judge=true;
            break;
        }
    }
    if(judge)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
import numpy as np
H, W = map(int, input().split())
L = []
A = []
for i in range(H):
    a = np.array([j%2 for j in list(map(int, input().split()))])
    aindex = np.where(a==1)
    for j in range(sum(a)//2):
        x1 = aindex[0][2*j]
        x2 = aindex[0][2*j+1]
        for k in range(x1,x2):
            A.append([i+1, k+1, i+1, k+2])
    if sum(a)%2==1:
        L.append(i)
        
        for m in range(aindex[0][-1],W-1):
            A.append([i+1, m+1, i+1, m+2])

for s in range(len(L)//2):
    y1 = L[2*s]
    y2 = L[2*s+1]
    for t in range(y1,y2):
        A.append([t+1, W, t+2, W])
print(len(A))
for a in A:
    print(" ".join(str(b) for b in a))

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

ll choose2(ll n) {
    return n*(n-1)/2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) a.at(i)--;
    vector<int> cnt(n);
    rep(i,n) cnt.at(a.at(i))++;
    ll tot = 0;
    rep(i,n) tot += choose2(cnt.at(i));
    rep(i,n) {
        ll ans = tot;
        ans -= cnt.at(a.at(i))*(cnt.at(a.at(i)) - 1)/2;
        ans += (cnt.at(a.at(i)) - 1)*(cnt.at(a.at(i)) - 2)/2;
        cout << ans << endl;
    }
    return 0;
}

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

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

class Dinic {
public:
  vector<vector<pair<int, int>>> v;
  vector<int> e;

  vector<int> k;
  vector<int> j;

  Dinic(int n) {
    v.resize(n);
    k.resize(n);
    j.resize(n);
  }
  void add_edge(int a, int b, int atob, int btoa = 0) {
    v[a].push_back(make_pair(b, e.size()));
    e.push_back(atob);
    v[b].push_back(make_pair(a, e.size()));
    e.push_back(btoa);
  }
  void dyk(int s) {
    for(auto& i : k) {
      i = inf;
    }
    queue<pair<int, int>> pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()) {
      int w = pq.front().first;
      int b = pq.front().second;
      pq.pop();
      if(k[b] > w) {
        k[b] = w;
        for(auto i : v[b]) {
          if(e[i.second] > 0) {
            pq.push(make_pair(w + 1, i.first));
          }
        }
      }
    }
  }
  int dfs(int s, int t, int p, int c) {
    if(p == t) {
      return c;
    }
    int all = 0;
    while(c > all && j[p] < v[p].size()) {
      if(k[v[p][j[p]].first] == k[p] + 1) {
        int r = dfs(s, t, v[p][j[p]].first, min(c - all, e[v[p][j[p]].second]));
        e[v[p][j[p]].second] -= r;
        e[v[p][j[p]].second ^ 1] += r;
        if(r < c - all) {
          j[p]++;
        }
        all += r;
      }
      else {
        j[p]++;
      }
    }
    return all;
  }
  int solve(int s, int t) {
    int all = 0;
    while(1) {
      dyk(s);
      for(auto& i : j) {
        i = 0;
      }
      int r = dfs(s, t, s, inf);
      if(r == 0) {
        return all;
      }
      all += r;
    }
  }
};

int dp[113][334];

int o[114];
int k[114];

signed main() {
  int n, w;
  cin >> n >> w;
  rep(i, n) {
    cin >> o[i] >> k[i];
  }
  trep(i, n) {
    trep(j, n * 3) {
      dp[i][j] = 0;
    }
  }
  rep(_, n) {
    rrep(i, n + 1) {
      trep(j, n * 3) {
        dp[i + 1][j + o[_] - o[0]] = max(dp[i + 1][j + o[_] - o[0]], dp[i][j] + k[_]);
      }
    }
  }
  int ans = 0;
  trep(i, n) {
    trep(j, n * 3) {
      if(i * o[0] + j <= w) {
        ans = max(ans, dp[i][j]);
      }
    }
  }
  cout << ans << endl;
}


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

ll n, d, a[200010];
int cnt;
inline void solve(int T) {
    cin >> n >> d;
    cnt = 0;
    ll x, y;
    rep(i, 1, n) {
         cin >> x >> y;
         if(x * x + y * y <=d * d)cnt++;
    }
    cout << cnt << endl;

}   
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
 
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    // system("pause");
}

Measured memory_bytes: 3612
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll d, g;
  cin >> d >> g;
  vll p(d), c(d);
  vvll scores(d);
  rep(i, d){
    cin >> p[i] >> c[i];
    scores[i] = vll(p[i]-1, 100*(i+1));
  }
  ll m = 1<<d;
  ll ans_min = INF;
  rep(i, m){
    ll score = 0;
    ll ans = 0;
    vll rest;
    rep(j, d){
      if((i>>j)&1){
        score += 100*(j+1)*p[j]+c[j];
        ans += p[j];
      }else{
        rest.insert(rest.end(), ALL(scores[j]));
      }
    }
    dump(ans, score, rest);
    sort(ALL(rest));
    reverse(ALL(rest));
    if(score >= g){
      chmin(ans_min, ans);
      continue;
    }
    rep(i, SZ(rest)){
      score += rest[i];
      ans++;
      if(score >= g){
        chmin(ans_min, ans);
        break;
      }
    }
  }
  print(ans_min);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int ans;
    ans = a + b;
    if(ans > a + c){
        ans = a + c;
    }
    if(ans > b + c){
        ans = b + c;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
s = list(input())
n = len(s)
children = [0]*n

def runlength(word):
    last_word = ''
    res = []
    for s in word:
        if last_word == s:
            res[-1] += 1
        else:
            res.append(s)
            res.append(1)
            last_word = s
    return res

cur_total = 0
runlengthed = runlength(s)
for i in range(0, len(runlengthed), 4):
    r_cnt = int(runlengthed[i+1])
    l_cnt = int(runlengthed[i+3])
    first_idx = cur_total+r_cnt-1
    second_idx = first_idx+1
    children[first_idx] = (r_cnt+1)//2+l_cnt//2
    children[second_idx] = r_cnt//2+(l_cnt+1)//2
    cur_total = cur_total + r_cnt + l_cnt

print(' '.join(list(map(str, children))))

Measured memory_bytes: 12712
#include <iostream>

using namespace std;

int main()
{
	int n, i = 1;
	cin >> n;

	while (i <= n)
	{
		if (i % 3 == 0)
			cout << " " << i;

		else if (i % 10 == 3)
			cout << " " << i;

		else {
			int x = i / 10;
			while (x)
			{
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}

				x /= 10;
			}
		}

		++i;
	}

	cout << endl;

	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

void solve(long long N)
{
    long long a = 0;
    long long b = 0;
    long long ans = 1e18;
    for (long long i = 1; i < (long long)sqrt(N) + 1; i++)
    {
        a = i;
        if (N % a == 0)
        {
            b = N / a;
            ans = min(ans, a + b - 2);
        }
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


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

int cnt[10];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    bool I, J, K;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                I = false, J = false, K = false;
                for(int l = 0; l < n; l++){
                    if(I){
                        if(J){
                            if(k == (s[l]-'0')) K = true;
                        }
                        else{
                            if(j == (s[l]-'0')) J = true;
                        }
                    }
                    else{
                        if(i == (s[l]-'0')) I = true;
                    }
                }
                if(K) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        cin >> s;
        if(s=="Sunny"){
                cout << "Cloudy"<<endl;
        }else if(s=="Cloudy"){
                cout << "Rainy"<< endl;
        }else{
                cout << "Sunny" << endl;
        }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int A;
        int B;

        try (Scanner sc = new Scanner(System.in)) {
            A = sc.nextInt();
            B = sc.nextInt();

        }
       
       
        System.out.println(lcm(A,B));
        

    }
    
    //最小公倍数
    static long lcm(long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return (long) (c / b);
    }


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n;
  cin >> n;

  for(ll i=111; i<=999; i+=111) {
    if(i >= n) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256