akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


class Main {
	
    public static void main(String[] a) throws NumberFormatException, IOException{
    	
    	BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		String line;
		int numDS = -1;
		int aSide = -1;
		int bSide = -1;
		int cSide = -1;
		
		ArrayList <String> results = new ArrayList<String>();
		
		//get number of data sets
		while ((line = stdin.readLine()) != null && 
				line.length()!= 0) {
			
			String[] checker = line.split(" ");
			
			if (checker.length == 1){
				numDS = Integer.parseInt(checker[0]);
			} else if (checker.length == 3){
			
				int temp1 = Integer.parseInt(checker[0]);
				int temp2 = Integer.parseInt(checker[1]);
				int temp3 = Integer.parseInt(checker[2]);
				
				if (temp1 < 1 || temp1 >1000 ||
					temp2 < 1 || temp2 >1000 ||
					temp3 < 1 || temp3 >1000){
					results.add("NO");
				} else {
					//get the highest number and place to cSide
					if (temp1 > temp2 && temp1> temp3){
						cSide = temp1;
						aSide = temp2;
						bSide = temp3;
					} else if (temp2 > temp1 && temp2 > temp3){
						cSide = temp2;
						aSide = temp1;
						bSide = temp3;
					} else {
						cSide = temp3;
						aSide = temp2;
						bSide = temp1;
					}
					
					//Pythagorean
					if ((cSide*cSide) == ((aSide*aSide)+(bSide*bSide))){
						results.add("YES");
					} else {
						results.add("NO");
					}
					
					if (results.size() == numDS){
						break;
					}
				}
			}
		}

		//print result
		for (String s: results){
			System.out.println(s);
		}
		
    }
}

Measured memory_bytes: 25932
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	a := make([]int, n)
	digitMap := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
		digitMap[a[i]]++
	}
	combMap := make(map[int]int)
	baseCombinations := 0
	cache = make(map[int]int)
	for k, numberOfBalls := range digitMap {
		comb := nC2(numberOfBalls)
		baseCombinations += comb
		combMap[k] = comb
	}
	for i := 0; i < n; i++ {
		answer := baseCombinations
		answer -= combMap[a[i]]
		answer += nC2(digitMap[a[i]] - 1)
		fmt.Println(answer)
	}
}

func copyMap(m map[int]int) map[int]int {
	copied := make(map[int]int)
	for k, v := range m {
		copied[k] = v
	}
	return copied
}

func findCombinations(a []int, i int, digitMap map[int]int) int {
	digitMap[a[i]]--
	cnt := 0
	for _, numberOfBalls := range digitMap {
		cnt += nC2(numberOfBalls)
	}
	return cnt
}

var cache map[int]int

func nC2(n int) int {
	if cache[n] > 0 {
		return cache[n]
	}

	molecule, denominator := 1, 1
	for i := 0; i < 2; i++ {
		molecule *= n - i
		denominator *= 2 - i
	}
	res := molecule / denominator

	cache[n] = res
	return res
}


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

using namespace std;

class Union_Find {
public:
	Union_Find(int n = 0) : d(n, -1) {}

	int find(int x)
	{
		if (d[x] < 0) return x;
		return d[x] = find(d[x]);
	}

	bool unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return false;
		if (-d[x] < -d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}

	int size(int x)
	{
		return -d[find(x)];
	}

private:
	vector<int> d;
};

int main()
{
	int n, m;
	cin >> n >> m;
	Union_Find uf(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		uf.unite(a - 1, b - 1);
	}

	int mx = 0;
	for (int i = 0; i < n; i++) {
		mx = max(mx, uf.size(i));
	}
	cout << mx << endl;

	return 0;
}

Measured memory_bytes: 4056
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int a, mi, ma, N;
    mi = 10e9 + 1;
    ma = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d", &a);
        ma = max(ma, a);
        mi = min(mi, a);
    }
    printf("%d", ma - mi);
    return 0;
}

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

const int maxn=100000;

struct Tree {
  int parent,left,right;
};

Tree tree[maxn]; int depth[maxn];

