akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e9;
const long double EPS = 1e-10;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];

  ll l = 0, r = INF + 1;
  while (r - l > 1) {
    ll m = (l + r) / 2;
    ll cnt = 0;
    rep(i, n) {
      cnt += max((ll)0, (h[i] - m * b + a - b - 1) / (a - b));
    }
    if (cnt > m) l = m;
    else r = m;
  }
  cout << r << endl;



  
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
//#include<string>
//#include<queue>
//#include<set>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef double db;
const int MOD = 1e9 + 7;
bool cmp(int a, int b)
{
	return abs(a) < abs(b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k, positive = 0, negative = 0, zero = 0;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		positive += (a[i] >= 0);
		negative += (a[i] < 0);
		zero += (a[i] == 0);
	}
	sort(all(a), cmp);
	if (k == n || (k % 2 == 1 && positive == 0))
	{
		if (zero > 0)
		{
			cout << 0;
			return 0;
		}
		ll ans = 1;
		for (int i = 0; i < k; ++i)
		{
			ans *= a[i];
			if (ans < 0)
				ans = (MOD - (abs(ans) % MOD)) % MOD;
			else
				ans %= MOD;
		}
		cout << ans;
		return 0;
	}
	vector<int> po(positive + 1), ne(negative + 1);
	for (int i = 0, j = positive - 1, u = negative - 1; i < n; ++i)
	{
		if (a[i] >= 0)
			po[j--] = a[i];
		else
			ne[u--] = a[i];
	}
	po[positive] = ne[negative] = 0;
	ll ans = 1;
	int i = 0, j = 0, sign = 1;
	while (k > 0)
	{
		if (po[i] < abs(ne[j]))
		{
			++j;
			sign *= -1;
		}
		else if (po[i] > abs(ne[j]))
		{
			++i;
		}
		else if (i == positive)
		{
			++j;
			sign *= -1;
		}
		else if (j == negative)
			++i;
		else
		{
			if (sign == -1)
				++j;
			else
				++i;
		}
		--k;
	}
	if (sign == -1)
	{
		if (i == 0)
		{
			++i, --j;
		}
		else
		{
			if (1ll * po[i - 1] * po[i] >= 1ll * ne[j - 1] * ne[j])
				++i, --j;
			else
				--i, ++j;
		}
	}
	for (int u = 0; u < i; ++u)
	{
		ans *= po[u];
		ans %= MOD;
	}
	for (int u = 0; u < j; ++u)
	{
		ans *= -ne[u];
		ans %= MOD;
		ans = (MOD - ans) % MOD;
	}
	cout << ans;
	return 0;
}

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

int main(int argc, char const *argv[]) {
    int x[100], n;

    // ????´???°??¨??°????????\???
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++){
        scanf("%d", &x[i]);
    }
    for(int i=0 ; i<n-1 ; i++){
        printf("%d ", x[i]);
    }
    printf("%d\n", x[n-1]);

    // ?????\?????????
    for(int i=1 ; i<n ; i++){
        for(int j=i-1 ; j>=0 ; j--){
            if(x[j] > x[j+1]) swap(x[j], x[j+1]);
            else break;
        }
        for(int j=0 ; j<n-1 ; j++){
            printf("%d ", x[j]);
        }
        printf("%d\n", x[n-1]);
    }

    return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
int dp[1 << 15][15],d[15][15],a,b,c,n,p,INF=1<<30;
int rec(int s,int v){
	if(dp[s][v]!=-1)return dp[s][v];
	if(s == (1<< n) -1 && v == 0)return dp[s][v] = 0;
	int res = INF;
	for(int i = 0;i<n;i++)if(!(s>>i & 1) && d[v][i] != -1)res = min(res,rec(s|(1<<i),i)+d[v][i]);
	return dp[s][v] = res;
}
int main(){
	memset(dp,-1,sizeof(dp));
	memset(d,-1,sizeof(d));
	cin >> n >> p;
	for(int u = 0; u < p;u++)cin>>a>>b>>c,d[a][b]=c;
	cout<<(INF == (a = rec(0,0))?-1:a)<<endl;
}

