akhauriyash/Code-Regression huggingface dataset:
def fact(A):
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)
n = int(input())
lis = []
for i in range(2,n+1):
    lis.extend(fact(i))
lis = sorted(lis)
L = set(lis)
import collections
c = collections.Counter(lis)
x = [0,0,0,0,0]
for R in L:
    if c[R] >= 2:
        x[0] += 1
    if c[R] >= 4:
        x[1] += 1
    if c[R] >= 14:
        x[2] += 1
    if c[R] >= 24:
        x[3] += 1
    if c[R] >= 74:
        x[4] += 1
ans = max((x[0]-2)*(x[1]-1)*x[1]//2, 0) + max((x[1]-1)*x[2], 0) + max((x[0]-1)*x[3], 0) + x[4]
print(ans)

Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}
void chmax(int &a, int b) { if (a < b) a = b; }
void chmin(lint &a, lint b) { if (a > b) a = b; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
    }
} iosetup;

int counter(int x) {
  if (x == 0) return 0;
  return counter(x >> 1) + (x & 1);
}

int a[20];
int x[20][20];
int y[20][20];

int main() {
  int n, ans = 0; cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    for (int j = 1; j <= a[i]; ++j) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  
  for (int bits = 1; bits < (1 << n); ++bits) {
    bool ok = true;
    for (int i = 1; i <= n; ++i) {
      if (!(bits & (1 << (i-1)))) continue;
      for (int j = 1; j <= a[i]; ++j) {
        if ((bits >> (x[i][j]-1)& 1) ^ y[i][j]) ok = false;
      }
    }
    if (ok) chmax((ans), (counter(bits)));
  }
  cout << ans << '\n';
}


















Measured memory_bytes: 256
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        int x=-1, k=-1;
        Scanner input = new Scanner(System.in);
        for(int i=1; i<=5; i++){
            x=input.nextInt();
            if(x==0){
                k=i;
            }
        }
        System.out.print(k);
    }
}

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