void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<tree[u].parent<<", "<<flush;
  cout<<"depth = "<<depth[u]<<", "<<flush;

  if (tree[u].parent==(-1)) {
    cout<<"root, "<<flush;
  }
  else if (tree[u].left==(-1)) {
    cout<<"leaf, "<<flush;
  }
  else {
    cout<<"internal node, "<<flush;
  }
  cout<<"["<<flush;
  for (int i=0,c=tree[u].left; c!=(-1); i++,c=tree[c].right) {
    if (i) {
      cout<<", "<<flush;
    }
    cout<<c<<flush;
  }
  cout<<"]"<<endl;
}
void Depth(int u,int dpt) {
  depth[u]=dpt;
  if (tree[u].right!=(-1)) {
    Depth(tree[u].right,dpt);
  }
  if (tree[u].left!=(-1)) {
    Depth(tree[u].left,dpt+1);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n; cin>>n;
  for (int i=0; i<n; i++) {
    tree[i].parent=tree[i].left=tree[i].right=(-1);
  }
  int l;
  for (int j=0; j<n; j++) {
    int id,k; cin>>id>>k;
    for (int i=0; i<k; i++) {
      int c; cin>>c;
      if (i==0) {
	tree[id].left=c;
      }
      else {
	tree[l].right=c;
      }
      l=c;
      tree[c].parent=id;
    }
  }
  int x;
  for (int i=0; i<n; i++) {
    if (tree[i].parent==(-1)) {
      x=i;
    }
  }
  Depth(x,0);
  for (int i=0; i<n; i++) {
    print(i);
  }
  return 0;
}



Measured memory_bytes: 7860
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int sum = 0;
        for(int i = 0; i < n; i++) {
            int l = in.nextInt(), r = in.nextInt();
            sum += r - l + 1;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 25932
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
int k;
string s;
void pass(char c) {
    assert(s[k++] == c);
}
string str();
string letter();
string cipher() {
    string res;
    while(k < s.size() && s[k] != ']') {
        res += str();
    }
    if(k < s.size()) {
        pass(']');
    }
    return res;
}

string str() {
    if(s[k] == '[') {
        pass('[');
        string t = cipher();
        reverse(t.begin(), t.end());
        return t;
    }
    return letter();
}

string letter() {
    int add = 0;
    while(!('A' <= s[k] && s[k] <= 'Z') && s[k] != '?') {
        if(s[k] == '+') {
            add += 1;
        } else if(s[k] == '-') {
            add -= 1;
        } else {
            assert(false);
        }
        k++;
    }
    string t = s.substr(k, 1);
    pass(t[0]);
    if(t[0] != '?') {
        t[0] = (t[0] - 'A' + add + 26 * 1000) % 26 + 'A';
    }
    return t;
}

int main(){
    while(cin >> s && s != ".") {
        k = 0;
        string t = cipher();
        for(char& c : t) if(c == '?') c = 'A';
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S;
  cin>>N>>S;
  if(N%2!=0){
    cout<<"No"<<endl;
    return 0;
  }
  string s1=S.substr(0,N/2);
  string s2=S.substr(N/2,N-1);
  if(s1==s2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long s = a - b;
		long count = Math.max(x - a, 0) / s;
		long total = (count % MOD) * (a % MOD) % MOD;
		x -= count * s;
		while (x >= a) {
		    total += a;
		    x += - a + b;
		}
		total += x;
		total %= MOD;
		System.out.println(total);
	}
}



Measured memory_bytes: 26364
import java.util.*;

/**
 * GettingStarted
 */
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();

        if (a >= b) {
            System.out.println(gcd(a, b));
        } else {
            System.out.println(gcd(b, a));
        }
    }

    private static int gcd(int a, int b) {
        while (b > 0) {
            int tmp = a;
            a = b;
            b = tmp % b;
        }
        return a;
    }
}


Measured memory_bytes: 26148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
typedef pair<int, int> P;
//typedef tuple<int, int, int> T;

string S, T;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> S >> T;
    map<int, set<int>> m1;
    bool flag = true;
    rep(i, S.size()) {
        m1[S[i]].insert(T[i]);
        if (m1[S[i]].size()>=2) flag = false;
    }
    map<int, set<int>> m2;
    rep(i, T.size()) {
        m2[T[i]].insert(S[i]);
        if (m2[T[i]].size()>=2) flag = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    int x;
    cin >> x;
    int ans = x % 1000;
    if (ans == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1000 - (x % 1000) << endl;
    }
}


Measured memory_bytes: 3636
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e4 + 10;
int n , x[N] , y[N];
vector<pii> order;
vi pos[N];

struct TwoSat {
  static const int N = 1e5 + 10;
  int dfn[N],low[N],id[N],st[N],_st,_,cc,n,mark[N];
  vi g[N];
  void ini(int tot) {
    n = tot * 2;
    rep(i,0,tot) g[i<<1].clear(),g[i<<1|1].clear();
  }
  void addedge(int u,int v,int pu,int pv) {
    u=u<<1|pu,v=v<<1|pv;
    g[u].pb(v);g[v^1].pb(u^1);
  }
  void dfs(int c,vi g[]){
    dfn[c]=low[c]=++cc;
    st[_st++]=c;
    for(auto t:g[c])
      if(!dfn[t])
        dfs(t,g),low[c]=min(low[c],low[t]);
      else if(!id[t])
        low[c]=min(low[c],dfn[t]);
    if(low[c]==dfn[c]){
      ++_;
      do{id[st[--_st]]=_;}while(st[_st]!=c);
    }
  }
  bool solve(){
    fill_n(dfn,n,cc=0);
    fill_n(low,n,_st=0);
    fill_n(id,n,_=0);
    rep(i,0,n) if(!dfn[i]) dfs(i,g);
    for(int i=0;i<n;i+=2)
      if(id[i]==id[i+1]) return false;
      //else mark[i>>1]=id[i]>id[i+1];
    return true;
  }
}sat;

void addedge(int u,int v,int pu,int pv) {
  sat.addedge(u,v,pu,pv);
}
int id(int l,int r) {return (l+r)|(l!=r);}
void build(int l,int r,int fa) {
  int c = id(l , r);
  if(fa) addedge(c , fa , 1 , 1);
  if(l != r) {
    int mid = (l + r) >> 1;
    build(l , mid , c);
    build(mid + 1 , r , c);
  }
}
void build(int l,int r,int L,int R,int p) {
  int c = id(l , r);
  if(L <= l && r <= R) {
    addedge(p , c , 1 , 0);
  } else {
    int mid = (l + r) >> 1;
    if(L <= mid) build(l , mid , L , R , p);
    if(R > mid) build(mid + 1 , r , L , R , p);
  }
}
bool check(int lim) {
  sat.ini(2 * sz(order));
  build(0 , sz(order) , -1);
  rep(i,0,n) {
    addedge(pos[i][0] << 1 , pos[i][1] << 1 , 1 , 0);
    addedge(pos[i][0] << 1 , pos[i][1] << 1 , 0 , 1);
  }
  for(int i=0,l=0,r=0;i<sz(order);++i) {
    while(r<sz(order)&&order[r].fi-order[i].fi<lim)
      r++;
    while(l<r&&order[i].fi-order[l].fi>=lim)
      l++;
    if(l < i) build(0 , sz(order) , l , i - 1 , i + i);
    if(i < r - 1) build(0 , sz(order) , i + 1 , r - 1 , i + i);
  }
  return sat.solve();
}

int main(){
  cin >> n;
  rep(i,0,n) {
    cin >> x[i] >> y[i];
    order.pb(mp(x[i] , i));
    order.pb(mp(y[i] , i));
  }
  sort(all(order));
  rep(i,0,sz(order)) pos[order[i].se].pb(i);
  int l = 0 , r = 1e9;
  while(l + 1 < r) {
    int mid = (l + r) >> 1;
    (check(mid) ? l : r) = mid;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 21116
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>

using namespace std;
bool issqr(int n)
{
	double x = sqrt(n);
	double y = floor(x);
	if (x == y)
		return true;
	else
		return false;
}
int main()
{
	int n; cin >> n; int a[2000];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < n; ++i)
	{
		if (!(i % 2))
			sum1 += a[i];
		else
			sum2 += a[i];
	}
	cout << abs(sum2 - sum1);
}

Measured memory_bytes: 3160
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define sep cout<<"\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
int main(){
	long n;
	cin>>n;
	if(n%2==0)cout<<n<<"\n";
	else cout<<2*n<<"\n";
}
/*
10
3 3 3 3 3 1 3 3 3 3 3 
0 1 2 3 4 5 6 7 8 9 10
* 
* 
8 3
7 3 1 1 1 1 2 5
3 5 2 3 4 1
0 1 2 3 4 5 6 7
* */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int n, m, k;
int dp[3001][3001][4], ar[3001][3001];

int calc(int i, int j, int cnt) {
        if (i== n&& j== m) {
                return 0;
        }
        if (i> n) return 0;
        if (j> m) return 0;

        int &ret= dp[i][j][cnt];
        if (ret!= -1) return ret;
        ret= -1e18;

        ret= max(ret, calc(i+ 1, j, 0));
        ret= max(ret, calc(i, j+ 1, cnt));

        if (cnt<= 2) {
                ret= max(ret, calc(i+ 1, j, 0)+ ar[i][j]);
                ret= max(ret, calc(i, j+ 1, cnt+ 1)+ ar[i][j]);
        }
        return ret;
}

void solve() {
        cin >> n>> m>> k;

        for (int i = 0; i< k; i++) {
                int x, y, z; cin >> x>> y>> z;
                ar[x- 1][y- 1]= z;
        }

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

        cout << calc(0, 0, 0)<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 355772
s=input()
s1=s[:2]
s2=s[2:]
l=set(['01','02','03','04','05','06','07','08','09','10','11','12'])
if s1 not in l and s2 not in l:
    print('NA')
elif s1 in l and s2 not in l:
    print('MMYY')
elif s1 not in l and s2 in l:
    print('YYMM')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3060
# -*- 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

N=int(input())
T=[0]+list(map(lambda x:int(x)*2,input().split()))+[0]
V=[0]+list(map(lambda x:int(x)*2,input().split()))+[0]
v=[INF]*(sum(T)+1)
def f(v,l,r,t):
    if t<l:
        return v+(l-t)
    elif l<=t<r:
        return v
    else:
        return v+(t-r)
t=0
for i in range(N+2):
    for j in range(len(v)):
        v[j]=min(v[j],f(V[i],t,t+T[i],j))
    t+=T[i]
ans=0
for i in range(len(v)-1):
    ans+=v[i]+v[i+1]
ans/=8
print(ans)

Measured memory_bytes: 43500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    ll d = abs(a - b);
    ll h = v - w;
    if (h <= 0) {
        cout << "NO" << endl;
        return 0;
    }
    ll tt = (d + (h - 1)) / h;
    if (tt <= t) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;

using int64 = long long;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D)) {
    puts("Yes");
  } else {
    puts("No");
  }
}






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

