akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
using namespace std;

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

Measured memory_bytes: 256
def f(a,b):
    mod = a%b
    if mod==0:
        return 0
    else:
        return b-mod
    
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ans=0
for i in reversed(range(n)):
    a,b = ab[i]
    ans+=f(a+ans,b)
print(ans)
    

Measured memory_bytes: 27380
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N,M,X,Y;
	scanf("%d %d %d %d",&N,&M,&X,&Y);

	int x_maxi = -BIG_NUM;
	int tmp;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		x_maxi = max(x_maxi,tmp);
	}

	int y_min = BIG_NUM;

	for(int i = 0; i < M; i++){

		scanf("%d",&tmp);
		y_min = min(y_min,tmp);
	}

	for(int Z = X+1; Z <= Y; Z++){

		if(Z > x_maxi && Z <= y_min){

			printf("No War\n");
			return 0;
		}
	}


	printf("War\n");

	return 0;
}


Measured memory_bytes: 3716
import sys
input = sys.stdin.readline
N, T = map(int, input().split())
ts = [int(x) for x in input().split()]

now = 0
ans = 0
for t in ts :
    if t >= now :
        ans += T
    else :
        ans += T - (now - t)
    now = t + T

print(ans)


Measured memory_bytes: 25744
from fractions import gcd

a, b, c, d = map(int, input().split())
print((b - (b // c + b // d - b // int(c * d / (gcd(c, d))))) - ((a - 1) - ((a - 1) // c + (a - 1) // d - (a - 1) // int(c * d / (gcd(c, d))))))

Measured memory_bytes: 5304
hw = input().split(" ");
h = int(hw[0]);
w = int(hw[1]);
f = [[0]*(w+2) for i in range(h+2)];
ans = [[0]*(w) for i in range(h)];
for i in range(1,h+1) :
	s = input()
	for j in range(1,w+1) :
		ans[i-1][j-1] = s[j-1];
		if s[j-1] == '.' :
			f[i][j] = 0;
		elif s[j-1] == '#':
			f[i][j] = 1;
for i in range(1,h+1) :
	for j in range(1,w+1) :
		if f[i][j] == 0 :
			countbom = 0;
			for k in range(i-1,i+2) :
				for l in range(j-1,j+2) :
					countbom += f[k][l];
			ans[i-1][j-1] = countbom;
for i in range(0,h) :
	out = '';
	for j in range(0,w) :
		out += str(ans[i][j]);
	print(out);

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	/*ll N, K;
	cin >> N >> K;
	ll t1 = N%K;
	ll t2 = abs(t1 - K);

	ll ans = min(t1, t2);
	

	cout << ans << endl;*/
	int N;
	//vector<ll> S(AMAX + 1);
	cin >> N;
	vector<int> data(N);
	vector<int> check(N);

	for (int i = 0; i < N; i++)
	{
		cin >> data.at(i);
		
	}


	sort(data.begin(), data.end(),greater<int>());
	for (int i = 0; i < N; i++)
	{
		if (data[i] % 10 == 0)
		{
			check[i] = 1;
		}

	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans += data[i];
	}
	for (int i = N - 1; i >= 0; i--)
	{
		if (ans % 10 != 0)
		{
			cout << ans << endl;
			return 0;
		}
		else
		{
			if (check[i] != 1)
			{
				ans -= data[i];
			}
		}
	}

	cout << 0 << endl;

	

	
	
	/*bool ans = false;
	vector<int> data();
	for (int i = 0; i < S.length(); i++)
	{
		for (char c = 'a'; c <= 'z'; c++)
		{
			if (c == S.at(i))
			{

			}
		}
	}
	for(char c = 'a';c<='z';c++)*/
	return 0;

}


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

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

    int N, K;
    cin >> N >> K;
    K--;
    cout << (N - 1 + K - 1) / K << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x, y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		x *= 2;
		ans++;
	}
	dunk(ans);
	return 0;
}

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

