akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	ll sum = 0;
	ll min = INF;
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		sum += a;
		if (b < a)chmin(min, b);
	}
	if (min == INF) {
		cout << 0;
	}
	else {
		cout << sum - min;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <random>

#define ff first
#define ss second

using namespace std;

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

pii operator+(pii a, pii b)
{
    return {a.ff+b.ff,a.ss+b.ss};
}

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

    string s;
    cin>>s;
    cout<<s;
    if(s.back()=='s') cout<<"es";
    else cout<<"s";

    return 0;
}


Measured memory_bytes: 3644
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: u64 = read();
    let a: u64 = read();
    let b: u64 = read();
    println!("{}", n / (a + b) * a + std::cmp::min(n % (a + b), a));
}



Measured memory_bytes: 4352
import numpy as np
def resolve():
	# N: 品物の個数、W: 容量の上限
	N, W = map(int, input().split())
	# DP配列の宣言: DP[N][W]
	dp = np.empty((N+1, W+1), dtype=np.int64)
	# DP配列の初期化
	dp[0,:] = 0
	for i in range(N):
		w_n, v_n = map(int, input().split())
		dp[i+1, :w_n] = dp[i, :w_n]
		dp[i+1, w_n:] = np.maximum(
			dp[i, w_n:],
			dp[i, :(W+1-w_n)] + v_n
		)
	print(dp[N, W])
resolve()

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

int32_t main(){
    int k;cin>>k;
    long long ans=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                // cout<<i<<" "<<j<<" "<<l<<"-->";
                ans+=__gcd(i,__gcd(j,l));
                
            }
        }
    }
    cout<<ans<<"\n";
   return 0;
}

Measured memory_bytes: 3648
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N, M = [int(x) for x in input().split()]

S =[]
for j in range (M):
    a = [x for x in input().split()]
    k = a[0]
    s = [int(x) for x in a[1:]]
    S.append(s)
P = [int(x) for x in input().split()]
ans = 0
for i in range (2**N):
    n = format(i,'b').zfill(N)
    
    count = 0
    for j in range (M):
        count2 = 0
        for k in range (len(S[j])):
            count2 += int(n[S[j][k]-1])
        if count2 %2 == P[j]:
            count += 1
    if count == M:
        ans += 1

print(ans)
        



 
    






Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define make_pair(a, b) mp(a, b)
typedef pair<int, int> pii; 
typedef long long ll;
const int maxn = 2e5 + 10;
const ll mod = 998244353;
ll f[maxn], g[maxn];
int n, k, l[20], r[20];
ll sum(int x) { return x > n ? 0 : g[x];}
int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= k; ++i) scanf("%d%d", &l[i], &r[i]);
	f[n] = 1; 
	g[n] = f[n];
	for(int i = n - 1; i; --i)
	{
		for(int j = 1; j <= k; ++j)
			f[i] = (f[i] + sum(i + l[j]) + mod - sum(i + r[j] + 1)) % mod;
		g[i] = (g[i + 1] + f[i]) % mod;
	}
	printf("%lld\n", f[1]);
	return 0;
}

Measured memory_bytes: 6932
#include <bits/stdc++.h>
using namespace std;
int parent[200100],n,m,sz[200100];
void Init(){
    for(int i = 1;i <= n;i++)
        parent[i] = i,sz[i]=1;
    return;
}
int get_boss(int v){
    if(parent[v] == v)
        return v;
    else
        return parent[v] = get_boss(parent[v]);
}
void Merge(int v,int u){
	u=get_boss(u);
	v=get_boss(v);
	if(u==v) return;
	if(sz[u]>sz[v]) swap(u,v);
	parent[u]=v;
	sz[v]+=sz[u];
    return;
}
int main(){
    int i,a,b;
    scanf("%d%d",&n,&m);
    Init();
    for(i = 0;i < m;i++)
    {
        scanf("%d%d",&a,&b);
        Merge(a,b);
    }
    int rt=0;
    for(i = 1;i <= n;i++)
    	rt=max(rt,sz[i]);
    printf("%d\n",rt);
    return 0;
}


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