int main(void) {
    int64_t A,B,C,K;

    cin >> A >> B >> C >> K;

    if(A >= K) {
        cout << K << "\n";
    } else if((A + B) >= K) {
        cout << A << "\n";
    } else {
        cout << A - (K - (A + B)) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
#include <climits>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
        // setw(6) << setfill('0')
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << "(" << v.first << ", " << v.second << ")";
    return ostr;
}

vector<string> split(const string &s, char delim) {
    vector<string> result;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
        if (!item.empty()) {
            result.push_back(item);
        }
    }
    return result;
}

int main() {
    vector<int> L(5); rep(i, 5) cin >> L[i];

    reps(1, i, 6) {
        if (L[i-1] != i) {
            cout << i << endl;
            exit(0);
        }
    }
}


Measured memory_bytes: 3620
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    nums = f.read_int_list()

    mi = min(nums)
    ma = max(nums)

    ans = float('inf')
    for i in xrange(mi, ma+1):
        cnt = 0
        for a in nums:
            if i < a:
                cnt += a-i
            elif (i-a)%2 == 0:
                cnt += (i-a)/2
            else:
                cnt += (i-a)/2 + 2

        ans = min(cnt, ans)

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6036
#include <stdio.h>

int heap[2000001];

main() {
  int i, n;

  scanf("%d", &n);

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

  for(i = 1; i < n + 1; i++) {
    if(i == 1) {
      printf("node %d: key = %d, left key = %d, right key = %d, \n", i, heap[i], heap[2 * i], heap[2 * i + 1]);
    }

    else if(i != 1 && (2 * i) > n) {
      printf("node %d: key = %d, parent key = %d, \n", i, heap[i], heap[i / 2]);
    }

    else if(i != 1 && (2 * i + 1) > n && 2 * i <= n) {
      printf("node %d: key = %d, parent key = %d, left key = %d, \n", i, heap[i], heap[i / 2], heap[2 * i]);
    }
    else {
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n", i, heap[i], heap[i / 2], heap[2 * i], heap[2 * i + 1]);
    }
  }
  return 0;
}