int main() {
  int n, T;
  long ans = 0;

  cin >> n >> T;

  vector<int> t(n);

  for (int i = 0; i < n; i++) cin >> t[i];

  for (int i = 0; i < n - 1; i++)
    if (t[i + 1] - t[i] < T)
      ans += t[i + 1] - t[i];
    else
      ans += T;

  cout << ans + T;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int X, Y;
    cin >> X >> Y;

    int res = 1;
    while(X*2 <= Y) {
        res++;
        X *= 2;
    }

    cout << res << endl;
    
    return 0;
}

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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

string s;

int main() {
	cin >> s;
	if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0]) return cout << "Yes", 0;
	cout << "No";
}

Measured memory_bytes: 256
INTEGER N,T
INTEGER C,J,Y
READ*,N,T
Y=1001!最初にYを答えに成りようにない値に設定しています
DO I=1,N
  READ*,C,J
  IF(J>T)CYCLE
  Y=MIN(Y,C)
END DO
IF(Y==1001)THEN
  PRINT"(A)","TLE"
ELSE
  PRINT"(I0)",Y
ENDIF
END

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
bool dp[101];

int main()
{
	fill(dp,dp+101,false);
	dp[0]=true;
	for(int i=0;i<100;i++)
	{
		for(int j=100;j>-1;j--)
		{
			if(dp[j])
			{
				if(j+4<101)
					dp[j+4]=true;
				if(j+7<101)
					dp[j+7]=true;
			}
		}
	}
	int n;
	cin>>n;
	if(dp[n])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
'''
- [ABC125 - C - GCD on Blackboard(300点)](https://qiita.com/hkrutknouch/items/e71488de4a0c8e83ee97)
- [累積GCDでAtCoder ABC 125 C – GCD on Blackboardを解く](https://muroiwataru.net/entry/abc-125-python)
'''

from fractions import gcd

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

#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (gcd(left[i],a[i]))
    right[n - i - 1] = (gcd(right[n - i],a[n - 1 - i]))

'''
5
64 48 16 18 12
の場合、

n = 0〜4
left:
    0 = 0
    1 = gcd(l[0], a[0]) → gcd(a[0])
    2 = gcd(l[1], a[1]) → gcd(a[0] + a[1])
    3 = gcd(l[2], a[2]) → gcd(a[0] + a[1] + a[2])
    4 = gcd(l[3], a[3]) → gcd(a[0] + a[1] + a[2] + a[3])
    5 = gcd(l[4], a[4]) → gcd(a[0] + a[1] + a[2] + a[3] + a[4])

right:
    5 = 0
    4 = gcd(r[5], a[4]) → gcd(a[4])
    3 = gcd(r[4], a[3]) → gcd(a[4] + a[3])
    2 = gcd(r[3], a[2]) → gcd(a[4] + a[3] + a[2])
    1 = gcd(r[2], a[1]) → gcd(a[4] + a[3] + a[2] + a[1])
    0 = gcd(r[1], a[0]) → gcd(a[4] + a[3] + a[2] + a[1] + a[0])
'''

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i],right[i + 1]))

    '''
    n = 0〜4
    gcd(l[0], r[1])  a[0] と a[4]〜a[1] のgcd :        a除外なし(全部同一の値のケース)
    gcd(l[1], r[2])  a[0] と a[4]〜a[2] のgcd :        a[1]を除外
    gcd(l[2], r[3])  a[0]〜a[1] と a[4]〜a[3] のgcd :  a[2]を除外
    gcd(l[3], r[4])  a[0]〜a[2] と a[4] のgcd :        a[3]を除外
    gcd(l[4], r[5])  a[0]〜a[3] と 0 の gcd :          a[4]を除外
    '''

print(ans)