int main(){
    int a,b,c,t;
    cin>>a>>b>>c;
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    if(b>c){
        t=b;
        b=c;
        c=t;
    }
    if(a>b){
        t=a;
        a=b;
        b=t;
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 3080
n=int(input())
w=list(map(int,input().split()))

s=sum(w)
s1=0
for i in range(n-1):
  s1_next=s1+w[i]
  if 2*s1_next>=s:
    print(min(s-2*s1,2*s1_next-s))
    exit()
  s1=s1_next

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////


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

	string ans = "Yes";
	if (Y < X * 2) { ans = "No"; }
	if (Y > X * 4) { ans = "No"; }
	if ((Y - X * 2) % 2 != 0) { ans = "No"; }
	cout << ans << endl;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc159/tasks/abc159_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, M;
  cin >> N >> M;

  ll res = N * (N - 1) / 2 + M * (M - 1) / 2;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
nk = list(map(int, input().split()))
dic={}
for i in range(1,nk[0]+1):
    dic[str(i)]=0


for i in range(nk[1]):
    d=int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        dic[str(a[j])]=1

keys= [k for k, v in dic.items() if v == 0]
print(len(keys))



Measured memory_bytes: 9200
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    ll k;
    cin>>s>>k;
    int i=0;
    k--;
    int n=s.size();
    while(s[i]=='1' and i<k)i++;
    cout<<s[i]<<endl;
    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL A,B,C;
int main(){
	cin>>A>>B>>C;
	if(A%2==1){
	   cout<<0<<endl;
	   return 0;
	}
	if(B%2==1){
	   cout<<0<<endl;
	   return 0;
	}
	if(C%2==1){
	   cout<<0<<endl;
	   return 0;
	}
	if(A==B&&C==B){
	   cout<<-1<<endl;
           return 0;
	}
	int ans=0;
	while(1){
	   int count=0;
	   if(A%2==1){
	      count++;
	   }
	   if(B%2==1){
	      count++;
	   }
	   if(C%2==1){
	      count++;
	   }
	   A/=2;
	   B/=2;
	   C/=2;
	   if(count==1||count==2){
	      break;
	   }
	   ans++;
	}
	cout<<ans<<endl;
	return(0);
}

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

#define MAX 50

int main() {
	int H, W;
	string s[MAX];
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	bool ans = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (s[i][j] == '.')
				continue;
			bool flg = false;
			if (i - 1 >= 0 && s[i - 1][j] == '#')
				flg = true;
			if (i + 1 < H && s[i + 1][j] == '#')
				flg = true;
			if (j - 1 >= 0 && s[i][j - 1] == '#')
				flg = true;
			if (j + 1 < W && s[i][j + 1] == '#')
				flg = true;
			ans = ans && flg;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using i64 = long long;

const int P = 9000, Q = P + 7, N = 2000 + 7;

int n, k;
int isp[Q], pri[Q];
int a[N], b[N];
i64 v[N][N];

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 2; i <= P; ++i) {
		if (!isp[i]) pri[++k] = i;
		for (int j = 1; j <= k & i * pri[j] <= P; ++j) {
			isp[i * pri[j]] = 1;
			if (i % pri[j] == 0) break;
		}
	}
	int l = 1, r = n * 2 + 10, z = 1;
	for (int i = -n; i <= n; ++i)
		if (i % 2 == 0) a[i + n] = z ? pri[l++] : pri[r--], z ^= 1;
	for (int i = 2; i <= n * 2; ++i)
		if (i % 2 == 0) b[i] = z ? pri[l++] : pri[r--], z ^= 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i + j) % 2 == 0) v[i][j] = a[i - j + n] * b[i + j];
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if ((i + j) % 2 == 1)
				v[i][j] = 1ll * a[i - j - 1 + n] * a[i - j + 1 + n] * b[i + j - 1] * b[i + j + 1] + 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j)
			printf("%lld ", v[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 7812
#include <bits/stdc++.h>
using namespace std;
#define int long long
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a;
    cin >> a;
    int n = a.length();
    vector <int> b(n);
    int s=0,k,pp,np,no,po,od=0;
    for(int i =0 ; i < n; ++i){
        if(a[i] =='1'){
            s+=1;
            b[i] = 1;
        }
        else if(a[i] == '0' && s %2 == 1){
            s += 1;
            b[i] = 1;
        }
    }
    k = (s+1)/2;
    np = k;
    od += k*(k+1);
    if(s % 2 == 1)od -= k;
    no=0;
    po=0;
    pp=(s+1)%2;
    for(int i = n-1; i>=0; --i){
        if(b[i] == 1)pp +=1;
        if(a[i] == '1'){
            if(pp %2 == 1){
                no += 1;
            }
            else po += 1;
        }
        if(b[i] == 0){
            np -= no;
            swap(no, po);
            np += no;
            od += np;
        }
    }
    cout << od << '\n';
}


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

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

int main() {
  int k;
  cin >> k;
  long long result = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        result += gcd(a, gcd(b, c));
      }
    }
  }
  cout << result;
  return 0;
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
int main(void){
  char s[100];
  scanf("%s",s);
  int n=strlen(s)-2;
  printf("%c%d%c",s[0],n,s[n+1]);
  return 0;
}

