akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> votes(n);
	int total = 0;
	for(int i = 0; i < n; i++){
		cin >> votes[i];
		total += votes[i];
	}
	int need = (total + 4 * m - 1) / (4 * m);
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(votes[i] >= need){
			cnt++;
		}
	}
	if(cnt >= m)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<int,long double> pd;
typedef pair<ld,int> pdd;

void debug_out(){cerr << ' ';}
template<typename t1,typename... t2>
void debug_out(t1 A, t2... B){cerr << " " << A;debug_out(B...);}
#define debug(...)cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)

const int MAXN = 1005;

struct node {ld x,y,r;};

vector<pd> adj[MAXN];

long double dist[MAXN];
node nodes[MAXN];

#define cerr if(0) cout

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ld sx,sy,ex,ey; int n;
	cin >> sx >> sy >> ex >> ey >> n;
	for (int i = 1; i <= n; ++i) cin >> nodes[i].x >> nodes[i].y >> nodes[i].r;
	nodes[0].x = sx, nodes[0].y = sy, nodes[0].r = 0;
	nodes[n+1].x = ex, nodes[n+1].y = ey, nodes[n+1].r = 0;
	for (int i = 0; i <= n+1; ++i) {
		for (int j = i+1; j <= n+1; ++j) {
			ld x1 = nodes[i].x, x2 = nodes[j].x;
			ld y1 = nodes[i].y, y2 = nodes[j].y;
			ld r1 = nodes[i].r, r2 = nodes[j].r;
			//ld d = sqrt(pow(abs(x1-x2),(ld)2)+pow(abs(y1-y2),(ld)2))-(r1+r2);
			ld d1 = abs(x1-x2)*abs(x1-x2);
			ld d2 = abs(y1-y2)*abs(y1-y2);
			ld d = sqrt(d1+d2)-(r1+r2);
			d = max(d,(ld)0);
			debug(x1,x2,y1,y2,d);
			cerr<<endl;
			adj[i].emplace_back(j,d);
			adj[j].emplace_back(i,d);
		}
	}
	for(int i = 0; i <= n+1; ++i) dist[i] = -1;
	priority_queue<pdd,vector<pdd>,greater<pdd> > pq;
	dist[0] = 0;
	pq.emplace((ld)0,0);
	while (pq.size()) {
		ld d = pq.top().f; int x = pq.top().s;
		pq.pop();
		if (dist[x]!=d) continue;
		for (auto it: adj[x]) {
			if (dist[it.f] == -1 || d+it.s < dist[it.f]) {
				dist[it.f] = d+it.s;
				pq.emplace(d+it.s,it.f);
			}
		}
	}
	cout << fixed << setprecision(10);
	cout<<dist[n+1];
	//for (int i = 0; i <= n+1; ++i) cout<<dist[i]<<' ';
    return 0;
}


Measured memory_bytes: 42768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

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

int n,m;
int a[SIZE],b[SIZE];
ll ans;
ll c[SIZE];

int par[SIZE]; //親
int rnk[SIZE]; //木の深さ
ll sz[SIZE]; //木の大きさ

//初期化(n要素0オリジン)
void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rnk[i] = 0;
    sz[i] = 1;
  }
}

//xの根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

//x,yの属する集合を併合
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y)return;

  if(rnk[x] < rnk[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(rnk[x] == rnk[y])rnk[x]++;
  }
  ans -= sz[x]*sz[y];
  sz[x] = sz[y] = sz[x]+sz[y];
}