Measured memory_bytes: 16144
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x,n;
    cin >> x >> n;
    vec(int,data,102);
    rep(i,n){
        int p;cin >> p;
        data[p]++;
    }
    rep(i,100){
        if(data[x-i]==0){
            cout << x-i << endl;
            break;
        }
        if(data[x+i]==0){
            cout << x+i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#ifdef MY_DEBUG_FLAG
template<typename T> void debug(T a) { cerr << a << ' '; }
template<typename T, typename U> void debug(pair<T, U> a) { cerr << a.first << ' ' << a.second << ' '; }
template<typename T> void debug(vector<T> a) { for(auto it : a) debug(it);}
template<typename T> void debug(set<T> a) { for(auto it : a) debug(it);}
#define db(a) cerr << "DEBUG ( " << #a << " == "; debug(a); cerr << ")\n"
#else
#define db(...)
#endif

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr)
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define dec(i,n,a) for(int i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()

constexpr int inf = 0x3f3f3f3f;
constexpr int MAXN = 1e5 + 10;
constexpr int mod = 1000000007;

// answer is 1*n + 2*(n-1) + 3*(n-2) ... n*1
// but we subtract from that value each pair
// for each pair ans -= left*(n-right+1)

int main() {
	int n; scanf("%d", &n);
	ll ans = 0;
	rep(i,0,n) ans += 1ll*(i+1)*(n-i);
	rep(i,1,n) {
		int l, r; scanf("%d %d", &l, &r);
		if(l > r) swap(l,r);
		ans -= 1ll*l*(n-r+1);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3832
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, K);
    AIN(ll, A, N);
    REP(k, min(K, 50LL))
    {
        vi B(N + 1);
        REP(i, N)
        {
            ++B[max(0LL, i - A[i])];
            --B[min(N, i + A[i] + 1)];
        }
        ll acc = 0;
        REP(i, N)
        {
            acc += B[i];
            A[i] = acc;
        }
    }
    JOUT(ALL(A)) << endl;
}

Measured memory_bytes: 6364
#include <stdio.h>

int main () {
    int x[10];
    for (int i = 1; i <= 5; i++)
    {
        scanf("%d", &x[i]);
    }
    for (int i = 1; i <= 5; i++)
    {
        if (x[i] == 0)
        printf("%d\n", i);
    }
    return 0;
}

Measured memory_bytes: 1680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int x = sc.NextInt();

        string answer = a <= x && a + b >= x ? "YES" : "NO";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
signed main(){
    char s[200000+1],t[200000+1];
    int i=0,w=0;
    scanf("%s %s",s,t);
    while(s[i]!='\0'){
        if(s[i]!=t[i]){
            w++;
        }
        i++;
    }
    printf("%d\n",w);
    return(0);
}

Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 40005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
string s;
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	cin >> s;
	if(s.substr(0,4) == "YAKI") puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll sum = a + b;
  ll ans = n/sum*a;
  n -= n/sum*sum;
  ans += min(a, n);
  cout << ans << endl;
  return 0;
}

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

int H, W;

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

  cin >> H >> W;
  string S[H];
  bool is_possible = true;

  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      if (S[h][w] == '.') {
        continue;
      }
      int num = 0;
      for (int y = -1; y <= 1; y ++) {
        if (h + y < 0 || h + y > H - 1) {
          continue;
        }
        for (int x = -1; x <= 1; x ++) {
          if (w + x < 0 || w + x > W - 1) {
            continue;
          }
          if (x + y == -1 || x + y == 1) {
            if (S[h + y][w + x] == '#') {
              num++;
            }
          }
        }
      }
      if (num == 0) {
        is_possible = false;
      }
      if (!is_possible) {
        break;
      }
    }
    if (!is_possible) {
      break;
    }
  }
  if (is_possible) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






std::map<long long, int> primeFactorisation_Map(long long n){
    std::map<long long, int> mp;
    for(long long i(2); i * i <= n; ++i)
        while(!(n % i)){
            ++mp[i]; n /= i;
        }
    if(n > 1) ++mp[n];
    return mp;
}