Measured memory_bytes: 128
def bigmod(a,n,p):
    if n==0:
        return 1
    elif n%2 == 1:
        return (a*bigmod(a,n-1,p))%p
    else:
        ret = bigmod(a,n//2, p)
        return (ret*ret)%p
p = 10**9+7
def ncr(n,r):
    if n-r<r:
        r = n-r
    den = 1
    for i in range(1,r+1):
        den = (den * i)%p
    den = bigmod(den, p-2, p)

    num = 1
    for i in range(n-r+1,n+1):
        num = (num * i)%p
    
    return (num * den)%p
    
    


if __name__ == "__main__":
    n,a,b = (int(x) for x in input().split())
    ans = bigmod(2,n, p) - 1
    ans -= ncr(n,a)  
    # print(ncr(n,a))  
    ans -= ncr(n,b)
    # print(ncr(n,b)) 

    ans %= p
    if ans<0:
        ans += p

    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   string c1, c2;
   cin >> c1 >> c2;
   if (c2[2] == c1[0] && c2[1] == c1[1] && c2[0] == c1[2]) cout << "YES" << endl;
   else cout << "NO" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int main()
{
	long long x=io::G(),y=io::G();
	int ans=0;
	for(;x<=y;x<<=1)++ans;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
using namespace std;
main()
{
    int R,G,B,N,ret = 0;;
    cin >> R >> G >> B >> N;
    for (int r = 0; r * R <= N; r++)
    {
        for (int g = 0; g * G <= N; g++)
        {
            if (r * R + g * G <= N && (N - r * R - g * G) % B == 0)
            {
                ret++;
            }
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string Str;
    cin >> Str;
    bool N = false, W = false, S = false, E = false;
    for(int i = 0; i < Str.size(); i++) {
        if(Str[i] == 'S') S = true;
        if(Str[i] == 'E') E = true;
        if(Str[i] == 'N') N = true;
        if(Str[i] == 'W') W = true;
    }

    if(S == N && W == E)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int N;

    scanf("%d", &N);

    int n = N % 10;

    if (n == 3) {
        printf("bon\n");
        return 0;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        printf("pon\n");
        return 0;
    } else {
        printf("hon\n");
        return 0;
    }
    return 0;
}

Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <string>
#include <typeinfo>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;


int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  
  int alice=0,bob=0;
  for(int i=n-1;i>-1;i--){
	if((n-1)%2 == i%2) alice += a[i];
	else bob += a[i];
  }

  cout << alice-bob << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from pprint import pprint

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, sys.stdin.readline().strip().split())
friends_set = [set() for _ in range(N)]
block_set = [set() for _ in range(N)]

uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, sys.stdin.readline().strip().split())
    uf.union(a-1, b-1)
    friends_set[a-1].add(b-1)
    friends_set[b-1].add(a-1)

for _ in range(K):
    c, d = map(int, sys.stdin.readline().strip().split())
    block_set[c-1].add(d-1)
    block_set[d-1].add(c-1)

# print(uf)
for i in range(N):
    # n = uf.find(i)
    # print(len(uf.members(n)), len(friends_set[i]), len(block_set[i]))
    # print(uf.members(n), friends_set[i], block_set[i])

    # TLE
    # print(len(set(uf.members(n)) - set([i]) - friends_set[i] - block_set[i]), end = " ")

    blocked = 0
    for j in block_set[i]:
        if uf.same(i, j):
            blocked += 1
    print(uf.size(i) - 1 - len(friends_set[i]) - blocked, end = " ")

Measured memory_bytes: 128800
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


// 剰余演算クラス
struct ModInt{
    static const LL MOD = 1e+9 + 7;
    LL v;
    ModInt():v(0){}
    ModInt(LL op):v(op){}
    ModInt operator+(ModInt op) const{ return (v + op) % MOD; }
    ModInt operator-(ModInt op) const{ return (v - op + MOD) % MOD; }
    ModInt operator*(ModInt op) const{ return (v * op) % MOD; }
    ModInt operator/(ModInt op) const{ return (v * op.inverse()) % MOD; }
    ModInt operator%(LL op) = delete;
    ModInt operator+=(ModInt op){ return v = (v + op) % MOD; }
    ModInt operator-=(ModInt op){ return v = (v - op + MOD) % MOD; }
    ModInt operator*=(ModInt op){ return v = (v * op) % MOD; }
    ModInt operator/=(ModInt op){ return v = (v * op.inverse()) % MOD; }
    ModInt operator-() const{ return MOD - v; }
    bool operator==(ModInt op) const{ return v == op.v; }
    bool operator!=(ModInt op) const{ return v != op.v; }
    ModInt inverse() const{ return pow(MOD-2); }
    ModInt pow(LL n) const{
        if(n < 0) return pow(MOD-1 + n);
        if(n == 0) return 1;
        ModInt res = pow(n/2);
        return res * res * ((n&1)?ModInt(v): ModInt(1));
    }
    LL get() const{ return v; }
private:
    operator LL() const{ return v; }
};
istream& operator>>(istream& st, ModInt& m){ st>>m.v; return st; }
ostream& operator<<(ostream& st, const ModInt& m){ st<<m.v; return st; }


int main(){
    LL n;
    cin >> n;
    vector<LL> c(n);
    for(LL i = 0; i < n; ++i){
        cin >> c[i];
    }
    sort(c.begin(), c.end());
    ModInt ans(0);
    for(LL i = 0; i < n; ++i){
        LL w = n-i;
        ans += ModInt(2).pow(n*2-1) * ModInt(c[i]);
        if(w > 1){
            ans += ModInt(w-1) * ModInt(2).pow(n*2-2) * ModInt(c[i]);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4724
#pragma GCC target("avx2")
#pragma GCC optimize("O3")

# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
int p[N];
int x[N];
int y[N];


double dist (double ax, double ay, double bx, double by) {
	return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}

int main () {
   SpeedForce;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> x[i] >> y[i];
		p[i] = i;
	}

	ld ans = 0;
	do {
		for (int i = 2; i <= n; i ++) {
			int j = p[i - 1];
			int k = p[i];
			ans += dist(x[j], y[j], x[k], y[k]);
		}
	} while(next_permutation(p + 1, p + n + 1));

	for (int i = n; i >= 1; i --)
		ans /= i;
	cout << fixed << setprecision(7) << ans;
   return Accepted;
}

// B...a

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

typedef long long ll;
const ll INF = 1e12;

ll land[210][210];
ll sea[210][210];
int N, M;
int R;
vector<int> z;

// even/odd, ship
ll cost[2][210];

int main() {
	while(cin >> N >> M, N || M) {
		// init
		for(int i = 0; i < 210; i++) {
			for(int j = 0; j < 210; j++) {
				land[i][j] = sea[i][j] = INF;
			}
			land[i][i] = sea[i][i] = 0;
			cost[0][i] = cost[1][i] = INF;
		}
		z.clear();

		// input
		for(int i = 0; i < M; i++) {
			ll x, y, t;
			string sl;
			cin >> x >> y >> t >> sl;
			x--; y--;
			if(sl == "L")
				land[x][y] = land[y][x] = min(land[x][y], t);
			else if(sl == "S")
				sea[x][y] = sea[y][x] = min(sea[x][y], t);
			else
				assert(1);
		}
		cin >> R;
		z.resize(R);
		for(int i = 0; i < R; i++) {
			cin >> z[i];
			z[i]--;
		}

		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					land[j][k] = min(land[j][k], land[j][i] + land[i][k]);
					sea[j][k] = min(sea[j][k], sea[j][i] + sea[i][k]);
				}
			}
		}

		cost[0][z[0]] = 0;
		for(int i = 1; i < z.size(); i++) {
			for(int j = 0; j < 210; j++)
				cost[i%2][j] = INF;
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					cost[i%2][j] = min(cost[i%2][j],
							land[z[i-1]][k] + sea[k][j] + land[j][z[i]] + cost[(i-1)%2][k]);
				}
				cost[i%2][j] = min(cost[i%2][j], land[z[i-1]][z[i]] + cost[(i-1)%2][j]);
			}
		}
		ll res = INF;
		for(int i = 0; i < N; i++) {
			res = min(res, cost[(R-1)%2][i]);
		}
		cout << res << endl;
	}
}

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