int main() {
  
  string S;
  cin >> S;
  
  int year = stoi(S.substr(0, 4));
  int month = stoi(S.substr(5, 2));
  int day = stoi(S.substr(8, 2));

  string res ="TBD";
  if(year<=2019){
    if(month<=4){
      if(day<=30){ res = "Heisei"; }
      else{res = "TBD";}
    }
    else{ res = "TBD"; }
  }
  
  
  cout << res << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
/*
void call(int n){
	int i=1;
	int x;
	CHECK_NUM:
		x=i;
		if(x%3==0){
			printf(" %d",i);
			goto END_CHECK_NUM;
		}
	INCLUDE3:
		if(x%10==3){
			printf(" %d",i);
			goto END_CHECK_NUM;
		}
		x/=10;
		if(x!=0) goto INCLUDE3;
	END_CHECK_NUM:
		if(++i<=n) goto CHECK_NUM;
	printf("\n");
}
*/
int main(){
	int n;
	int i;
	int x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0){
			printf(" %d",i);
		}
		else{
			while(x!=0){
				if(x%10==3){
					printf(" %d",i);
					x=0;
				}
				x/=10;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/agc023/tasks/agc023_b
#include <bits/stdc++.h>
int n, t;
char s[305][305];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%s", s[i]);
    for (int i = 0; i < n; i++) {
        bool ok = true;
        for (int j = 0; ok & j < n - 1; j++)
            for (int k = j + 1; ok & k < n; k++)
                if (s[(j + i) % n][k] != s[(k + i) % n][j])
                    ok = false;
        t += ok;
    }
    printf("%d\n", t * n);
}

Measured memory_bytes: 384
#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(){
	int n;
	cin >> n;
	vector<int> d(n);
	rep(snip_i, n) cin >> d.at(snip_i);
	sort(d.begin(), d.end());
	vector<vector<int>> time(24, vector<int>());
	rep(i, n){
		int add = d.at(i);
		time.at(add).push_back(i);
	}
	bool flag = false;
	int bf = 0, ans = 25;
	rep(i, 24){
		int comp = -1;
		int s = time.at(i).size();
		if(i == 0 && s != 0){
			cout << 0 << endl;
			return 0;
		}
		if(s == 0)continue;
		else if(s == 1){
			if(i < 12){
				if(flag == true){
					int tr = 24 - i;
					time.at(tr).push_back(time.at(i).at(0));
					flag = false;
				}else{
					comp = i;
					flag = true;
				}
			}else{
				comp = i;
			}
		}else if(s == 2){
			if(i >= 12){
				cout << 0 << endl;
				return 0;
			}
			comp = i;
			int tr = 24 - i;
			time.at(tr).push_back(time.at(i).at(0));
		}else{
			cout << 0 << endl;
			return 0;
		}
		if(comp != -1){
			int diff = comp - bf;
			ans = min(ans, diff);
			bf = comp;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int MOD;
vector<int> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  assert(!(n<k));
  assert(!(n<0||k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int pow(int x,int y){//x^yを返す
  if(x==1){return 1;}
  int tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  int p,a;
  cin>>p;
  MOD=p;
  vector<int> a1(0);
  vector<int> ans(p);
  for(int i=0;i<p;i++){
    cin>>a;
    if(a==1){a1.push_back(i);}
  }
  init_nCk(p-1);
  for(int i=0;i<(int)a1.size();i++){
    ans.at(0)++;
    for(int j=0;j<p;j++){
      ans.at(j)-=nCk(p-1,j)*pow(-1*a1.at(i),p-j-1)-MOD*MOD;
      ans.at(j)%=MOD;
    }
  }
  for(int i=0;i<p;i++){
    cout<<ans.at(i);
    if(i<p-1){cout<<" ";}
  }
}

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

vector<string> ans;
int n;

void f(string s, int i, int k)
{
  if (i == n) {
    cout << s << endl;
    return;
  }
  int num = s[i-1] - 'a';
  k = max(k, num+1);
  for (int j=0; j<k+1; j++) {
    f(s, i+1, k);
    s[i]++;
  }
}

int main()
{
  cin >> n;
  string s = "";
  rep(i, n) s.push_back('a');
  f(s, 1, 1);
  // sort(ans.begin(),ans.end());
  // for (auto v:ans) {
  //   cout << v << endl;
  // }

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  cin>>n;
  string s;
  ll a[5]={};
  for(int i=0;i<n;i++){
    cin>>s;
    char c=s.at(0);
    if(c=='M')
      a[0]++;
    else if(c=='A')
      a[1]++;
    else if(c=='R')
      a[2]++;
    else if(c=='C')
      a[3]++;
    else if(c=='H')
      a[4]++;
  }
  ll c=0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        c+=a[i]*a[j]*a[k];
      }
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int mod=1000003;
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[1000010],inv[1000010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    fac[0]=1;
    for(int i=1;i<mod;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[mod-1]=power(fac[mod-1],mod-2);
    for(int i=mod-1;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
    int T=read();
    while(T--)
    {
    	int st=read(),d=read(),n=read();if(d==0){pr2(power(st,n));continue;}
      	st=1LL*st*power(d,mod-2)%mod;
    	if(!st || n>mod-st){puts("0");continue;}
    	pr2(1LL*fac[st+n-1]*inv[st-1]%mod*power(d,n)%mod);
    }
   	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
    }else{
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
def dfs(s):
    if int(s) > N:
        return 0
    if all([s.count(i) for i in "753"]):
        result = 1
    else:
        result = 0
    
    for i in "753":
        result += dfs(s+i)
    return result

print(dfs("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<ll> l(n);
  for(int i=0;i<n;++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int cnt = 0;
  for(int i=0;i<n;++i) {
    for(int j=i+1;j<n;++j) {
      auto it = lower_bound(l.begin(), l.end(), l[i] + l[j]);
      int pos = distance(l.begin(), it);
      cnt += pos - 1 - j;
    }
  }
  cout << cnt << endl;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;


int n,k;
int main(){
	cin >> n >> k;
	vector<double> p(n+1);
	for(int i = 0; i < n; i++){
		double x; cin >> x;
		p[i+1] = p[i] + (x+1)/2;
	}
	double ans = 0.0;
	for(int i = 0; i < n-k+1; i++){
		double tmp = p[i+k] - p[i];
		ans = max(ans, tmp);
	}
	// cout << ans << endl;
	printf("%.12lf\n", ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	long double a, b, x; cin >> a >> b >> x;

	long double border = a * a * b / 2.;
	const long double PI = 3.141592653579323846264338;
	if(border < x) printf("%.12Lf\n", atanl(2. / (a * a * a) * (a * a * b - x)) * 180. / PI);
	else printf("%.12Lf\n", atanl(a * b * b / (2. * x)) * 180. / PI);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,v;
    char op;
    scanf("%lld %c %lld",&a,&op,&b);
    if(op=='+')
    {
        v=a+b;
        printf("%lld\n",v);
    }
    else if(op=='-')
    {
        v=a-b;
        printf("%lld\n",v);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int x,gh=0,g=0,z;
    
    scanf("%d",&x);
    while(x>5){
        while(x>=500){
            gh++;
            x-=500;
        }
        x-=5;
        if(x>0){
            g++;
        }
    }
    z=gh*1000+g*5;
    printf("%d\n",z);
    return 0;
}

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

int main(){
  int n,k;
  double m=0,work;
  cin>>n>>k;
  vector<double> a(n+1);
  rep(i,n){
    cin >> work; 
    work=(work+1)/2.0;
    a[i]=a[i-1]+work;
    if(i>=k){
      m=max(m,a[i]-a[i-k]);
    }
  }
  cout << fixed << setprecision(10)<<m << endl;
}

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

long f(string s, int a) {
    long ans = 0;

    int b = (1 << (s.length() - 2));
    int before_i = 0;

    for (int i = 0; i < s.length() - 1; i++) {
        if (a & b) {
            ans += stol(s.substr(before_i, i + 1 - before_i));
            before_i = i + 1;
        }
        b >>= 1;
    }

    ans += stol(s.substr(before_i, s.length() - before_i));

    return ans;
}

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

    long ans = stol(s);

    for (int i = 1; i < (1 << (s.length() - 1)); i++) {
        ans += f(s, i);
    }

    cout << ans << endl;

    return 0;
}


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

const int mod = 1000000007;
int dp[100005][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  rep(i,n) {
    { // a+b = 0
      if (s[i] == '0') {
        dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
      } else {
        dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
      }
    }
    { // a+b = 1
      if (s[i] == '0') {
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      } else {
        (dp[i+1][0] += dp[i][0]*2 % mod) %= mod;
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      }
    }
  }
  int ans = (dp[n][0]+dp[n][1]) % mod;
  cout << ans << endl;
  return 0;
}    


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	vector<int> xp;
	for(int i = 0; i < n; ++i){
		xp.push_back(vec[i] - (i + 1));
	}
	long long b = 0;
	sort(xp.begin(), xp.end());
	if(n % 2 != 0){
		b = xp[n / 2];
	}
	else{
		b = (xp[n / 2] + xp[(n / 2) - 1]) / 2;
	}
	long long sum = 0;
	for(int i = 0; i < n; ++i){
		sum += abs(vec[i] - (b + i + 1));
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include <stdio.h>

typedef unsigned int	U32;
typedef unsigned char	U08;

#define INPUT_NUM_MIN	1							/* 入力値の範囲下限 */
#define INPUT_NUM_MAX	1000000000					/* 入力値の範囲上限 */

void SwapNum_Void(U32 *u32_x, U32 *u32_y);
U32 CalcGcd_U32(U32 u32_x, U32 u32_y);


/***********************************************************************************
 ++module <main>
 ++outline
	メイン関数
 ++arguments
	<>	<u32_return_val>	[戻り値]
 ++supp
	<戻り値>
		0：正常終了
		1：異常終了
	<引数>
		なし
	<補足説明>
		なし
 ++end_module
************************************************************************************/
int main(void)
{
													/* 入力値1 */
	U32 u32_x   = 0;								/* 変数定義 */
	U32 u32_y   = 0;								/* 入力値2 */
	U32 u32_gcd = 0;								/* 最大公約数(Greatest Common Divisor) */
	U08 u08_return_val = 0;							/* 戻り値 */
	
	do
	{
		scanf("%d %d", &u32_x, &u32_y);				/* 数値入力 */
		
		if( (u32_x < INPUT_NUM_MIN) || (INPUT_NUM_MAX < u32_x)
			|| (u32_y < INPUT_NUM_MIN) || (INPUT_NUM_MAX < u32_y) )		/* 入力値が範囲外だった場合 */
		{
			u08_return_val = 1;						/* 戻り値に1を設定 */
			break;
		}
		
		if(u32_x < u32_y)							/* 1つ目の入力値の方が小さかった場合 */
		{
			SwapNum_Void(&u32_x, &u32_y);				/* 数値入れ替え */
		}
		
		u32_gcd = CalcGcd_U32(u32_x, u32_y);		/* 最大公約数の計算 */
		
		printf("%d\n", u32_gcd);					/* 最大公約数の表示 */
	}while(0);										/* 一度だけ実行 */
	
	return u08_return_val;
}



/***********************************************************************************
 ++module <SwapNum_Void>
 ++outline
	2つの変数の値を入れ替える関数
 ++arguments
	<>	<>		[]
	<>	<u32_x>	[入れ替え対象変数1]
	<>	<u32_y>	[入れ替え対象変数2]
 ++supp
	<戻り値>
		なし
	<引数>
		u32_x：入れ替え対象変数1
		u32_y：入れ替え対象変数2
	<補足説明>
		なし
 ++end_module
************************************************************************************/
void SwapNum_Void(U32 *u32_x, U32 *u32_y)
{
									/* 一時保持変数 */
	U32 u32_tmp = 0;				/* 変数定義 */
	
	u32_tmp = *u32_x;				/* u32_xの値を保持 */
	*u32_x  = *u32_y;				/* u32_yの値をu32_xに格納 */
	*u32_y  = u32_tmp;				/* 保持していたu32_xの値をu32_yに格納 */
}



/***********************************************************************************
 ++module <CalcGcd_U32>
 ++outline
	2つの自然数の最大公約数を計算する関数
 ++arguments
	<>	<>		[最大公約数]
	<>	<u32_x>	[自然数1]
	<>	<u32_y>	[自然数2]
 ++supp
	<戻り値>
		最大公約数
	<引数>
		u32_x：自然数1
		u32_y：自然数2
	<補足説明>
		なし
 ++end_module
************************************************************************************/
U32 CalcGcd_U32(U32 u32_x, U32 u32_y)
{
									/* x%yの結果を保持する変数 */
	U32 u32_rem = 0;				/* 変数定義 */
	
	/* ヒントによると、「xとyの最大公約数は、yとx%yの最大公約数と一致する」らしい */
	/* → x%yの結果がゼロになるまでxにyの値を、yにx%yの結果を格納し続け、 */
	/*    x%yの結果がゼロになった時のyが最大公約数 */
	while(1)						/* x%yの結果がゼロではない間ループ */
	{
		u32_rem = u32_x % u32_y;	/* x%yを計算 */
		
		if(0 == u32_rem)			/* x%yの結果がゼロの場合 */
		{
			break;
		}
		
		u32_x = u32_y;				/* u32_xを更新 */
		u32_y = u32_rem;			/* u32_yを更新 */
	}
	
	return u32_y;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


struct QU {
  V<> par, rank, _size;

  QU(int n) : par(n), rank(n), _size(n, 1) { 
    iota(par.begin(), par.end(), 0);
  }

  int find(int a) {
    if (par[a] == a) return a;
    return par[a] = find(par[a]);
  }

  bool same(int a, int b) { return find(a) == find(b); }

  int size(int a) { return _size[find(a)]; }

  void unite(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
      par[a] = b;
      _size[b] += _size[a];
    } else {
      par[b] = a;
      _size[a] += _size[b];
    }
    if (rank[a] == rank[b]) rank[a]++;
  }
};

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, m, k; cin >> n >> m >> k;
  V<> c(n); for (int i = 0; i < n; ++i) cin >> c[i], --c[i];
  struct Edge { int u, v, w; };
  V<Edge> es;
  QU qu(n);
  for (int i = 0; i < m; ++i) {
    int u, v, w; cin >> u >> v >> w, --u, --v;
    es.push_back({u, v, w});
    qu.unite(u, v);
  }
  sort(begin(es), end(es), [](const Edge& lhs, const Edge& rhs) { return lhs.w < rhs.w; });
  V<> vs(n); iota(begin(vs), end(vs), 0);
  sort(begin(vs), end(vs), [&](int u, int v) { return c[u] < c[v]; });
  for (int i = 0; i < n - 1; ++i) if (c[vs[i]] != -1 and c[vs[i]] == c[vs[i + 1]]) qu.unite(vs[i], vs[i + 1]);
  set<int> sc;
  for (int i = 0; i < n; ++i) sc.insert(qu.find(i));
  int C = sc.size(), D = 0;
  for (int i = 0; i < n; ++i) D += c[i] == -1;
  set<int>().swap(sc);
  for (int i = 0; i < n; ++i) if (c[i] != -1) sc.insert(c[i]);
  int E = k - sc.size();
  if (C - 1 > D - E) return cout << -1 << '\n', 0;
  qu = QU(k + n);
  lint res = 0;
  int ce = 0;
  for (const auto& e : es) {
    int u = c[e.u] != -1 ? c[e.u] : k + e.u;
    int v = c[e.v] != -1 ? c[e.v] : k + e.v;
    if (qu.same(u, v)) continue;
    qu.unite(u, v);
    res += e.w;
    ++ce;
    if (ce == k - 1) break;
  }
  cout << res << '\n';
}

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N)
  {
    cin >> S[i];
  }
  int ans = 0;
  rep(A, N)
  {
    bool is_ok = true;
    rep(i, N) rep(j, N)
    {
      if (i == j)
        continue;
      if (S[(i + A) % N][j] != S[(j + A) % N][i])
      {
        is_ok = false;
        goto endloop;
      }
    }
  endloop:

    if (is_ok)
      ans += N;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	map<int, int> mp;
	repl(i, 2, n + 1) {
		int p = i;
		repl(j, 2, sqrt(i) + 1) {
			while (p % j == 0) {
				p /= j;
				mp[j]++;
			}
		}
		if (p != 1) mp[p]++;
	}
	vector<int> a(100);
	for (auto p : mp) a[p.second + 1]++;
	for (int i = 98; i >= 0; i--) a[i] += a[i + 1];
	int ans = a[75] + a[25] * (a[3] - 1) + a[15] * (a[5] - 1) + a[5] * (a[5] - 1) / 2 * (a[3] - 2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

palindrome = input().rstrip()
chars = []
for s in palindrome:
    chars.extend(s)

hug = 0
after = -1
for key, value in enumerate(chars):
    if(key > (len(chars) - 1) / 2):
        break
    if(value != chars[after]):
        chars[after] = value
        hug += 1
    after -= 1

print(hug)



Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int k,i,j,a[11] = {},keta = 1;cin >> k;
  for(i=0;i<k;i++){
    a[0]++;
    for(j=0;j<keta;j++){
      if(a[j] == 10 || (j+1 != keta && a[j]>a[j+1]+1)){
        a[j+1]++;a[j] = 0;
      }
    }
    if(a[keta] != 0) keta++;
    for(j=keta-2;j>=0;j--){
      if(a[j] < a[j+1]-1) a[j] = a[j+1]-1;
    }
  }
  for(i=keta-1;i>=0;i--) cout << a[i];
  cout << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true) {
    C -= B;
    if ( C <= 0 ) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if ( A <= 0 ) {
      cout << "No" << endl;
      break;
    }
  }
}

Measured memory_bytes: 3672
n, k = map(int, input().split())

mod = 10**9 + 7
cnt = [0]*(k + 1)
ans = 0
for i in range(k, 0, -1):
    cnt[i] = (pow(k//i, n, mod) - sum(cnt[2*i:k+1:i])) % mod
    ans = (ans + i*cnt[i]) % mod

print(ans)


Measured memory_bytes: 12032
#include<stdio.h>

int main(void) {

	int x;
	int a, b, c, d, e, f;
	int tmp;  
	
	scanf("%d", &x);

	for (a = 0; a <= (x/100); a++) {
		for (b = 0; b <= (x/100); b++) {
			for (c = 0; c <= (x / 100); c++) {
				for (d = 0; d <= (x / 100); d++) {
					for (e = 0; e <= (x / 100); e++) {
						for (f = 0; f <= (x / 100); f++) {
							tmp = 100*a + 101*b + 102*c + 103*d + 104*e + 105*f;
							if (tmp == x) {
								printf("1");
								return 0;
							}
						}
					}
				}
			}
		}
	}
	
	printf("0\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N,M; cin >> N >> M;
    vector<pint> s(N);
    vector<pint> c(M);
    for(int i=0;i<N;i++) cin >> s[i].first >> s[i].second;
    for(int i=0;i<M;i++) cin >> c[i].first >> c[i].second;
    for(int i=0;i<N;i++){
        int x = s[i].first; int y = s[i].second;
        int dmin = INFI; int idx;
        for(int j=0;j<M;j++){
            int d = abs(x-c[j].first) + abs(y-c[j].second);
            if(dmin > d){dmin = d; idx = j+1;}
        }
        cout << idx << endl;
    }

}


Measured memory_bytes: 3632
#シェルソート
N = int(input())
A = [int(input()) for _ in range(N)]
def insertionSort(A, N, g):
    cnt = 0
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            tmp = A[j]
            A[j] = A[j+g]
            A[j+g] = tmp
            j = j - g
            cnt += 1
    return cnt, A

def shellSort(N, A):
    
    m, g, G, cnt = 0, 1, [], 0
    while g <= N:
        m += 1
        G.append(g)
        g = 4 ** m + 3 * 2 ** (m - 1) + 1

    G.reverse()
    
    for i in range(m):
        c, A = insertionSort(A, N, G[i])
        cnt += c
    print(m)
    print(' '.join([str(g) for g in G]))
    print(cnt)
    for a in A:
        print(a)

shellSort(N, A)



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k, a, b;
  cin >> k >> a >> b;
  long long ans = 1;
  if (b <= a + 2) {
    ans += k;
  } else {
    ans += max(0LL, (k - a + 1) / 2) * (b - a) + ((k - a + 1) % 2) + a - 1;
  }
  cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

n = int(input())
d = list(int(i) for i in input().split())

ans = 0
for l in range(n):
  for r in range(l + 1, n):
    if l == r:
      continue
    else:
      ans += (d[l] * d[r])

print(ans)


Measured memory_bytes: 13784
#include <stdio.h>
#include <stdlib.h>

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

int arr[200001];
int ans[200001];

int main() {
    long int N, K, A[200001];
    int num = 1;
    int a = 0, b = 0, sum=0;
    int answer;
    scanf("%ld %ld", &N, &K);
    for (int i=0; i < N; i++) {
        scanf("%ld", A+i);
    }

    for (int i = 0; i < N ; i++) {
        if (arr[A[i]] == 0) a++;
        arr[A[i]]++;
    }
    /*
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            continue;
        }else {
            for (int u = i+1; u < N; u++) {
                if (A[i] == A[u]) {
                    num++;
                    A[u] = 0;
                }
            }
            arr[i] = num;
            num = 1;
            A[i] = 0;
        }
    }
    */
   qsort(arr, N, sizeof(int), compare_int);

   /*
    for (int i = 0; i < N; i++) {
        for (int u = 0; u < N; u++) {
            if (a < arr[u]) {
                a = arr[u];
                b = u;
            }
        }
        ans[i] = a;
        arr[b] = 0;
        a = 0;
        b = 0;
    }
    
    for (int i=0; i < K; i++) {
        sum += ans[i];
    }
    answer = N - sum;
    */

   for (int i = 0; i < K; i++) {
       sum += arr[i];
   }
   answer = N - sum;
    
    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

int main() {
    cin>>N>>K;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ans = 0;
    rep(i,N){
        if(a[i] > K){
            ans += a[i] - K;
            a[i] = K;
        }
        if(i != 0){
            if(a[i] + a[i-1] > K){
                ans += a[i] + a[i-1] - K;
                a[i] = max(0LL, K - a[i - 1]);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size()/2; i++) {
    if (s[i] != s[s.size() - i - 1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
import numpy as np

N, D = [int(x) for x in input().split()]

X = np.zeros((N, D), np.float)
for i in range(N):
  X[i,] = [int(x) for x in input().split()]

def dist(X1, X2):
  return np.linalg.norm(X1-X2)

ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    d = dist(X[i,], X[j,])
    if d.is_integer():
      ans += 1
print(ans)

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

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b > c + d)
	{
		cout << "Left" << endl;
	}
	else if (a + b < c + d)
	{
		cout << "Right" << endl;
	}
	else
	{
		cout << "Balanced" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,x,y;
  cin>>n>>x>>y;
  int INF=n;
  vector<vector<int> >dis(n);
  vector<int>ans(n);
  for(int i=0;i<n;i++)
  {
    dis[i].resize(n,INF);
   	if(i!=0)dis[i][i-1]=1;
    dis[i][i]=0;
   	if(i!=n-1)dis[i][i+1]=1;
  }
  dis[x-1][y-1]=1;
  dis[y-1][x-1]=1;
  for(int i=0;i<n;i++)
  {
    if(i==y-1)continue;
    dis[x-1][i]=min(abs(x-1-i),dis[x-1][y-1]+abs(y-1-i));
    dis[y-1][i]=min(abs(y-1-i),dis[y-1][x-1]+abs(x-1-i));
  }
    for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        dis[i][j]=min(abs(i-j),dis[i][x-1]+dis[x-1][j]);
        if(j>i)ans[dis[i][j]]++;
        //cout<<dis[i][j]<<' ';
      }
      //cout<<endl;
    }
  for(int i=1;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 19288
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = INTINF;
	int tmp;
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<int > l;
	REP(i, n) {
		cin >> tmp;
		l.push_back(tmp);
	}
	int aa, bb, cc;
	REP(i, 1 << (2*n)){
		aa = 0;
		bb = 0;
		cc = 0;
		tmp = 0;
		REP(j, n){
			int v = ((i >>(2*j)) & 3);
			if(v == 0){
				if(aa != 0) tmp += 10;
				aa += l[j];
			}
			if(v == 1){
				if(bb != 0) tmp += 10;
				bb += l[j];
			}
			if(v == 2){
				if(cc != 0) tmp += 10;
				cc += l[j];
			}
		}
		if(!(aa && bb && cc)) continue;
		tmp += abs(aa - a);
		tmp += abs(bb - b);
		tmp += abs(cc - c);
		ans = min(tmp, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
#define mod 1000000007
using namespace std;
char a[100005];
LL f[100005][4];
int main(void)
{
	int i,n;
	scanf("%s",a+1);n=strlen(a+1);
	f[0][0]=1;
	for(i=1;i<=n;++i)
	{
		if(a[i]=='A')
		{
			f[i][0]=f[i-1][0];
			f[i][1]=(f[i-1][0]+f[i-1][1])%mod;
			f[i][2]=f[i-1][2];
			f[i][3]=f[i-1][3];
		}
		else if(a[i]=='B')
		{
			f[i][0]=f[i-1][0];
			f[i][1]=f[i-1][1];
			f[i][2]=(f[i-1][1]+f[i-1][2])%mod;
			f[i][3]=f[i-1][3];
		}
		else if(a[i]=='C')
		{
			f[i][0]=f[i-1][0];
			f[i][1]=f[i-1][1];
			f[i][2]=f[i-1][2];
			f[i][3]=(f[i-1][2]+f[i-1][3])%mod;
		}
		else
		{
			f[i][0]=(f[i-1][0]*3)%mod;
			f[i][1]=(f[i-1][1]*3+f[i-1][0])%mod;
			f[i][2]=(f[i-1][2]*3+f[i-1][1])%mod;
			f[i][3]=(f[i-1][3]*3+f[i-1][2])%mod;
		}
	}
	printf("%lld\n",f[n][3]);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
int main(){
  int q;
  cin >> q;
  for(int loop = 0;loop < q;loop++){
	int n;
	string str;
	cin >> n;
	cin >> str;
	vector<vector<bool> > field(2,vector<bool>(n+1,false));
	for(int i = 0;i < 2*n;i++){
	  if(str[i] == 'Y'){
		field[0][(i+1)/2] = true;
	  }
	  if(str[i+2*n] == 'Y'){
		field[1][(i+1)/2] = true;
	  }
	}

	int ans = n;
	bool first = true;
	int b_s = 0;
	for(int i = 0;i < n+1;i++){
	  if(first){
		if(field[1][i]){
		  first = false;
		  ans += 2;
		  b_s = 1;
		}else if(field[0][i]){
		  first = false;
		  ans++;
		}
	  }else{
		if(field[0][i] && field[1][i]){
		  ans+=2;
		  b_s = 0;
		}else if(field[0][i]){
		  ans++;
		  b_s = 0;
		}else if(field[1][i]){
		  ans++;
		  b_s = 1;
		}
	  }
	}
	
	if(b_s == 1)ans++;
	cout << ans << endl;
	
	
  }
  return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
//template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vl v(7);
	ll ans=0;
	rep(i,7)cin>>v[i];
	ans=v[0]/2*2+v[3]/2*2+v[4]/2*2;
	if(v[0]&&v[3]&&v[4]){
		chmax(ans,(v[0]-1)/2*2+(v[3]-1)/2*2+(v[4]-1)/2*2+3);
	}
	ans+=v[1];

	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll sum = 0;
    for(int i=0;i<n-1;i++){
        sum += a[i];
    }
    if(sum>a[n-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
A = gets.chomp.to_i
B = gets.chomp.to_i
C = gets.chomp.to_i
X = gets.chomp.to_i
ptn = 0
(A+1).times do |a|
    (B+1).times do |b|
        if ((X-(500*a+100*b))/50).between?(0,C)
            ptn += 1
        end
    end
end
print "#{ptn}\n"

Measured memory_bytes: 1788
N,Y= map(int,input().split())

Y2 = Y - 1000*N
if Y2==0:
    print(0, 0, N)
elif Y2<0:
    print("-1 -1 -1")
else:
    count = 0
    while(True):
       if Y2<0 or Y2/9000 + count > N:
        print("-1 -1 -1")
        break
       if Y2%9000 == 0:
        print(Y2//9000,count,N-Y2//9000-count)
        break
       Y2 -= 4000
       count += 1


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int N, A, B, C, D;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;
	
	bool ans = true;
	for (int i = A; i < max(C, D); i++) {
		if (S[i] == S[i - 1] && S[i] == '#') ans = false;
	}
	
	bool jdg = false;
	if (B < D && D < C) {
		FOR(i, B - 1, D) {
			if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') jdg = true;
		}
		if (!jdg) ans = false;
	}
	puts(ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n; cin >> n;
    vector<double> a(n);
    REP(i,n) cin >> a[i];
    double ave = accumulate(ALL(a),0) / n;
    double now = (double)INF;
    int ans = n-1;
    REPR(i,n) {
        if(now>=abs(a[i]-ave)) {
            now = abs(a[i]-ave);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    string S;
    cin >> N >> S;
    if(N % 2 == 0) {
        N /= 2;
        rep(i, N) {
            if(S[i] != S[N + i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
    string vec1, vec2;
    cin >> vec1 >> vec2;
    int N = vec1.size();
    int X = 0;

    for (int i = 0; i < N; i++) {
        if (vec1.at(i) == vec2.at(i)) {

        }
        else {
            X++;
        }
    }

    cout << X << endl;

    return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll N;
	double sum = 0;
	cin >> N;
	rep(i, N) {
		double tmp;
		cin >> tmp;
		sum += 1.0/tmp;
	}
	printf("%.10f\n", 1/ sum);

}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int root[1000005];
int cntt[1000005];
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int& x:a) cin>>x,++cntt[x];
	bool pairwise=1;
	for(int i=2;i<1000005;++i){
		int cnt=0;
		for(int j=i;j<1000005;j+=i){
			cnt+=cntt[j];
		}
		if(cnt>1) pairwise=0;
	}
	if(pairwise) return cout<<"pairwise coprime",0;
	int g=0;
	for(int i=0;i<n;++i) g=__gcd(g,a[i]);
	if(g==1) return cout<<"setwise coprime",0;
	cout<<"not coprime"; 
	return 0;
}


Measured memory_bytes: 10928
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** PRoblem0257 : Railway Ticket **/
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	
	if ((a && b) || c)
		cout << "Open" << endl;
	else
		cout << "Close" << endl;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    ll n, k;
    cin >> n >> k;
    vector<bool> f(10, true);
    REP(i, k){
        ll d;
        cin >> d;
        f[d] = false;
    }
    for(ll ans = n;; ans++){
        bool ok = true;
        for(ll tmp = ans; tmp > 0; tmp /= 10){
            if(!f[tmp % 10]){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int solve(int,int);
int A[2000],n;
  
int solve(int x,int y) {
  if(A[x] == y)
    return 1;
  if(x+1 == n)
    return 0;
  if(solve(x+1,y-A[x]) || solve(x+1,y)) 
    return 1;
  return 0;  
  }
int main(void) {
  
  int S[2000],i,m;
  
  scanf("%d",&n);
    
  for(i=0;i<n;i++) 
    scanf("%d",&A[i]);
    
  scanf("%d",&m);
  for(i=0;i<m;i++) 
    scanf("%d",&S[i]);
    
  for(i=0;i<m;i++) {
    if(solve(0,S[i])) 
      printf("yes\n");
    else printf("no\n");
      
  }
  return 0; 
}

Measured memory_bytes: 1812
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
#define N 1000000007
using namespace std;
typedef long long llong;

int main() {
	int n; cin >> n;
	vector<llong>t(n), a(n), h(n);
	bool f = false;
	for (int i = 0; i < n; i++) {
		h[i] = -1;
	}
	for (int i = 0; i < n; i++)cin >> t[i];
	for (int i = 0; i < n; i++)cin >> a[i];
	h[0] = t[0];
	for (int i = 1; i < n; i++) {
		if (t[i] != t[i - 1]) {
			h[i] = t[i];
		}
	}
	if (h[n - 1] != -1 && h[n - 1] != a[n - 1]) {
		f = true;
		cout << 0 << endl;
		return 0;
	}
	h[n - 1] = a[n - 1];

	for (int i = n - 2; i >= 0; i--) {
		if (h[i] != -1 && a[i] < h[i]) {
			f = true;
			cout << 0 << endl;
			return 0;
		}
		if (a[i] != a[i + 1]) {
			if (h[i] != -1 && h[i] != a[i]) {
				f = true;
				cout << 0 << endl;
				return 0;
			}
			h[i] = a[i];
		}
	}

	llong cnt = 1;
	for (int i = 0; i < n; i++) {
		if (h[i] == -1) {
			cnt = (cnt*(llong)min(t[i], a[i])) % N;
		}
	}

	/*for (int i = 0; i < n; i++) {
		cout << h[i] << " ";
	}
	cout << endl;*/
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678];
ll keta(ll x) {
	ll res = 0;
	while (x > 0) {
		x /= 10; res++;
	}
	return res;
}
signed main() {
	map<ll, ll> cost;
	ll n, m, a, b, c, x, cnt = 0, ans = 1; string s, t;
	cin >> n; vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
		if (v[h] == 0) { cout << 0 << endl; return 0; }
	}
	for (int h = 0; h < n; h++) {
		if (keta(ans) - 1 + keta(v[h]) - 1 > 18) { cout << -1 << endl; return 0; }
		if (keta(ans) - 1 + keta(v[h]) - 1 == 18) {
			if ((ans / pow(10, keta(ans) - 1)) * (v[h] / pow(10, keta(v[h]) - 1)) >= 10) {
				cout << -1 << endl; return 0;
			}
		}
		ans *= v[h];
		if (ans > INF) { cout << -1 << endl; return 0; }
	}
	if (ans > INF) { cout << -1 << endl; return 0; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4112