akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n, m; cin >> n >> m;

    ll ans1 = 0, ans2 = 0;

    ll a = m / 4;
    if(m % 4 > 1 && n >= 1) ans1++;
    ans1 += a;

    ll c = m / 2;
    if(n <= c){
        ans2 += n;
        c -= n;
        ans2 += c / 2;
    }else{
        ans2 += c;
        if(m % 2 > 1) ans2++;
    }

    cout << max(ans1, ans2) << endl;
}


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

using namespace std;

int main(int argc, char* argv[])
{
  int N, Q; cin >> N >> Q;
  string S; cin >> S;

  vector<int> cnt(N, 0);
  for (int i = N - 2; i >= 0; i--) {
    cnt[i] = cnt[i+1];
    if (S[i] == 'A' && S[i+1] == 'C') {
      cnt[i]++;
    }
  }

  for (int i = 0; i < Q; i++) {
    int l, r; cin >> l >> r;
    cout << cnt[l-1] - cnt[r-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long ans;
  ans = A*(N/(A+B)) + min(N%(A+B), A);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node
{
	int x,v;
	node () {} ;node (int _x,int _v) {x=_x;v=_v;}
	bool operator < (const node &t) const {return v>t.v;}
};
priority_queue<node> QA,QB;
int A,B,C,X,Y;
int main()
{
	cin>>X>>Y;
	cin>>A>>B>>C;
	for (int i=1;i<=A;++i)
	{
		int v;
		scanf("%d",&v);
		QA.push(node(0,v));
	}
	for (int i=1;i<=B;++i)
	{
		int v;
		scanf("%d",&v);
		QB.push(node(0,v));
	}
	while (QA.size()>X) QA.pop();
	while (QB.size()>Y) QB.pop();
	for (int i=1;i<=C;++i)
	{
		int v;
		scanf("%d",&v);
		int a=QA.top().v;
		int b=QB.top().v;
		if (a<b)
		{
			if (v>a)
			{
				QA.pop();
				QA.push(node(0,v));
			}
		}
		else
		{
			if (v>b)
			{
				QB.pop();
				QB.push(node(0,v));
			}
		}
	}
	long long ans=0;
	while (!QA.empty()) ans+=QA.top().v,QA.pop();
	while (!QB.empty()) ans+=QB.top().v,QB.pop();
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  
  int N,l,s,A = 0;
  cin >> N;
  
  for (int i = 0;i < N;i++) {
    
    cin >> l >> s;
    
    A += s - l + 1;
  }
  cout << A << endl;
}


Measured memory_bytes: 3616
k, s = gets.split.map(&:to_i)

count = 0

(0..k).each do |x|
  (0..k).each do |y|
    z = s - x - y
    if z >= 0 && z <= k
      if x + y + z == s
        count += 1
      end
    end
  end
end

puts count

Measured memory_bytes: 1788
#include<iostream>

using namespace std;
int main() {
  const int mod(1e9+7);
  int n;
  cin >> n;
  int mat[n][n];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      cin >> mat[i][j];
  
  int dp[1 << n] = {};
  dp[0] = 1;
  //for (int a = 0; a < n; ++a)
    for (int i = 0; i < (1 << n) - 1; ++i) {
      int a = __builtin_popcount(i);
		for (int b = 0; b < n; ++b) {
          if (mat[a][b] && !(i & (1 << b)))
            dp[i ^ (1 << b)] += dp[i];
          	dp[i ^ (1 << b)] %= mod;
        }
    }
  cout << dp[(1 << n) - 1] << endl;
  return 0;
}

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

int main() {
int n;
cin >> n;
vector<int> a(n);
vector<int> b(n);
rep(i,n) cin >> a.at(i);
for(int i = 0; i < n; i++){
  b.at(i) = i + 1;
}

  
bool ans  = false;
rep(i,n){
  rep(j,n){
    swap(a.at(i),a.at(j));
    if(a == b){
      ans = true;
      break;
    }
    swap(a.at(i),a.at(j));
  }
}
puts(ans ? "YES" : "NO");
}
  


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

int n, a;
ll dp[2551][52][52];
int x[50];
ll ans;

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

int main(){
	cin >> n >> a;
	lp(n)
		cin >> x[i];
	lp(2501)
		lop(51, j)
			lop(51, k)
				dp[i][j][k] = 0;
	dp[0][0][0] = 1;
	lp(n) {
		lop(2501, j) {
			lop(i + 1, k) {
				dp[j + x[i]][i + 1][k + 1] += dp[j][i][k];
				dp[j][i + 1][k] += dp[j][i][k];
//				cout << j << sp << i << sp << k << sp << dp[j][i][k] << endl;
			}
		}
	}
	ans = 0;
	lp(n) {
		ans += dp[a*(i + 1)][n][i + 1];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 54144
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    i64 n;
    cin >> n;
    i64 ans = 0;
    i64 base = 10;

    while(n >= base)
    {
        if(n%2 == 0) ans += n / base;
        base *= 5;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
  long long int n, i;
  char str[200];
  cin >> n;
  cin >> str;
  if(strlen(str)<=n) 
  cout << str << endl;
  else
  {
  	for(i=0;i<n;i++) 
  	cout << str[i] ;
  	
  	cout << "..." << endl;
  } 
  return 0;
} 
	


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll T1, T2, A1, A2, B1, B2;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll d1 = (T1 * A1 + T2 * A2) - (T1 * B1 + T2 * B2); 
    if(d1 == 0){
        cout << "infinity" << endl;
        return 0;
    }
    ll d2 = T1 * A1 - T1 * B1;
    ll ans = 1 + 2 * abs(d2 / d1);
    if(abs(d2) % abs(d1) == 0) ans--;
    cout << (d2 > 0 ^ d1 > 0 ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;

const int N=100005;

int n,n1,n2,n3,t1,t3;
ll ans;
int a[N],b[N],c[N];

int main(){
	int i;
	scanf("%d",&n); n1=n2=n3=n;
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	for (i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(a+1,a+1+n1);
	sort(b+1,b+1+n2);
	sort(c+1,c+1+n3);
	t1=0; t3=n3+1;
	for (;t3>1&&c[t3-1]>b[1];t3--);
	for (i=1;i<=n2;i++){
		for (;t1<n1&&a[t1+1]<b[i];t1++);
		ans+=1ll*(n3-t3+1)*t1;
		if (i<n2) for (;t3<=n3&&c[t3]<=b[i+1];t3++);
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;

/* [💭] [💡] [🎈] */

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

    int n;
    cin >> n;
    cout << (1000 - (n % 1000)) % 1000;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int r,g;
  cin >> r >> g;

  cout << 2*g-r << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    ll x,k,d;
    cin>>x>>k>>d;
    x = abs(x);
    ll quo =  x/d;
    quo = min(quo,k);
    x -= (quo*d);
    if ((k - quo)%2){
        cout<<abs(x-d)<<endl;
    }
    else cout<<x<<endl;
    
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 3644
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn not(b: bool) -> bool {
    if b {
        false
    } else {
        true
    }
}

fn fact(n: u64) -> u64 {
    if n == 0 {
        1
    } else {
        (n * fact(n - 1)) % 1000000007
    }
}

fn main() {
    let s: String = read();
    let t: String = read();
    let sv: Vec<char> = s.chars().collect();
    let tv: Vec<char> = t.chars().collect();
    let mut ans: u32 = 0;
    if sv[0] == tv[0] {
        ans += 1;
    }
    if sv[1] == tv[1] {
        ans += 1;
    }
    if sv[2] == tv[2] {
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }
using namespace std;

int H, W;
vector<string> field(52, "");

int main() {
    cin >> H >> W;
    field.resize(H+2);

    rep(i, W+2) field[0] += '.';
    for (int i = 1; i <= H; i++) {
        field[i] += '.';
        string line; cin >> line;
        field[i] += line;
        field[i] += '.';
    }
    rep(i, W+2) field[H+1] += '.';

    // rep(i, H+2) {
    //     rep(j, W+2) {
    //         cout << field[i][j];
    //     }
    //     cout << endl;
    // }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (field[i][j] == '#') {
                char up = field[i-1][j];
                char down = field[i+1][j];
                char left = field[i][j-1];
                char right = field[i][j+1];
                if (up == '.' && down == '.' && left == '.' && right == '.'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, z=1e9+7;
  cin >> N;
  vector<long long> memo(N);
  int bit=0, temp=0;
  for(int i=0; i<N; i++){
    long long a;
    cin >> a;
    memo.at(i)=a;
    if(a!=0){
    temp=log2(a)+1;
    bit=max(bit,temp);
    }
  }
  vector<long long> zero(bit,0), one(bit,0);
  for(int i=0; i<N; i++){
    long long a=memo.at(i);
    for(int j=0; j<bit; j++){
      if(a>>j &1){
        one.at(j)++;
//      cout<<"i:"<<i<<" j:"<<j<<" a>>j1:"<<(a>>j)<<endl;
      }
      else{
        zero.at(j)++;
//      cout<<"i:"<<i<<" j:"<<j<<" a>>j0:"<<(a>>j)<<endl;
      }
    }
  }
  long long ans=0;
  for(int i=bit-1; i>=0; i--){
    ans*=2;
    ans+=zero.at(i)*one.at(i);
    ans%=z;    
//    cout<<"i:"<<i<<" zero.at(i):"<<zero.at(i)<<" one.at(i):"<<one.at(i)<<" ans:"<<ans<<endl;
  }

  cout << ans<< endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	string O,E;
	cin>>O>>E;
	rep(i,O.size()){
		cout<<O[i];
		if(i<E.size())
		cout<<E[i];
	}	
	cout<<endl;
}

Measured memory_bytes: 256
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using multiInt = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
*/
/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-10;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= 1000; i++)
  {
    for (int j = 0; j <= 1000; j++)
    {
      if (i + j == x and 2 * i + 4 * j == y)
      {
        Yes(1);
        return;
      }
    }
  }
  Yes(0);
}

int main()
{
  init_main();

  solve();

  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  int N = S.size();
  vector<int> DP(N + 1, 0);
  REP(i, N) DP[i + 1] = 1 << (S[i] - 'a');
  REP(i, N) DP[i + 1] ^= DP[i];
  if (__builtin_popcount(DP[N]) <= 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> DDP((1 << 26), INT32_MAX / 2);
  DDP[0] = 0;
  FOR(i, 1, N + 1) {
    REP(j, 26) { DDP[DP[i]] = min(DDP[DP[i]], DDP[DP[i] ^ (1 << j)] + 1); }
  }
  cout << DDP[DP[N]] << endl;

  return 0;
}


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

int main() {
	int month, day;
	while(1) {
		cin >> month >> day;
		if(month == 0) break;
		else {
			int counter = 1;
			int numDay = 0;
			while(1) {
				if(month == counter) {
					numDay += day;
					break;
				}
				else {
					if(counter == 1 || counter == 3 || counter == 5 || counter == 7 || counter == 8 || counter == 10 || counter == 12) {
						numDay += 31;
						counter++;
					}
					else if(counter == 2){
						numDay += 29;
						counter++;
					}
					else {
						numDay += 30;
						counter++;
					}
				}
			}
			if(numDay % 7 == 1) cout << "Thursday" << endl;
			else if(numDay % 7 == 2) cout << "Friday" << endl;
			else if(numDay % 7 == 3) cout << "Saturday" << endl;
			else if(numDay % 7 == 4) cout << "Sunday" << endl;
			else if(numDay % 7 == 5) cout << "Monday" << endl;
			else if(numDay % 7 == 6) cout << "Tuesday" << endl;
			else cout << "Wednesday" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                String SS = sc.next();
                int N = 0, W = 0, S = 0, E = 0;
                for (int i = 0; i < SS.length(); i++) {
                        switch (SS.charAt(i)) {
                                case 'N' : {N++;break;}
                                case 'W' : {W++;break;}
                                case 'S' : {S++;break;}
                                case 'E' : {E++;break;}
                        }
                }
                if ((N == 0 && S == 0 || N != 0 && S != 0) && (W == 0 && E == 0 || W != 0 && E != 0)) {
                        System.out.println("Yes");
                } else {
                        System.out.println("No");
                }
        }
}

Measured memory_bytes: 9552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), C = getint();
	int D[31][31];
	rep1(i, C) rep1(j, C) {
		D[i][j] = getint();
	}

	int T[3][31] = {};
	rep1(i, N) rep1(j, N) {
		T[(i + j) % 3][getint()]++;
	}
	
	int kotae = 1e9;
	rep1(i, C) rep1(j, C) rep1(k, C) {
		if (i != j && j != k && k != i) {
			int kari = 0;
			rep1(p, C) kari += T[0][p] * D[p][i];
			rep1(p, C) kari += T[1][p] * D[p][j];
			rep1(p, C) kari += T[2][p] * D[p][k];
			kotae = min(kotae, kari);
		}
	}
	co(kotae);

	Would you please return 0;
}

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

void solve(){
  string s;
  cin >> s;
  int sum = 0;
  for(int i=0; i<4; ++i){
    if(s[i] == '+') sum++;
    else sum--;
  }
  cout << sum << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	cout<<max(0,c-(a-b))<<endl;
	return 0;
}

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int[] A = new int[9];
            int[] card = new int[9];

            for(int i=0; i<3; i++)
            {
                String S = Console.ReadLine();
                String[] L = S.Split(' ');
                A[i*3] = int.Parse(L[0]);
                A[i*3+1] = int.Parse(L[1]);
                A[i*3+2] = int.Parse(L[2]);
            }

            int N = int.Parse(Console.ReadLine());
            int[] B = new int[N];

            for(int i=0; i<N; i++)
            {
                B[i] = int.Parse(Console.ReadLine());
                for(int j=0; j<9; j++)
                {
                    if(B[i] == A[j])
                    {
                        card[j] = 1;
                    }
                }
            }

            if(card[0] + card[1] + card[2] == 3 || card[3] + card[4] + card[5] == 3 || card[6] + card[7] + card[8] == 3 || card[0] + card[3] + card[6] == 3 || card[1] + card[4] + card[7] == 3 || card[2] + card[5] + card[8] == 3 || card[0] + card[4] + card[8] == 3 || card[2] + card[4] + card[6] == 3)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

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

#define MAX_V 200

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v){
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        int u = G[v][i], w = match[u];
        if(w < 0 || !used[w] && dfs(w)){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < V; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v))  res++;
        }
    }
    return res;
}

int main(){
    int x, y, e;
    cin >> x >> y >> e;
    V = x+y;
    int a, b;
    while(e-- > 0){
        cin >> a >> b;
        add_edge(a,x+b);
    }
    cout << bipartite_matching() << endl;
    return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

const int mod = (int)1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll mul(ll a, ll b, ll md){
	return a*b % md;
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e5+5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	ll n, m, d; cin>>n>>m>>d;
	double ans = double((n-d) * (m-1))/(n*n);
	if(d) ans *= 2;
	cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0); // cin, cout の高速化
#define MOD 1000000007
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)

int main()
{
    IOS

        int N,
        T;
    cin >> N >> T;
    int ans = 1e9;
    REP(i, N)
    {
        int c, t;
        cin >> c >> t;
        if (t <= T && c < ans)
        {
            ans = c;
        }
    }

    if (ans == 1e9)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

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

using namespace std;

typedef long long ll;

const int mod = 1e9 + 7;

int add(int i, int j) { return ((i += j) < mod ? i : i -= mod); }
int mult(int i, int j) { return (ll) i * j % mod; }
int pwr(int i, int k) {
    int r = 1;
    while(k) {
        if(k & 1)
            r = mult(r, i);
        i = mult(i, i);
        k >>= 1;
    }
    
    return r;
}

int fac[200002];
int invfac[200002];
int bin(int i, int j) {
  if( i < j ) return 0;
  return mult(mult(fac[i], invfac[j]), invfac[i - j]);
}

int A[100001];
int B[100001];

int main() {
    int n; cin >> n;
    for(int i = 0; i <= n; ++i)
        cin >> A[i];
    fac[0] = 1;
    for(int i = 1; i < 200002; ++i)
        fac[i] = mult(i, fac[i - 1]);
    invfac[200001] = pwr(fac[200001], mod - 2);
    for(int i = 200000; i > -1; --i)
        invfac[i] = mult(i + 1, invfac[i + 1]);
    
    
    int rx = 2;
    for(int i = 0; i <= n; ++i) {
        if(B[A[i]]) rx += i - B[A[i]];
        B[A[i]] = i + 1;
    }
    
    rx = n + 1 - rx;
    for(int i = 0; i <= n; ++i)
        cout << ((ll)bin(n + 1, i + 1) - bin(rx, i) + mod) % mod << '\n';
    
    return 0;
}

Measured memory_bytes: 3584
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last ,long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long res;
	long A, B; cin >> A >> B;

	res = max(A + A - 1, max(B + B - 1, A + B));

	cout << res << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder sb = new StringBuilder();

		br.readLine();
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int x, y, b, p;
			double regular, discount;
			StringTokenizer st = new StringTokenizer(line);
			x = Integer.parseInt(st.nextToken());
			y = Integer.parseInt(st.nextToken());
			b = Integer.parseInt(st.nextToken());
			p = Integer.parseInt(st.nextToken());
			regular = x * b + y * p;
			discount = (x * (b > 5 ? b : 5) + y * (p > 2 ? p : 2)) * 0.8;
			sb.append(
					Double.valueOf(regular < discount ? regular : discount)
							.intValue()).append('\n');
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 18420
N, M = map(int, input().split())
sc_list = [list(map(int, input().split())) for i in range(M)]

res = [-1 for _ in range(N)]

flg = True
for s, c in sc_list:
    if res[s-1] == -1 or res[s-1] == c:
        res[s-1] = c
    else:
        flg = False
        break

if flg:
    if N == 1:
        print(max(res[0], 0))
    else:
        if res[0] == 0:
            print(-1)
        else:
            for i in range(N):
                if res[i] == -1:
                    if i == 0:
                        res[i] = 1
                    else:
                        res[i] = 0
            print("".join(map(str, res)))
else:
    print(-1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long double ldb;
typedef long long int ll;
const ll mod=1e9+7;

ll n, lef, rig, mid, best, N;
ll x[11111], y[11111], cv[22222], wow[44444];
pair<ll, ll> world[22222]; // loc, myindex
vector<int> cedge[222222];
vector<int> redge[222222];
vector<int> ord;
int whi[301000], gr;
bool vis[301000];

void add_edge(int u, int v)
{
	cedge[u].push_back(v);
	redge[v].push_back(u);
}

void dfs_1(int v)
{
	vis[v]=true;
	for(int i=0 ; i<cedge[v].size() ; i++)
		if(vis[cedge[v][i]]==0) dfs_1(cedge[v][i]);
	ord.push_back(v);
}

void dfs_2(int v)
{
	vis[v]=true; whi[v]=gr;
	for(int i=0 ; i<redge[v].size() ; i++)
		if(vis[redge[v][i]]==0) dfs_2(redge[v][i]);
}

void calc_scc(void)
{
	ll i, u, v;
	for(i=0 ; i<2*N ; i++) if(!vis[i]) dfs_1(i);
	for(i=0 ; i<2*N ; i++) vis[i]=false;
	reverse(ord.begin(), ord.end());
	for(i=0 ; i<2*N ; i++) // n = ord.size()
	{
		v=ord[i];
		if(vis[v]) continue;
		gr++; dfs_2(v);
	}
}

int NOT(int x)
{
	if(x>=N) return x-N;
	else return x+N;
}

void add_clause(int x, int y) // x -> y - (if you want to use "not x" here use ~x)
{
//	cout<<x<<" "<<y<<"\n";
	if((x>>31)&1) x=(~x)+N;
	if((y>>31)&1) y=(~y)+N;
	add_edge(x,y); add_edge(NOT(y),NOT(x));
}

bool satisfy(void)
{
	for(int i=0 ; i<N ; i++) if(whi[i]==whi[NOT(i)]) return false;
	return true;
}

void build_seg(int index, int s, int e)
{
	int m=(s+e)>>1;
	if(s==e) { wow[m]=index; return; }
	add_clause(index<<1, index);
	add_clause(index<<1|1, index);
	build_seg(index<<1, s, m);
	build_seg(index<<1|1, m+1, e);
}

void add_seg(int index, int s, int e, int l, int r, int src)
{
	if(l>e || r<s) return;
	if(l<=s && e<=r) { add_clause(wow[src], ~index); return; }
	int m=(s+e)>>1;
	add_seg(index<<1, s, m, l, r, src);
	add_seg(index<<1|1, m+1, e, l, r, src);
}

bool isok(ll X)
{
	ll i, j, ind, u, v;
	for(i=0 ; i<=16*n ; i++) cedge[i].clear(), redge[i].clear();
	for(i=0 ; i<=16*n ; i++) whi[i]=0, vis[i]=false; ord.clear(); gr=0;
	build_seg(1, 1, 2*n); 
	for(i=1 ; i<=2*n ; i++) // file complaints
	{
		ind=lower_bound(world+1, world+2*n+1, make_pair(world[i].first-X+1, -1LL))-world;
		if(ind<=i-1) add_seg(1, 1, 2*n, ind, i-1, i); // cout<<"LOW "<<i<<" "<<ind<<"\n";
		ind=upper_bound(world+1, world+2*n+1, make_pair(world[i].first+X, -1LL))-world; ind--;
		if(ind>=i+1) add_seg(1, 1, 2*n, i+1, ind, i); // cout<<"HIGH "<<i<<" "<<ind<<"\n";
	}
	for(i=1 ; i<=n ; i++)
	{
		u=wow[cv[2*i-1]]; v=wow[cv[2*i]];
		add_clause(u, ~v); add_clause(~u, v);
	}
	calc_scc();
	if(satisfy()) return true;
	return false;
}

int main(void)
{
	fio; ll i, j; cin>>n; N=8*n;
	for(i=1 ; i<=n ; i++) cin>>x[i]>>y[i];
	for(i=1 ; i<=n ; i++)
	{
		world[2*i-1]=make_pair(x[i], 2*i-1);
		world[2*i]=make_pair(y[i], 2*i);
	}
	sort(world+1, world+2*n+1);
	for(i=1 ; i<=2*n ; i++) cv[world[i].second]=i;
	lef=1; rig=1e9;
	while(lef<=rig)
	{
		mid=(lef+rig)/2;
		if(isok(mid)) best=mid, lef=mid+1;
		else rig=mid-1;
	}
	cout<<best; return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;

const ll MOD = 1000 * 1000 * 1000 + 7;

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

    int n;
    cin >> n;
    vector<ll> a(n);
    ll c = 1;
    for (auto& x : a) {
        cin >> x;
        x -= c;
        c++;
    }
    sort(a.begin(), a.end());
    ll b = a[n / 2];
    ll ans = 0;
    for (auto& x : a)
        ans += abs(x - b);
    cout << ans << endl;
}

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

int main(void){
  int N, M;
  cin >> N >> M;
  int ans = 0;
  for(int i=1;i<sqrt(M)+1;i++){
    if(M%i==0){
      int a=i;
      int b= M/i;
      if(b>=N){
        ans = max(ans, a);
      }
      if(a>=N){
        ans = max(ans, b);
      }
    }
  }
  cout << ans;
  return 0;
}


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

int main()
{
    long long int n, a, b, c, res = 0;
    cin >> n >> a >> b;
    long long int p[3] = {0};
    for(int i = 0; i < n; ++i){
        cin >> c;
        if(c <= a) p[0]++;
        else if(c > a && c <= b) p[1]++;
        else p[2]++;
    }
    for(int i = 0; i < n; ++i){
        if(p[0] == 0 || p[1] == 0 || p[2] == 0) break;
        else{
            res++;
            p[0]--;
            p[1]--;
            p[2]--;
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class date {
public:
    int year;
    int month;
    int day;
    void in(){cin>>year>>month>>day;}
    bool flag(){if(year<0||month<0||day<0)return false; else return true;}
    
};
int urucalendar[] = {31,29,31,30,31,30,31,31,30,31,30,31};
int calendar[]    = {31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
    date a,b;
    while(1){
        a.in(); b.in();
        if(!(a.flag()&&b.flag()))return 0;
        int cnt=0;
        while(true){
            if(a.year==b.year&&a.month==b.month&&a.day==b.day)break;
            cnt++;a.day++;
            if((a.year%4==0&&(a.year%100!=0))||a.year%400==0){
                if(a.day==urucalendar[a.month-1]+1){
                    a.day=1;
                    a.month++;
                }
                if(a.month==13){
                    a.month=1; a.year++;
                    }
            }else {
                if(a.day==calendar[a.month-1]+1){
                    a.day=1;
                    a.month++;
                }
                if(a.month==13){
                        a.month=1; a.year++;
                }
            }
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 2984
N,K=map(int,input().split())
A=list(map(int,input().split()))
dic={}
for i in A:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
ans=0
for k,v in sorted(dic.items(),key=lambda x: x[1]):
    if K >= len(dic): break
    ans+=v
    K+=1
print(ans)

Measured memory_bytes: 40440
n,k=map(int,input().split())
mod=10**9+7
ans=0
l=[0]*(k+1)
 
for i in range(k,0,-1):
    l[i]=pow(k//i,n,mod)
    for j in range(2*i,k+1,i):
        l[i]-=l[j]
        l[i]=pow(l[i],1,mod)
    ans+=l[i]*i
    ans=pow(ans,1,mod)
 
print(ans)

Measured memory_bytes: 11156
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, k;
    cin>>a>>b>>k;
    ll temp = min(a, k);
    a = a - temp;
    k = k - temp;
    temp = min(b, k);
    b = b - temp;
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    private long fac[];
    private long finv[];
    private long inv[];
    private static int MAX_LEN = 510000;
    private static int MOD = 1000000007;
    public static void main(String[] args) {
        Main main = new Main();
        main.COMinit();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long ans = 0;
        for (int i = 0; i <= Math.min(N,K); i++) {
            long t1 = COM(N, i);
            // N-i個に1以上を配置して和をnにする
            // N-i個に0以上を配置して和をn-(n-i)=iにする
            long t2 = COM(i+(N-i-1),i);
            ans += t1 * t2;
            ans %= MOD;
        }
        System.out.println(ans);
    }
    void COMinit() {
        this.fac = new long[MAX_LEN];
        this.finv = new long[MAX_LEN];
        this.inv = new long[MAX_LEN];
        this.fac[0] = this.fac[1] = 1;
        this.finv[0] = this.finv[1] = 1;
        this.inv[1] = 1;
        for (int i = 2; i < MAX_LEN; i++) {
            fac[i] = fac[i-1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i-1] * inv[i] % MOD;
        }
    }
    long COM(int n, int k) {
        if (n < k) {
            return 0;
        };
        if (n <0 || k < 0) {
            return 0;
        }
        return fac[n] * (finv[k] * finv[n - k]%MOD)%MOD;
    }
}


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

int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(c>=a+b) cout<<0<<" "<<0;
	else if(c>=a) cout<<0<<" "<<b-(c-a);
	else cout<<a-c<<" "<<b;
}

Measured memory_bytes: 3624
N = gets.to_i
as = gets.split.map(&:to_i).map{|a| a*N}

ave = as.inject(:+)/N
ans = [1e9, 0]
N.times do |i|
    result = [(ave-as[i]).abs, i]
    ans = [ans, result].min
end
puts ans[1]

Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

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

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

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>m(n);
	int total = x;
	int ans = n;
	rep(i, n) {
		cin >> m[i];
		total -= m[i];
	}
	sort(m.begin(), m.end());
	ans += total / m[0];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){

	string s;
	cin >> s;
	int bit = (1 << (s.length()-1)) - 1;
	ll ans = 0LL;
	for(int i = bit; i >= 0; i--) {
		ll sum = 0LL;
		ll cur = 0LL;
		for (int j = 0; j < s.length(); j++) {
			cur = cur * 10 + (s[j] - '0');
			if (i & 1 << j) {
				sum += cur;
				cur = 0LL;
			}
		}
		if (cur != 0LL)
			sum += cur;
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import copy

s = list(input())
n = len(s) - 1

ans = 0
for bit in range(1 << n):

    #print(bin(bit))

    p = []
    for i in range(n):
        if bit & (1 << i):
            p.append(i)
    #print(p)

    m = 1
    s_ = copy.copy(s)
    for idx in p:
        s_[idx+m:idx+m] = '+'
        m += 1
    #print(s_)

    ss = ''.join(s_)
    #print(ss)
    ans += sum([int(n) for n in ss.split('+')])

print(ans)

Measured memory_bytes: 9356
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);

  int ans=0;
  int rest=N;
  int num=0;

  while(rest>0){
    num = rest % 10;
    rest = rest / 10;
    ans += num;
  }

  if(ans == 1) printf("10\n");
  else printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
use std::env;
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    let N = read::<i32>();
    let A = read::<i32>();
    let B = read::<i32>();

    if N*A < B {
        println!("{}", N*A);
    } else {
        println!("{}", B);
    }

}


Measured memory_bytes: 4352
import java.util.Scanner;


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

        final int N = scan.nextInt();
        final int D = scan.nextInt();

        int ans = 0;

        for (int i = 0; i < N; i++) {
            
            int point1 = scan.nextInt();
            int point2 = scan.nextInt();
            double dintance = Math.sqrt(Math.pow((double)point1,2)+Math.pow((double)point2,2));
            if ((dintance <= (double)D)){
                ans++;
            }
        }

        scan.close();

        System.out.println(ans);
    }
}

Measured memory_bytes: 59688
#include<bits/stdc++.h>
using namespace std;
int v[30][114514];
int i[30];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c,d=2,e=1,f=0,g=0;
  cin >>a>>b;
  for(int n=4;n<=a;n++){
    for(int m=22;m<=b;m++){
      c=m%10,d=m/10;
      if(c>=2&&d>=2){
	if(n==(m%10)*(m/10)) f++;
      }
    }
  }
  cout <<f<<'\n';
  return (0);
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll i,ans=0,n,m;
	scanf("%lld%lld",&n,&m);
	for(i=1;i*i<=m;i++) if(m%i==0)
	{
		if(n*i<=m) ans=max(ans,i);
		if(n<=i) ans=max(ans,m/i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()

int norm(int x, int n) {
    x %= n;
    if (x < 0)
        return x + n;
    return x;
}

int solve(string a, string b) {
    // cerr << "solve\n";
    int n = sz(a);

    vector<int> nx(n), pr(n);
    forn (i, n) {
        int j = i;
        while (b[j] != '1')
            j = norm(j + 1, n), ++nx[i];
        j = i;
        while (b[j] != '1')
            j = norm(j - 1, n), ++pr[i];
    }

    int res = 1e9;
    forn (sh, n) {
        // cerr << "sh " << sh << '\n';
        int cur = sh;
        vector<pair<int, int>> qs;
        qs.emplace_back(0, 0);
        forn (i, n) {
            int o = norm(i - sh, n);
            cur += (a[o] != b[i]);
            if (a[o] == '1' && b[i] == '0') {
                if (nx[o] <= sh)
                    continue;
                int dl = norm(pr[o], n);
                int dr = norm(nx[i], n);
                qs.emplace_back(dl, dr);
            }
        }
        sort(all(qs));
        int cr = 0;
        res = min(res, cur + (cr + qs.back().first) * 2);
        // cerr << "cur " << cur + (cr + qs.back().first) * 2 << '\n';
        while (sz(qs) > 1) {
            cr = max(cr, qs.back().second);
            // cerr << "cur " << cur + (cr + qs.back().first) * 2 << '\n';
            qs.pop_back();
            res = min(res, cur + (cr + qs.back().first) * 2);
        }
    }
    return res;
}

signed main() {
#ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
#endif
    string a, b;
    cin >> a >> b;

    if (a == b) {
        cout << 0 << '\n';
        return 0;
    }

    if (find(all(b), '1') == b.end()) {
        cout << -1 << '\n';
        return 0;
    }
    int res = solve(a, b);
    reverse(all(a));
    reverse(all(b));
    res = min(res, solve(a, b));
    cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

unsigned long long w = 1000000007;

unsigned long long func(unsigned long long a){
  unsigned long long ret = 1;
  while(a != 1){
    ret *= a;
    ret %= w;
    a -= 1;
  }
  return ret;
}

void solve(){
  int n, m; cin >> n >> m;
  unsigned long long x = max(n, m), y = min(n, m);
  if(x - y > 1){
    cout << 0 << endl;
    return;
  }
  unsigned long long ans;
  if(x - y == 1){
    ans = func(x);
    ans %= w;
    ans *= func(y);
    ans %= w;
    cout << ans % w << endl;
    return;
  }
  ans = func(x);
  ans %= w;
  ans *= func(y);
  ans %= w;
  cout << ans * 2 % w << endl;
  return;
}

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


Measured memory_bytes: 256