int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int S1 = A * B;
	int S2 = C * D;
	cout << max(S1, S2) << endl;
}

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

using namespace std;

#define INF 1<<30
#define LINF 1ll<<60ll
#define pb(a) push_back(a)
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;++i)
#define FORVEC(i, v) for(int i = 0;i < sz(v);++i)

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

#define fil0(i,n) cout<<swet(n)<<setfill('0')<<i<<resetiosflags(ios_base::floatfield)


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//?????¶????????±?????????
		int n = sc.nextInt();
		//3?¬?????????? ?£? ??? ??¨?±??????? ?????°??????????????????
		//?????? 4?£? 3????????? 10??¨?±?
		int  [][][] list = new int[4][3][10];
		//??¨????????¨?±??????????
		//b ?£?
		for(int i = 0; i < 4; i++){
			//f ???
			for(int j= 0 ; j< 3; j++){
				//r ??¨?±???????
				for(int k =0; k < 10; k++ ){
					//?£? ??? ??¨?±??????????
					list [i][j][k] = 0;
				}
			}
		}
		//???????????¨???
		for(int i =0; i <n;i++){
			//?????????0?????????????§????????????? ?£? ??? ??¨?±??????????????????????v ?????°???????´? list [?\\???][?¨?][???]
			list [sc.nextInt() - 1][sc.nextInt() - 1][sc.nextInt() - 1] +=  sc.nextInt();
		}
		//??¨???
		//b ?£?
		for(int i = 0; i < 4; i++){
			//f ???
			for(int j= 0 ; j< 3; j++){
				//r ??¨?±???????
				for(int k =0; k < 10;k++ ){
					//?£? ??? ??¨?±??????????
					System.out.print(" " + list [i][j][k] );
				}
				System.out.println();
			}
			//i???3???????????´????????§???????????????
			if(i < 3){
				System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 29752
fun main(args : Array<String>) {
    val S = readLine()!!

    val map = S.toCharArray().groupBy { it }.entries

    var count1 = 0
    map.forEach {
        count1++
        if (it.value.size != 2) {
            println("No")
            return
        }
    }

    if (count1 == 2) {
        println("Yes")
    } else {
        println("No")
    }
}

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

using namespace std;

int main()
{
	string a, b, c;
	char A, B, C;

	cin >> a >> b >> c;

	A = (char)a[0] - 0x20;
	B = (char)b[0] - 0x20;
	C = (char)c[0] - 0x20;

	cout << A << B << C << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll h, n;
    cin>>h>>n;
    ll m = 0, x = 0;
    //vector<ll> moves(n);
    loop(n){
        cin>>x;
        m += x;
    }
    if (m>=h) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}

int main() {
	IOS;
	string s;
	cin >> s;
	bool unko = true;
	int use = 0;
	if (s[0] != 'A')unko = false;
	for (int i = 1; i < s.size(); i++) {
		if (s[i] >= 'a' && s[i] <= 'z')continue;
		else if (i > 1 && i <= s.size() - 2 && s[i] == 'C')use++;
		else unko = false;
	}
	if (use == 1 && unko == true)cout << "AC" << endl;
	else cout << "WA" << endl;
}



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

int dir[10]={1,0,0,1,-1,0,0,-1};

int main()
{
    int m,n,flag;
    char mapp[52][52];
    bool mm[52][52];
    memset(mapp,'.',sizeof(mapp));
    memset(mm,true,sizeof(mm));
    cin>>m>>n;
    //getchar();
    for(int i=1;i<m+1;i++)
        cin>>&mapp[i][1];
    for(int i=1;i<m+1;i++)
    {
        for(int k=1;k<n+1;k++)
        {
           flag=1;
            if(mapp[i][k]=='#')
            {
                flag=0;
                for(int p=0;p<8;p+=2)
                {
                    if(mapp[i+dir[p]][k+dir[p+1]]=='#')
                    {
                        flag=1;
                        break;
                    }
                }

            }
            if(!flag)
            {
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

arr = inputs[1]

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
  p arr
end

cnt = 0
for i in 0..arr.size-3
  cnt += 1 if arr[i+1] != [arr[i], arr[i+1], arr[i+2]].max and arr[i+1] != [arr[i], arr[i+1], arr[i+2]].min
end


puts cnt


Measured memory_bytes: 1788
#![allow(unused_imports)]

use proconio::*;
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        k: usize,
    }
    if k % 2 == 0 || k % 5 == 0 {
        println!("-1");
        return;
    }
    let mut s = 7;
    let mut ans = 1;
    while s % k != 0 {
        ans += 1;
        s *= 10;
        s += 7;
        s %= k;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2204
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int idx1 = 0; 
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'A') {
                idx1 = i;
                break;
            }
        }

        int idx2 = 0; 
        for (int i = s.length - 1; i >= 0; i--) {
            if (s[i] == 'Z') {
                idx2 = i;
                break;
            }
        }
        
        System.out.println(idx2 - idx1 + 1);

        return;
    }

}

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

const Int MAX = 1000010;

int main(){
    Int N;
    cin >> N;
    vector<Int> A(N);
    rep(i,N) cin >> A[i];
    //A[N] = 1000005; //門番
    sort(A.begin(),A.end());

    if (A[0] == 1) {
        if (A[1] != 1) {
            cout << 1 << endl;
            return 0;
        }
        else {
            cout << 0 << endl;
            return 0;
        }
    }

    vector<bool> prime(MAX, true);
    Int cnt = 0;
    rep(i,N) {
        Int now = A[i];
        if (prime[now]) {
            if (i == N-1) cnt++;
            else if (A[i+1] != now) cnt++;
            //cout << i << endl;
            for (int j = now; j < MAX; j += now) {
                prime[j] = false;
            }
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 4780
#include<stdio.h>
int main()
{
  int j,i,n,p,c,r,ss=0;
  int N[100000],C[10000],X[10000];
  while(1){
    scanf("%d%d",&n,&r);
    if(n==0 && r==0)break;
    for(i=0;i<n;i++){
      N[i]=i+1;
    }
    for(i=0;i<r;i++){
      scanf("%d%d",&p,&c);
      for(j=0;j<c;j++){
	C[j]=N[n-p-j];
      }
      for(j=n-p+1;j<n;j++){
        N[j-c]=N[j];
      }
      for(j=0;j<c;j++){
        N[n-j-1]=C[j];
      }
      
    }
    /* for(i=0;i<n;i++){
      printf("%d ",N[i]);
      }*/
    X[ss]=N[n-1];
    ss++;
  }
  for(i=0;i<ss;i++){
    printf("%d\n",X[i]);
    }
  return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

using namespace std;

int main() {
    

    
    int a, b, c, x, y;
    
    cin >> a >> b >> c >> x >> y;
    
    long long mincost = max(x, y) * 2 * c;
    long long mid;
    if (x > y)
    {
        mid = (x - y) * a;
    }
    else
    {
        mid = (y - x) * b;
    }
    mincost = min(mincost, min(x, y) * 2 * c + mid);
    mincost = min(mincost, (long long)(x * a + y * b));
    
    cout << mincost << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return &Scanner{sc}
}

func (sc *Scanner) NextInt() int {
	sc.sc.Scan()
	i, err := strconv.Atoi(sc.sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := NewScanner()
	n := sc.NextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.NextInt()
	}
	current := -1
	broken := 0
	i := 1
	if len(a) == 1 && a[0] == 1 {
		fmt.Println(0)
		return
	}
	if a[0] == 1 {
		current = 1
	}
	for ; i < n; i++ {
		if a[i] == 1 {
			current = 1
		}
		if current < 0 {
			broken++
			continue
		}
		if a[i] == current+1 {
			current++
		} else {
			broken++
		}
	}
	if current < 0 {
		fmt.Println(-1)
		return
	}
	fmt.Println(broken)
}

Measured memory_bytes: 3840
n = list(input())
gaps = len(n) - 1
import copy
ans = 0
for i in range(2 ** gaps):
    formula = copy.deepcopy(n)
    ops = [""] * gaps
    for j in range(gaps):
        if (i >> j) & 1:
            ops[gaps-j-1] = "+"
    formula1 = ""
    for f,op in zip(formula,ops + [""]):
        formula1 += (str(f) + op)
    ans += eval(formula1)

print(ans)


Measured memory_bytes: 3444
// be name khoda
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define int long long
#define mpr make_pair 
typedef long long ll;
#pragma GCC optimize("Ofast")

const int maxn = 1e6+10;
const int N = 1e6+5;
const int mod = 998244353;
const int inf = 1e9+10;

int n, m, q;
int a[maxn], ps[maxn];

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin>> n;
    for(int i = 1; i <= n; i++) cin>> a[i];
    sort(a+1, a+n+1);
    for(int i = 1; i <= n; i++) ps[i] = ps[i-1] + a[i];
    
    int ans = 0;
    for(int i = n-1; i >= 1; i--)
    {
        if(2*ps[i] < a[i+1]) return cout<< n-i, 0;
    }
    cout<< n;
}





Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

const int N = 2e5 + 10;
ll a[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n, k;
    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
    ll ans = 0;
    for (int i=k+1; i<=n; i++) {
        ans += a[i];
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
   return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int X,A,B; cin >> X >> A >> B;
    //賞味期限Ａ日前
    //買ってからB日後
    //賞味期限Ｘ日
    if (A>B) cout << "delicious" << endl;
    else if (A==B) cout << "delicious" << endl;
    else if (A<B && X>=B-A) cout << "safe" << endl;
    else if (A<B && X<B-A) cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

int t;

int main(){
	int *prime;
	prime = (int *)malloc(1000010*sizeof(t));
	if(prime==NULL) cout<<"no mem\n";
	rep(i,1000010){
		prime[i]=true;
	}
	prime[0]=prime[1]=false;
	for(int i=2;i<1000010;i++){
		if(prime[i]){
			for(int j=i*2;j<1000010;j+=i){
				prime[j]=false;
			}
		}
	}
	//rep(i,30) cout<<i<<" "<<prime[i]<<endl;
	int *sum;
	int num=0;
	sum=(int *)malloc(1000010*sizeof(t));
	if(sum==NULL) cout<<"no mem\n";
	rep(i,1000010){
		if(prime[i]){
			num++;
		}
		sum[i]=num;
	}
	int n;
	while(cin>>n){
		cout<<sum[n]<<endl;
	}
	return 0;
}

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

int main(){
  int K,S;
  cin >> K>>S;
  int ans = 0;
  for(int i=0;i<=K;i++){
     for(int j=0;j<=K;j++){
       int z = S-i-j;
       if(z>=0 && z<=K){
         ans++;
       }
     }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int h;
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    int flag;
    if(y%2!=0)flag=0;
    else{
        int num1=y/4;
        int num2=y%4;
        if(num2>0)num1++;
        int num3=y/2;
        if(x>=num1&&x<=num3)flag=1;
        else flag=0;
    }
    if(flag)printf("Yes\n");
    else printf("No\n");
    return 0;

}


Measured memory_bytes: 3636
#include <cstdio>
using namespace std;
int a[300],b[300],c[300];
int m;
void push(int aa,int bb,int cc){
    m++;
    a[m]=aa;
    b[m]=bb;
    c[m]=cc;
}
int main() {
    int L;
    scanf("%d",&L);
    L--;
    int x=1,n=20;
    while(L>=0){
        if (L==0){
            if (x<n)
                push(x,n,0);
            break;
        }
        if (L==1){
            push(x,n,0);
            push(x,n,1);
            break;
        }
        if (L%2==0)
            push(x,n,L);
        L=(L+1)/2;
        push(x,x+1,0);
        push(x,x+1,L);
        L--;
        x++;
    }
    printf("%d %d\n",n,m);
    for (int i=1;i<=m;i++)
        printf("%d %d %d\n",a[i],b[i],c[i]);
    return 0;
}


Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
// ll MOD = 1000000007;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
string s,t;
int N,K;

vi A,B;
vpii datas;
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int main(){
	cin>>N;
	vi dist;
	rep(i,N){
		int d;
		cin>>d;
		dist.pb(d);
	}
	bool flag=true;
	ll ans=0;
	if(dist[0]!=0)flag=false;
	sort(all(dist));
	int cnt[114514]={0};
	int ma=0;
	rep(i,N){
		if(i>0&&dist[i]==0)flag=false;
		if(i>0&&(dist[i]-dist[i-1])>1)flag=false;
		cnt[dist[i]]++;
		ma=max(ma,dist[i]);
	}
	if(flag){
		ans=(ll)1;
		rep(i,ma){
			ans*=powMod(cnt[i],cnt[i+1],MOD);
			ans%=MOD;
		}
	}
	cout<<ans<<endl;

}





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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    set<ll> cnt;
    rep(i, N) {
        ll a = A[i];
        cnt.insert(a);
    }
    if (cnt.size() == N)  {
        cout << "YES" << '\n';
    }else{
        cout << "NO" << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int count = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    count += (r - l + 1);
  }
  cout << count << endl;
}

Measured memory_bytes: 256