int main(){
    int n; std::cin >> n;
    std::map<long long, int> mp(primeFactorisation_Map(n));
    long long ans(n);
    for(auto pr: mp){
        long long p(pr.first);
        ans /= p;
        ans *= p - 1;
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3124
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		InputStreamReader isr;
		BufferedReader br;
		try {
	   		br = createBufferedReader();
	        String line = br.readLine();
	        char[] arr = line.toCharArray();
	        String res = "Yes";
	        for (int i = 0; i < arr.length; i++) {
	        	if (i % 2 == 0 && arr[i] == 'L') {
	        		res = "No";
	        		break;
	        	}
	        	if (i % 2 == 1 && arr[i] == 'R') {
	        		res = "No";
	        		break;
	        	}
	        }
	        System.out.println(res);
		} catch (IOException ioe) {
			ioe.printStackTrace();
		} catch (IllegalArgumentException iae) {
			iae.printStackTrace();
			System.err.println("入力が正しくありません。");
		}
	}

	// 以下問題問わずに共通部分
	// 標準入力の BufferedReader を返す.
	private static BufferedReader createBufferedReader() {
		InputStreamReader isr =new InputStreamReader(System.in);
	   	return new BufferedReader(isr);
	}
}


Measured memory_bytes: 23252
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct dualsegtree{
	function<T(T,T)>lazycalcfn,updatefn;
	int n;
	T lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	dualsegtree(int n_=0,T defvalue=0,
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>updatefn_=[](T a,T b){return a+b;},
		T lazydefvalue_=0
	):lazydefvalue(lazydefvalue_),
		lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(n,defvalue);
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i]=v[i];
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			if(k<n-1)
			{
				lazy[k]=lazycalcfn(lazy[k],x);
				lazyflag[k]=true;
			}
			else dat[k-n+1]=updatefn(dat[k-n+1],x);
		}
		else
		{
			if(lazyflag[k])
			{
				update(0,n,lazy[k],k*2+1,l,(l+r)/2);
				update(0,n,lazy[k],k*2+2,(l+r)/2,r);
				lazy[k]=lazydefvalue;
				lazyflag[k]=false;
			}
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
		}
	}
	T query(int i)
	{
		T ret=dat[i];
		i+=n-1;
		while(i>0)
		{
			i=(i-1)/2;
			if(lazyflag[i])ret=updatefn(ret,lazy[i]);
		}
		return ret;
	}
};
main()
{
	int N,Q;
	cin>>N>>Q;
	dualsegtree<int>P(N,(int)((1LL<<31)-1),
		[](int a,int b){return b;},[](int a,int b){return b;});
	for(;Q--;)
	{
		int q;cin>>q;
		if(q==0)
		{
			int s,t,x;cin>>s>>t>>x;
			P.update(s,t+1,x);
		}
		else
		{
			int i;cin>>i;cout<<P.query(i)<<endl;
		}
	}
}



Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    ll N, Q;
    void input() { cin >> N >> Q; }
    void output() {
        vector<vector<ll>> dec(2, vector<ll>(N, -1));
        vector<ll> d(2, N - 2);
        ll res = (N - 2) * (N - 2);
        REP(q, Q) {
            int t, x;
            cin >> t >> x;
            --t;
            if (dec[t][x] < 0) {
                d[!t] = x - 2;
                for (int i = x; i < N; ++i) {
                    if (dec[t][i] >= 0) break;
                    dec[t][i] = d[t];
                }
            }
            res -= dec[t][x];
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 7944
#include <stdio.h>
 
class Dice4{
public:
    int number[6];
 
    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };
 
    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
};
 
int main(){
    int n,k,j;
    scanf("%d",&n);
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
                &array[i].number[3],&array[i].number[4],&array[i].number[5]);
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}


Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);

    string s;
    cin >> s;

    // 答えは(変色回数-1) 漸化式で証明できる

    int change = 0;
    char pc = 'N';
    for (auto &&c : s)
    {
        if (c != pc)
            change++;

        pc = c;
    }

    const int ans = change - 1;

    cout << ans << endl;
}


Measured memory_bytes: 512
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int n,k;

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n >> k;
	int ans = 1;
	while(n--)
	{
		ans = min(ans * 2,ans + k);
	}	
	rc(ans);
}


Measured memory_bytes: 256
#include <iostream>

int N;

int main() {
  std::cin>>N;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    long long x;  std::cin>>x;
    while (x % 2 == 0) {
      x /= 2;
      ans++;
    }
  }
  std::cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 256