int main(){
  cin >> n >> m;
  ans = ((ll)n)*((ll)(n-1))/2LL;
  c[m] = ans;
  rep(i,0,m){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }
  init(n);
  for(int i=m-1;i>=0;i--){
    unite(a[i],b[i]);
    c[i] = ans;
  }
  rep(i,1,m+1){
    cout << c[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4480
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 998244353;

int gcd(int a,int b){
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);

    rep(i,n)cin >> a[i];
    b[0] = a[0];
    c[n-1] = a[n-1];
    for(int i = 1;i < n;i++){
        b[i] = gcd(a[i],b[i-1]);
        c[n-1-i] = gcd(a[n-1-i],c[n-i]);
    }
    int ans = max(c[1],b[n-2]);
    for(int i = 1;i < n-1;i++){
        ans = max(ans,gcd(b[i-1],c[i+1]));
    }
    cout << ans << endl;
    rep(i,n) cerr << b[i] << " ";cerr << endl;
    rep(i,n) cerr << c[i] << " ";cerr << endl;





    
    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc125.contest.atcoder.jp/tasks/abc125_c


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

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

    int sn = 0;
    for (int i = n; i > 0; i /= 10) {
        sn += i % 10;
    }

    cout << (n % sn == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    ll ans = 1;
    for(ll i = 1;i * i <= M;i++){
        if(M % i)continue;
        ll a = 1, b = 1;
        if(M / i >= N)a = i;
        if(i >= N)b = M / i;
        ans = max({ans, a, b});
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c, x;
    int total=0;
    scanf("%d%d%d%d", &a, &b, &c, &x);
    for (int i=0; i<a+1; i++)
        for (int j=0; j<b+1; j++)
            for (int k=0; k<c+1; k++)
                if (500*i+100*j+50*k==x)
                    total++;
    printf("%d", total);
    return 0;
}


Measured memory_bytes: 256
def SelectionSort(A):
    count = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j] < A[mini]:
                mini = j
        if A[i] != A[mini]:
            A[i], A[mini] = A[mini], A[i]
            count += 1
    return A, count

N = int(input())
A = list(map(int, input().split()))
selection_sort, count = SelectionSort(A)
print(*selection_sort)
print(count)


Measured memory_bytes: 5608
#include <stdio.h>
#include <math.h>

int main(void) {
  double x1, x2, y1, y2;
  double dist;

  scanf("%lf %lf %lf %lf", &x1, &x2, &y1, &y2);

  dist = sqrt((y1 - x1) * (y1 - x1) + (y2 - x2) * (y2 - x2));

  printf("%lf\n", dist);

  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main(){
  int n;
  long long a;
  long long minValue = 1000000;
  long long maxValue = -1000000;
  long long sum = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a < minValue)minValue = a;
    if (a > maxValue)maxValue = a;
    sum += a;
  }
  cout << minValue << " " << maxValue << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

    vector<char> name(0);

    while (n > 0)
    {
        ll next = (n - 1) / 26;
        ll m = (n - 1) % 26;

        name.push_back(m + 'a');

        n = next;
    }

    reverse(name.begin(), name.end());

    for (int i = 0; i < name.size(); i++)
    {
        cout << name[i];
    }

    cout << endl;
}

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

#define debug(x) (cerr << #x << " = " << x << endl;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c)

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

const int maxn = 6;

int s[maxn], c[maxn];

int poww(int a, int b)
{
  int ans = 1;
  while(b--)
  {
    ans *= a;
  }
  return ans;
}

int main()
{
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;

  for(int i = 0; i < m; i++)
  {
    cin >> s[i] >> c[i];
    s[i]--;
  }


  for(int i = n-1 == 0 ? 0 : poww(10,n-1); i < poww(10,(n)); i++)
  {
    string t = to_string(i);
    bool ok = true;
    // cout << t << endl;
    for(int j = 0; j < m; j++)
    {
      ok &= t[s[j]] == (c[j] + '0');
    }
    if(ok)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;

  return 0;
}

Measured memory_bytes: 256
#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);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 1;i < n;++i) {
		if (a[i - 1] == a[i]) {
			ans++;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int n,m;
int t[10]={0,2,5,5,4,5,6,3,7,6};
int num[8]={-1,-1,-1,-1,-1,-1,-1,-1};
int digits[10004],frm[10004],cntp[10004];
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int x;
		cin>>x;
		num[t[x]]=max(x,num[t[x]]);
	}
	memset (digits,-1,sizeof(digits));
	digits[0]=0;
	for (int i=1;i<=n;i++){
		for (int j=0;j<8;j++)
			if(num[j]!=-1 && i-j>=0){
				int x=i-j;
				if (digits[x]==-1) continue;
				if (digits[x]<digits[i]-1) continue;
				if (num[j]<cntp[i]) continue;
				cntp[i]=num[j];
				digits[i]=digits[x]+1;
				frm[i]=x;
			}
	}
	int x=n;
	while (x!=0){
		cout<<cntp[x];
		x=frm[x];
	}
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0566

"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline


def main(args):
    N = int(input())
    scores = [0] * (N+1)
    scores[0] = -1
    results = [-1] * (N+1)

    for _ in range(N*(N-1)//2):
        a, b, c, d = [int(x) for x in input().split()]
        if c > d:
            scores[a] += 3
        elif c < d:
            scores[b] += 3
        else:
            scores[a] += 1
            scores[b] += 1

    pq = []
    for i, s in enumerate(scores[1:], start=1):
        heappush(pq, [-s, i])

    rank = 1
    display_rank = 1
    prev_score = float('inf')
    while pq:
        s, i = heappop(pq)
        if s == prev_score:
            results[i] = rank
        else:
            rank = display_rank
            results[i] = rank
        display_rank += 1
        prev_score = s

    for r in results[1:]:
        print(r)



if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
#include <cmath>

using namespace std;
typedef long long ll;

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

int main(){
    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << n * 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

const int mod=1000000007;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum=0;
    rep(i,n) {
        sum+=a[i];
        sum%=mod;
    }
    ll ans=0;
    rep(i,n) {
        sum-=a[i];
        if(sum<0) sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    cout << ans << endl;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<double> p;
  vector<vector<double>> dp;
  Solver(LL n) : n(n), p(n + 1), dp(n + 1, vector<double>(n + 1)){};

  void solve() {
    for (int i = 1; i <= n; ++i) {
      cin >> p[i];
    }
    dp[0][0] = 1.0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j <= i; ++j) {
        dp[i + 1][j + 1] += dp[i][j] * p[i + 1];
        dp[i + 1][j] += dp[i][j] * (1.0 - p[i + 1]);
      }
    }
    double ans = 0.0;
    for (int i = 0; i <= n; ++i) {
      if (i > n - i) {
        ans += dp[n][i];
      }
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 71168
import java.util.*;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A >= 13){
            System.out.println(B);
            return;
        } else if(A >= 6 && A <= 12) {
            System.out.println(B/2);
            return;
        } else {
            System.out.println(0);
            return;
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    deque<int> path;

    vector<bool> used(N,false);
    int s = 0;
    int t = G[s][0];

    path.push_front(s);
    path.push_back(t);
    used[s] = true;
    used[t] = true;

    while(1){
        int u = path.back();

        bool flag = false;
        for(int v : G[u]){
            if(used[v]) continue;
            used[v] = true;
            flag = true;
            path.push_back(v);
            break;
        }
        if(!flag){
            break;
        }
    }

    while(1){
        int u = path.front();
        bool flag = false;
        for(int v : G[u]){
            if(used[v]) continue;
            used[v] = true;
            flag = true;
            path.push_front(v);
            break;
        }
        if(!flag){
            break;
        }
    }

    cout << path.size() << endl;
    for(auto v : path){
        cout << v+1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 6656
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int N = in.nextInt();
        int K = in.nextInt();

        int[] values = new int[N];
        for (int i = 0; i < N; i++) {
            values[i] = in.nextInt();
        }
        Arrays.sort(values);

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N-K+1; i++) {
            min = Math.min(values[i+K-1] - values[i], min);
        }

        System.out.println(min);
    }

}


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

int main() {
  int n, m;
  while ( cin >> n >> m ) {
    pair<long long,long long> pl[ n+5 ];
    
    for (int i = 0; i < n; ++i) {
      long long a, b; cin >> a >> b;
      pl[i] = make_pair( a, b );
    }
    
    sort( pl, pl+n );
    long long mny = 0;
    int buy = 0, tok = -1;
    while ( buy+pl[++tok].second < m ) {
      buy += pl[tok].second;
      mny += pl[tok].first*pl[tok].second;
    }
    
    mny += (m-buy)*pl[tok].first;
    cout << mny << '\n';
  }
  return 0;
}


Measured memory_bytes: 1792
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# a〜z -- START --
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
# a〜z --- END ---

lc=[0]*26

def main():
  n=I()
  s=S()

  ans=1

  for x in s:
    lc[l.index(x)]+=1

  for x in lc:
    ans*=(x+1)
    ans%=mod

  return ans-1

# main()
print(main())


Measured memory_bytes: 5592
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 262144
int main() {
	int n;
	cin >> n;
	for (long long i = 1;i <= 3500;++i) {
		for (long long q = i;q <= 3500;++q) {
			long long left = 4 * i * q;
			long long right = n * (i*q);
			long long top = 3500;
			long long bot = 0;
			while (top - bot > 1) {
				long long h = (top + bot)/2;
				long long low = left * h;
				long long high = right + n * h * (i + q);
				if (low > high) {
					top = h;
				}
				else if (low == high) {
					cout << i << " " << q << " " << h << endl;
					return 0;
				}
				else {
					bot = h;
				}
			}
			long long h = bot;
			long long low = left * h;
			long long high = right + n * h * (i + q);
            if (low == high) {
				cout << i << " " << q << " " << h << endl;
				return 0;
			}
			 h = top;
			 low = left * h;
			high = right + n * h * (i + q);
			if (low > high) {
				top = h;
			}
			else if (low == high) {
				cout << i << " " << q << " " << h << endl;
				return 0;
			}
			else {
				bot = h;
			}
			//left *= h
			//right += n*h*(q+i)
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

int main() {
  int N;
  cin >> N;
  int A[N + 1];
  ll sum = 0;
  REPS(i, N + 1) {
    cin >> A[i];
    sum += A[i];
  }
  ll ans[N + 1];
  ll others = 0;
  for(int i = 2; i <= N; i += 2) {
    others += 2 * A[i];
  }
  ans[1] = sum - others;
  for(int i = 2; i <= N; i++) {
    ans[i] = 2 * A[i - 1] - ans[i - 1];
  }
  REPS(i, N + 1) {
    if(i != N) {
      cout << ans[i] << " ";
    } else {
      cout << ans[i] << endl;
    }
  }
}


Measured memory_bytes: 2432
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (N, K) = Scanner.Scan<int, int>();
            var P = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x) - 1).ToArray();
            var C = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var answer = -(long)1e18;

            for (var start = 0; start < N; start++)
            {
                var x = start;
                var cycle = new List<long>();
                var sum = 0L;
                while (true)
                {
                    x = P[x];
                    cycle.Add(C[x]);
                    sum += C[x];
                    if (x == start) break;
                }
                var tmp = 0L;
                for (var i = 0; i < cycle.Count; i++)
                {
                    tmp += cycle[i];
                    if (i + 1 > K) break;
                    var current = tmp;
                    if (sum > 0)
                    {
                        var e = (K - i - 1) / cycle.Count;
                        current += sum * e;
                    }
                    answer = Math.Max(answer, current);
                }
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
        }
    }
}


Measured memory_bytes: 49268
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

// int n,m,x,y,res=0,sz[2*up],par[2*up],ans[2*up];

// int get(int x)
// {
//     return x*(x-1)/2;
// }

// int find(int x)
// {
//     if(par[x]==x)
//         return x;
//     else
//         return par[x]=find(par[x]);
// }

// void merge(int u,int v)
// {
//     x=find(u);
//     y=find(v);
//     if(sz[x]<sz[y])
//         swap(x,y);
//     res-=get(sz[x]);
//     res-=get(sz[y]);
//     sz[x]+=sz[y];
//     res+=get(sz[x]);
//     par[v]=u;
// }

// void solve()
// {
//     cin>>n>>m;
//     vector<pii>q(m+1);
//     vector<pair<int,pii>>e(n);
//     repn(i,1,n)
//     {
//         sz[i]=1;
//         par[i]=i;
//     }
//     repn(i,1,n-1)
//     {
//         cin>>e[i].ss.ff>>e[i].ss.ss>>e[i].ff;
//     }
//     repn(i,1,m)
//     {
//         cin>>q[i].ff;
//         q[i].ss=i;
//     }
//     sort(all(e));
//     sort(all(q));
//     int pos=1;
//     repn(i,1,m)
//     {
//         while(pos<n && e[pos].ff<=q[i].ff)
//         {
//             x=e[pos].ss.ff;
//             y=e[pos].ss.ss;
//             merge(x,y);
//             ++pos;
//         }
//         ans[q[i].ss]=res;
//     }
//     repn(i,1,m)
//     {
//         cout<<ans[i]<<" ";
//     }
//     cout<<endl;
// }


int pre[2*up],a[2*up];
void solve()
{
    int n,m,a;
    cin>>n>>m;
    multiset<int,greater<int>>s;
    repn(i,1,n)
    {
        cin>>a;
        s.insert(a);
    }
    repn(i,1,m)
    {
        int p=*(s.begin());
        s.erase(s.begin());
        s.insert(p/2);
    }
    int ans=0;
    for(auto &u:s)
    {
        //cout<<u<<endl;
        ans+=u;
    }
    cout<<ans<<endl;
}

int32_t main()
{
    int t;
    // memset(prime, true, sizeof(prime)); 
    // sieve();
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 4992
package main
import(
  "fmt"
)
func main(){
  var n, i, temp int
  fmt.Scan(&n)
  l:
  for i=1;i<=n;i++{
    temp=i*i
    if temp>n{
      fmt.Println((i-1)*(i-1))
      break l
    }else if n==1{
      fmt.Println("1")
      break l
    }
  }
}

Measured memory_bytes: 512
# include "iostream"
# include "cstdio"

using namespace std;

long long A,B;

long long Work(long long Now){
	register long long Result=0;
	while(Now%4){
		Result^=Now;
		Now--;
	}
	Result^=Now;
	return Result;
}

int main(){
	register int i;
	register long long Ans;
	scanf("%lld%lld",&A,&B);
	Ans=Work(A-1)^Work(B);
	printf("%lld",Ans);
	return 0;
} 

Measured memory_bytes: 256
N = int(input())

h = list(map(int,input().split()))
cost = [float("inf")]*N
cost[0] = 0
for i in range(N-1):
    a = abs(h[i+1]-h[i])
    if (cost[i]+a) < cost[i+1]:
        cost[i+1] = cost[i]+a
    if N - 2 > i :
        b = abs(h[i+2]-h[i])
        if (cost[i]+b) < cost[i+2]:
            cost[i+2] = (cost[i]+b)
print(cost[N-1])

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<b){
    cout<<"a < b"<<endl;
  }
  else if(a>b){
    cout<<"a > b"<<endl;
  }
  else{
    cout<<"a == b"<<endl;
  }
}

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

int gcd(int a,int b){
	int t;
	while(b){
		t=a%b,a=b,b=t;
	}
	return a;
}

int main(){
	int tc,f,i;
	while(cin>>tc>>f){
		int a[100010];
		for(i=0;i<tc;i++)cin>>a[i];
		a[tc]=f;
		sort(a,a+tc+1);
		int b[100001];
		for(i=0;i<tc;i++)b[i]=a[i+1]-a[i];
		//cout<<"b0:"<<b[0]<<endl;
		int g=gcd(b[0],b[0]);
		for(i=1;i<tc;i++)g=gcd(g,b[i]);
		cout<<g<<endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int x, a, b;
    cin >> x >> a >> b;
    if (a >= b) cout << "delicious";
    else if (a + x >= b) cout << "safe";
    else cout << "dangerous";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char in[11], out[11];
    scanf("%s", in);
    int n = 0, x = 0;
    while(in[n] != '\0'){
        if(in[n] == '0'){
            out[x++] = '0';
        }else if(in[n] == '1'){
            out[x++] = '1';
        }else{
            if(x > 0){
                x--;
            }
        }
        n++;
    }
    out[x] = '\0';
    printf("%s", out);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main()
{
	int a[5];
	int k;
	for (auto i = 0; i < 5; i++)
	{
		std::cin >> a[i];
	}
	std::cin >> k;

	auto isOk = true;
	for (auto i = 0; i < 5; i++)
	{
		for (auto j = i + 1; j < 5; j++)
		{
			if (abs(a[j] - a[i]) > k)
			{
				isOk = false;
			}
		}
	}

	if (isOk)
	{
		std::cout << "Yay!";
	}
	else
	{
		std::cout << ":(";
	}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    int A[101][101];
    int B[101];
    int C[101];
    int n,m;
    int i,j;
    
    scanf("%d %d", &n, &m);
    
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    
    for(j=0;j<m;j++){
        scanf("%d",&B[j]);
    }
    
    for(i=0;i<n;i++){
        C[i]=0;
        for(j=0;j<m;j++){
            C[i]+=A[i][j]*B[j];
        }
        printf("%d\n",C[i]);
    }
    return 0;
}



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

int main(){
	int N;
	cin>>N;
	vector<long>arr;
	long tmp;
	int num=0;
	for(int i=0;i<N;++i){
		cin>>tmp;
		if(tmp<0){
			num++;
			arr.push_back(-tmp);
		}
		else arr.push_back(tmp);
	}
	sort(arr.begin(),arr.end());
	long ans=0;
	if(num%2==0){
		for(int i=0;i<N;++i){
			ans+=arr[i];
		}
	}
	else{
		for(int i=1;i<N;++i){
			ans+=arr[i];
		}
		ans-=arr[0];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
N, W = map(int, input().split())
Weight = [0]
Value = [0]
ans = 0
for i in range(N):
    w, v = map(int, input().split())
    Weight.append(w)
    Value.append(v)
VS = sum(Value)
DP = [[float('inf')] * (VS + 1) for i in range(N + 1)]

for n in range(N + 1):
    for val in range(VS + 1):
        if val == 0:
            DP[n][val] = 0
        elif Value[n] > val:
            DP[n][val] = DP[n - 1][val]
        else:
            DP[n][val] = min(DP[n - 1][val], DP[n - 1][val - Value[n]] + Weight[n])
            if (n == N) and (DP[n][val] <= W):
                ans = max(ans, val)

print(ans)

Measured memory_bytes: 309712
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int A = sc.nextInt();
    	int B = sc.nextInt();

    	System.out.println(A*B);

    }
}


Measured memory_bytes: 27040
import java.util.*;

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

		int result = 0;
		int cnt = 0;
		
		int a = 0;
		int b = 0;
		String op = "a";
		while(!(op.equals("?"))) {
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
			if(op.equals("?")) {
				break;
			} else if(op.equals("+")) {
				result = a + b;
				al.add(result);
				cnt++;
			} else if(op.equals("-")) {
				result = a - b;
				al.add(result);
				cnt++;
			} else if(op.equals("*")) {
				result = a * b;
				al.add(result);
				cnt++;
			} else if(op.equals("/")) {
				result = a / b;
				al.add(result);
				cnt++;
			}
		}
		
		for(int i = 0; i < cnt; i++) {
			System.out.println(al.get(i));
		}
		
	}
}

Measured memory_bytes: 26316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
int main(){
    int n,c;cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c));
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            cin >> d[i][j];
        }
    }
    vector<vector<int>> color(n,vector<int>(n));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> color[i][j];
            color[i][j]--;
        }
    }
    vector<vector<int>> sum(3,vector<int>(c));
    for(int C=0;C<c;C++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if((i+j)%3==0){
                    sum[0][C]+=d[color[i][j]][C];
                }
                else if((i+j)%3==1){
                    sum[1][C]+=d[color[i][j]][C];
                }
                else sum[2][C]+=d[color[i][j]][C];
            }
        }
    }
    int ans=INF;
    for(int i=0;i<c;i++){
        for(int j=0;j<c;j++){
            for(int k=0;k<c;k++){
                if(i==j||j==k||i==k) continue;
                ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	REP(i, m) cin >> x[i];

	if (m == 1)
	{
		cout << 0 << endl;
		return 0;
	}

	sort(x.begin(), x.end());
	vector<int> root(m - 1);

	REP(i, m - 1)
	{
		root[i] = x[i + 1] - x[i];
	}

	sort(root.rbegin(), root.rend());

	int ans = 0;

	FOR(i, n - 1, m - 1)
	{
		ans += root[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    string t = "abcdefghijklmnopqrstuvwxyz";
    set<char> sett;
    rep(i, 0, s.size())
        sett.insert(s[i]);
    int j = 0;
    for (auto it=sett.begin(); it!=sett.end();)
        while (j < t.size())
        {
            if (*it == t[j])
            {
                advance(it, 1);
                j++;
            }
            else 
            {
                cout << t[j];
                return 0;
            }
        }
    cout << "None";
    return 0;
}

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

int main() {

	int n, k; cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	int sum = 0;
	for (int i = 0; i < k; i++) {
		sum += p[i];
	}

	cout << sum << endl;
	return 0;
}

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

const int MAXN=21111;
int a[MAXN], b[MAXN], f[MAXN], g[MAXN];
int n, m, num1, num2, ans;

int main() {
    scanf("%d", &n);
    for(int i=1;i<=n;++i) {
        scanf("%1d", &a[i]);
        num1+=(i==1 || a[i]!=a[i-1]) ? 1 : 0;
    }
    for(int i=1;i<=n;++i) {
        scanf("%1d", &b[i]);
        num2+=(i==1 || b[i]!=b[i-1]) ? 1 : 0;
    }
    if(num1>num2) {
        for(int i=1;i<=n;++i) {
            swap(a[i], b[i]);
        }
        swap(num1, num2);
    }
    for(int i=1;i<=n;++i) {
        g[++m]=2;
    }
    for(int i=1;i<=n;++i) {
        if(i==1 || b[i]!=b[i-1]) g[++m]=2;
        g[++m]=b[i];
    }
    for(int i=0;i<=n;++i) {
        g[++m]=2;
    }
    ans=1e9;
    for(int i=1;i+num1+n<=m;++i) {
        if(a[1]==b[1] && !((n+i)&1)) continue;
        else if(a[1]!=b[1] && ((n+i)&1)) continue;
        for(int j=1;j<=i;++j) {
            f[j]=2;
        }
        int now=i;
        for(int j=1;j<=n;++j) {
            if(j>1 && a[j]!=a[j-1]) f[++now]=2;
            f[++now]=a[j];
        }
        for(;++now<=m;) {
            f[now]=2;
        }
        int L=1, R=1, res=0;
        // for(int j=1;j<=m;++j) {
        //  printf("%c", f[j]<=1 ? f[j]+'0' : '|');
        // } puts("");
        // for(int j=1;j<=m;++j) {
        //  printf("%c", g[j]<=1 ? g[j]+'0' : '|');
        // } puts("");
        while(L<=m && R<=m) {
            if(f[L]==2 && g[R]==2) {
                res+=abs(L-R);
                ++L;
                ++R;
            }
            while(L<=m && f[L]!=2) ++L;
            while(R<=m && g[R]!=2) ++R;
        }
        // printf("==> %d\n", res);
        ans=min(ans, res);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>

int gcd(int x, int y) {
  if (y == 0) {
    return x;
  } else {
    gcd(y, x % y);
  }
}

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans = gcd(ans, a);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define int long long

int n,a[100005],f,s;

map<int,int> cnt;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        if(cnt[a[i]]>=2){
            if(a[i]>f) s=f,f=a[i];
            else if(a[i]>s) s=a[i];
        }
        if(cnt[a[i]]>=4){
            if(a[i]>s) s=a[i];
        }
        cnt[a[i]]=0;
    }
    cout << f*s;
}


Measured memory_bytes: 7296
#include <iostream>

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if ((a + d - 1) / d >= (c + b - 1) / b) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void) {
	int n, m, a[1000];
	double sum = 0;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	int count = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] >= sum * (1.0 / (4 * m))) {
			count += 1;
		}
	}

	printf(count>=m ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;

int main(void){
	int n; cin >> n;
	string str; cin >> str;
	for(int i=0; i<str.length(); i++){
		str[i] += n;
		if(!isalpha(str[i]) || str[i] >= 'a'){
			str[i] -= 26;
		}
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long
int main() {
   ll x,k,d;
   cin>>x>>k>>d;
   x=abs(x);
   ll str= min(k,x/d);
   k-= str;
   x-= str*d ;
   if(k%2==0)
    cout<<x<<endl;
else cout<< abs(d-x)<<endl; 
    
}


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

int main(void){
    int n;
    while(cin>>n, n){
        bool on = false, l = false, r = false;
        int cnt = 0;
        rep(i,n){
            string s;
            cin>>s;
            if(s[0]=='l') l^=true;
            if(s[0]=='r') r^=true;
            if(l == r && on^l){
                on^=true;
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3120
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;

int main() {
	array<int, 3> N;
	int Max = 0, Sum = 0;
	int K;
	for (int i = 0; i < 3; i++) {
		cin >> N[i];
		Sum += N[i];
		Max = max(N[i], Max);
	}
	cin >> K;
	Sum = Sum - Max + Max * pow(2, K);
	cout << Sum<< endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e6+3)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(all(a));
  int ans = 0;
  for(int i=0;i<k;i++)ans+=a[i];
  cout<<ans;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200000;
int n, s;
vector < int > ans;
int f(int b, int n){
    if (n < b) return n;
    return f(b, n / b) + n % b;
}
void check(int x){
    if (x < 2) return;
    int res = f(x, n);
    if (res == s){
        ans.pb(x);
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
	cin >> n >> s;
	if (n == s){
        cout << n + 1;
        return 0;
	}
	for (int i = 2; i * i <= 2 * n; i++){
        check(i);
	}
	for (int i = 1; i * i <= n - s; i++){
        if ((n - s) % i == 0){
            check(i);
            check((n - s) / i + 1);
        }
	}
	if (ans.empty())
	cout << -1; else{
	    sort(ans.begin(), ans.end());
	    cout << ans[0];
	}
}


Measured memory_bytes: 256
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
n = int(input())
ans = 0
sum = 0
ansdic = {}
for i in range(n):
  s = input()
  slist = [i for i in s]
  slist.sort()
  smoji = ','.join(slist)
  if smoji in ansdic:
    ansdic[smoji] += 1
  else:
    ansdic[smoji] = 1
for i in ansdic:
  if ansdic[i] > 1:
    sum += cmb(ansdic[i],2)
print(sum)

Measured memory_bytes: 65368
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> anum(4, 0);
    REP(i, n) ++anum[a[i]];

    vector<vector<vector<ld>>> dp(n+1, vector<vector<ld>>(n+1, vector<ld>(n+1, 0.L)));
    
    REP(i, n+1) {
        REP(j, n+1) {
            REP(k, n+1) {
                ll s = i + j + k;
                if (s <= 0 || n < s) continue;
                dp[i][j][k] = (ld)(n - s) / s;
                if (i > 0) dp[i][j][k] += (dp[i-1][j+1][k  ] + 1) * i / s;
                if (j > 0) dp[i][j][k] += (dp[i  ][j-1][k+1] + 1) * j / s;
                if (k > 0) dp[i][j][k] += (dp[i  ][j  ][k-1] + 1) * k / s;
            }
        }
    }
    
    cout << fixed << setprecision(30) << dp[anum[3]][anum[2]][anum[1]] << endl;
    
}

Measured memory_bytes: 433408