Measured memory_bytes: 5000
N = int(input())
A = [int(i) for i in input().split()]
# 全部のパターンだとN**2
# 仕組み的に低い人ほどあとにきた方がうまくいきそうに見える
A.sort(reverse=1)
s = A[0]
for i in range(N-2):
    p = i
    if i % 2 == 1:
        p -= 1
    s += A[p//2+1]
print(s)

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  vec<ll_ll> v(N);
  for (int i = 0; i < N; i++) {
    ll p, d;
    cin >> p >> d;
    v[i].fi = p + d;
    v[i].se = p - d;
  }
  sort(all(v));

  ll ans = 1;
  ll_ll cur = v[0];
  rep(i, 1, N) {
    if (v[i].se < cur.fi) continue;
    ans++;
    cur = v[i];
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>

int a[200005];

signed main(){
	
	int n,k;cin>>n>>k;
	
	rep(i,200005) a[i] = 0;
	
	rep(i,n)
	{
		int x;cin>>x;
		a[x]++;
	}
	int cnt = 0;
	rep(i,200005) if(a[i])cnt++;
	
	rep(i,200005) if(a[i]==0) a[i]=123456789;
	sort(a,a+200005);
	int ans = 0;
	rep(i,cnt-k) ans +=a[i];
	cout << ans << endl;
	
	
}
 

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

/*** Template Begins ***/

typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
int n, a[N], pre[N];


void solve() {
    
    cin >> n;
    fr(i,1,n) cin >> a[i];
    fr(i,1,n) pre[i] = pre[i-1]+a[i];

    int ans = INT_MAX;
    fr(i,1,n) {

        int cur = abs(pre[i] - (pre[n]-pre[i]));
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using lli = long long;
int main(){
	int n;
	lli gu_su[200010]={0};
	lli kisu_[200010]={0};
	
	cin >> n;
	
	for(int i=1;i<=n;i++){
		if(i%2!=0){
			cin >> kisu_[i];//i = 1 , 3 , 5 , 7...
		}else{
			cin >> gu_su[i];//i = 2 , 4 , 6 , 8...
		}
	}

	if(n%2==0){
		for(int i=n;i>=2;i=i-2){
			cout << gu_su[i] << " ";
		}
		for(int i=1;i<=n-1;i=i+2){
			cout << kisu_[i] << " ";
		}
		cout << endl;
	}else{
		for(int i=n;i>=1;i=i-2){
			cout << kisu_[i] << " ";
		}
		for(int i=2;i<=n-1;i=i+2){
			cout << gu_su[i] << " ";
		}
		cout << endl;
	}
	
	return 0;
}

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

#define space ' '
#define enter "\n"
#define fi first
#define se second
#define INF 2000000007
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef set <int> si;
typedef map <int, int> mii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <pii> vii;

template <typename T>
T sqr (T x)
{
    return x * x;
}

template <typename T>
T gcd (T a, T b)
{
    return b ? gcd(b, a % b) : a;
}

template <class T>
bool chmin (T &x, const T &y)
{
    if (y < x)
    {
        x = y;
        return true;
    }
    return false;
}

template <class T>
bool chmax (T &x, const T &y)
{
    if (x < y)
    {
        x = y;
        return true;
    }
    return false;
}


template <class P, class Q>
ostream & operator << (ostream &os, const pair <P, Q> &p)
{
    return os << '(' << p.fi << ", " << p.se << ')';
}


template <class T>
ostream & operator << (ostream &os, const vector <T> &v)
{
    os << '{';
    bool was = false;
    for (const T & x : v)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << '}';
    return os;
}

template <class T>
ostream & operator << (ostream &os, const set <T> &v)
{
    os << '[';
    bool was = false;
    for (const T & x : v)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << ']';
    return os;
}

template <class P, class Q>
ostream & operator << (ostream &os, const map <P, Q> &m)
{
    os << '<';
    bool was = false;
    for (const auto &x : m)
    {
        if (was)
            os << ", ";
        was = true;
        os << x;
    }
    os << '>';
    return os;
}

const int MAXN = (int)1e5 + 10;

int n;
ll x, a[MAXN], ma = 0, pos = 0;

int main ()
{
    //freopen("", "r", stdin); freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n >> x;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i < n; i++)
        if (a[i] + a[i + 1] > ma)
            ma = a[i] + a[i + 1], pos = i;
    if (ma < x)
    {
        cout << "Impossible";
        return 0;
    }
    cout << "Possible\n";
    for (int i = 1; i < pos; i++)
        if (i != pos)
            cout << i << enter;
    for (int i = n - 1; i >= pos; i--)
        cout << i << enter;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int n;
	ll k;
	cin >> n >> k;
	vector<P> v(n);
	rep(i, n) {
		cin >> v.at(i).first >> v.at(i).second;
	}
	sort(v.begin(), v.end());
	
	ll sum = 0;
	rep(i, n) {
		sum += v.at(i).second;
		if (sum >= k) {
			cout << v.at(i).first;
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<int> A;
int num[10] = {0,2,5,5,4,5,6,3,7,6};

void input(){
    fast_io();
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int a; cin >> a;
        A.push_back(a);
    }
}

bool change_st(string s, string t){
    if(s.length()>t.length()) return false;
    if(s.length()==t.length()){
        for (int i = 0; i < s.length(); i++)
        {
            if(s[i]>t[i]) return false;
            if(s[i]<t[i]) return true;
        }
    }
    return true;
}

string memo[11000];
string MaxInt(int n){
    if(n==0) return "";
    if(n<0) return "-";
    if(memo[n].length()>0) return memo[n];
    string ret;
    for (int a:A)
    {
        string v = to_string(a)+MaxInt(n-num[a]);
        if(v.back()=='-') continue;
        if(change_st(ret,v)) ret = v;
    }
    if(ret.length()==0) return "-";
    return memo[n] = ret;    
}

int solve(){
    string ans = MaxInt(N);
    cout << ans << endl;
    return 0;
}   

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

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int w;
int a[100010],l[100010],r[100010];

int main(void){
	cin >> w;
	rep(i,w) cin  >> a[i];
	int num=0;
	rep(i,w){
		if(a[i]==0)
			num=inf;
		else if(a[i]>0)
			r[i]=min(a[i],num);
		else
			num=min(num,abs(a[i]));
		num=max(0,num-1);
	}
	num=0;
	for(int i=w-1;i>=0;--i){
		if(a[i]==0)
			num=inf;
		else if(a[i]>0)
			l[i]=min(a[i],num);
		else
			num=min(num,abs(a[i]));
		num=max(0,num-1);
	}
	int ans=0;
	rep(i,w) ans+=max(l[i],r[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2332
from collections import deque

def solve(K):
    checked = [99999999999] * (K + 1)
    queue = deque()
    queue.append((1, 1))
    checked[1] = 1
    while queue:
        x, n = queue.popleft()
        if x == 0:
            return n
        _ = (x * 10) % K 
        if n < checked[_]:
            queue.appendleft((_, n))
            checked[_] = n
        _ = (x + 1) % K 
        if n + 1 < checked[_]:
            queue.append((_, n + 1))
            checked[_] = n + 1
    return None

K = int(input())
print(solve(K))



Measured memory_bytes: 9192
a,b = map(int,input().split())

count_p = 0
count = 0

if b == 1:
    print(count)

else:
    while True:
        if count == 0:
            count_p += a
    
        else:
            count_p += a-1
    
        count += 1
    
        if count_p >= b:
            break

    print(count)

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

int main(){
  int n,k;
  string s;
  cin >> n >> s >> k;
  char c=s.at(k-1);
  for(int i=0;i<n;i++){
    if(s.at(i)!=c){
      s.at(i)='*';
    }
  }
  cout << s << endl;
}

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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n , k;
	
	cin >> n >> k;
	int tot = 0;
	
	while(n > 0) {
		tot++;
		n /= k;
	}
	cout << tot;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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

	typedef long long ll;
	using namespace std;

	int main(){
		int n,m,c;
		cin >> n >> m >> c;
		int count = 0;
		ll s = 0;
		vector <int> b;
		for(int i=0; i < m;i++){
			int t;
			cin >> t;
			b.push_back(t);
		}

		while(n--){
			s = 0;
			for(int i=0;i<m;i++){
				int t;
				cin >> t;
				s += t*b[i]; 
			}
			s += c;
			if(s >0){
				count++;
			}
		}
		cout << count <<endl;

		return 0;
	}

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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  vector<int> dist(n);
  int max = 0;

  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++){
    if (i == n - 1) dist[i] = a[0] + k - a[i];
    else dist[i] = a[i + 1] - a[i];
    if (max < dist[i]) max = dist[i];
  }
  cout << k - max;

}

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int h,w,a[200][200]; scanf("%d%d",&h,&w);
	rep(i,h) rep(j,w) scanf("%d",&a[i][j]);

	static int dp[201][200][200];
	rep(i,h+1) rep(j1,w) rep(j2,w) dp[i][j1][j2]=-INF;
	dp[0][0][0]=0;
	rep(i,h){
		// 1 行下に降りる
		rep(j1,w) for(int j2=j1;j2<w;j2++) if(dp[i][j1][j2]!=-INF) {
			int val;
			if(j1<j2) val=a[i][j1]+a[i][j2];
			else      val=a[i][j1];
			dp[i+1][j1][j2]=dp[i][j1][j2]+val;
		}

		// 左の人を動かす
		rep(j2,w){
			rep(j1,j2-1) if(dp[i+1][j1][j2]!=-INF) {
				dp[i+1][j1+1][j2]=max(dp[i+1][j1+1][j2],dp[i+1][j1][j2]+a[i][j1+1]);
			}
		}

		// 右の人を動かす
		rep(j1,w){
			for(int j2=j1;j2<w-1;j2++) if(dp[i+1][j1][j2]!=-INF) {
				dp[i+1][j1][j2+1]=max(dp[i+1][j1][j2+1],dp[i+1][j1][j2]+a[i][j2+1]);
			}
		}
	}

	int ans=-INF;
	rep(j1,w) ans=max(ans,dp[h][j1][w-1]);
	printf("%d\n",ans);

	return 0;
}


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

int main(){
	int H , W , A , B; cin >> H >> W >> A >> B;
	if(A > W / 2 || B > H / 2){puts("-1"); return 0;}
	for(int i = 1 ; i <= B ; ++i){
		for(int j = 1 ; j <= A ; ++j)
			putchar('0');
		for(int j = A + 1 ; j <= W ; ++j)
			putchar('1');
		putchar('\n');
	}
	for(int i = B + 1 ; i <= H ; ++i){
		for(int j = 1 ; j <= A ; ++j)
			putchar('1');
		for(int j = A + 1 ; j <= W ; ++j)
			putchar('0');
		putchar('\n');
	}
	return 0;
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c - (a-b)) << endl;
}

Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main()
{
	char a[4];
	int i;
	int count = 0;
	scanf("%s", a);
	
	for (i = 0; i < 4; i++)
	{
		if(a[i] == '+')
			count++;
		if(a[i] == '-')
			count--;
	}
	
	printf("%d\n", count);

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

  vector<int> a(n), b(n), cum(100010, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    cum[a[i]]++;
    cum[b[i] + 1]--;
  }
  for (int i = 1; i < 100010; i++) {
    cum[i] += cum[i - 1];
  }

  int ans = 1;
  for (int i = 1; i < 100010; i++) {
    if (cum[i] >= i - 1) ans = i;
  }
  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c;
char ga[100005][5],ans[100005];
int main(){
	cin>>n>>a>>b>>c;
	for (int i=1;i<=n;i++)  cin>>ga[i][1]>>ga[i][2];
	for (int i=1;i<=n;i++)
	{
		if (ga[i][1]=='A'&&ga[i][2]=='B')
		{
			if (a<b)
			{
				a++,b--;
				ans[i]='A';
			}
			else if (a>b)
			{
				a--,b++;
				ans[i]='B';
			}
			else if (a==b)
			{
				if (ga[i+1][1]=='A'||ga[i+1][2]=='A')
				{
					a++,b--;
					ans[i]='A';
				}
				else
				{
					a--,b++;
					ans[i]='B';
				}
			}
		}
		if (ga[i][1]=='A'&&ga[i][2]=='C')
		{
			if (a<c)
			{
				a++,c--;
				ans[i]='A';
			}
			else if (a>c)
			{
				a--,c++;
				ans[i]='C';
			}
			else if (a==c)
			{
				if (ga[i+1][1]=='A'||ga[i+1][2]=='A')
				{
					a++,c--;
					ans[i]='A';
				}
				else
				{
					a--,c++;
					ans[i]='C';
				}
			}
		}
		if (ga[i][1]=='B'&&ga[i][2]=='C')
		{
			if (b<c)
			{
				b++,c--;
				ans[i]='B';
			}
			else if (b>c)
			{
				b--,c++;
				ans[i]='C';
			}
			else if (b==c)
			{
				if (ga[i+1][1]=='B'||ga[i+1][2]=='B')
				{
					b++,c--;
					ans[i]='B';
				}
				else
				{
					b--,c++;
					ans[i]='C';
				}
			}
		}
		if (a<0||b<0||c<0)  return cout<<"No"<<endl,0;
	}
	cout<<"Yes"<<endl;
	for (int i=1;i<=n;i++)  cout<<ans[i]<<endl;

	return 0;
}


Measured memory_bytes: 4224
n = int(input())
s = input()

dp = [set(), set()]

dp[0].add("")
for i in range(n):
    dp[(i + 1) % 2] = dp[i % 2].copy()
    i1 = (i + 1) % 2
    i0 = (i + 0) % 2
    for j in dp[i0]:
        if len(j) < 3:
            dp[i1].add(j + s[i])

ans = 0
for j in dp[n % 2]:
    if len(j) == 3:
        # print(j)
        ans += 1

print(ans)


Measured memory_bytes: 56156
#12:00
#解説解答
n,m = map(int,input().split())
inf = 10 ** 18
pst = [[] for _ in range(n)]
for i in range(1,n):
  pst[i].append([0,i-1])
for _ in range(m):
  l,r,c = map(int,input().split())
  l -= 1
  r -= 1
  pst[l].append([c,r])
#print(pst)
import heapq
nxt = pst[0]
heapq.heapify(nxt)
#print(nxt)
seen = [inf for _ in range(n)]
seen[0] = 0
for x in nxt:
  seen[x[1]] = x[0]
while True:
  #print(nxt)
  if nxt == []:
    print(-1)
    break
  c,r = heapq.heappop(nxt)
  if r == n-1:
    print(seen[r])
    break
  for x in pst[r]:
    #print(pst[r])
    #print(x)
    xc,xr = x
    if seen[xr] > seen[r] + xc:
      seen[xr] = seen[r] + xc
      heapq.heappush(nxt,[seen[xr],xr])
#print(seen)

Measured memory_bytes: 88880
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

struct Arc {
    // accessible to the reverse edge
    size_t src, dst;
    Weight capacity, cost, flow;
    size_t rev;
    Arc() {}
    Arc(size_t src, size_t dst, Weight capacity, Weight cost=0):
        src(src), dst(dst), capacity(capacity), cost(cost), flow(0), rev(-1)
    {}
    Weight residue() const {
        return capacity - flow;
    }
};

bool operator<(const Arc &e, const Arc &f) {
    if (e.cost != f.cost) {
        return e.cost > f.cost;
    } else if (e.capacity != f.capacity) {
        return e.capacity > f.capacity;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Arcs=vector<Arc>;
using Node=vector<Arc>;
using FlowNetwork=vector<Node>;

void connect(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, 0, -k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

void join(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, c, k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

pair<Weight, Weight> mincost_flow(
    FlowNetwork &g, size_t s, size_t t, Weight F=INF
) {
    size_t V=g.size();
    vector<Arc *> prev(V, NULL);

    pair<Weight, Weight> total;  // <cost, flow>
    while (F > total.second) {
        vector<Weight> d(V, INF); d[s]=0;
        for (size_t i=0; i<V; ++i) {
            bool updated=false;
            for (size_t v=0; v<V; ++v) {
                if (d[v] == INF) continue;
                for (Arc &e: g[v]) {
                    if (e.capacity <= 0) continue;

                    if (d[e.dst] > d[e.src] + e.cost) {
                        d[e.dst] = d[e.src] + e.cost;
                        prev[e.dst] = &e;
                        updated = true;
                    }
                }
            }

            if (!updated) break;
        }

        if (d[t] == INF) {
            total.first = -1;
            return total;
        }

        Weight f=F-total.second;
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src])
            f = min(f, e->capacity);

        total.second += f;
        total.first += f * d[t];
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src]) {
            e->capacity -= f;
            g[e->dst][e->rev].capacity += f;
        }
    }

    return total;
}

int main() {
    size_t V, E;
    Weight F;
    scanf("%zu %zu %lld", &V, &E, &F);

    FlowNetwork g(V);
    for (size_t i=0; i<E; ++i) {
        size_t u, v;
        Weight c, d;
        scanf("%zu %zu %lld %lld", &u, &v, &c, &d);

        connect(g, u, v, c, d);
    }

    printf("%lld\n", mincost_flow(g, 0, V-1, F).first);
    return 0;
}

Measured memory_bytes: 2880
n=int(input())
a=list(map(int,input().split()))

ans=n*10**9

b=[0]
for i in range(1,n+1):
    b.append(a[i-1]+b[i-1])

for i in range(n-1):
    t_ans=abs(b[i+1]-(b[-1]-b[i+1]))
    ans=min(ans,t_ans)

print(ans)

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

using namespace std;

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

    double x = ceil(N / 1.08);

    if (floor(x * 1.08) == N) {
        cout << x << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=105;
const int maxn=1e5+5;
int a[N],v[N];
ll dp[N][maxn];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i]>>v[i];
	for(int i=0;i<=n;++i)
		dp[i][0]=0,	dp[0][i]=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=k;++j)
			if(j<a[i]) dp[i][j]=dp[i-1][j];
			else dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]+v[i]);
		cout<<dp[n][k]<<endl;
	return 0;
} 

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

int merge(int A[],int left,int mid,int right){
	int count=0;
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i=0;i<n1;i++){
		L[i] = A[left+i];
	}
	for(int i=0;i<n2;i++){
		R[i] = A[mid + i];
	}
	L[n1] = 2147483647;
	R[n2] = 2147483647;
	int i = 0;
	int j = 0;
	for(int k=left;k<right;k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
		}
		count++;
	}
	return count;
}

