akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

const double PI=(acos(-1));

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int bb=b,cc=c;
    int cnt=0;
    while(bb<=a){
        bb*=2;
        ++cnt;
    }
    while(cc<=bb){
        cc*=2;
        ++cnt;
    }
    if(cnt<=k)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
        


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;



int main(){
  ios_base::sync_with_stdio(false);

  string s;

  cin >> s;
  for(int i=0;i<s.size();i++){
    if(i % 2==0){
      cout << s[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 592
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
l=b.index(max(b))

if a[l]==0: print(0),sys.exit()
elif a[l]>0:
	print(N*2)
	for i in range(2):
		print(l+1,1)
	for i in range(1,N):
		for j in range(2):
			print(i,i+1)

else:
	print(N*2)
	for i in range(2):
		print(l+1,N)
	for i in range(N,1,-1):
		for j in range(2):
			print(i,i-1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;

int gcd(int a, int b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

int main(){
    int N,X;
    int A,B;

    cin >> N;
    if(N == 1){
        cout<< "Hello World" << endl;
    }else{
        cin>>A>>B;
        cout<<A+B<<endl;
    }

}

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

#define MAX 20000
using namespace std;



int main(){
  string str;
  std::cin >> str;
  if((str[0]==str[1]&&str[1]==str[2])||(str[2]==str[3]&&str[1]==str[2])){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    string S;
    cin >> S;
    if (S == "0"){
      break;
    }
    int N = S.size();
    vector<int> cnt(11, 0);
    int sum = 0;
    int power = 1;
    cnt[0] = 1;
    int ans = 0;
    for (int i = N - 1; i >= 0; i--){
      sum += (S[i] - '0') * power;
      sum %= 11;
      if (S[i] != '0'){
        ans += cnt[sum];
      }
      cnt[sum]++;
      power *= 10;
      power %= 11;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3264
N = int(input())
A = list(map(int, input().split()))

# A_set = list(set(A))
# Ad = {a_set:A.count(a_set) for a_set in A_set}
Ad = {}
for i in A:
  if not i in Ad:
    Ad[i]=0
  Ad[i] += 1

score_sum = sum([x*(x-1)/2 for x in list(Ad.values())])

for a in A:
    print(int(score_sum - (Ad[a] - 1)))


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#include <random>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y; cin >> x >> y;
	if (y >= 2 * x && (y - 2 * x) % 2 == 0 && 4 * x >= y && (4 * x - y) % 2 == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3616
gets
a = gets.split.map &:to_i
loop do # N
  a.sort! # logN
  a = a[0..0] + a[1..-1].map{|aa|aa = aa % a[0]} # N
  a.delete_if{|aa|aa == 0} # N
  break if a.size == 1
end
p a[0]
# 2
# 1
# 1000000000


Measured memory_bytes: 11632
import math

A, B, H, M = map(int, input().split())

L = (2*math.pi*H + (math.pi*M)/30.0)
S = ((math.pi*H)/6.0 + (math.pi*M)/360.0)
ans = math.sqrt(A**2 + B**2 -2*A*B*math.cos(abs(L-S)))
print(ans)


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn];
string s, ss;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    ll cnt=0;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 1; i < n; i++)
        if(a[i]<a[i-1]) cnt+=(ll)a[i-1]-(ll)a[i], a[i]+=(ll)a[i-1]-(ll)a[i];
    cout << cnt << "\n";
}


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

struct Card{
    char suit, value;
};

void BubbleSort(struct Card A[], int N){
    int flag =1;
    int swap = 0;
    while(flag){
        flag = 0;
        for(int i = N-1; i >= 1; i--){
            if(A[i].value < A[i-1].value){
                Card tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flag = 1;
                swap++;
            }
        }
    }
}

void SelectionSort(struct Card A[], int N){
    int swap = 0;
    for(int i = 0; i < N; i++){
        int minj = i;
        for(int j = i; j < N; j++){
            if(A[j].value < A[minj].value){
                minj = j;
//                swap++;
            }
        }
        if(A[minj].value != A[i].value){
            Card tmp = A[minj];
            A[minj] = A[i];
            A[i] = tmp;
            swap++;
        }
//        swap(data[minj], data[i]);
    }

}
void print(struct Card A[], int N){
    for(int i = 0; i < N; i++){
        cout<<A[i].suit<<A[i].value;
        if(i != N-1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }
}
bool isStable(struct Card A[], struct Card B[], int N){
    for(int i = 0; i < N; i++){
        if((A[i].value != B[i].value) || (A[i].suit != B[i].suit)){
            return false;
        }
    }
    return true;
}
int main(){
    int a;
    cin>>a;
    Card C1[100], C2[100];
//    vector<string> data(a);
    for(int k = 0; k < a; k++){
        cin>>C1[k].suit>>C1[k].value;
    }
    for(int i = 0; i < a; i++){
        C2[i] = C1[i];
    }
    BubbleSort(C1,a);
    SelectionSort(C2,a);
    print(C1,a);
    if(isStable(C1,C1,a)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    print(C2,a);
    if(isStable(C1,C2,a)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
}


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

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

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

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

  int32_t H, W;
  cin >> H >> W;
  vector<vector<bool>> is_open(H, vector<bool>(W, false));
  for (int32_t row = 0; row < H; ++row) {
    string s;
    cin >> s;
    for (int32_t column = 0; column < W; ++column) {
      if (s.c_str()[column] == '.') {
        is_open[row][column] = true;
      }
    }
  }

  int32_t nexts[][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

  int32_t result = INT32_MIN;
  for (int32_t from_row = 0; from_row < H; ++from_row)
    for (int32_t from_column = 0; from_column < W; ++from_column) {
      if (is_open[from_row][from_column]) {
        vector<vector<bool>> visited(H, vector<bool>(W, false));
        vector<vector<int32_t>> distances(H, vector<int32_t>(W, INT32_MAX));
        queue<Pair> q;
        visited[from_row][from_column] = true;
        distances[from_row][from_column] = 0;
        q.emplace(from_row, from_column);
        while (!q.empty()) {
          const Pair target = q.front();
          q.pop();
          for (const auto &n : nexts) {
            const Pair next(target.first + n[0], target.second + n[1]);
            if (next.first >= 0 && next.first < H && next.second >= 0 && next.second < W &&
                is_open[next.first][next.second] && !visited[next.first][next.second]) {
              visited[next.first][next.second] = true;
              distances[next.first][next.second] =
                  min(distances[next.first][next.second], distances[target.first][target.second] + 1);
              q.emplace(next);
              result = max(result, distances[next.first][next.second]);
            }
          }
        }
      }
    }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  ll n;
  cin >> n;
  vll a(200009,0);
  vll b(n);
  rep(i,n){
    cin>>b[i];
    a[b[i]]++;
  }
  ll ans = 0;
  rep(i,200008){
    if(a[i])ans+=a[i]*(a[i]-1)/2;
  }
  rep(i,n){
    ll cnt = ans;
    cnt-=a[b[i]]*(a[b[i]]-1)/2;
    cnt+=(a[b[i]]-1)*(a[b[i]]-2)/2;
    cout << cnt << endl;
  }
  
}






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


ll cnt[1000006];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        
        ll n;
        cin>>n;
        ll ar[n];
        ll sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>ar[i];
            cnt[ar[i]]++;
            sum+=ar[i];
        }
        int q;
        cin>>q;
        while(q--)
        {
            int a,b;
            cin>>a>>b;
            ll val = cnt[a]*(b-a);
            cout<<sum+val<<endl;
            sum = sum + val;
            //cout<<sum<<endl;
            cnt[b]+=cnt[a];
            cnt[a] = 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 5156
'use strict';

function main(stdin) {
  const input = stdin.split('\n');
  const N = Number(input.shift());
  const params = input[0].split(' ').map(v => parseInt(v, 10));

  const sorted = params.sort((a, b) => a - b);
  const ans = sorted.reduce((a, b) => (a + b) / 2);
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>

using namespace std;
//using Graph = vector<vector<int>>;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N,W; cin >>N >>W;
  ll w[N],v[N],dp[N+1][W+1]; memset(dp,0,sizeof(dp));
  for(int i=0; i<N; i++) cin >>w[i] >>v[i];
  for(int i=1; i<=N; i++) for(int j=0; j<=W; j++){
    dp[i][j]=dp[i-1][j];
    if(j) dp[i][j]=max(dp[i][j],dp[i][j-1]);
    if(j>=w[i-1]) dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
  }
  cout <<dp[N][W];
return 0;}

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

const ll p = 1e9+7;

int n;
int i = 0;

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

	if (n == 3) {
		cout << "2 5 63\n";
		return 0;
	}

	while (true) {
		if (n >= 8) {
			cout << 12*i+2 << ' ' << 12*i+3 << ' ' << 12*i+4 << ' ' << 12*i+6 << ' ' << 12*i+8 << ' ' << 12*i+9 << ' ' << 12*i+10 << ' ' << 12*i+12 << ' ';
			n -= 8;
			i++;
			continue;
		}

		if (n == 1)
			cout << 12*i+6 << endl;
		if (n == 2)
			cout << 12*i+6 << ' ' << 12*i+12 << endl;
		if (n == 3)
			cout << 12*i+2 << ' ' << 12*i+4 << ' ' << 12*i+6 << endl;
		if (n == 4)
			cout << 12*i+2 << ' ' << 12*i+4 << ' ' << 12*i+3 << ' ' << 12*i+9 << endl;
		if (n == 5)
			cout << 12*i+2 << ' ' << 12*i+3 << ' ' << 12*i+4 << ' ' << 12*i+6 << ' ' << 12*i+9 << endl;
		if (n == 6)
			cout << 12*i+2 << ' ' << 12*i+3 << ' ' << 12*i+4 << ' ' << 12*i+6 << ' ' << 12*i+9 << ' ' << 12*i+12 << endl;
		if (n == 7)
			cout << 12*i+2 << ' ' << 12*i+3 << ' ' << 12*i+4 << ' ' << 12*i+6 << ' ' << 12*i+8 << ' ' << 12*i+9 << ' ' << 12*i+10 << ' ' << endl;
		return 0;
	}
}

Measured memory_bytes: 384
/* main code starts from line 130. */

/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

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

// container library
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;
template <typename T>
using PQ = priority_queue<T>;

using ll = long long;
using str = string;

#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end

#define SORT(v) sort(ALL(v))
#define GSORT(v) sort(ALL(v), greater<decltype((v).front())>())

/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n - 1, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n-1 to 0)
// Natural REP runs from 1 to n (R: n to 1)

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

#define fcout cout << fixed << setprecision(10)

/* ----------- debug ---------- */

template <typename T, typename U>
void testP2(T a, U b) {
    cout << "(" << a << ", " << b << ")" << endl;
    return;
}

template <typename T>
void testV(T v) {
    cout << "[";
    for (auto i : v) {
        cout << i << ", ";
    }
    cout << "\b\b]" << endl;
    return;
}

template <typename T>
void testV2(T v) {
    for (auto sv : v) {
        testV(sv);
    }
    cout << endl;
    return;
}

#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p)                      \
    cout << GET_VAR_NAME(p) << " = "; \
    testP2(p.fst, p.snd);

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

/* ---------- Type Definition ----------- */


/* ---------- Global Variance ----------- */


/* ------------- Functions -------------- */


/* ----------- Main Function ------------ */

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

    string S;
    cin >> S;
    cout << S.substr(0, SIZE(S) - 8) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ai[100][100];
    int a,b;
    scanf("%d %d",&a,&b);
    getchar();
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
            scanf("%c",&ai[i][j]);
        getchar();
    }

    int flag = 0;
    for(int i=1;i<=a;i++)
    {
        for(int j=1;j<=b;j++)
        {
            if(ai[i][j]=='#'&&ai[i+1][j]!='#'&&ai[i-1][j]!='#'&&ai[i][j+1]!='#'&&ai[i][j-1]!='#')
            {
                flag=1;
                //printf("%d %d\n",i,j);
                break;
            }
        }
    }
    if(flag == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "C"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << '\n'
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<float, float> ff;
typedef pair<double, double> dd;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, k, D[10];
	scanf("%d %d", &n, &k);
	REP0(i, k) scanf("%d", &D[i]);
	for(int i = n;; ++i) {
		bool check = true;
		int d = i, _d;
		while (d != 0) {
			_d = d % 10;
			d /= 10;
			REP0(j, k) {
				if (_d == D[j]) {
					check = false;
					break;
				}
			}
		}
		if (check) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

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

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    rep(i, n)
    {
        rep(j, d)
        {
            cin >> x[i][j];
        }
    }
    ll ans = 0;
    rep(i, n)
    {
        rep2(j, i + 1, n)
        {
            ll now = 0;
            rep(k, d)
            {
                now += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            rep(k, 200)
            {
                if (k * k == now)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N; cin >> N;
    vector<ll> a(N + 2, 0), s(N + 2, 0);
    rep(i, N){
        cin >> a[i + 1];
        s[i + 1] = s[i] + abs(a[i] - a[i + 1]);
    }
    s[N + 1] = s[N] + abs(a[N] - a[N + 1]);

    rep(i, N){
        pt(s[i] + abs(a[i + 2] - a[i]) + s[N + 1] - s[i + 2]);
    }
    return 0;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

typedef pair<int, int> P;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    

    int H, W, sx, sy;
    cin >> H >> W;
    char s[H][W];
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
          cin >> s[i][j];
        }
    }
        
    int ans = 0;
    for(int m=0;m<H;m++){
      for(int n=0;n<W;n++){
        if(s[m][n] == '#') continue;
        sx = m;
        sy = n;
        int dist[25][25];
        fill((int*)dist, (int*)(dist + max(H, W)), INF);
        queue<P> que;
        dist[sx][sy] = 0;
        que.push(P(sx, sy));
        while(!que.empty()){
            P p = que.front();
            que.pop();
            int x = p.first;
            int y = p.second;
            
            for(int i = 0; i < 4; ++i){
                int nx = x + dx[i], ny = y + dy[i];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W)  continue;
                if(s[nx][ny] == '#')    continue;
                
                if(dist[nx][ny] > dist[x][y] + 1){
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push(P(nx, ny));
                }
            }
            for(int a = 0; a < H; ++a){
                for(int b = 0; b < W; ++b){
                    if(dist[a][b] == INF)   continue;
                    ans = max(ans, dist[a][b]);
                }
            }
        }
      }
    }
    
    cout << ans << endl;
}


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

using namespace std;

int n, w;
long long weight[101];
long long value[101];
long long dp[100001];

int main()
{
    cin >> n >> w;
    long long lval = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
        lval += value[i];
    }

    for (int i=1; i<=lval; i++) {
        dp[i] = 1e18;
    }
    dp[0] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int j = lval; j > 0; j--)
        {
            if(j - value[i] >= 0) dp[j] = min(dp[j], dp[j - value[i]] + weight[i]);
        }
    }

    long long mx = 0;
    for(int i = 1; i <= lval; i++)
    {
        if(dp[i] <= w) mx = i;
    }

    cout << mx << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#define inf INT_MAX/2
using namespace std;
typedef pair<int, int> P;
struct edge { int to, cost; };
int h, w;
vector<edge> G[2500];
int d[2500];
string field[50];
int dijkstra() {
    fill(d, d+2500, inf);
    d[0]=0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0,0));
    while (!que.empty()) {
        P p=que.top(); que.pop();
        int v=p.second;
        if (d[v]<p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e=G[v][i];
            if (d[e.to]>d[v]+e.cost) {
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    return d[h*w-1];
}
int main() {
    scanf("%d%d",&h,&w);
    for (int i=0; i<h; i++) {
            cin>>field[i];
    }
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (i!=h-1) {
                G[i*w+j].push_back((edge){(i+1)*w+j,field[i+1][j]-'0'});
            }
            if (j!=w-1) {
                G[i*w+j].push_back((edge){i*w+j+1,field[i][j+1]-'0'});
            }
        }
    }
    printf("%d\n",dijkstra());
}

Measured memory_bytes: 0
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0

N = i()
C = s()

RW = [[0,0] for i in range(N)]
R = 0
W = 0

for i in range(N):
    if C[i] == "W":
        W += 1
    else:
        R += 1
    RW[i][0] = R
    RW[i][1] = W

K = R - RW[R-1][0]
ans = min(K,R,W)
print(ans)





Measured memory_bytes: 94016
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> T;
	if (T[0] != T[1] && T[1] != T[2] && T[2] != T[3]) {
		cout << "Good";
	}
	else {
		cout << "Bad";
	}

}

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

int main() {
	int n,s;
	while(cin>>n>>s,n)
	{
		int c=0;
		int comb=(1<<n)-1;
		while(comb<(1<<10))
		{
			int sum=0;
			for(int i=0;i<10;i++)
			{
				if(comb>>i&1)sum+=i;
			}
			if(sum==s)c++;
			int x=comb&-comb,y=comb+x;
			comb=(((comb&~y)/x)>>1)|y;
		}
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 3060
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> memo(100000, Vec(2, -LINF));
Vec2<ll> tree;

void dfs(ll node, ll par){
	repr(i, tree[node].size()){
		if(tree[node][i] == par) tree[node].erase(tree[node].begin()+i);
		else dfs(tree[node][i], node);
	}
}

ll f(ll node, ll flg){
	if(memo[node][flg] != -LINF) return memo[node][flg];

	ll res = 1;
	if(!flg){
		for(ll i : tree[node]){
			res *= f(i, 1);
			res %= MOD;
		}
	}else{
		for(ll i : tree[node]){
			res *= f(i, 0)+f(i, 1);
			res %= MOD;
		}
	}
	return memo[node][flg] = res;
}

int main(void){
	ll n;
	cin >> n;
	tree.resize(n);
	rep(i, n-1){
		ll x, y;
		cin >> x >> y;
		x--, y--;
		tree[x].pb(y);
		tree[y].pb(x);
	}
	dfs(0, -1);

	co((f(0, 0)+f(0, 1))%MOD);

	return 0;
}


Measured memory_bytes: 18176
# https: // onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_A
# 要素のmaxであるkさえわかっていればO(n+k)でソートできる高速なソート。天才かと思った。
# ソートしたい配列の数字をidxに対応させて、count 配列を作成. count配列を累積和。それがidxに対応しているというびっくり方法。
# ! 0 based-indexにするために、本とは違う実装


n = int(input())
A = list(map(int, input().split()))
A.sort()

print(*A)



Measured memory_bytes: 224588
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	k := make([]int, m)
	s := make([][]int, m)
	p := make([]int, m)
	for i := range k {
		fmt.Scan(&k[i])
		s[i] = make([]int, k[i])
		for j := range s[i] {
			fmt.Scan(&s[i][j])
			s[i][j]-- // 0-indexedに変換しておく
		}
	}
	for i := range p {
		fmt.Scan(&p[i])
	}
	ans := 0
	for i := 0; i < (1 << uint(n)); i++ { // スイッチのパターンを全列挙する
		ok := true
		for j := 0; j < m; j++ {
			cnt := 0
			for k := 0; k < len(s[j]); k++ { // j-1番目のスイッチ群のチェック
				if i&(1<<uint(s[j][k])) != 0 { // パターンの中でs[j][k]スイッチはONか?
					cnt++
				}
			}
			if cnt%2 != p[j] {
				ok = false
				break
			}
		}
		if ok {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define MAX_M 1000000
int p[MAX_M];
string S[MAX_M];

int wa[MAX_N];
int ac[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int N, M;
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    cin >> p[i] >> S[i];
  }

  for (int pi = 1; pi <= N; pi++) {
    ac[pi] = 0;
    wa[pi] = 0;
  }
  
  // -----------------------------

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

    if (S[i] == "WA" && ac[p[i]] == 0 ) {
      wa[p[i]]++;
    }
    else if (S[i] == "AC") {
      ac[p[i]] = 1;
    }
  }

  int pen_all = 0;
  int ac_all = 0;
  
  for (int i = 1; i <= N; i++) {

    if(ac[i] >= 1) pen_all = pen_all + wa[i];
    ac_all  = ac_all + ac[i];
  }

  cout << ac_all << " " << pen_all << endl;
  
  return 0;
  
}


Measured memory_bytes: 19712
n = int(input())
a = [0]+[int(input()) for _ in [0]*n]
used = [False, True]+[False]*(n-1)
ans = 0
now = 1
while now!=2:
    if not used[a[now]]:
        used[a[now]] = True
        now = a[now]
        ans += 1
    else:
        print(-1)
        break
else:
    print(ans)

Measured memory_bytes: 8568
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main() {
  string s;
  cin>>s;
  int ans=0,good=0;
  for (int i=0;i<s.size();++i) {
    if (s[i]=='R') ++ans;
    else ans=0;
    good=max(good,ans);
  }
  cout<<good<<'\n';
}

Measured memory_bytes: 3592
#include <cstdio>
using namespace std;
#define Mod 1000000007
#define N 17
int a[N],f[N][1<<N],pw[1<<N],ni[1<<N],n,m,i,mask,j;
inline int qmi(int di,int zhi)
{
	int ret=1,x=di;
	while (zhi){
		if (zhi&1) ret=1LL*ret*x%Mod;x=1LL*x*x%Mod;zhi>>=1;
	}return ret;
}
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) scanf("%d",&a[i]);a[0]=1;
	f[0][0]=(n&1)?(-1):1;
	pw[0]=1;
	for(mask=1;mask<=(1<<n);mask++)	pw[mask]=1LL*pw[mask-1]*mask%Mod;
	ni[(1<<n)]=qmi(pw[(1<<n)],Mod-2);
	for(mask=(1<<n);mask>=1;mask--) ni[mask-1]=1LL*ni[mask]*mask%Mod;
	for(mask=1;mask<(1<<n);mask++) f[0][mask]=-f[0][mask-(mask&(-mask))];
	for(i=1;i<=m;i++)
	{
		for(mask=0;mask<(1<<n);mask++)
			if (mask-a[i]+2>=0)	f[i-1][mask]=1LL*f[i-1][mask]*pw[mask-a[i-1]+1]%Mod*ni[mask-a[i]+2]%Mod;
		else	f[i-1][mask]=0;
		for(mask=0;mask<(1<<n);mask++)
		{
			if(mask-a[i]+2>0)	f[i][mask]=(1LL*f[i-1][mask]*(mask-a[i]+2)+f[i][mask])%Mod;
			for(j=0;j<n;j++)	if(!(mask&(1<<j))) f[i][mask|(1<<j)]=(1LL*f[i-1][mask]*(1<<j)+f[i][mask|(1<<j)])%Mod;
		}
	}
	int ans=1LL*f[m][(1<<n)-1]*pw[(1<<n)-a[m]]%Mod*qmi(2,n)%Mod;
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 8064
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let x: usize = input();
    let y: usize = input();
    let z: usize = input();
    let k: usize = input();
    let mut a: Vec<i64> = (0..x).map(|_| input()).collect();
    let mut b: Vec<i64> = (0..y).map(|_| input()).collect();
    let mut c: Vec<i64> = (0..z).map(|_| input()).collect();

    a.sort_by_key(|a| -a);
    b.sort_by_key(|b| -b);
    c.sort_by_key(|c| -c);

    let mut q = std::collections::BinaryHeap::new();
    for &a in &a {
        for &b in &b {
            for &c in &c {
                if q.len() < k {
                    q.push(Reverse(a + b + c));
                } else {
                    let Reverse(w) = q.pop().unwrap();
                    if w < a + b + c {
                        q.push(Reverse(a + b + c));
                    } else {
                        q.push(Reverse(w));
                        break;
                    }
                }
            }
        }
    }

    let mut ans = Vec::from(q);
    ans.sort();
    with_stdout_lock(|mut w| {
        for a in ans {
            writeln!(w, "{}", a).unwrap();
        }
    });
}

#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
struct Reverse<T>(T);
impl<T: Ord> Ord for Reverse<T> {
    fn cmp(&self, other: &Reverse<T>) -> std::cmp::Ordering {
        other.0.cmp(&self.0)
    }
}
impl<T: PartialOrd> PartialOrd for Reverse<T> {
    fn partial_cmp(&self, other: &Reverse<T>) -> Option<std::cmp::Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: std::fmt::Display> std::fmt::Display for Reverse<T> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        self.0.fmt(f)
    }
}


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

int N;
int A[210];

int main(){
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> A[i];
  
  int res = 0;
  
  while(true){
    bool exist_odd = false;
    for(int i = 0; i < N; ++i){
      if(A[i] % 2 != 0){
        exist_odd = true;
        break;
      }
      A[i] /=2;      
    }
    if(exist_odd) break;
    ++res;
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long min = calc(A, B, C);
		min = Math.min(min, calc(B, A, C));
		min = Math.min(min, calc(C, A, B));
		System.out.println(min);
	}
	
	static long calc(long A, long B, long C){
		return ((long)Math.ceil(1.0 * A / 2) - A / 2) * B * C;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PA;
typedef priority_queue<int, vector<int>, greater<int> > GQint;
typedef priority_queue<int> PQint;
typedef priority_queue<PA, vector<PA>, greater<PA> > GQpair;
typedef priority_queue<PA> PQpair;
typedef	set<int> Sint;
typedef	set<PA> SPA;
typedef map<int, int> MAP;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 100000002
#define MOD 100000
#define MAXN 102
#define MAXM 1002
#define MAXK 100002

ll n,x,m[MAXN],sum,mi = INF;

int main()
{
    cin >> n >> x;
    REP(i, 0, n){
        cin >> m[i];
        sum += m[i];
        mi = mi > m[i] ? m[i] : mi;
    }
    ll a = (x - sum) / mi;
    cout << n + a << endl;



    return 0;
}
/*













*/


Measured memory_bytes: 256
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int n,c=0;
    double m,sum=0;
    bool f=0;
    cin>>n>>m;
    vector<int>a(n);
    lp(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.rbegin(),a.rend());
    lp(i,n){
        if(a[i]>=sum/(4*m))
            c++;
        if(m<=c)
            break;
    }
    cout<<((c>=m)?"Yes":"No")<<endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n, n>0){
		ll ans=0;
		for(int i=2; i<=n; i++){
			if (i%2==0){
				if (n % (i/2)==0){
					if ((n/(i/2)) % 2==1 && n/(i/2)/2-i/2+1>=1) ans++;
				}
			}else{
				if (n%i==0 && n/i-i/2>=1) ans++;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << "\n"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e2 + 3;

ll n, k, a[N], sum, cnt;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
	for (ll i = 1; i <= n; ++i) cin >> a[i];
	
	cnt = 1; sum = 0;
	for (ll i = 1; i <= n; ++i, ++cnt) {
		sum += a[i];
		if (sum > k) break;
	}
	cout << cnt;
	
	return 0;
}


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

int main() 
{
    int N;
    cin >> N;
    long long sum = 0;
    vector<long long>A(N,0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    
    long long sum1 = 0;
    long long ans = 1e18;
    for (int i = 0; i < N; i++) {
        sum1 += A[i];
        if (i+1<N) {
            ans = min(ans, abs(sum - 2*sum1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4768
#include<iostream>
#include<algorithm>
#include<vector>
using LL = long long;
LL N,w;
LL W, V;
LL size[4];
LL ans;
std::vector<LL> dp1,dp2,dp3,dp4;
void value(LL x, LL y, LL z, LL q) {
	LL sum = 0;
	for (LL aa = 0; aa < x; aa++) {
		sum += dp1[aa];
	}
	for (LL aa = 0; aa < y; aa++) {
		sum += dp2[aa];
	}
	for (LL aa = 0; aa < z; aa++) {
		sum += dp3[aa];
	}
	for (LL aa = 0; aa < q; aa++) {
		sum += dp4[aa];
	}
	ans = std::max(ans, sum);
}
void solve() {
	for (LL i = 0; i <= dp1.size(); i++) {
		for (LL j = 0; j <= dp2.size(); j++) {
			for (LL k = 0;k <= dp3.size(); k++) {
				for (LL l = 0; l <= dp4.size(); l++) {
					LL ww=0;
					ww += i*w;
					ww += j*(w + 1);
					ww += k*(w + 2);
					ww += l*(w + 3);
					if (ww <= W) {
						value(i, j, k, l);
					}
				}
			}
		}
	}
}
int main() {
	std::cin >> N >> W;
	std::cin >> w>> V;
	dp1.push_back(V);
	for (LL i = 1; i < N; i++) {
		LL tmp,Q;
		std::cin >> tmp >> Q;
		if (tmp - w == 0) dp1.push_back(Q);
		if (tmp - w == 1) dp2.push_back(Q);
		if (tmp - w == 2) dp3.push_back(Q);
		if (tmp - w == 3) dp4.push_back(Q);
 
	}
	std::sort(dp1.rbegin(), dp1.rend());
	std::sort(dp2.rbegin(), dp2.rend());
	std::sort(dp3.rbegin(), dp3.rend());
	std::sort(dp4.rbegin(), dp4.rend());
	solve();
	std::cout << ans ;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;




int main() {

    char s[1000000];
    int start = 500000;
    int l = start;
    int r = start;

    string in;
    cin >> in;
    int len = in.size();
    r = l + len - 1;
    rep(i,len) s[start+i] = in[i];
    int q;
    cin >> q;
    int mirror = 0;
    rep(i,q) {
        int t;
        cin >> t;
        if (t == 1) ++mirror;
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1 && mirror%2 == 0) || (f == 2 && mirror % 2 == 1)) {
                --l;
                s[l] = c;
            }
            else {
                ++r;
                s[r] = c;
            }
        }
    }

    if (mirror%2 == 0) {
        for (int i = l; i <= r; ++i) {
            cout << s[i];
        }
    }
    else {
        for (int i = r; l <= i; --i) {
            cout << s[i];
        }
    }
    cout << endl;
        
}




//              g++ -std=c++1z






Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> v[16];
bool b[16];
int n,ma=0;

void h1(int i){
	bool c[16];
	int o=1,count=0;
	for(int j=1;j<=n;j++){
		if(b[j]==false)
		continue;
		count++;
		for(auto k:v[j]){
			if((k.second==0&&b[k.first]==true)||(k.second==1&&b[k.first]==false))
			o=0;
		}
	}
	if(o==1)
	ma=max(ma,count);
	if(i>n)
	return;
	b[i]=true;
	h1(i+1);
	b[i]=false;
	h1(i+1);
}

int main() {
	int count=0;
	cin>>n;
	memset(b,false,sizeof(b));
	for(int i=1;i<=n;i++){
		v[i].clear();
		int a,b,c;
		cin>>a;
		while(a--){
			cin>>b>>c;
			v[i].push_back({b,c});
		}
	}
	h1(1);
	cout<<ma;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, l, t;
#define LL long long
const int N = 200000;
int xi[N], dir[N], xx[N];
int main()
{
//    freopen("input.txt","r",stdin);
	cin >> n >> l >> t;
    LL c = 0;
    for (int i = 0; i < n; ++ i)
    {
        cin >> xi[i] >> dir[i];
        if (dir[i] == 2) dir[i] = -1;
        int nx = xi[i] + t * dir[i];
        c += (nx > 0? nx / l: (nx - l + 1) / l);
        xx[i] = (nx % l + l) % l;
    }
    sort(xx, xx + n);
    for (int i = 0; i < n; ++ i)
        cout << xx[((i + c) % n + n) % n] << "\n";
}

Measured memory_bytes: 2432