Measured memory_bytes: 596
from sys import exit
MOD = 10**9 + 7
L = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
dic = {}
for s in S:
    if not s in dic:
        dic[s] = 1
    else:
        dic[s]+=1
ans =1
for d in dic.keys():
    ans*=dic[d]+1
print((ans-1)%MOD)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
    bool tmp;
    if(a!=b&&w>=v)tmp=false;
    else{
        if((v-w)*t>=abs(a-b))tmp=true;
        else tmp=false;
    }
    if(tmp)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>

using namespace std;

typedef long long ll;

const ll q = 10000000000 + 7;

int main() {
	
	int n;
	cin >> n;
	cout << n * n * n << endl;

	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define X first
#define Y second
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int main()
{
     int op;
     while(cin>>op)
     {
         if(op == 1)
            cout<<"Hello World"<<endl;
         else
         {
             int x,y;
             cin>>x>>y;
             cout<<x+y<<endl;
         }

     }
}












Measured memory_bytes: 256
W = input()
cnt = 0

while True :
    t = input()
    
    if t == "END_OF_TEXT" :
        break
    else :
        T = t.lower()
        T = T.split()
        
        for i in range(len(T)) :
            if T[i] == W :
                cnt += 1
                      
print(cnt)


Measured memory_bytes: 5560
# https://atcoder.jp/contests/abc120/tasks/abc120_b
# B - K-th Common Divisor

A, B, K = gets.chomp.split().map(&:to_i)


num = [A,B].min()
i = num

nums = []

while i != 0
    nums << i if (A % i) == 0 and (B % i) == 0   
    i = i - 1 
end

p nums[K-1]

Measured memory_bytes: 14216
using System;

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            decimal ans = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        ans += Gcd(i, j, k);
                    }
                }
            }

            Console.WriteLine(ans.ToString());
        }


        // ユークリッドの互除法 3
        public static decimal Gcd(decimal a, decimal b, decimal c)
        {
            var gcd2 = Gcd(a, b);
            var gcd3 = Gcd(gcd2, c);
            return gcd3;
        }


        // ユークリッドの互除法 
        public static decimal Gcd(decimal a, decimal b)
        {
            if (a < b)
            {
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }

Measured memory_bytes: 27700
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <tuple>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> h;
	int i,n;
	cin>>n;
	h.resize(n);
	for(i=0;i<n;i++)
		cin>>h[i];
	bool pos = true;
	for(i=(n-2);i>=0;i--)
	{
		if(h[i]<=(h[i+1]))
			continue;
		if((h[i]-1)<=(h[i+1]))
		{
			h[i] = h[i] - 1;
		}
		else
		{
			pos = false;
			break;
		}
	}
	if(pos)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] == S[i + 1]) {
      cout << i + 1 << " " << i + 2 << "\n";
      return 0;
    }
  }
  for (int i = 0; i < S.size() - 2; i++) {
    if (S[i] == S[i + 2]) {
      cout << i + 1 << " " << i + 3 << "\n";
      return 0;
    }
  }
  cout << -1 << " " << -1 << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
  int a[102][102] ={0};
  int b[102][102] ={0};
  long int c;
  int num1,num2,num3;
  cin >> num1>> num2 >> num3;

  for(int i = 0; i < num1 ; i++)
  {
    for(int j = 0; j < num2 ; j++)
    {
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < num2 ; i++)
  {
    for(int j = 0; j < num3 ; j++)
    {
      cin >> b[i][j];
    }
  }
  for(int k = 0 ; k < num1; k ++ )
  {
    for(int i = 0; i < num3 ; i++)
    {
      c = 0;
      for(int j = 0; j < num2; j++)
      {
        c += a[k][j]*b[j][i];
      }
      if(i != 0)cout << ' ';
      cout << c;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(){
	long long n,k,sum1=0,sum2;
	cin >> n >> k;
	if(k%2==0){
		sum1 =(n + k/2)/k;
	}
	sum2 = n/k;
	cout << sum1*sum1*sum1+sum2*sum2*sum2;
}

Measured memory_bytes: 256
n=int(input())
r=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(n)]
b.sort()
for i in range(n):
    target=-1
    for j in range(len(r)):
        if r[j][0]<b[i][0] and r[j][1]<b[i][1]:
            if target==-1 or r[j][1]>r[target][1]:
                target=j
    if target!=-1:
        del r[target]
print(n-len(r))


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	map<int,int> ct;
	for (int i=0; i<m; i++) {
		int l,r; cin>>l>>r;
		ct[l]++; ct[r+1]--;
	}
	int ret=0,cur=0;
	for (int i=1; i<=n; i++) {
		cur+=ct[i];
		if(cur==m)
			ret++;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  string a, b;
  cin >> a >> b;
  a += b;
  int n = stoi(a), m = sqrt(n);
  if (sqrt(n) == m) Yes();
  else No();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

int main() {
    
    ll n, k;
    cin >> n >> k;
    
    ll ret = 0;
    for (ll i = k; i <= n + 1; ++i)
    {
        ll min = ((i - 1) * i) / 2ll;
        ll max = ((2ll * n + 1 - i) * i) / 2ll;
        ret += (max - min + 1ll) % mod;
        ret %= mod;
    }
    
    
    cout << ret << endl;

    
    return 0;
}

Measured memory_bytes: 3180
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmin(a,b) a=min(a,b);
#define N 100010
vector<P> g[2*N];
ll d[2*N],n,h,w;

ll mi[2];
bool dfs(ll x,ll dis,ll col){
    if(d[x]!=-1e17){
	if(d[x]!=dis)return 0;
	return 1;
    }//cout<<"#"<<x<<" "<<dis<<" "<<col<<endl;
    d[x]=dis; chmin(mi[col],dis);
    for(auto y:g[x]){
	if(!dfs(y.first,y.second-dis,col^1))return 0;
    }
    return 1;
}

int main(){
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
	ll a,b,c;cin>>a>>b>>c;
	b+=N;
	g[a].push_back(make_pair(b,c));
	g[b].push_back(make_pair(a,c));
    }
    for(int i=0;i<2*N;i++)d[i]=-1e17;
    bool ok=1;
    for(int i=0;i<2*N;i++){
	if(d[i]!=-1e17)continue;
	mi[0]=mi[1]=1e17;
	ok&=dfs(i,1,0);
	if(mi[0]+mi[1]<0)ok=0;//cout<<"%"<<mi[0]<<" "<<mi[1]<<endl;
    }
    cout<<(ok?"Yes":"No")<<endl;
    return 0;
}




Measured memory_bytes: 16384
<?php
    fscanf(STDIN,"%d%d%d",$A,$B,$C);
    
    $K = intval(trim(fgets(STDIN)));
    
    $count=0;
    while($A >= $B){
        $B = 2*$B;
        $count++;
    }
    
    while($B >= $C){
        $C = 2*$C;
        $count++;
    }
    
    if($count<=$K){
        echo "Yes";
    }else{
        echo "No";
    }

?>

Measured memory_bytes: 16216
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define modulo 1000000007
#define INF 100000000000000000
#define int long long int
using namespace std;
int32_t main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	string s;
	cin >> n;
	cin >> s;
	if(n%2==1){
	cout << "No";
	return 0;
		}
	for(int i=0;i<n/2;i++){
	if(s[i]!=s[i+(n/2)]){
	cout << "No";
	return 0;
	}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
S = []
for i in range(n):
    s = list(input())
    S.append(s)
ans = []
first = list(S[0])

for i in range(len(first)):
    flag = True
    for j in range(1,n):
        if first[i] not in S[j]:
            flag = False
    if flag:
        ans.append(first[i])
        for h in range(1,n):
            S[h].remove(first[i])
ans.sort()
print(''.join(ans))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class129
    {
        static void Main()
        {
            var A = new int[32] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
            var K = int.Parse(Console.ReadLine());
            Console.WriteLine(A[K-1]);
        }
    }
}


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

bool nonprime[1000001] = {};
int accum[1000001] = {};
int scoresheet[1000001];

int main(){
    nonprime[0] = nonprime[1] = true;
    for(int i = 2; i <= 1000000; i++){
        if(!nonprime[i]){
            for(int j = i+i; j <= 1000000; j+=i){
                nonprime[j] = true;
            }
        }
    }

    for(int i = 2; i <= 1000000; i++){
        if(nonprime[i-1]){
            accum[i] = accum[i-1];
        }else{
            accum[i] = accum[i-1] + 1;
        }
    }

    while(1){
        int n;
        cin >> n;
        if(n == 0)  break;

        for(int i = 0; i <= 1000000; i++)   scoresheet[i] = 0;

        set<int> result;
        int ans = 0;

        for(int i = 0; i < n; i++){
            int p, m;
            cin >> p >> m;

            int cnt = accum[min(p+m, 1000000)] - accum[max(0, p-m)];
            if(p+m <= 1000000 && !nonprime[p+m])    cnt++;

            result.insert(p);
            scoresheet[p] += cnt;

            if(cnt == 0)    ans--;
            else            ans += cnt-1;
        }
/*
        for(set<int>::iterator it = result.begin(); it != result.end(); it++){
            int x = scoresheet[*it];
            if(x == 0)   ans--;
            else         ans += x-1;
        }
*/
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 11936
#include <iostream>
#include <stdio.h>
#include <string.h>
#define MAX_N 2005

using namespace std;

int n;
int pw[MAX_N];
int pb[MAX_N];
int dp[MAX_N][MAX_N];
int costw[MAX_N][MAX_N];
int costb[MAX_N][MAX_N];

void read()
{
	scanf("%d",&n);
	char s[4]; int x;
	for(int i=1;i<=(n<<1);i++)
	{
		scanf("%s%d",s,&x);
		if(s[0]=='W') pw[x]=i;
		else pb[x]=i;
	}
}

void cal_c()
{
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=i;j++) costw[i][0]+=(pw[j]>pw[i+1]);
		for(int j=1;j<=n;j++) costw[i][j]=costw[i][j-1]+(pb[j]>pw[i+1]);
	}
	for(int j=0;j<n;j++)
	{
		for(int i=1;i<=j;i++) costb[0][j]+=(pb[i]>pb[j+1]);
		for(int i=1;i<=n;i++) costb[i][j]=costb[i-1][j]+(pw[i]>pb[j+1]);
	}
}

void cal_dp()
{
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(i) dp[i][j]=min(dp[i][j],dp[i-1][j]+costw[i-1][j]);
			if(j) dp[i][j]=min(dp[i][j],dp[i][j-1]+costb[i][j-1]);
		}
	}
}