import collections
N = int(input())
a = list(map(int,input().split()))
b = [a[i]-1 for i in range(len(a))]
c = [a[i]+1 for i in range(len(a))]
a.extend(b)
a.extend(c)
X = collections.Counter(a)
print(X.most_common()[0][1])

Measured memory_bytes: 31708
import math
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
if is_prime(N):
    print(1)
elif N == 1:
    print(0)
else:
    insu = factorization(N)
    ans = 0
    for i,j in insu:
        p = 1
        while True:
            j -= p
            if j >= 0:
                N = N // (i**p)
                ans += 1
            else:
                break
            p += 1
    print(ans)

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

char a[107][107];
int f[26];
int k[3];

int h, w;
int n4, n2, n1;

int main(){
	cin >> h >> w;
	for(int i=0; i<h; i++)for(int j=0; j<w; j++){ cin >> a[i][j]; f[a[i][j]-'a']++; }

	if(h%2==1 && w%2==1){
		n1 = 1;
		n2 = h + w -2;
	}
	else if(h%2==0 && w%2==1){
		n1 = 0;
		n2 = h;
	}
	else if(h%2==1 && w%2==0){
		n1 = 0;
		n2 = w;
	}
	else{
		n1 = 0;
		n2 = 0;
	}
	n4 = h*w - n1 -n2;

	for(int i=0; i<26; i++){
		int p = f[i]/4;
		if(n4 >= p*4)n4 = n4 - p*4;
		else if(n2 >= p*4)n2 = n2 - p*4;
		else{
			printf("No\n");
			return 0;
		}
		f[i] = f[i]%4;
		int q = f[i]/2;
		if(n2 >= q*2)n2 = n2 -q*2;
		else{
			printf("No\n");
			return 0;
		}
		f[i] = f[i]%2;
		if(n1 >= f[i])n1 = n1 - f[i];
		else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
int a, b, c;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> a >> b >> c;
	if (a == b && b == c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 256
n = int(input())
lists = list(map(int, input().split()))

center = sum(lists)/n
i_part = sum(lists)//n
f_part = center - i_part

if f_part >= 0.5:
    central_int = i_part + 1
else:
    central_int = i_part

stamina = 0
for x in lists:
    stamina += (x-central_int)**2
print(stamina)

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

#define gcu getchar_unlocked
#define ii inline int in
ii(int c) {
	int n = 0;
	bool minus = false; if (c == '-') minus = true, c = gcu();
	do {n = 10 * n + (c - '0'), c = gcu();} while (c >= '0');
	//return n; }
	return minus ? -n : n; }
ii() {return in(gcu());}
inline bool scan(int &n) {int c=gcu();return c==EOF?false:(n=in(c),true);}
//void scan(string &s) {for (char c; !isspace(c = gcu()); s += c);}
#undef ii
#define pcu putchar_unlocked
template <typename T>
void out(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); }
void out(const char *s){while(*s)pcu(*s++);}
void out(char c){pcu(c);}
//void out(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
void out(head&& h, tail&&... t){out(h);out(move(t)...);}
template <typename T>
//void out(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
void out(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef svo

typedef vector<vector<int>> map;

bool walk(int x, int y, map &m) {
	static const int
		dx[] = {1, 1, 0, -1, -1, -1, 0, 1},
		dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
	if (x < 0 || x >= (int) m[0].size() ||
		y < 0 || y >= (int) m.size() ||
		m[y][x] == 0)
		return false;
	m[y][x] = 0;
	int i = 0;
	for (; i < 8; i++)
		walk(x + dx[i], y + dy[i], m);
	return true;
}

int main() {
	int W, H;
	while(scan(W) && scan(H) && (W || H)) {
		map m(H, vector<int>(W));
		for (auto &v: m)
			for (int &i :v)
				i = in();
		int c = 0;
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
				if (walk(j, i, m))
					c++;
		//for (auto v : m)
		//	out(v);
		//out('\n');
		out(c, '\n');
	}
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


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

	string s;
	ll a,b,c;
	a=b=c=0;
	cin >> s;

	FOR(i,0,s.size()){
		if(s[i]=='a')a++;
		if(s[i]=='b')b++;
		if(s[i]=='c')c++;
	}

	ll mi = min({a,b,c});
	ll ma = max({a,b,c});

	if((ma-mi)<2){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(all(a));
    int j=0;
    while(sum%10==0){
        if(a[j]%10!=0) sum-=a[j];
        j++;
        if(j==n) break;
    }
    if(j==n&&sum%10==0) sum=0;
    cout<<sum;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	int n;
	S(d, n);
	while (n--) {
		int r, t;
		fscanf(stdin, "%d%d", &r, &t);
		int a = 5 * (t / 30) + (r / 100),
			b = 5 * (t / 30) + (r / 100 + 1),
			c = 5 * (t / 30 + 1) + (r / 100),
			d = 5 * (t / 30 + 1) + (r / 100 + 1);
		if (!(r % 100) && !(t % 30)) P(d, a);
		else if (!(t % 30)) fprintf(stdout, "%d ", a), P(d, b);
		else if (!(r % 100))fprintf(stdout, "%d ", a), P(d, c);
		else fprintf(stdout, "%d ", a),
			 fprintf(stdout, "%d ", b),
			 fprintf(stdout, "%d ", c),
			 P(d, d);
	}
	return 0;
}

Measured memory_bytes: 604
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ans = 0
pre = 0
n.times do |i|
    if a[i] > b[i] + pre then
        ans += b[i] + pre
        pre = 0
    else
        ans += a[i]
        pre = (a[i] > pre ? b[i] + pre - a[i] : b[i])
    end
end

puts ans + (a[n] > pre ? pre : a[n])

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

#pragma GCC optimize(2)

#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define per(i, r, l) for (int i = (r); i >= (l); --i)
using namespace std;

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

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

int main() {
	int a = gi(), b = gi();
	puts(a == b ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[3];
    int ans;
    for(int i;i<3;i++){
        cin >>a[i];
    }
    sort(a,a+3);
    ans=a[0]-a[2];
    if(ans<0)ans*=-1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i=1; i<=n; i++)
	{
		int x;
		cin >> x;
		if (x%2==0)
			if (!(x%3==0||x%5==0))
			{
				cout << "DENIED" << endl;
				return 0;
			}
	}
	cout << "APPROVED" << endl;
	return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())

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

b = []
for i in range(n):
    b.append(abs(a[i]-x))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

if n == 1:
    print(b[0])
else:
    ans = gcd(b[0], b[1])
    for i in range(2, n):
        ans = gcd(ans, b[i])
    print(ans)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;





int main()
{
string s ;
cin>>s;

for(int index  = 0 ;index < s.size();index++)
    if(index%2==0)
    cout<<s[index];
cout<<endl;

 return 0;
}


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

#define INF 1000000000000


int main()
{
	ll a,b;
  cin>>a>>b;
  ll k=(a+(b/2))/b;
  ll l=a/b;
  if(b%2==1){
    cout<<l*l*l<<endl;
  }
  if (b%2==0){
    cout<<k*k*k+l*l*l<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
//#include<fstream>
#include<stdlib.h>

using namespace std;

int int_sort(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {

	//ifstream fin("in.txt");

	while (true) {
		int in = 0;
		int n = 0;

		bool finish = true;

		int a[6] = {};
		int result[20] = {};
		int count = 0;

		cin >> in;
		cin >> n;
		
		if (in == 0 && n == 0)break;

		result[0] = in;

		while (finish) {

			//input???????§£???????????????????´?
			for (int i = 0; i < n; i++) {
				a[n - i - 1] = in % 10;
				in /= 10;
			}

			qsort(a, n, sizeof(int), int_sort);

			int tmp_min = 0;
			int tmp_max = 0;
			int log = 1;

			//????????????????????°?????????
			for (int i = 0; i < n; i++) {
				tmp_min += a[n - i - 1] * log;
				tmp_max += a[i] * log;
				log *= 10;
			}

			in = tmp_max - tmp_min;
			for (int i = 0; i <= count; i++) {

				//????????§???????????¨????????°?¬????????????????
				if (in != result[i])continue;

				cout << i << " " << in << " " << count - i + 1 << endl;
				finish = false;
				break;
			}

			count++;
			result[count] = in;

		}
	}


	return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    int s = accumulate(ALL(A), 0);
    int t = (s + 4*M - 1)/(4*M);
    sort(ALL(A), greater<int>());
    REP(i, M) {
        if(A[i] < t) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-10;
const int inf=0x3f3f3f3f;
const int N=5e5+20;
int n,a[N]; 
int main()
{
	while(cin>>n)
	{
		for(int i=1;i<=n;i++)
			cin>>a[i];
		int ans=2e6;;
		for(int k=-100;k<=100;k++)
		{
			int res=0;
			for(int i=1;i<=n;i++)
				res+=(a[i]-k)*(a[i]-k);
			ans=min(res,ans);	
		}	
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
double x[10];
double y[10];
double dist[10][10];

int a[10];

double cal()
{
    double ans = 0;
    for(int i=1; i<n; i++) ans += dist[a[i]][a[i+1]];
    return ans;
}

double tot;
int cnt;


int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n) cin >> x[i] >> y[i];
    Forn(i, n) Forn(j, n) dist[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
    Forn(i, n) a[i] = i;
    while(1)
    {
        //Forn(i, n) cout << a[i] << " ";
        //cout << endl;
        //cout << "cal = " << cal() << endl;
        tot += cal();
        cnt++;
        if(!next_permutation(a+1, a+n+1)) break;
    }
    //cout << tot << " " << cnt << endl;
    cout << fixed << setprecision(8) << tot / cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define sz 100005
using namespace std;



int main()
{


    FASTIO
    string s;
    cin >> s;
    if(s=="Sunny")cout<<"Cloudy";
    if(s=="Cloudy")cout<<"Rainy";
    if(s=="Rainy")cout<<"Sunny";



return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  n=int(input())
  a=tuple(map(int,sys.stdin.readline().split()))
  b=[0]*n
  i=1
  for index in a:
    b[index-1]=i
    i+=1
  print(" ".join(map(str,b)))
if __name__=="__main__":
  main()

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

int pow(int n,int r){
  if (r == 0) return 1;
  else return n * pow(n,r-1);
}

double prob(double n, double K){
  if (n >= K) return 1;
  int count = 0;
  while(1){
    n *= 2;
    count ++;
    if (n >= K) break;
  }
  return double(1) / pow(2,count);
}

int main(){
  
  int N,K;
  cin >> N >> K;
  
  double ans = 0;
  
  for (double i=1;i<=N;i++){
    double part = double(prob(i,K) / N);
    //cout << std::setprecision(9) << part << endl; //test
    ans += part;
  }
  
  cout << std::setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.Map as Map
import qualified Data.IntMap as IMap
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

solve n m
  | n == 1 && m== 1 = 1
  | n == 2 = 0
  | m == 2 = 0
  | m == 1 = n-2
  | n == 1 = m-2
  | otherwise = (n-2) * (m-2)
  
main = do
    [n,m] <- (map read . words) <$> getLine
    print $ solve n m


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

int main()
{
	int n, m, l;
	int i, j, k;
	
	cin >> n >> m >> l;
	int a[n][m], b[m][l];
	long c[n][l];
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin >> a[i][j];
		}
	}
	
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin >> b[i][j];
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			c[i][j]=0;
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];	
			}
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			cout << c[i][j];
			if(j!=l-1)
				cout << ' ';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
using namespace std;
int a[200005];
typedef long long ll;
ll mod = 1000000007;
ll fa[100005];
ll po(ll a, int b)
{
    if(b==0)return 1;
    ll x = po(a, b/2);
    x = (x*x)%mod;
    if(b%2)x = (a*x)%mod;
    return x;
}
vector<int> v[100005];
ll ncr(int n, int r)
{
    if(r > n)return 0;
    if(r < 0)return 0;
    ll num = fa[n];
    ll den = (fa[r] * fa[n-r])%mod;
    den = po(den, mod-2);
    return (num * den)%mod;
}
int main() {
	int n,i;
	fa[0] = 1;
	for(n=1;n<=100001;n++)
	fa[n] = (n * fa[n-1])%mod;
	scanf("%d",&n);
	for(i=1;i<=n+1;i++){
	scanf("%d",&a[i]);
	v[a[i]].push_back(i);
	}
	for(i=1;i<=n;i++)
	if(v[i].size()==2)break;
	

    int  len;
    int d = v[i][1] - v[i][0];
    for(len=1; len<=n+1;len++)
    {
        ll total = ncr(n+1, len);
        ll rem=0;
       rem = ncr(n-d, len-1);
        printf("%lld\n",(mod + total-rem)%mod);
    }
   
	return 0;
}


Measured memory_bytes: 7808
#include "stdio.h"
 
int main(void)
{
    int n,i,t;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        if(i%3==0)
        {
            printf(" %d",i);
            continue;
        }
        t=i;
        while(t>2)
        {
            if(t%10==3)
            {
                printf(" %d",i);
                break;  
            }
            t /= 10;
        }
    }
    printf("\n");
    return 0;
}

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

typedef long long ll;

int main()
{
    ll h;
    ll n;
    cin >> h >> n;
    int i;
    vector<int> a(n);
    vector<int> b(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> dp(h+1,1e9);
    dp.at(0) = 0;
    for(i = 0;i <= h;++i){
        for(int j = 0;j < n;++j){
            dp.at(i) = min(dp.at(i),dp.at(max(0, i - a.at(j))) + b.at(j));
        }
    }
    cout << dp.at(h) << endl;
    return 0;
}

Measured memory_bytes: 384
#マックスから引くやり方
import numpy as np
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
# 届く時間を1の位で切り上げたとき、届く時間の和
Menu = [A,B,C,D,E]
L1=[0]
L2=[]
time_max=0
extra=[]
"""
解答1
"""
for i in Menu:
    if i%10==0:
        L1.append(i)
    else:
        L2.append(i + 10 - int(i%10))
        extra.append(i%10)

if len(L2)>0:        
	tmp = 10 - min(extra)
	time_max=sum(L1)+sum(L2)
	print(time_max-tmp)
else: #全部10で割れる場合
  print(sum(L1))
 
 
 

Measured memory_bytes: 12508
# coding: utf-8
# Your code here!

for l in range(4):
    t,n = [int(i) for i in input().split()]
    if t == 1:
        print(6000*n)
    elif t == 2:
        print(4000*n)
    elif t == 3:
        print(3000*n)
    elif t == 4:
        print(2000*n)
        


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define	pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigboi        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(all(v), RNG);
// Use mt19937_64 for 64 bit random numbers.

void solve(){	
	int x ,y, z;
	cin>>x>>y>>z;
	swap(x, y);
	swap(x, z);
	cout<<x<<" "<<y<<" "<<z<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
 
}


Measured memory_bytes: 256
import * as fs from "fs";

const [s, t] = fs.readFileSync("/dev/stdin", "utf8").split("\n");


function solve(s: string, t: string): number {
	let nearestChars: Map<string, number> = new Map();
	let array: Array<Map<string, number>> = new Array(s.length);

	for(let i=s.length-1; i>=0; i--) {
		array[i] = new Map(nearestChars);
		array[i].set(s[i], i);
		nearestChars = array[i];
	}
	let t_i = 0, s_i = 0;
	let consumed = 0;
	while (t_i < t.length) {
		if (array[s_i].has(t[t_i])) {
			consumed += array[s_i].get(t[t_i])-s_i+1;
			s_i = array[s_i].get(t[t_i])+1;
			t_i += 1;
		} else if (array[0].has(t[t_i])) {
			consumed += array.length-s_i+array[0].get(t[t_i])+1;
			s_i = array[0].get(t[t_i])+1;
			t_i += 1
		} else {
			return -1
		}
		s_i %= s.length;
	}
	return consumed;
}

console.log(solve(s, t));

/**
for (const [s, t] of tests) {
	console.log(`s=${s}, t=${t}`, solve(s, t));
}
*/


Measured memory_bytes: 159956