akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;


int main(){
  ll n;
  cin >> n;
  map<ll,ll> mp;
  ll ans=0;
  for(int i=0;i<n;++i){
    int a;
    cin >> a;
    mp[a]++;
    ans+=a;
  }
  ll q;
  cin >> q;
  vector<ll> cal(q);
  for(int i=0;i<q;++i){
    int b,c;
    cin >> b >> c;
    ll num=mp[b];
    mp[b]=0;
    //if(num==0)continue;
    ans-=b*num;
    mp[c]+=num;
    ans+=num*c;
    cal[i]=ans;
    //cout << ans << endl;
  }
  for(int i=0;i<q;++i){
    cout << cal[i] <<endl;
  }
  return 0;
}


Measured memory_bytes: 9904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<ll> c(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i) >> c.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	ll MIN=-1000000000000000000;
	vector<ll> dist(n,MIN);
	dist.at(0)=0;
	rep(i,n){
		rep(j,m){
			dist[b[j]]=max(dist[b[j]],dist[a[j]]+c[j]);
		}
	}
	ll ans=dist[n-1];
	rep(i,n){
		rep(j,m){
			dist[b[j]]=max(dist[b[j]],dist[a[j]]+c[j]);
		}
	}
	if(ans!=dist[n-1]) cout << "inf" << endl;
	else cout << dist[n-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
 
 int mod=1000000007;
 long long fast_exp(long long a,long long n,long long mod1)
    {
     
      if (n==0)return 1;
      else if (n==1)return a;
      if (n%2==0)return fast_exp((a*a)%mod1,n/2,mod1);
      else return (a*fast_exp((a*a)%mod1,n/2,mod1))%mod1;
    }
void solve()
{
    int n;
    cin >> n;
    vector<int>arr(n);
    for (int c=0;c<n;c++)
        cin >> arr[c];

    if (n%2==0)
        {
            long long dp[2*100001];
            dp[n-1]=arr[n-1];
            dp[n-2]=max(arr[n-1],arr[n-2]);
            for (int c=n-3;c>=0;c--)
                {
                    if (c%2==0)
                        dp[c]=max(arr[c]+dp[c+2],dp[c+1]);
                    else 
                        dp[c]=(arr[c]+dp[c+2]);

                }
                cout << dp[0] << endl;
        }
    else
    {
        long long dp[2*100001][2];
        dp[n-1][0]=arr[n-1];
            dp[n-2][0]=max(arr[n-1],arr[n-2]);
            for (int c=n-3;c>=0;c--)
                {
                    if (c%2==1)
                        dp[c][0]=max(arr[c]+dp[c+2][0],dp[c+1][0]);
                    else 
                        dp[c][0]=(arr[c]+dp[c+2][0]);

                }

            dp[n-1][1]=0;
            dp[n-2][1]=max(arr[n-1],arr[n-2]);
            for (int c=n-3;c>=0;c--)
                {
                    if (c%2==1)
                        dp[c][1]=dp[c][0];
                    else 
                        dp[c][1]=max(dp[c+1][1],arr[c]+dp[c+2][1]);
                }
            cout << dp[0][1] << endl;
            
    }
    
    
        

}
    


    
 

int main()
{
    fast_io;
    int t;
   // cin >> t;
t=1;
    for (int tt=1;tt<=t;tt++)
    {
       // cout << "Case #" << tt << ": " ;    
        solve();
        
 
    }
 
    
    return 0;
}
 


Measured memory_bytes: 7148
#include<bits/stdc++.h>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // string s;
    // cin>>s;
   	// int flag=1;
    // for(int i=0;i<s.size();++i){
    // 	for(int j=i+1;j<s.size();++j){
    // 		if(s[i]==s[j]){
    // 			flag=0;
    // 			break;
    // 		}
    // 	}
    // }
    // cout<<((flag)?"yes":"no");



    // string s;
    // cin>>s;
    // set<char>c;
    // for(char k:s) c.insert(k);
    // cout<<((s.size()==c.size())?"yes":"no");
    


    // string s;
    // cin>>s;
    // map<char,int>m;
    // for(int i=0;i<s.size();++i){
    // 	if(m[s[i]]>0){
    // 		cout<<"no";
    // 		return 0;
    // 	}
    // 	++m[s[i]];
    // }
    // cout<<"yes";

    // int a,b;
    // cin>>a>>b;
    // int ans=a+b;
    // (ans>=10)?cout<<"error":cout<<ans;
    

    // int n;
    // cin>>n;
    // int a,mx=0,mi=1000;
    // for(int i=0;i<n;++i){
    // 	cin>>a;
    // 	if(mx<a) mx=a;
    // 	if(mi>a) mi=a;
    // }


    // int n;
    // cin>>n;
    // int ar[n];
    // for(int i=0;i<n;++i) cin>>ar[i];
   	// cout<<*max_element(ar,ar+n)-*min_element(ar,ar+n);
    

    // int n,m;
    // cin>>n>>m;
    // n+=2;
    // m+=2;
    // for(int i=0;i<n;++i){
    // 	for(int j=0;j<m;++j){
    // 		if(i==0 || i==n-1 || j==0 || j==m-1) cout<<"#";
    // 		else{
    // 			char c;
    // 			cin>>c;
    // 			cout<<c;
    // 		}
    // 	}
    // 	cout<<'\n';
    // }

    // int x,y;
    // cin>>x>>y;
    // int ar[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    // cout<<((ar[x]==ar[y])?"Yes":"No");
    

    // string a,b,c;
    // cin>>a>>b>>c;
    // cout<<(((a.back()==b.front()) && (b.back()==c.front()))?"YES":"NO");
    
    // int a,b,c;
    // cin>>a>>b>>c;
    // cout<<((a<=c && c<=b)?"Yes":"No");
   
	// string s;
	// getline(cin,s);
	// cout<<s;        

    int a,b,c;
    cin>>a>>b>>c;
    cout<<(((a*100+b*10+c)%4==0)?"YES":"NO");





    return 0;
}

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