void work()
{
	cal_c();
	cal_dp();
	printf("%d\n",dp[n][n]);
}

int main()
{
	read();
	work();
}


Measured memory_bytes: 47360
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

template<unsigned P> struct ModInt {
  using M = ModInt;
  unsigned v;
  ModInt() : v(0) {}
  ModInt(auto x) : v(x >= 0 ? x % P : (P - -x % P) % P) {}
  constexpr ModInt(unsigned v, int) : v(v) {}
  static constexpr unsigned p() { return P; }
  M operator+() const { return *this; }
  M operator-() const { return {v ? P - v : 0, 0}; }
  explicit operator bool() const noexcept { return v; }
  bool operator!() const noexcept { return !(bool) *this; }
  M operator*(M r) const { return M(*this) *= r; }
  M operator/(M r) const { return M(*this) /= r; }
  M operator+(M r) const { return M(*this) += r; }
  M operator-(M r) const { return M(*this) -= r; }
  bool operator==(M r) const { return v == r.v; }
  bool operator!=(M r) const { return !(*this == r); }
  M& operator*=(M r) { v = (uint64_t) v * r.v % P; return *this; }
  M& operator/=(M r) { return *this *= r.inv(); }
  M& operator+=(M r) { if ((v += r.v) >= P) v -= P; return *this; }
  M& operator-=(M r) { if ((v += P - r.v) >= P) v -= P; return *this; }
  M inv() const {
    int a = v, b = P, x = 1, u = 0;
    while (b) {
      int q = a / b;
      swap(a -= q * b, b);
      swap(x -= q * u, u);
    }
    assert(a == 1);
    return x;
  }
  M pow(auto n) const {
    if (n < 0) return pow(-n).inv();
    M res = 1;
    for (M a = *this; n; a *= a, n >>= 1) if (n & 1) res *= a;
    return res;
  }
  friend M operator*(auto l, M r) { return M(l) *= r; }
  friend M operator/(auto l, M r) { return M(l) /= r; }
  friend M operator+(auto l, M r) { return M(l) += r; }
  friend M operator-(auto l, M r) { return M(l) -= r; }
  friend ostream& operator<<(ostream& os, M r) { return os << r.v; }
  friend istream& operator>>(istream& is, M& r) { lint x; is >> x; r = x; return is; }
  friend bool operator==(auto l, M r) { return M(l) == r; }
  friend bool operator!=(auto l, M r) { return !(l == r); }
};
using Mint = ModInt<1000003>;
V<Mint> fact, ifact;
void init(int n, int B = 2) {
  fact.resize(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = i * fact[i - 1];
  }
  ifact.resize(n + 1);
  ifact[n] = fact[n].inv();
  for (int i = n; i > 0; --i) {
    ifact[i - 1] = i * ifact[i];
  }
}


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  init(1000002);
  int q; cin >> q;
  while (q--) {
    Mint x, d; int n; cin >> x >> d >> n;
    if (!x or !d) cout << x.pow(n) << '\n';
    else {
      x /= d;
      Mint res;
      if (x.v + n - 1 >= Mint::p()) res = 0;
      else res = fact[x.v + n - 1] * ifact[x.v - 1];
      res *= Mint(d).pow(n);
      cout << res << '\n';
    }
  }
}

