akhauriyash/Code-Regression huggingface dataset:
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

ll gcd(ll a,ll b)
{
	if (b==0) return a;
	return gcd(b,a%b);
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=20010;
int n,k;
int dp[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>k>>n;
	for (int i=1;i<=2*k;++i) dp[i]=MOD;
	while (n--)
	{
		int a,b;
		cin>>a>>b;
		a=min(a,k);
		for (int i=a;i<=2*k;++i) dp[i]=min(dp[i],dp[i-a]+b);
	}
	int mi=MOD;
	for (int i=k;i<=2*k;++i) mi=min(mi,dp[i]);
	cout<<mi;
}





Measured memory_bytes: 384
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


string solve(string s){
    string ret="";
    char data[20][10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    int d[20]={0,5,3,3,3,3,3,4,3,4};
    
    string tmp="";
    rep(i,s.sz){
        if(s[i]!='0'){
            tmp+=s[i];
        }
        else{
            if(tmp.sz>0){
                ret+=data[ tmp[0]-'0' ][(tmp.sz-1)%d[tmp[0]-'0']];
                tmp.clear();
            }
        }
    }
    return ret;
    
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        cout<<solve(s)<<endl;
        
    }
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=998244353;
const ll mod=998244353;
signed main(){
    ll h,w,n;cin>>h>>w>>n;
    vector<vector<ll> >a(w);
    set<pll>st;
    rep(i,n){
        ll x,y;cin>>x>>y;
        x--;y--;
        st.insert(mp(x,y));
        a[y].pb(x);
    }
    rep(i,w){
        a[i].pb(h);
        st.insert(mp(i,h));
        sort(all(a[i]));
    }
    ll nx=0,ny=0;
    ll ans=h;
    while(nx<h&&ny<w){
        if(st.find(mp(nx+1,ny))!=st.end()){
            ans=min(ans,nx+1);
            break;
        }
        ll p=*upper_bound(all(a[ny]),nx);
        ans=min(ans,p);
        nx++;
        if(st.find(mp(nx,ny+1))==st.end()){
            ny++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 40188
import java.util.Scanner;

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

		String word=input.nextLine();
		
		StringBuilder sb=new StringBuilder(word);
		if(word.length()==2)
			System.out.println(word);
		else
			System.out.println(sb.reverse());
	
	}
	


}



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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    FOR(i, h) cin >> c[i];

    int sol = 0;
    FOR(mask, 1 << (h+w)){
        int cnt = 0;
        FOR(i, h){
            if ((mask >> i)&1) continue;
            FOR(j, w){
                if ((mask >> h+j)&1) continue;
                cnt += c[i][j] == '#';
            }
        }
        sol += cnt == k;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



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

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

#define INF 2e9
#define ALL(v) v.begin(), v.end()

int main(){
    int n;
    cin>>n;
    int X[n];
    int b=0;
    int s=101;
    rep(i,n){
        int x;
        cin>>x;
        X[i]=x;
        if(x>b){
            b=x;
        }
        if(x<s){
            s=x;
        }
    }
    int ans=10000001;
    for(int i=s;i<=b;i++){
        int sum=0;
        rep(j,n){
            int distance=pow((X[j]-i),2);
            sum+=distance;
        }
        if(sum<ans){
            ans=sum;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
template<class T>bool chmaxj(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
void YesNo(bool y) { cout << (y ? "Yes" : "No") << endl; } //true==yes


#define INF 21474836

//////////////////////////////////////////////////////////////


int main() {

	string s;
	cin >> s;
	YesNo(s[2] == s[3] && s[4] == s[5]);

	return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  // int n=6, m=10;
  // auto c=new int[][](n, m);
  // auto dir=[[-1, -1], [-1, 0], [-1, 1], [0, 1], [1, 1], [1, 0], [1, -1], [0, -1]];
  // foreach(i; 0..n)foreach(j; 0..m){
  //   c[i][j]^=1;
  //   foreach(d; dir){
  //     auto ni=i+d[0], nj=j+d[1];
  //     if(ni<0 || ni>=n || nj<0 || nj>=m) continue;
  //     c[ni][nj]^=1;
  //   }
  // }

  // foreach(i; 0..n) writeln(c[i]);

  // writeln(313*2+1591*2);

  long n, m; rd(n, m);
  if(n==1 && m==1) writeln(1);
  else if(n==1) writeln(m-2); 
  else if(m==1) writeln(n-2);
  else writeln(n*m-((n-1)*2+(m-1)*2));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int k;
    static Set<String> set;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        k = sc.nextInt();
        set = new TreeSet<String>();
        int n = str.length();
        
        String[] array = new String[n];
        for (int i = 0; i < n; i++) {
            array[i] = String.valueOf(str.charAt(i));
        }
        
        solve("", array);
        
        int i = 1;
        for (String s : set) {
            if (i == k) {
                System.out.println(s);
                break;
            }
            i++;
        }

    }
    
    public static void solve(String str, String[] array) {
        Set<String> privateSet = new TreeSet<String>();
        
        for (int i = 0; i < array.length - (str.length() - 1); i++) {
            String str2 = "";
            for (int j = i; j < i + str.length(); j++) {
                str2 += array[j];
            }
            
            if (str.equals(str2) && i + str.length() < array.length) {
                privateSet.add(str2 + array[i + str.length()]);
            }
        }
        
        for (String s : privateSet) {
            set.add(s);
            if (set.size() >= k) return;
            solve(s, array);
        }
    }
}


Measured memory_bytes: 28628
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	inputArray := strings.Split(scanner.Text(), " ")
	x, _ := strconv.Atoi(inputArray[0])
	y, _ := strconv.Atoi(inputArray[1])
	cnt := 0

	for x <= y {
		cnt++
		x = x * 2
	}
	fmt.Println(cnt)
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int i=1;
    while(i>0){
        int x;
        cin>>x;
        if(x==0){
            break;
        }
        else{
            cout<<"Case "<<i<<": "<<x<<endl;
            i++;
        }
    }
}


Measured memory_bytes: 3008
#include <iostream>

using namespace std;

int main()
{
	int n;
	
	while (cin >> n){
		int snum = n % 39;
		
		cout << "3C";
		if (snum == 0){
			snum = 39;
		}
		else if (snum < 10){
			cout << '0';
		}
		cout << snum << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    if(x < 2 || 2*n-2 < x){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    int m = 2 * n - 1;
    vector<int> a(m, -1);
    a[n-1] = x;
    a[n-2] = x - 1;
    a[n] = x + 1;
    int num = 1;
    rep(i,m){
        if(a[i] != -1) continue;
        while(x-1 <= num && num <= x+1) ++num;
        a[i] = num++;
    }
    rep(i,m) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4024
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))


ans = 1
INF = 1000000000000000000

if (0 in a):
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if(ans > INF):
        print(-1)
        sys.exit()

print(ans)


Measured memory_bytes: 22952
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
string s, p;
signed main() {
	ld a, b, c, d;
	cin >> a >> b >> c;
	//三角形の面積 S、周の長さ L, a を底辺としたときの高さ h
	printf("%.10LF\n%.10LF\n%.10LF\n", a*b*sin(c / 180 * M_PI) / 2, a + b + sqrt(a*a + b * b - 2 * a*b*cos(c / 180 * M_PI)), b*sin(c / 180 * M_PI));
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 1;
    
    if (b != a) {
        ans++;
    }
    
    if ((c != a) && (c != b)) {
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Die Game
public class Main{

	static class Dice <T>{
		public T[] id;
			enum Face{TOP, BOTTOM, FRONT, BACK, RIGHT, LEFT};
			
			public T get(Face f){
				return id[f.ordinal()];
			}
			
			public Dice<T> copy(){
				return new Dice<T>(id[0], id[1], id[2], id[3], id[4], id[5]);
			}
			
			public Dice() {
				@SuppressWarnings("unchecked")
				T[] tid = (T[])new Object[6];
				id = tid;
			}
			
			public Dice(T top, T bottom, T front, T back, T right, T left) {
				@SuppressWarnings("unchecked")
				T[] tid = (T[])new Object[6];
				id = tid;
				id[Face.TOP.ordinal()] = top;
				id[Face.BOTTOM.ordinal()]= bottom;
				id[Face.FRONT.ordinal()] = front;
				id[Face.BACK.ordinal()] = back;
				id[Face.RIGHT.ordinal()] = right;
				id[Face.LEFT.ordinal()] = left;
			}
			
			//true: Xツ篠イツ陛サツ古シツづ可偲ィツ前ツづ可転ツつェツつキ
			//false: Xツ篠イツ陛サツ古シツづ可可慊づ可転ツつェツつキ
			void rollX(boolean isReverse) {
				if(!isReverse) roll(Face.TOP, Face.FRONT, Face.BOTTOM, Face.BACK);
				else roll(Face.TOP, Face.BACK, Face.BOTTOM, Face.FRONT);
			}
			
			//true: Yツ篠イツ陛サツ古シツづ可債カツづ鳴転ツつェツつキ
			//false: Yツ篠イツ陛サツ古シツづ可右ツづ鳴転ツつェツつキ
			void rollY(boolean isReverse) {
				if(!isReverse) roll(Face.TOP, Face.LEFT, Face.BOTTOM, Face.RIGHT);
				else roll(Face.TOP, Face.RIGHT, Face.BOTTOM, Face.LEFT);
			}
			
			//true: Zツ篠イツ陛サツ古シツづ可右ツづ鳴嘉アツつキ
			//false: Zツ篠イツ陛サツ古シツづ可債カツづ鳴嘉アツつキ
			void rollZ(boolean isReverse) {
				if(!isReverse) roll(Face.FRONT, Face.LEFT, Face.BACK, Face.RIGHT);
				else roll(Face.FRONT, Face.RIGHT, Face.BACK, Face.LEFT);
			}
			
			private void roll(Face w, Face x, Face y, Face z) {
				T tmp = id[w.ordinal()];
				id[w.ordinal()] = id[x.ordinal()];
				id[x.ordinal()] = id[y.ordinal()];
				id[y.ordinal()] = id[z.ordinal()];
				id[z.ordinal()] = tmp;
			}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		Dice<Integer> dice = new Dice<Integer>(1, 6, 5, 2, 4, 3);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			Dice<Integer> d = dice.copy();
			while(n--!=0){
				String s = sc.next();
				if("north".equals(s))d.rollX(false);
				else if("south".equals(s))d.rollX(true);
				else if("east".equals(s))d.rollY(false);
				else d.rollY(true);
			}
			System.out.println(d.get(Dice.Face.TOP));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 0
#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>;

ll dp[101][100001];

int main() {
    int N,W;
    cin >> N >> W;
    vector<int> w(N),v(N);
    // vector< vector<int> > dp(N);
    
    rep(i,N){
        cin >> w[i] >> v[i];    
    }
    
    rep(i,100001){
        dp[0][i] = 1001001001001001001;
    }
    dp[0][0] = 0;
    rep(i,N){
        rep(j,100001){
            if(j < v[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            }
        }      
    }
    int ans = 0;
    rep(i,100001){
        if(dp[N][i] <= W){
            ans = i;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 82516
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
#define VMAX 200000+10
const int MOD = 1000000007;
const ll INF = 50000000000000;
typedef std::pair<int,int> P;
struct edge {
	ll to, cost;
	bool operator>(const edge &s) const {
		return cost > s.cost;
	}
};
    ll N,A[3][500];
	ll ans=-1,temp;
int main(){
	cin>>N;
	REP(j,2)REP(i,N)cin>>A[j][i];
	REP(i,N){
		if(i==0){
			REP(i,N)temp+=A[1][i];
		}else{
			temp-=A[1][i-1];
		}
		temp+=A[0][i];
		ans=max(temp,ans);
	}

    cout<<(ans)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<iomanip>
#include<cstring>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int INF=0x3f3f3f3f;
int mode=1e9+7;
double arr[200020];
double brr[200020];
int main()
{
	int n,k;
	cin>>n>>k;
	int a;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		arr[i]=(a+1)/2.0;
		brr[i+1]=brr[i]+arr[i];
	}
	double maxn=0;
	for(int i=0;i<=n-k;i++)
	{
		maxn=max(maxn,brr[i+k]-brr[i]);
	}
	printf("%.12lf\n",maxn);
	return 0;
}

Measured memory_bytes: 3328
n=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(n):
    for j in range(8):
        if (j*400)<=A[i]<((j+1)*400):
            B.append(j)
    if 3200<=A[i]:
        C.append(i)
print(max(len(set(B)),1),len(set(B))+len(C))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  ll h,w;
  cin >> h >> w;
  if(h == 1) cout << 1 << endl;
  else if(w == 1) cout << 1 << endl;
  else if(h%2 == 0)
  {
      cout << h * w / 2 << endl;
  }
  else
  {
      int l = w/2, H = (h + 1)/2;
      cout << H * w - l << endl;
  }
  return 0;
}


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

using namespace std;

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

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> a(n);
    for (auto &c : a) cin >> c;
    int ans = 0;
    for (int mask1 = 0; mask1 < (1 << n); mask1++) {
        for (int mask2 = 0; mask2 < (1 << m); mask2++) {
            vector<string> b = a;
            for (int i = 0; i < n; i++) {
                if (mask1 & (1 << i)) {
                    for (int j = 0; j < m; j++) {
                        b[i][j] = 'r';
                    }
                }
            }
            for (int i = 0; i < m; i++) {
                if (mask2 & (1 << i)) {
                    for (int j = 0; j < n; j++) {
                        b[j][i] = 'r';
                    }
                }
            }
            int cnt = 0;
            for (auto &c : b) {
                for (auto &l : c) {
                    cnt += (l == '#');
                }
            }
            ans += cnt == k;
        }
    }
    cout << ans;
    return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int min = 999999999, max = a[0];
	for (int i = 0; i < n; i++) {
		if (a[i] < min) min = a[i];
		if (a[i] > max) max = a[i];
	}
	cout << max - min;
     return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MOD ((ll)(1e9+7))
#define HS1 ((ll)(137))
#define HS2 ((ll)(1e9+9))
#define ARRS ((ll)(1e6+900))
#define pb push_back
#define mid ((l+r)>>1)
#define PI 3.14159265358979323846




int main(){
	ll n,k,p,d;
	cin>>n>>k>>p;
	if(n==1){
		cin>>k;
		cout<<abs(k-p);
		return 0;

	}
	for(int i=0; i<n-2; i++){
		cin>>k;
	}
	cin>>k>>d;
	cout<<max(abs(k-d),abs(p-d));
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

#define debug(x) cout << #x << ": " << x << endl;
#define ll long long

#define mod 998244353

ll inv[1<<20]; // ith index will store (1/i)%mod

void populate(int n) {
    inv[1] = 1;
    for(int i = 2;i <= n;i++) {
        inv[i] = mod-((inv[mod%i]*(mod/i))%mod);
    }
}

int N, MV = 1000000;
ll A[1<<20], freq[1<<20], sum[1<<20], answer = 0;
vector<int> divs[1<<20];

void populate_divs() {
  for(int i = 1;i <= MV;i++) {
    int num = i;
    while(num <= MV) {
      divs[num].push_back(i);
      num += i;
    }
  }
}

int main() {
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);

  cin >> N;
  for(int i = 0;i < N;i++) {
    cin >> A[i];
    freq[A[i]]++;
  }

  populate(MV);
  populate_divs();

  for(ll d = MV;d >= 1;d--) {
      ll num = d;
      ll sum_m = 0;
      ll sq_sum = 0;

      while(num <= MV) {
        sum_m = (sum_m + freq[num]*num)%mod;
        sq_sum = (sq_sum + freq[num]*((num*num)%mod))%mod;
        num += d;
      }

      ll a = (sum_m*sum_m)%mod;
      ll b = (a - sq_sum + mod)%mod;
      ll c = (b*inv[2])%mod;

      //if(d == 1) {debug(a);debug(b);debug(c);debug(sum[d])};

      sum[d] = (c + mod - sum[d])%mod;
      answer = answer + ((sum[d]*inv[d])%mod);
      answer %= mod;

      //if(d == 1) {debug(answer)};

      for(int i = 0;i < divs[d].size();i++) {
        ll dv = divs[d][i];
        sum[dv] = (sum[dv]+sum[d])%mod;
      }
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 142464
const int isDebugMode = 1;
#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;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#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 pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
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> long long recgcd(T1 a, T2 b){return a % b ? recgcd(b , a % b) : b;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

struct SegmentTree{
private:
    ll unit = 0;
    ll op(ll a,ll b){return a + b;}
    ll n;
    vector<ll> node;

public:
SegmentTree(vector<ll> v){
    ll sz = (ll)v.size();
    n = 1;while(n<sz) n *= 2;
    node.resize(2*n-1,unit);
    for(ll i=0;i<sz;i++) node[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--) node[i]=op(node[2*i+1],node[2*i+2]);
}

    void update(ll x,ll val){
        x += n-1;
        node[x] = val;
        while(x>0){
            x = (x-1)/2;
            node[x] = op(node[2*x+1],node[2*x+2]);
        }
    }

    ll query(ll a,ll b,ll k = 0,ll l = 0,ll r = -1){
        if (r<0) r = n;
        if (r<=a || b<=l) return unit;
        if (a<=l && r<=b) return node[k];
        ll vl = query(a,b,2*k+1,l,(l+r)/2);
        ll vr = query(a,b,2*k+2,(l+r)/2,r);
        return op(vl,vr);
    }
};

int main(){
    ll N; cin >> N;
    string S; cin >> S;
    vector<ll> c(N);
    rep(i, N) c[i] = S[i] == 'W';
    SegmentTree tree(c);
    ll ans = INF;
    rep(i, N + 1)chmin(ans, max(tree.query(0, i), N - i - tree.query(i, N)));
    pt(ans);
}

Measured memory_bytes: 10724
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int n;
	cin >> n;
	vector<int>p(n);
	double q;
	for (int a = 0; a < n; a++) { cin >> p[a];}
	std::sort(p.begin(), p.end());
	q = p[0];
	for (int a = 1; a < n; a++) { q = (q + p[a]) / 2.0; }
	cout << q;
	return 0;
}

Measured memory_bytes: 256
#B - Simplified mahjong
n=int(input())
modlists=[0]*(n+1)
for  i in range(n):
    s=int(input())
    modlists[i]=s
add=0
lefted=0
for i in range(n):
    if modlists[i]!=0:
        add+=modlists[i]
    elif modlists[i]==0:
        lefted+=add%2
        add=0
sums=sum(modlists)
print((sums-lefted)//2)


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

int main() {
  int a,b,cnt;cin >> a >> b;
  if(a%2!=0){
    cnt = a/2+1;
  }else{
    cnt = a/2;
  }

  if(cnt<b){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(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)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

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

    vector<pair<int,int>> vec(n);
    

    REP(i,n){
        cin >> vec[i].second >> vec[i].first;
    }

    SORT(vec);
    int s = 0;
    REP(i,n){
        s += vec[i].second;

        if(s > vec[i].first){
            cout << "No" <<endl;
            return 0;
        }
    }
    cout << "Yes" <<endl;
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, mod = 1000000007;

int n, m;
int a[N];
char s[N];

int main()
{
    n = gi(), m = gi();
    LL sum = 0;
    for (int i = 1; i <= m; i+=1) a[i] = gi(), sum += a[i];
    cout << max(n - sum, 1ll * (-1)) << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e7;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, m, q, ans, a[N], cnt;
string s;
vector < ll > v, v1;
set< char > st;
int main(){
    TIME
    cin >> s;
    for( auto it:s )
        st.insert(it);
    if( st.size() == 1 )
        cout << "No";
    else
        cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N, M;
	cin >> N >> M;

	vector<ll> divisors;

	for (ll i = 1; i <= sqrt(M); ++i)
	{
		if (M%i == 0)
		{
			if (M / i < i) break;
			if (M / i == i)
			{
				divisors.push_back(i);
				break;
			}

			divisors.push_back(i);
			divisors.push_back(M / i);
		}
	}

	ll ans = 0;
	ll tmp = M / N;
	for (auto& d : divisors)
	{
		if (d <= tmp)
		{
			chmax(ans, d);
		}
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n,k,s;cin >> n >> k >> s;
    vector<int> ans(n);
    for(int i=0;i<k;i++) ans[i]=s;
    if(s==1000000000){
        for(int i=k;i<n;i++) ans[i]=1;
    }
    else{
        for(int i=k;i<n;i++) ans[i]=s+1;
    }
    for(int i=0;i<n;i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();
        int[] H = new int[N];
        for (int i = 0; i < H.length; ++i) {
            H[i] = sc.nextInt();
        }

        System.out.println(solve(H, T, A));

        sc.close();
    }

    static int solve(int[] H, int T, int A) {
        return IntStream.range(0, H.length).boxed().min((i1, i2) -> Integer
                .compare(Math.abs(1000 * T - 6 * H[i1] - 1000 * A), Math.abs(1000 * T - 6 * H[i2] - 1000 * A))).get()
                + 1;
    }
}

Measured memory_bytes: 39432
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    bool f = false;
    double d = 1;
    for(;ch != '-' && (ch < '0' || ch > '9');ch = getchar());
    if(ch == '-'){f = true; ch = getchar();}
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
    if(ch == '.') for(ch = getchar();ch >= '0' && ch <= '9';ch = getchar()) x += (ch - '0') * (d *= 0.1);
    if(f) x = -x;
}
template<typename T>
inline bool chkmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chkmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
int n, m;
int main(){
    read(n); read(m);
    printf("%d\n", n * (n - 1) + m * (m - 1) >> 1);
}

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

typedef long long ll;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;

	int cnt=0, placeB=1;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'a') {
			if (cnt < (A + B)) {
				cnt++;
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (S[i] == 'b') {
			if (cnt < (A + B)) {
				if (placeB <= B) {
					cnt++;
					placeB++;
					cout << "Yes" << endl;
				}
				else {
					cout << "No" << endl;
				}
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}


}

Measured memory_bytes: 896
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	x := nextInt()

	sum := x
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		m := nextInt()
		slice[i] = m
		sum -= m
	}

	sort.Ints(slice)
	// fmt.Println(slice)
	count := n
	// fmt.Println(count)
	for sum > 0 {
		sum -= slice[0]
		if sum < 0 {
			break
		}

		count++

		// fmt.Printf("sum = %d\n", sum)
	}

	fmt.Println(count)
}


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

h = []

for i in range(N):
    tmp = int(input())
    h.append(tmp)
    
h.sort()

ans = 2*10**9

for i in range(N-K+1):
    now = abs(h[i+K-1] - h[i])
    if now<ans:
        ans = now
        
print(ans)

Measured memory_bytes: 7512
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int N;  cin >> N;
    ll *a = new ll[N];
    for (int i = 0; i < N; i++)
        cin >> a[i];

    ll mod = 1e9+7;

    vector<vector<int> > b(N, vector<int>(60));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 60; j++) {
            b[i][j] = a[i] % 2;
            a[i] /= 2;
        }
    }
    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 60; j++)
            cout << b[i][j];
        cout << endl;
    }
    */

    vector<vector<ll> > p(N, vector<ll>(60)), q(N, vector<ll>(60));
    for (int k = 0; k < 60; k++) {
        p[N-1][k] = (1-b[N-1][k]);
        q[N-1][k] = b[N-1][k];

        for (int i = N-1; i > 0; i--) {
            p[i-1][k] = p[i][k] + (1-b[i-1][k]);
            q[i-1][k] = q[i][k] + b[i-1][k];
        }
    }
    /*
    cout << endl;
    for (int i = 0; i < N; i++) {
        for (int k = 0; k < 60; k++)
            cout << p[i][k];
        cout << endl;
    }
    */

    ll ans = 0, tmp = 1;
    for (int k = 0; k < 60; k++) {
        ans += tmp * p[0][k] % mod * q[0][k] % mod;
        ans %= mod;
        tmp *= 2;
        tmp %= mod;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 392352
import java.util.Scanner;


public class Main {
	
	private static boolean chech(char[] input, int start, int last){
		for(int i = start; i <= last; i++){
			if(input[i] == '(' || input[i] == '['){
				char cntup = input[i];
				char cntdown = input[i] == '(' ? ')' : ']';
				
				boolean flag = false;
				int count = 1;
				for(int j = i+1; j <= last; j++){
					if(input[j] == cntup){
						count++;
					}else if(input[j] == cntdown){
						if(count == 1){
							flag = true;
							if(!chech(input, i+1, j-1)){
								return false;
							}
						
							i = j;
							break;
						}
						
						count--;
					}
				}
				
				if(!flag){
					return false;
				}
				
			}else if(input[i] == ')' || input[i] == ']'){
				return false;
			}
		}
		
		return true;
		
	}
	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			String str = sc.nextLine();
			if (str.equals(".")) {
				break;
			}
			
			System.out
					.println(chech(str.toCharArray(), 0, str.length() - 1) ? "yes"
							: "no");
		}
	}
}	

Measured memory_bytes: 12000
#include <cstring>
#include <cstring>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <stack>
#include <sstream>
#include <set>
#include <cstring>
#include <unordered_set>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << ' ';
	if (a + b < n)cout << 0;
	else cout << a + b - n;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
string s,t;
map<char,int>mp;
map<int,char>mpinv;
set<char>vec;
int to_number1(){
    int num = 0;
    for(int i=0;i<s.length();){
        if(vec.count(s[i])==1){
            num+=mp[s[i]]*mp[s[i+1]];
            i+=2;
        }
        else{
            num+=mp[s[i]];
            i++;
        }
    }
    return num;
}

int to_number2(){
    int num = 0;
    for(int i=0;i<t.length();){
        if(vec.count(t[i])==1){
            num+=mp[t[i]]*mp[t[i+1]];
            i+=2;
        }
        else{
            num+=mp[t[i]];
            i++;
        }
    }
    return num;
}

string convert(int multiply){
    string z = "";
    int digit = 0;
    while(multiply>0){
        int r = multiply%10;
        if(r>0){
            if(r == 1){
                z.push_back(mpinv[pow(10,digit)]);
            }
            else{
                z.push_back(mpinv[pow(10,digit)]);
                z.push_back(mpinv[r]);
            }
        }
        multiply/=10;
        digit++;
    }
    reverse(z.begin(),z.end());
    return z;
}

int main(void){
    for(int i=2;i<=9;i++){
        char x = i+'0';
        mp[x]=i;
        mpinv[i]=x;
        vec.insert(x);
    }
    mp['i']=1;
    mpinv[1]='i';
    mp['x']=10;
    mpinv[10]='x';
    mp['c']=100;
    mpinv[100]='c';
    mp['m']=1000;
    mpinv[1000]='m';
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>t;
        int x = to_number1();
        int y = to_number2();
        string z = convert(x+y);
        cout<<z<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 190;//, mod = 1e9 + 7;
int n, m;
unsigned char xdp[17][maxn][maxn][maxn], ydp[17][maxn][maxn][maxn];
int mat[maxn][maxn];
int sum(int lx, int rx, int ly, int ry) {
	lx--, ly--;
	return mat[rx][ry] - mat[lx][ry] - mat[rx][ly] + mat[lx][ly];
}
bool good(int lx, int rx, int ly, int ry) {
	return sum(lx, rx, ly, ry)==0||sum(lx, rx, ly, ry)==(rx-lx+1)*(ry-ly+1);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	char t;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			cin >> t;
			mat[i][j] = mat[i-1][j] + mat[i][j-1] - mat[i-1][j-1] + (t=='#');
		}
	for(int c = 0; c < 17; c++) {
		for(int lx = 1; lx <= n; lx++) {
			for(int rx = lx; rx <= n; rx++) {
				for(int y = 1; y <= m; y++) {
					unsigned char &t = xdp[c][lx][rx][y];
					if(c==0) {
						t = y;
						while(t <= m && good(lx, rx, y, t)) t++;
					} else {
						t = xdp[c-1][lx][rx][y];
						if(t<=m) t = xdp[c-1][lx][rx][t];
						while(t <= m) {
							int u = ydp[c-1][y][t][lx];
							if(u <= n) u = ydp[c-1][y][t][u];
							if(u>rx) t++;
							else break;
						}
					}
				}
			}
		}
		
		for(int ly = 1; ly <= m; ly++) {
			for(int ry = ly; ry <= m; ry++) {
				for(int x = 1; x <= n; x++) {
					unsigned char &t = ydp[c][ly][ry][x];
					if(!c) {
						t = x;
						while(t <= n && good(x, t, ly, ry)) t++;
					} else {
						t = ydp[c-1][ly][ry][x];
						if(t <= n) t = ydp[c-1][ly][ry][t];
						while(t <= n) {
							int u = xdp[c-1][x][t][ly];
							if(u <= n) u = xdp[c-1][x][t][u];
							if(u>ry) t++;
							else break;
						}
					}
				}
			}
		}
	}
	int ans = 0;
	while(ans < 17 && xdp[ans][1][n][1] <= m && ydp[ans][1][m][1] <= n) ans++;
	cout << ans;
}


Measured memory_bytes: 227456
#include <bits/stdc++.h>
#define maxn 100000
using namespace std;

int n,k;
int h[maxn];
int dp[maxn];

int main() {
	k = 2;
	cin >> n;
	for( int i = 0 ; i < n ; i++ )
		cin >> h[i];
	for( int i = 1 ; i < n ; i++ ) {
		dp[i] = (1 << 30);
		for( int j = max( i-k , 0 ) ; j < i ; j++ )
			dp[i] = min( dp[i] , dp[j] + abs( h[i] - h[j] ) );
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
string s,t1,t2;
bool ok1,ok2;
void nhap(){
  cin>>s;
}
void xuly(){
  for(int i=0;i<4;++i){
    if(i<2) t1=t1+s[i];
    else t2=t2+s[i];
  }
  if(t2<="12" && t2!="00") ok1=1;
  if(t1<="12" && t1!="00") ok2=1;
  if(ok1 && ok2){
    cout<<"AMBIGUOUS";
    return;
  }
  else{
    if(!ok1 && !ok2) cout<<"NA";
    if(ok1) cout<<"YYMM";
    if(ok2) cout<<"MMYY";
    return;
  }
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


Measured memory_bytes: 256