int main() {
	int n; cin >> n;
	if (n == 1 || n == 2 || n == 3 || n == 5 || n == 6 || n == 9 || n == 10 || n == 13 || n == 17) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,sum=0;
	cin>>n;
	long long arr[n+1];
	for(long long i=1;i<=n;i++){
		cin>>arr[i];
		if(i%2!=0&&arr[i]%2!=0){
			sum++;
		}
	}
	cout<<sum;
}

Measured memory_bytes: 3624
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = h[k-1] - h[0]
for i in range(n-k+1):
    if h[i+k-1] - h[i] < ans:
        ans = h[i+k-1] - h[i]
print(ans)

Measured memory_bytes: 7384
N = int(input())
A = list(map(int, input().split()))

d = [0]*N
d[0] = 1000
for i in range(1, N):
    if A[i-1] < A[i]:
        d[i] = d[i-1]+(d[i-1]//A[i-1])*(A[i]-A[i-1])
    else:
        d[i] = d[i-1]
print(d[-1])


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

vector <ii> ed[N];

int n,sub[N];

ll ans,dep[N];

int calc(int cur,int back) {
  sub[cur] = 1;
  for (auto i : ed[cur])
    if (i.first != back)
      sub[cur] += calc(i.first,cur);
  return sub[cur];
}

int find(int cur,int back) {
  for (auto i : ed[cur])
    if (i.first != back && sub[i.first] > n / 2)
      return find(i.first,cur);
  return cur;
}

void f(int cur,int back,ll d) {
  ans += d * 2;
  dep[cur] = d;
  sub[cur] = 1;
  bool leaf = true;
  for (auto i : ed[cur]) {
    if (i.first != back) {
      leaf = false;
      f(i.first,cur,d + i.second);
      sub[cur] += sub[i.first];
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n;
  for (int i = 1 ; i < n ; i++) {
    int u,v,c;
    cin >> u >> v >> c;
    ed[u].push_back({v,c});
    ed[v].push_back({u,c});
  }
  calc(1,-1);
  int root = find(1,-1);
  f(root,-1,0);

  for (auto i : ed[root]) {
    if (n - sub[i.first] == sub[i.first]) {
      cout << ans - dep[i.first] << endl;
      return 0;
    }
  }

  ll mn = 1e18;

  for (auto i : ed[root])
    mn = min(mn,dep[i.first]);

  cout << ans - mn << endl;
}

Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

int main() {

	int a, b, c;
	cin >> a >> b >> c;

	int left = a - b;
	int ans = max(0, c - left);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep3(i,k,n) for(int i = k; i < n; i++)
using namespace std;

int n,A[100000];

int parti(int A[],int p,int r){
    int x=A[r];
    int i=p-1;
    rep3(j,p,r){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
    swap(A[i+1],A[r]);
    return i+1;
}

int main(void){
    cin >> n;
    rep(i,n) scanf("%d",&A[i]);

    int q = parti(A, 0, n-1);

    rep(i,n){
        if(i) cout << " ";
        if(i==q) cout << "[";
        cout << A[i];
        if(i==q) cout << "]";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3500
n = int(input())
h = list(map(int, input().split()))

h.reverse()
val = 0
ans = 0
for i in range(1, n, 1):
    if h[i-1] <= h[i]:
        val += 1
    else:
        val = 0
    ans = max(ans, val)
print(ans)

Measured memory_bytes: 14252
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

bool F[10][110] = {};
int P[11][110] = {};

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

  int N;
  cin >> N;

  REP(i, N) {
    REP(j, 10) {
      cin >> F[j][i];
    }
  }
  REP(i, N) {
    REP(j, 11) {
      cin >> P[j][i];
    }
  }
  int ma = -(1 << 30);
  for (int i = 1; i < (1 << 10); i++) {
    int m = 0;
    REP(j, N) {
      int c = 0;
      REP(k, 10) {
        if ((i & (1 << k)) > 0 && F[k][j]) {
          c++;
        }
      }
      m += P[c][j];
    }
    ma = max(ma, m);
  }

  cout << ma << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int64_t> rain(N);
  for(int i=0; i<N; i++){
    if(i %2 == 0){
      rain.at(0) += vec.at(i);
    }
    else{
      rain.at(0) -= vec.at(i);
    }
  }
  for(int i=1; i<N; i++){
    rain.at(i) = vec.at(i-1)*2 - rain.at(i-1);
  }
  
  for(int i=0; i<N; i++){
    cout << rain.at(i);
    if(i == N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int a[N];
int n;
int ans = 0;
bool cmp(const int &x,const int &y)
{
  return x > y;
}
int main()
{
  scanf("%d",&n);
  for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
  sort(a+1,a+n+1,cmp);
  for(int i=1; i<=n; ++i) if(i+1>a[i+1])
  {
    for(int j=i+1; a[j]==i; ++j) ans^=1;
    ans|=((a[i]-i)&1);
	puts(ans?"First":"Second");
    return 0;
  } 
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

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

	ll x = 0, s = 0;
	int l = 0, r = 0;
	ll ans = 0;
	for(; l < n; ++l){
		while(r < n && (x^a[r]) == (s+a[r])){
			x^=a[r];
			s+=a[r];
			r++;
		}
		ans += r-l;
		x ^= a[l];
		s -=a[l];
	}
	cout << ans << endl;
}


Measured memory_bytes: 4820
#include <cstdio>
#include <algorithm>
using namespace std;
int main(void){
    long long int global_max = 0, curr_val = 0;
    int n, t;
    scanf("%d", &n);
    scanf("%d", &t);
    global_max += t-1; curr_val+= t-1;
    for (int i = 2; i <= n; i++) {
        scanf("%d", &t);
        curr_val+= t-i;
        global_max = max(global_max, curr_val);
    }
    printf("%lld\n", curr_val);

    return 0;
}



Measured memory_bytes: 2756
#include<iostream>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
string a,b;
int main(){
  scan(a);scan(b);
  string c=a+b;
  int inc=stoi(c);
  int j=0;
  rep1(i,400){
    if(i*i==inc){
      prin("Yes");
      break;
    }
    j++;
  }
  if(j==400) prin("No");
  
  
    

  
  return 0;
}


Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        #print(i)
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

fact = make_divisors(N)

ans = 10000
for a in fact:
    b = N // a
    ans = min(ans,max(len(str(a)),len(str(b))))
print(ans)

Measured memory_bytes: 3064
def q2():
    N = [i for i in input()]
    S = 0
    for n in N:
        S += int(n)
    N = int(''.join(N))
    d,m = divmod(N, S)
    if m == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    q2()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef unsigned long long int ull;
typedef long long int ll;

int a[500005];
const int M=1e4;
ll cnt[M];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j*j<=n;j++)
        {
            for(int k=1;k*k<=n;k++)
            {
                ll val=i*i+j*j+k*k+i*j+j*k+i*k;
                   if(val<=n)
                   {
                       cnt[val]++;
                   }
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<cnt[i]<<endl;

}


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

int main()
{
    int n, x;
    while (true)
    {
        cin >> n >> x;
        if (n==0 && x==0) break;
        int ans = 0;
        for (int i=1; i<=n-2; i++)
        {
            for (int j=i+1; j<=n-1; j++)
            {
                for (int k=j+1; k<=n; k++)
                {
                    if (i+j+k==x) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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

int main(){
 while(true){
  int n;
  cin >> n;
  if(n==0) break;
 
  char c[n];
  for(int i=0; i<n; i++){
   cin >> c[i];
  }
 
  int can[26] = {0}; //????£????(candidate)????\¨??°
  
  for(int i=0; i<n; i++){
   can[(int)(c[i]-'A')]++;
   
   int max1 = -1; //??????
   int max2 = -1; //??????

   //A~Z???????\¨??°???????????????
   for(int j=0; j<26; j++){
    if(can[j]>max1){
     max2 = max1;
     max1 = can[j];
    }else if(can[j]>max2){
     max2 = can[j];
    }
   }

   //????????????????????????????\¨??°???????????????
   if(max1-max2>n-(i+1)){
    for(int j=0; j<26; j++){
     if(can[j]==max1){
      cout << (char)(j+'A') << ' ';
      break;
     }
    }
    cout << (i+1) << endl;
    break;
   }

   //???????????§????\¨????????´???
   if(i==n-1){
    cout << "TIE" << endl;
    break;
   }
  }
 }
 
 return 0;
}

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

double N, K;

double continuous(double i) {
  double re = 0;
  while(i < K) {
    i *= 2;
    re++;
  }
  return re;
}

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

  
  double ans = 0;
  for (double i = 1; i < N + 1; i++) {
    ans += pow(0.5, continuous(i)) / N;  
  }
  cout << fixed << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,N;
const int MAXN=1e3+10;
const int MAXH=1e4+10;
int dp[MAXN][MAXH];
int a[MAXN];
int b[MAXN];
const int inf=1e9;
int dfs(int n,int h){
    if(h<=0)return 0;
    if(n==N)return inf;
    if(dp[n][h]!=-1)return dp[n][h];
    return dp[n][h]=min(dfs(n+1,h),b[n]+dfs(n,h-a[n]));
}
int main(){
    cin>>H>>N;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++)cin>>a[i]>>b[i];
    cout<<dfs(0,H)<<endl;;
    
	return 0;
}

Measured memory_bytes: 40320
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli a, b,ans=0;
    cin >> a >> b;
    for (; a <= b;a++){
        string t = to_string(a);
        string rt = t;
        reverse(all(rt));
        if(t==rt)
            ans++;
    }
    out(ans);
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  char s[200001];
  char t[200001];
  scanf("%s",s);
  scanf("%s",t);
  int size=0;
  while(s[size]!='\0') size++;
  int count=0;
  for (int i=0;i<size;i++) {
    if(s[i]!=t[i]) count++;
  }
  printf("%d\n",count);
}

Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;

int main(){

  string s;
  cin >> s;

  if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3])cout << "Yes" << endl;
  else if(s[0]==s[2] && s[1]!=s[2] && s[3]==s[1])cout << "Yes" << endl;
  else if(s[0]==s[3] && s[1]==s[2] && s[3]!=s[1])cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3552
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    S = input().rstrip('\n')

    balance = 0
    balance_min = 0
    for s in S:
        if s == "(":
            balance += 1
        else:
            balance -= 1
        balance_min = min(balance_min, balance)
    ans = S
    if balance_min < 0:
        ans = "(" * (balance_min * -1) + S
        balance -= balance_min
    if balance > 0:
        ans += ")" * balance
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
// Problem : A - Tak and Hotels (ABC Edit)
// Contest : AtCoder - AtCoder Beginner Contest 044
// URL : https://atcoder.jp/contests/abc044/tasks/abc044_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, k, x, y;
	cin >> n>> k >> x>>y;
	cout << min(n,k)*x + max(0,n-k)*y;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	long long int b[a];
	forr(i,0,a)
		cin>>b[i];
	long long int ct=0;
	sort(b,b+a, greater<int>());
	if(a%2==0){
	forr(i,1,(a)/2)
		ct+=b[i];
	cout<<ct*2+b[0];
	}
	else
	{
		forr(i,1,a/2)
			ct+=b[i];
		cout<<2*ct+b[0]+b[a/2];
	}
	
	return 0; 	
}

Measured memory_bytes: 5220
/*
    Author : manu_sy
*/
#include "bits/stdc++.h"
using namespace std;
 
/** Template Begins **/
#define int ll 
typedef long long        ll;
typedef pair<int,int>    PII;

#define IOS         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl        '\n'
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(a)      (a).begin(), (a).end()
#define FOR(i,a,b)  for(int i=a;i<=b;i++)
#define LP(i,n)     for(int i=0;i< n;i++)
 
/* Debug */
 
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.F << "," << P.S << ")";
} 
 
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
 
template<class TH> void _dbg(const char *sdbg, TH h){ cerr << sdbg << '=' << h << endl; }
 
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr << *sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
 
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif
 
/* Debug Ends */
 
const int N = 3e2+7;
const int INF = 1e17+7;

/** Template Ends **/
int dp[N][N][N], n, K, h[N];
vector<int> v;
 
signed main() {
 
    IOS;
    cin >> n >> K;
    FOR(i,1,n) {
    	cin >> h[i];
    	v.pb(h[i]);
    }
    v.pb(0);
    sort(all(v));
    v.resize(unique(all(v)) - v.begin());

    int l = v.size();
    FOR(i,0,n) FOR(j,0,l-1) FOR(k,0,K) dp[i][j][k] = INF;

    dp[0][0][0] = 0;
    FOR(i,0,n-1) FOR(j,0,l-1) FOR(k,0,K)
    {
    	int ch = v[j];
    	int nh = lower_bound(all(v), h[i + 1]) - v.begin();
    	debug(i, j, k, ch, nh, dp[i][j][k]);

    	dp[i + 1][nh][k] = min(dp[i+1][nh][k], dp[i][j][k] + max(0LL, h[i + 1] - ch));
    	dp[i + 1][j][k + 1] = min(dp[i + 1][j][k + 1], dp[i][j][k]);
    }
    int ans = INF;
    FOR(j,0,l-1) FOR(k,0,K) ans = min(ans, dp[n][j][k]);
    cout << ans << endl;

    return 0;
}























Measured memory_bytes: 223616
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

    int n, k;
double fact(double d) {
    double num = 1.0;
    while(d < k) {
        d *= 2;
        num *= 2;
    }
    return num;
}

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

    double ans = 0.0;

    rep(i,n) {
        double dice = i + 1;
        if(dice >= k)
            ans += (double)1/n;
        else{
            ans += (double)1/(n * fact(dice));
        }
    }
    cout << setprecision(16);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll N,P;
    cin>>N>>P;
    ll i=2;
    ll tmp=P;
    ll ans=1;
    if(N==1) { cout<<P<<endl; return 0; }
    while(tmp>1){
        if(i>sqrt(P)) break;
        if(tmp<(long long)powl((long double)i,(long double)N)) break;
        if(tmp%(long long)powl((long double)i,(long double)N) ==0){
            tmp/=pow(i,N);
            ans*=i;
        }else{
            i++;
        }
    }
    cout<<ans<<endl;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    rep(i,n){
        if(a[a[i]] == i) ans++;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	static long[][] memo;
	static int []w,v;
	static int n;
	public static long dp(int i,int remW) {
		if(remW==0||i==n)
			return 0;
		if(memo[i][remW]!=-1)
			return memo[i][remW];
		long take=0;
		if(!(remW-w[i]<0))
		 take = dp(i+1,remW-w[i])+v[i];
		
		long  leave =dp(i+1,remW);
		return memo[i][remW]=Math.max(take, leave);
	}
	
	
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        n=sc.nextInt();
       int W=sc.nextInt();
       memo=new long [n][W+1];
       for(int i=0;i<n;i++) {
    	   for(int j=0;j<memo[i].length;j++)
    		   memo[i][j]=-1;
       }
        w=new int[n];
       v=new int[n];
       for(int i=0;i<n;i++) {
    	   w[i]=sc.nextInt();
    	   v[i]=sc.nextInt();
       }
       out.println(dp(0,W));
        out.flush();
    }

    static class Scanner
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {br = new BufferedReader(new InputStreamReader(system));}
        public Scanner(String file) throws Exception {br = new BufferedReader(new FileReader(file));}
        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public String nextLine()throws IOException{return br.readLine();}
        public int nextInt() throws IOException {return Integer.parseInt(next());}
        public double nextDouble() throws IOException {return Double.parseDouble(next());}
        public char nextChar()throws IOException{return next().charAt(0);}
        public Long nextLong()throws IOException{return Long.parseLong(next());}
        public boolean ready() throws IOException{return br.ready();}
        public void waitForInput() throws InterruptedException {Thread.sleep(3000);}
    }
}
    

Measured memory_bytes: 126932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
class ModInt {
  static int MOD;
  long long x;

 public:
  static void mod(int m) { MOD = m; }

  ModInt(long long v = 0) : x(v % MOD) {
    if (x < 0) x += MOD;
  }

  ModInt& operator+=(const ModInt& r) {
    x += r.x;
    if (x >= MOD) x -= MOD;
    return *this;
  }

  ModInt& operator-=(const ModInt& r) {
    x -= r.x;
    if (x < 0) x += MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& r) {
    x = (x * r.x) % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& r) {
    *this *= r.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt& r) const { return ModInt(*this) += r; }
  ModInt operator-(const ModInt& r) const { return ModInt(*this) -= r; }
  ModInt operator*(const ModInt& r) const { return ModInt(*this) *= r; }
  ModInt operator/(const ModInt& r) const { return ModInt(*this) /= r; }
  bool operator==(const ModInt& r) const { return x == r.x; }
  bool operator!=(const ModInt& r) const { return x != r.x; }

  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

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

  friend istream& operator>>(istream& is, ModInt& x) { return is >> x.x; }

  int getMod() { return MOD; }

  long long val() { return x; }
};
int ModInt::MOD = 1000000007;
template <typename T>
class Combination {
  vector<T> fact, ifact;

 public:
  Combination(int nMax) : fact(nMax + 1), ifact(nMax + 1) {
    fact[0] = 1;
    for (int i = 0; i < nMax; ++i) fact[i + 1] = fact[i] * (i + 1);
    for (int i = 0; i < nMax + 1; ++i) ifact[i] = fact[i].inverse();
  }

  T factorial(int n) const { return fact[n]; }
  T inverseFactorial(int n) const { return ifact[n]; }

  T P(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k);
  }

  T C(int n, int k) const {
    if (n < 0 || k < 0 || n < k) return 0;
    return factorial(n) * inverseFactorial(n - k) * inverseFactorial(k);
  }

  T H(int n, int k) const {
    if (n < 0 || k < 0) return 0;
    return k == 0 ? 1 : C(n + k - 1, k);
  }
};

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(K);
  rep(i, K) cin >> a[i];

  Combination<ModInt> comb(N);

  vector<vector<ModInt>> dp(K + 1, vector<ModInt>(N + 1, 0));
  dp[0][0] = 1;

  rep(i, K) rep(j, N + 1) {
    for (int k = 0; k <= a[i]; ++k) {
      dp[i + 1][j + k] += dp[i][j] * comb.C(N - j, k) * comb.C(N - k, a[i] - k);
    }
  }

  cout << dp[K][N] << endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

#define cmax(_a, _b) (_a < (_b) ? _a = (_b), 1 : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b), 1 : 0)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))

#define maxn 20010
typedef long long ll;
typedef double db;

int n, a[maxn], b[maxn], c[maxn], p[maxn];
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) a[i] = n * i, scanf("%d", &p[i]);
	for (int i = 1, sum = n * n + 1; i <= n; ++i, ++sum) b[p[i]] = sum - a[p[i]];
	for (int i = 1; i <= n; ++i) printf("%d ", a[i]); puts("");
	for (int i = 1; i <= n; ++i) printf("%d ", b[i]); puts("");
	return 0;
}

Measured memory_bytes: 768
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if -3 in np.sum(a, axis=0) or -3 in np.sum(a, axis=1):
    flag = True
if np.sum(a.diagonal()) == -3 or a[0][2] + a[1][1] + a[2][0] == -3:
    flag = True

print('Yes' if flag else 'No')


Measured memory_bytes: 12508
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

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

    int N;
    map<string, int> cnt;

    int maxc = 0;
    read(N);
    rep(i, N) {
        string s; read(s);
        chmax(maxc, cnt[s] += 1);
    }

    vector<string> ans;
    for (auto &e: cnt) {
        if (e.second == maxc) ans.emplace_back(e.first);
    }

    sort(all(ans));
    for (const auto &e : ans) print(e);

    return 0;
}


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

using namespace std;

int main()
{
    int n , alice=0 , bob=0 ;   cin >> n ;
    int arr[n] ;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    reverse(arr,arr+n);

    for(int i=0 ;i<n;i+=2)
        alice+=arr[i] ;
    for(int i=1 ;i<n;i+=2)
        bob+=arr[i] ;

    cout<<alice-bob;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
//最大公約数
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
//最小公倍数
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X;
  cin >> N >> X;
  ll x[N];
  FOR(i,0,N) cin >> x[i];
  if(N == 1) {
    cout << abs(x[0] - X) << endl;
    return 0;
  }
  ll xx[N];
  FOR(i,0,N) {
    xx[i] = abs(x[i] - X);
  }
  ll ans = gcd(xx[0], xx[1]);
  FOR(i,0,N) ans = gcd(ans, xx[i]);
  cout << ans << endl;
}

Measured memory_bytes: 1792
S=input()
words=[a for a in S]
answers=[]
for n in words:
    if n=='1':
        answers.append('1')
    elif n=='0':
        answers.append('0')
    else:
        if not answers:
            continue
        else:
            answers.pop()
mojiretu=''
for x in answers:
    mojiretu+=x
print(mojiretu)


Measured memory_bytes: 2940
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
C = int(s[3])
D = int(s[4])
if N%A == 0:
  X = int(N/A)
else:
  X = N//A+1
if N%C == 0:
  Y = int(N/C)
else:
  Y = N//C+1
X1 = X*B
Y1 = Y*D
if X1 >= Y1:
  print(Y1)
else:
  print(X1) 



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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << (a.at(n - 1) - a.at(0)) << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a>>b;
	if((a*b)%2==0){
		cout<<"Even"<<endl;
	}
	else{
		cout<<"Odd"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
  ll n,m=100,i=0;
  cin>>n;
  while(1){
      if(m>=n)break;
      else m=m*1.01;
     
      i++;
  }
  cout<<i<<endl;
}
   



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

int main() {
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;

  cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pi 3.1415926535897
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug 0
#define loop(a,b) for(a=0;a<b;a++)
#define test() while(t--)
 
using namespace std;
 

 

int pointer,n;
ll maxm,res;

ll vis[100005];
ll ar[100005];
ll ans[100005];
ll mark[100005];
ll segTree[500005];
ll cost[100006];

vector<int> adj[100005];

void constructTree(int node, int start, int end)
{
    if(start == end)
    {
         segTree[node] = 0;
    }
    else
    {
        int mid = (start + end) / 2;
        constructTree(2*node, start, mid);
        constructTree(2*node+1, mid+1, end);
        segTree[node] = max(segTree[2*node],segTree[2*node+1]);
    }
}


void update(int si, int ss, int se,int pos,ll val)
{
    if (ss>se || pos<ss || pos>se)
        return ;
        
 
   
    if (ss==se)
    {
    	//int old_val=cost[ss];
    	cost[ss]=val;
    	ll new_val=cost[ss];
    	ll old_val=segTree[si];
    	ll diff=new_val-old_val;
        segTree[si]+=diff;
        return;
    }
    
 
    int mid = (ss+se)/2;
    update(si*2, ss, mid,pos,val);
    update(si*2+1, mid+1,se,pos,val);
 
    segTree[si] = max(segTree[si*2],segTree[si*2+1]);
    //return;
}

ll get(int node, int start, int end, int l, int r)
{
	
	if(r < start || end < l)
    {
        return 0;
    }
    if(l <= start && end <= r)
    {
        return segTree[node];
    }
    
    
   
    int mid = (start + end) / 2;
    ll min1 = get(2*node, start, mid, l, r);
    ll min2 = get(2*node+1, mid+1, end, l, r);
    return max(min1,min2);
}

void DFS(int s)
{

	vis[s]=true;
	
	
	vector<int>::iterator it;
	vector<pair<int,ll> >::iterator jt;
	
	int val=ar[s];
	
	ans[s]=val;
//	update(1,1,n,pointer,ans[s]);
	pointer++;
	
	
	for(it=adj[s].begin();it!=adj[s].end();++it)
	{
		if(!vis[*it])
		{
		
		//val=ar[*it];
		mark[*it]=ar[*it]^ans[s];
		res=res^mark[*it];
		
		//cout<<res<<"\n";
		if(res>maxm)
		maxm=res;
		DFS(*it);	
			
		}
		//answ[*it]=dist[*it];
	
		//update(1,1,n,pointer,dist[*it]);
		
			
		
	   }
	
	pointer--;
	res=mark[s];
	
	
}


int main()
{
	int m,a,b,i,j,q,v,home,k,t,n;
	ll w;
	
string str;

cin>>n;

b=0;
j=0;

  for(i=0;i<n;i++)
  {
  	cin>>q;
  	
  	if(q%2==0 && q%4!=0)
  	{
  		j++;
  		continue;
	  }
  	
  	if(q%4==0)
  	b++;
  }
  
  b+=(j/2);
  
  a=n/2;
  
  if(b>=a)
  cout<<"Yes";
  else
  cout<<"No";
  
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int l[110];
    for (int i = 0; i < n; i++) cin >> l[i];

    sort(l, l + n, greater<int>());
    int sum = 0;
    for (int i = 1; i < n; i++) sum += l[i];
    if (sum > l[0]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,M;cin>>N>>M;
    vector<priority_queue<int>>connected(N);
    vector<int>H(N);
    int a,b;
    int ans=0;
    rep(i,N){
        cin>>H.at(i);
    }
    rep(i,M){
        cin>>a>>b;
        connected.at(a-1).push(H.at(b-1));
        connected.at(b-1).push(H.at(a-1));
    }
    rep(i,N){
        if(connected.at(i).empty()){
            ans++;
        }else if(H.at(i)>connected.at(i).top()){
            ans++;
        }
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 9608
#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 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(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll 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 sum(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));}
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>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
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;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/
struct UnionFind{
	vl par,dist;
	UnionFind(int x){par.assign(x,-1); dist.assign(x,0);}
	ll find(ll x){return par[x]<0?x:find(par[x]);}
	ll depth(ll x){return par[x]<0?0:depth(par[x])+dist[x];}
	bool same(ll x,ll y){return find(x)==find(y);}
	ll size(ll x){return -par[find(x)];}
	ll diff(ll x,ll y){return same(x,y)?depth(x)-depth(y):LINF;}
	void unite(ll x,ll y,ll k=0){
		k+=depth(y); k-=depth(x); k=-k;
		x=find(x); y=find(y);
		if(x==y)return;
		if(size(x)<size(y)){swap(x,y);k=-k;}
		par[x]+=par[y]; par[y]=x; dist[y]=k;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	
	UnionFind uf(n);
	rep(i,m){
		int t,a,b;
		cin>>t>>a>>b;
		if(t==0){
			int c; cin>>c;
			uf.unite(a,b,c);
		}else{
			ll v=uf.diff(a,b);
			tf(v==LINF,"?",v);
		}
	}
	return 0;
}


Measured memory_bytes: 4416
#include<iostream>
#include<fstream>
#include<string>

using namespace std;


int main(){
	
	int a,b,c,d;
	cin >> a>> b >> c;
	
	if(a==b && b==c)
		cout << 1;
 	else if(a!=b && b!=c&&c!=a)
 		cout << 3;
 	else
 		cout << 2;
	cout << endl;
	
	
	
return 0;	
};

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  vector<string> s(3);
  cin>>s[0]>>s[1]>>s[2];
  reverse(ALL(s[0]));
  reverse(ALL(s[1]));
  reverse(ALL(s[2]));
  buf=0;
  char c;
  while(1){
    if(s[buf].size()==0){
      cout<<char(buf+'A')<<endl;
      break;
    }
    c=s[buf].back();
    s[buf].pop_back();
    //cout<<char(buf+'A') spa s[buf]<<endl;
    buf=c-'a';
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
typedef vector<pp> VPP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<(int)p.real()<<' '<<(int)p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

double Diameter(VP p){
	int n=p.size(),I=0,J=0;
	for(int i=1;i<n;i++){
		if(p[i].imag()>p[I].imag()) I=i;
		if(p[i].imag()<p[J].imag()) J=i;
	}
	double res=abs(p[I]-p[J]);
	int i=I,j=J;
	do{
		if(Det(p[(i+1)%n]-p[i],p[(j+1)%n]-p[j])>0) j=(j+1)%n;
		else i=(i+1)%n;
		if(abs(p[i]-p[j])>res) res=abs(p[i]-p[j]);
	}while(i!=I||j!=J);
	return res;
}

int n,q;
VP a;
C x;

int main(){
	cin>>n;
	a=VP(n);
	for(auto &i:a) In(i);
	cout<<syosu(9)<<Diameter(a)<<endl;
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define lli long long int
#define ll long long
#define mod 1000000007
#define v vector
#define pb push_back
#define pf pop_front;
#define fi first
#define se second
using namespace std;

void solve()
{
    string s;
    cin>>s;
    int cnt = 0,ans = 0;
    for (int i = 0; i < 3; ++i)
    {
        if(s[i] == 'R')
            cnt++;
        else
        {
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    if(cnt != 0)
        ans = max(ans,cnt);
    cout<<ans;


    
}


int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();

    }
    return 0;

}



Measured memory_bytes: 3608
using System;
class ITP1_8_A
{
    static void Main()
    {
        string ipt = Console.ReadLine();
        string opt = "";
        for (int i = 0; i < ipt.Length; i++)
            if (char.IsUpper(ipt, i)) opt += char.ToLower(ipt[i]);
            else if (char.IsLower(ipt, i)) opt += char.ToUpper(ipt[i]);
            else opt += ipt[i];
        Console.WriteLine(opt);
    }
}

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;

  int L = A +B;
  int R = C +D;

  if(L == R)
    cout << "Balanced" << endl;
  else
  {
      cout << (L > R ? "Left" : "Right");
  }
   
}


Measured memory_bytes: 256