Measured memory_bytes: 8704
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	ks := make([]int, n)
	ass := make([][]int, n)
	for i := range ks {
		var k int
		fmt.Scan(&k)
		ass[i] = make([]int, k)
		for j := range ass[i] {
			fmt.Scan(&ass[i][j])
		}
	}

	counter := make(map[int]int)
	for _, as := range ass {
		for _, a := range as {
			counter[a]++
		}
	}

	cnt := 0
	for _, num := range counter {
		if num == n {
			cnt++
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  ll sum = 100;
  ll x;
  cin >> x;
  ll ans = 0;
  while(sum < x) {
    ans++;
    sum *= 1.01;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
using namespace std;

int main() {
  long long x, n=100;
  scanf("%lld", &x);
  int i=1;
  while(true) {
    n += n / 100;
    if(n >= x) {
      printf("%d", i);
      break; 
    }
    i++;
  }
  return 0;
}

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

int main(){
  int a,b,c,k;
  cin >>a >>b >>c >>k;
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}

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

string f(ll n){
  if(n==0) return "";
  n--;
  return f(n/26) + string(1,'a'+n%26);
}

int main(){
  ll n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n,x;
    cin>>n>>x;
    int minw=INF;
    for(int i=0;i<n;i++){
        int m;
        cin>>m;
        minw=min(m,minw);
        x-=m;
    }
    cout<<x/minw+n<<endl;

    return 0;
}




Measured memory_bytes: 764
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int mod = 998244353, gen = 3;

inline int Mul(int a, int b) {
  return (long long)a * b % mod;
}

inline int Add(int a) {
  return a >= mod ? a - mod : a;
}

inline int Sub(int a) {
  return a < 0 ? a + mod : a;
}

int Pow(int a, int b) {
  int c = 1;
  for (; b; b >>= 1) {
    if (b & 1) c = Mul(c, a);
    a = Mul(a, a);
  }
  return c;
}

void FFT(int *a, int n) {
  for (int i = 0; i < 1 << n; ++i) {
    int j = 0, x = i;
    for (int k = 0; k < n; ++k) {
      j = (j << 1) | (x & 1);
      x >>= 1;
    }
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    int root = Pow(gen, (mod - 1) / (2 << i));
    for (int j = 0; j < 1 << n; j += 2 << i) {
      int w = 1, *l = a + j, *r = a + j + (1 << i);
      for (int k = 0; k < 1 << i; ++k, w = Mul(w, root)) {
        int t = Mul(w, r[k]);
        r[k] = Sub(l[k] - t);
        l[k] = Add(l[k] + t);
      }
    }
  }
}

void IFFT(int *a, int n) {
  reverse(a + 1, a + (1 << n));
  FFT(a, n);
  int inv = Pow(1 << n, mod - 2);
  for (int i = 0; i < 1 << n; ++i) {
    a[i] = Mul(a[i], inv);
  }
}

void Conv(int *a, int *b, int n) {
  FFT(a, n);
  if (a != b) {
    FFT(b, n);
  }
  for (int i = 0; i < 1 << n; ++i) {
    a[i] = Mul(a[i], b[i]);
  }
  if (a != b) {
    IFFT(b, n);
  }
  IFFT(a, n);
}

void PowC(int *a, int *b, int len, int exp) {
  int n = 0;
  while (1 << n < len << 1) {
    ++n;
  }
  memset(b, 0, (1 << n) * sizeof(int));
  b[0] = 1;
  for (; exp; exp >>= 1) {
    if (exp & 1) {
      Conv(b, a, n);
      for (int k = len; k < 1 << n; ++k) {
        b[k] = 0;
      }
    }
    Conv(a, a, n);
    for (int k = len; k < 1 << n; ++k) {
      a[k] = 0;
    }
  }
}

const int maxn = 10000;

char s1[maxn + 1], s2[maxn + 1];
int fact[maxn + 1], ifact[maxn + 1];
int p[1 << 15], q[1 << 15];

int main(void) {
  scanf("%s%s", s1, s2);
  int a = 0, b = 0;
  for (int i = 0; s1[i]; ++i) {
    if (s1[i] == '1' && s2[i] == '1') {
      ++a;
    } else if (s1[i] == '1') {
      ++b;
    }
  }
  fact[0] = 1;
  for (int i = 1; i <= a + b; ++i) {
    fact[i] = Mul(fact[i - 1], i);
  }
  ifact[a + b] = Pow(fact[a + b], mod - 2);
  for (int i = a + b; i >= 1; --i) {
    ifact[i - 1] = Mul(ifact[i], i);
  }
  for (int i = 0; i <= a; ++i) {
    p[i] = ifact[i + 1];
  }
  PowC(p, q, a + 1, b);
  int sum = 0;
  for (int i = 0; i <= a; ++i) {
    sum = Add(sum + q[i]);
  }
  sum = Mul(sum, Mul(fact[a + b], Mul(fact[a], fact[b])));
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.second > b.second;
}

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

    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    sort(all(A));
    vector<pair<int, int>> BC(M);
    REP(i, M) {
        cin >> BC[i].first >> BC[i].second;
    }
    sort(BC.begin(), BC.end(), comp);
    
    int bidx = 0, cidx = 0;
    ll sum = 0;
    REP(i, N) {
        if (bidx < M) A[i] = max(A[i], BC[bidx].second);
        cidx++;
        if (cidx == BC[bidx].first) {
            bidx++;
            cidx = 0;
        }
        sum += A[i];
    }
    
    
    cout << sum << endl;
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 998244353;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

ll rsq (vector <ll> & tree, ll l, ll r)
{
	ll i, j, n = tree.size ()/2;
	l = max (0LL, l);
	r = max (0LL, r);
	ll ret = 0;
	for (l += n, r += n; l < r; l >>= 1, r >>= 1)
	{
		if (l&1) ret += tree[l++], ret %= MOD;
		if (r&1) ret += tree[--r], ret %= MOD;
	}
	return ret;
}

void upd (vector <ll> & tree, ll p, ll v)
{
	ll i, n = tree.size ()/2;
	tree[n + p] = v;
	for (i = (n + p) >> 1; i > 0; i >>= 1)
		tree[i] = tree[i<<1] + tree[i<<1|1],
		tree[i] %= MOD;
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n, k;
	cin >> n >> k;
	vector <ll> dp (n), tree (2*n, 0);
	vector <pair <ll, ll>> qr (k);
	trav (p, qr) cin >> p.f >> p.s;
	sort (qr.begin (), qr.end ());
	dp[0] = 1;
	tree[n] = 1;
	for (i = n; i > 0; i >>= 1)
		tree[i] = 1;
	for (i = 1; i < n; ++i)
	{
		for (j = 0; j < k; ++j)
			dp[i] += rsq (tree, i - qr[j].s, i - qr[j].f + 1),
			dp[i] %= MOD;
		upd (tree, i, dp[i]);
	}
	//trav (a, dp) cout << a << '\n';
	cout << dp[n - 1] << '\n';

	return 0;
}



Measured memory_bytes: 7940
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
 
using namespace std;
 
typedef long long ll;

#define ff first
#define se second
#define all(a) begin(a),end(a)
typedef vector<int> VI;
const ll mod = 1e9 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    VI a;
    for(int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    sort(all(a));
    int res = 0;
    for (int i = 0; i < k; i++) {
        res += a[i];
    }
    cout << res;
    return;
}

// int Depth(BitTree T) {
//     int l_depth = 0, r_depth = 0;
//     // if (root == NULL) return 0;
//     else {
//         l_depth = Depth(T.lrchild) + 1;
//         r_depth = Depth(T.rchild) + 1;
//     }
//     return l_depth > r_depth ? l_depth : r_depth;
// }

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    int sum = 0;
    for (int y = 1; y <= N; y++)
    {
        int x;
        cin >> x;
        sum += 2 * min(x, K-x);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256