int mergeSort(int A[],int left,int right){
	int count=0;
	if(left+1 < right){
		int mid = (left + right)/2;
		count += mergeSort(A,left,mid);
		count += mergeSort(A,mid,right);
		count += merge(A,left,mid,right);
	}
	return count;
}

int main(){
	int num=0;
	cin >> num;
	int array[num];
	for(int i=0;i<num;i++){
		cin >> array[i];
	}
	int count = mergeSort(array,0,num);
	for(int i=0;i<num-1;i++){
		cout << array[i] << " ";
	}
	cout << array[num-1] << endl << count << endl;
	return 0;
}
	

Measured memory_bytes: 6984
import math
A,B,H,M=list(map(int,input().split()))
move = 60*H+M
a_move = math.radians(move/720*360)
b_move = math.radians(M/60*360)

ax = A*math.cos(a_move)
ay = A*math.sin(a_move)
bx = B*math.cos(b_move)
by = B*math.sin(b_move)

ans = math.sqrt(math.pow(ax-bx,2) + math.pow(ay-by,2))
print(ans)

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

using namespace std;

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

  vector<int> S(13);
  vector<int> H(13);
  vector<int> C(13);
  vector<int> D(13);

  string t;
  int n;
  for(int i = 0; i < N; i++){
    cin >> t >> n;
    if( t == "S" ){
      S.at(n-1) = n;
    } else if (t == "H"){
      H.at(n-1) = n;
    } else if (t == "C"){
      C.at(n-1) = n;
    } else if (t == "D"){
      D.at(n-1) = n;
    }
  }
  
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 13; j++){
      if( i == 0 ){
        if( S.at(j) == 0 ){
          cout << "S " << j+1 << endl;
        }
      } else if ( i == 1){
        if( H.at(j) == 0 ){
          cout << "H " << j+1 << endl;
        }
      } else if ( i == 2){
        if( C.at(j) == 0 ){
          cout << "C " << j+1 << endl;
        }
      } else if ( i == 3){
        if( D.at(j) == 0 ){
          cout << "D " << j+1 << endl;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3132
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3808
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;

const int mod = 1000000007;

int main() {
	int H, W, K; cin >> H >> W >> K;

  	vector<vector<int> > dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) {
				bool ok = true;
				for (int l = 0; l < W - 2; ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << '\n';
  
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  int n;
  cin>>n;
  cin>>s;
  int ct=0;
  for(int i=0;i<s.length();i++)
  {
      if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
      ct++;
  }
  cout<<ct<<"\n";
}

Measured memory_bytes: 256
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))

int main() {
  string str;
  cin >> str;
  int x = -1, y = -1;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == 'A' && x == -1) {
      x = i;
    }
    if (str[i] == 'Z') {
      y = i;
    }
  }
  cout << y - x + 1 << endl;
  return 0;
}


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

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

    std::vector<int> p(n);
    for (int i = 0; i < n; i++) {
        std::cin >> p[i];
    }

    int ans = 1;
    int min = p[0];
    for (int i = 1; i < n; i++)
    {
        min = std::min(p[i], min);
        if(min >= p[i]) {
            ans++;
        }
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cctype>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	bool minus = false;
	if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
//svo(vector<T> &v){for(int &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}

typedef vector<int> v;

void make_heap(v &h) {
	const int H = h.size();
	for (int i = H / 2 - 1; i >= 0; i--) {
		int v = h[i], p = i;
		for (int c = p * 2 + 1; c < H; c = p * 2 + 1) {
			if (c + 1 < H && h[c] < h[c + 1])
				++c;
			if (v > h[c])
				break;
			h[p] = h[c];
			p = c;
		}
		h[p] = v;
	}
}

int main() {
	int n = in();
	v h(n);
	for (int &x: h)
		x = in();

	make_heap(h);

	out(h);
}



Measured memory_bytes: 4060
n = gets.to_i
s = gets.chomp

x = s.chars.group_by(&:itself).map{|k, v| [k, v.size]}.to_h.map {|_, num| num == 1 ? 2 : num + 1}.inject(:*) - 1
puts (x % (Rational(1000000000/1) + 7)).to_i

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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n;
    cin >> n;
    if(n%2) cout << "0\n";
    else
    {
        n/=2;
        int ans = 0, curr = 5;
        while(curr <= n)
        {
            ans += n/curr;
            curr*= 5;
        }
        cout << ans << "\n";
    }

    return 0;
}



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

int main() {
    int n;
    cin >> n;
    double x;
    string u;
    double ans = 0;
    for(int i = 0; i < n; i++){
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }
        else{
            ans += x * 380000;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, K;
    cin >> N >> K;
    map<long, long> A;
    for(size_t i=0;i<N; i++)
    {
        long a;
        cin >> a;
        A[a]++;
    }
    vector<long> num;
    for(auto a:A) num.push_back(a.second);
    sort(num.begin(), num.end());
    long total=0;
    if(A.size()>K)
    {
        for(ll i=0;i<A.size()-K; i++)
        {
            total+=num[i];
        }
    }
    cout << total << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

vector<string> split(string str, char del) {
  int first = 0;
  int last = str.find_first_of(del);
  vector<string> result;

  while (first < str.size()) {
    result.push_back(str.substr(first, last - first));
    first = last + 1;
    last = str.find_first_of(del, first);
    if (last == string::npos) last = str.size();
  }
  return result;
}

void solve(long long A, long double B){
  vector<string> v = split(to_string(B), '.');
  long long b = stol(v[0] + v[1][0] + v[1][1]);
  long long ret = A * b / 100;
  cout << ret << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long double B;
    scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dx[]={1,1,1,1,1,2,2,2,3},h,w;
int dy[]={-2,-1,0,1,2,-1,0,1,0};
string t;
int main(){
  while(cin>>w>>h,w){
    int d[h][w][2],a[h][w],ans=1e9;
    r(i,h)r(j,w)r(k,2)d[i][j][k]=1e9;
    r(i,h)r(j,w){
      cin>>t;
      if(t=="X")a[i][j]=-1;
      else if(t=="T")a[i][j]=0;
      else if(t=="S")a[i][j]=0,
        d[i][j][0]=d[i][j][1]=0;
      else a[i][j]=(t[0]-'0');
    }
    r(q,h)for(int i=h-1;i>=0;i--)
      r(j,w)r(k,2)r(l,9)if(d[i][j][k]!=1e9){
        int x=j,y=i+dy[l];
        if(k)x+=dx[l];
        else x-=dx[l];
        if(x<0||x>=w||y<0||y>=h)continue;
        if(a[y][x]==-1)continue;
        if(d[i][j][k]+a[y][x]<d[y][x][!k])
          d[y][x][!k]=d[i][j][k]+a[y][x];
      }
    r(i,w)if(a[0][i]==0)
      ans=min(ans,min(d[0][i][0],d[0][i][1]));
    if(ans!=1e9)cout<<ans<<endl;
    else cout<<(-1)<<endl;
  }
}

Measured memory_bytes: 2992
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int N, M, L[200009], R[200009]; bool vis[200009]; vector<int> g[200009];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
		g[L[i]].push_back(i);
	}
	int ret = 0;
	priority_queue<int> que;
	for (int i = M + 1; i >= 0; i--) {
		for (int j : g[i]) que.push(R[j]);
		if (i != 0 && i != M + 1 && !que.empty()) {
			ret++;
			que.pop();
		}
	}
	fill(vis + 1, vis + ret + 1, true);
	vector<int> x;
	while (!que.empty()) x.push_back(que.top()), que.pop();
	int cur = 1;
	for (int i = x.size() - 1; i >= 0; i--) {
		cur = max(cur, x[i]);
		while (cur <= M && vis[cur]) cur++;
		if (cur > M) break;
		ret++; cur++;
	}
	cout << N - ret << endl;
	return 0;
}

Measured memory_bytes: 11000
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.length();
	int ans=0;
	for(int l=0, r=n-1;l<=r;l++,r--)
		if(s[l]!=s[r])
			ans++;
	cout<<ans;
}

Measured memory_bytes: 256
object Main extends App {
  val ref = Array.ofDim[Boolean](26)
  io.StdIn.readLine.toCharArray
    .foreach(ch => ref(ch-97) = true)
  val ans = if(ref.forall(_ == true)) "None" else (ref.indexWhere(_ == false) + 97).toChar
  println(ans)
}

Measured memory_bytes: 29148
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void file(){
#ifndef ONLINE_JUDGE
	freopen("a_input.txt", "r", stdin);
	freopen("a_output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
}
int dx[] = { 0, 0, -1, 1, 1, 1, -1, -1 };
int dy[] = { 1, -1, 0, 0, 1, -1, 1, -1 };
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main(){
	//file();
	fast();
	int n;
	cin >> n;
	int sum = 0, mx = 0;
	while (n--){
		int a;
		cin >> a;
		sum += a;
		mx = max(mx, a / 2);
	}
	sum -= mx;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int A, N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if(N <= K){
		A = N * X;
    } else {
		A = K *  X + N * Y - K * Y;
    }
	cout << A;
}

Measured memory_bytes: 256
N,A,B,C=map(int,input().split())
L=[0]*N
for i in range(N):
  L[i]=int(input())

# ある竹を,Aに使う、Bに使う、Cに使う、どれにも使わない　の4パターンで全探索
# A,B,C	それぞれに対して2つ目以降は10Pかかる

stack=[]
# Aの長さ、Bの長さ、Cの長さ、処理した竹の本数、消費MP
stack.append([0,0,0,0,0])
ans=1000*10
while stack:
  a,b,c,num,mp=stack.pop()
  if num==N:
    if a==0 or b==0 or c==0:
      continue
    mp+=abs(A-a)+abs(B-b)+abs(C-c)
    if mp<ans:
      ans=mp
    continue
  for i in range(4):
    if i==0:
      stack.append([a+L[num],b,c,num+1,mp+(a!=0)*10])
    if i==1:
      stack.append([a,b+L[num],c,num+1,mp+(b!=0)*10])
    if i==2:
      stack.append([a,b,c+L[num],num+1,mp+(c!=0)*10])
    if i==3:
      stack.append([a,b,c,num+1,mp])
print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,h;
    scanf("%lld%lld",&h,&n);
    ll a[n],b[n];
    rep(i,0,n){
        scanf("%lld%lld",&a[i],&b[i]);
    }
    ll dp[h+1];
    rep(i,0,h+1) dp[i]=INF;
    dp[0]=0;
    rep(i,0,n){
        rep(j,1,h+1){
            dp[j]= min2( dp[j] , dp[max2(0,j-a[i])]+b[i] ) ;
        }
        // rep(j,0,h+1){
        //     printf("%lld ",dp[j]);
        // }
        // PN;
    }
    printf("%lld\n",dp[h]);
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;

    while( m != n ){
        if ( m > n ) m %= n;
        else         n %= m;

        if(m == 0) return n;
        if(n == 0) return m;
    }
    return m;
}

template <typename T>
T lcm( T m, T n ){
    if ( ( 0 == m ) || ( 0 == n ) ) return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    auto CD = lcm(C,D);
    auto divC  = B/C - (A-1)/C;
    auto divD  = B/D - (A-1)/D;
    auto divCD = B/CD - (A-1)/CD;
    cout<<(B-A+1-divC-divD+divCD)<<endl;

    return 0;
}

Measured memory_bytes: 256