akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1234567890
#define pii pair<int,int>
#define LL long long
using namespace std;

int main () {
    //clock_t start = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin >> n >> k;
    int a[n+5];
    for (int i=1;i<=n;i++) cin >> a[i];
    sort (a+1,a+n+1);
    int ans = 0;
    for (int i=1;i<=k;i++) ans += a[i];
    cout << ans << endl;
    //cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3648
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

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

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
string T = "";
ll cases;

int main() {
	go;
    cin >> S >> T;
    ll ans = 0;
    fi(i, 0, S.size(), 1) {
    	if(S[i] != T[i]) {
    		ans++;
    	}
    }
    cout << ans << "\n";
    
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int main() {
	int h, w, i, j, k;
	cin >> h >> w;
	int a[h][w], n;
	vector<int>s;

	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	n = 0;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w-1; j++) {
			if (a[i][j] % 2 != 0 && a[i][j]!=0) {
				a[i][j]--;
				a[i][j + 1]++;
				n++;
				s.push_back(i);
				s.push_back(j);
				s.push_back(i);
				s.push_back(j + 1);
			}
		}
	}
	for (i = 0; i < h - 1; i++) {
		if (a[i][w - 1] % 2 != 0 && a[i][w-1]!=0) {
			a[i][w-1]--;
			a[i + 1][w - 1]++;
			n++;
			s.push_back(i);
			s.push_back(w - 1);
			s.push_back(i + 1);
			s.push_back(w - 1);
		}
	}

	cout << n << endl;
	for (i = 0; i < n; i++) {
		cout << s[4 * i]+1 << " " << s[4 * i + 1]+1 << " " << s[4 * i + 2]+1 << " " << s[4 * i + 3]+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5104
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n,h = inp
kt = []
n.times{kt << inp}
kt.sort_by!{|u|u[0]}
max = kt.pop
kt.sort_by!{|u|u[1]}.reverse!
ans = 0
kt.each do |a|
  if(h <= max[1])
    ans += 1
    p ans
    exit
  end
  if(a[1] > max[0])
    h -= a[1]
    ans += 1
  end
  if(h <= 0)
    p ans
    exit
  end
end
if(h <= max[1])
  ans += 1
  p ans
  exit
end
ans += 1
h -= max[1]
ans += r_up(h,max[0])
p ans


Measured memory_bytes: 13516
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int sum=0;
  if (a<b) {
    sum+=a;
  } else {
    sum+=b;
  }

  if (c<d) {
    sum+=c;
  } else {
    sum+=d;
  }
  
  cout<<sum;

  return 0;

}


Measured memory_bytes: 256
#
import sys

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        p= b[i]
        q= d[i]
        while p%q :
            r=q
            q=p%q
            p=r
        if (b[i]-q)+a[i]%q > c[i]:
            print("No")
        else:
            print("Yes")
    



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

int main(){
    
    // 1. 入力情報取得.
    int A, B ,C;
    scanf("%d %d %d", &A, &B, &C);
    
    // 2. 家1 -> 家3 -> 家2 であるかを判定.
    bool ok = false;
    if(A < C && C < B) ok = true;
    if(B < C && C < A) ok = true;
    
    // 3. 出力.
    if(ok) printf("%s\n", "Yes");
    else   printf("%s\n", "No");
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]){
        char buf[128]={0};
        char* p=NULL;
        int a = 0;
        int b = 0;

        memset(buf, 0, sizeof(buf));
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        p = strtok(buf, " ");
        a = atoi(p);
        if(a<0){return 0;}

        p = strtok(NULL, " ");
        b = atoi(p);
        if(b<0){return 0;}

#ifdef DEBUG1
        printf("input: a=%d, b=%d\n", a, b);
#endif

        if(a%2==1 && b%2==1){
                printf("Odd\n");
        }
        else{
                printf("Even\n");
        }

        return 0;

}

Measured memory_bytes: 128
def main():
  import sys
  input = sys.stdin.readline
  n=int(input())
  p=[0]+[int(i) for i in input().split()]+[0]
  ans=0
  for i in range(1,n+1):
    if p[i]==i:
      if p[i+1]==i+1:
        p[i+1]=i
      ans+=1
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 13876
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

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

int main(){
  ll n;
  cin>>n;
  map<ll,int>mp=prime_factor(n);

  ll ans=0;
  for(auto x:mp){
    ll p=x.fi;
    ll s=x.se;
    ll now=0,cnt=0;
    while(now+cnt+1<=s){
      cnt++;
      now+=cnt;
    }
    ans+=cnt;
  }

  cout<<ans<<endl;

  return(0);
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
long long f[15][15];
int top,sta[15];
inline int check(long long limit)
{
	top=0;
	while(limit)sta[++top]=limit%10,limit/=10;
	int ans=0;
	for(int i=1;i<top;i++)
	{
		for(int j=1;j<10;j++)ans+=f[i][j];
	}
	bool bk=true;
	for(int i=top;i>=1;i--)
	{
		if(i==top)
		{
			for(int j=1;j<sta[i];j++)ans+=f[i][j];
		}
		else
		{
			for(int j=0;j<sta[i];j++)if(abs(j-sta[i+1])<=1)ans+=f[i][j];
			if(abs(sta[i]-sta[i+1])>1){bk=false;break;}
		}
	}if(bk==true)ans++;
	return ans;
}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    for(int i=0;i<10;i++)f[1][i]=1;
    for(int i=2;i<=10;i++)
    {
    	for(int j=0;j<10;j++)
		{
			f[i][j]+=f[i-1][j];
			if(j>0)f[i][j]+=f[i-1][j-1];
			if(j<9)f[i][j]+=f[i-1][j+1];
		}
    }
    int n=read();
    long long l=1LL,r=3234566667LL,ans;
    while(l<=r)
    {
    	long long mid=l+r>>1;
    	if(check(mid)>=n)ans=mid,r=mid-1;
    	else l=mid+1;
    }printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
x,y=input().split()
x=int(x)
y=int(y)
if x==2 | y==2:
    print('No')
    exit()
lt1=[1,3,5,7,8,10,12]
lt2=[4,6,9,11]
if (lt1.count(x)==1 and lt1.count(y)==1) or (lt2.count(x)==1 and lt2.count(y)==1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import qualified Data.Sequence as Seq
import Data.Foldable (or)
import qualified Test.QuickCheck as QC

naive :: U.Vector Bool -> Int
naive v = let s0 = Seq.fromFunction (U.length v) (v U.!)
          in loop 0 [s0]
  where
    loop !i ss = case concat <$> mapM oneStep ss of
                   Nothing -> i
                   Just ss' -> loop (i+1) ss'

oneStep :: Seq.Seq Bool -> Maybe [Seq.Seq Bool]
oneStep s = let (s0,s1') = Seq.spanl not s
                (s2,s1) = Seq.spanr id s1'
            in if Seq.null s1 then
                 Nothing
               else
                 Just $ [ Seq.update j True $ Seq.update i False s1
                        | i <- Seq.elemIndicesL True s1
                        , j <- Seq.elemIndicesR False s1
                        ] ++
                        [ Seq.update i False s1
                        | i <- Seq.elemIndicesL True s1
                        ] ++
                        [ Seq.update j True s1
                        | j <- Seq.elemIndicesR False s1
                        ]

solve :: U.Vector Bool -> Int
solve xs = let ys0 = U.scanl' (\acc t -> if t then acc + 1 else acc) 0 xs
               ys1 = U.scanr' (\t acc -> if t then acc else acc + 1) 0 xs
               ys = U.zipWith max ys0 ys1
           in U.minimum ys

main = do
  n <- readLn @Int
  s <- BS.getLine -- 'R' or 'W'
  -- 操作後： replicate k 'R' ++ replicate (n - k) 'W' for some k
  let v = U.generate n (\i -> s `BS.index` i == 'W')
  print $ solve v

check :: [Bool] -> Bool
check xs = let v = U.fromList xs in solve v == naive v

runTest :: IO ()
runTest = QC.quickCheckWith (QC.stdArgs { QC.maxSize = 15 })  check


Measured memory_bytes: 7540
from collections import defaultdict
from queue import Queue
N = int(input())
e_dict = {}

num_e_count = defaultdict(int)
edge_dict = defaultdict(list)
for _ in range(N-1):
    u, v, w = tuple(map(int, input().split()))
    e_dict[(u, v)] = not bool(w%2)
    e_dict[(v, u)] = not bool(w%2)
    num_e_count[v]+=1
    num_e_count[u]+=1
    edge_dict[v].append(u)
    edge_dict[u].append(v)

start_point = None
for k, v in num_e_count.items():
    if v == 1:
        start_point = k
        break


result = [None] * N

result[start_point-1] = 1

done_set = set()
next_points = Queue(maxsize=N)
next_points.put(start_point)

while len(done_set) < N:
    u = next_points.get()
    for v in edge_dict[u]:
        if v not in done_set:
            next_points.put(v)
            if e_dict[(u, v)]:
                result[v-1] = result[u-1]
            else:
                result[v-1] = 1 - result[u-1]
        done_set.add(u)

for r in result:
    print(r)


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

int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.substr(i,3)=="ABC"){
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector<vector<int64_t>>A(3,vector<int64_t>(N));
  for(int i=0;i<N;i++){
  cin>>A.at(0).at(i);
    cin>>A.at(1).at(i);
    cin>>A.at(2).at(i);
   }int64_t ans=0;
  for(int bit=0;bit<(1<<3);bit++){
  vector<int64_t>B(N);
    for(int i=0;i<N;i++){
      int64_t x=A.at(0).at(i);
      int64_t y=A.at(1).at(i);
      int64_t z=A.at(2).at(i);
      int64_t b=x+y+z;
    for(int j=0;j<3;j++){
  if(bit&(1<<j))
    b-=2*A.at(j).at(i);
  } B.at(i)=b;
    } sort(B.begin(),B.end());
    reverse(B.begin(),B.end());
    int64_t pos=0;
    for(int k=0;k<M;k++)
      pos+=B.at(k);
    if(ans<pos)
      ans=pos;
  }cout<<ans<<endl;
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  string s;
  cin >> s;
  string t = s;
  reverse(all(s));
 
  ll len = s.size();
  string s1 = s.substr(0,(len-1)/2);
  string s2 = s.substr((len+3)/2-1);
 
  string t1 = s1;
  string t2 = s2;
 
  reverse(all(s1));
  reverse(all(s2));
 
  if(s1 == t1 && s2 == t2 && s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const ll N = 110, V = 1100 * N, mod = 1e9 + 7; 
ll a[N], b[N], dp[V], ans;
int main(){
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++){
        cin >> b[i] >> a[i];
    }
    for(int j = 0; j <= V; j++)
        dp[j] = mod;
    dp[0] = 0; 
    for(int i = 1; i <= n; i++){
        for(ll j = V - 1; j >= a[i]; j--){ 
            dp[j] = min(dp[j], dp[j - a[i]] + b[i]);
            if(dp[j] <= w)ans = max(ans, j);
        } 
    }
    cout << ans << endl;
}  

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3+10 ;
long long dp[100005],v[100005],w[100005],V;
int main()
{
    long long n,x,ans=0;
    cin>>n>>x;
    for(int i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
        V+=v[i];
    }
    memset(dp,0x3f3f3f3f,sizeof dp);
    dp[0]=0;
    for(int i=0; i<n; i++)
    {
        for(int j=V; j>0; j--)
        {
            if(j-v[i]>=0)
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
        }
    }
    for(int i=0; i<=V; i++)
    {
        if(dp[i]<=x)
            ans=max(ans,(long long)i);
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 1152
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0):
        break
    cnt = 0
    for i in range(1, n + 1):
        for j in range(i + 1,n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1
    print(cnt)



Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main()
{
long long a[87];
a[0]=2;
a[1]=1;
int n;
cin >>n;
for(int i=2;i<=n;i++) 
a[i]=a[i-1]+a[i-2];
cout << a[n]; 
system("pause"); 
return 0;
}


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

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

  if ((A + B) < (C + D)) {
    cout << "Right" << endl;
  }
  else if ((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Left" << endl;
  }

}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
lis5=0
lis7=0
for i in a,b,c:
    if i ==5:
        lis5+=1
    elif i ==7:
        lis7+=1
if lis5==2 and lis7==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 2940
N, K = map(int, input().split())
R, S, P =map(int, input().split())
T = input().rstrip()
_mapping = {"r": P, "s": R, "p": S}
d = [None] * K
ans = 0
for i, t in enumerate(T):
    k = i % K
    if d[k] == t:
        d[k] = None
        continue
    else:
        d[k] = t
        ans += _mapping[t]
        continue
print(ans)


Measured memory_bytes: 3828
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = s.size()-2;i >= 0;i-=2){
        string t,u;
        t = s.substr(0,i/2);
        u = s.substr(i/2,i/2);
        if(t.compare(u)==0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
if N%2==0:
    dp=[[-float("inf") for _ in range(2)] for _ in range(N+10)]
    if N==2:
        print(max(A[0],A[1]))
    else:
        for i in range(N):
            if i==0:
                dp[i][0]=A[0]
            elif i==1:
                dp[i][1]=A[1]
            elif i==2:
                dp[i][0]=A[0]+A[2]
            else:
                for j in range(2):
                    if j==0:
                        dp[i][0]=max(dp[i][0],dp[i-2][0]+A[i])
                    elif j==1:
                        dp[i][1]=max(dp[i][1],dp[i-2][1]+A[i],dp[i-3][0]+A[i])
        print(max(dp[N-1]))
else:
    #print(A[0],A[1])
    dp=[[-float("inf") for _ in range(3)] for _ in range(N+10)]
    if N==3:
        print(max(A[0],A[1],A[2]))
    else:
        for i in range(N):
            if i<4:
                if i==0:
                    dp[i][0]=A[0]
                if i==1:
                    dp[i][1]=A[1]
                if i==2:
                    dp[i][2]=A[2]
                    dp[i][0]=A[0]+A[2]
                if i==3:
                    dp[i][1]=max(dp[1][1]+A[3],dp[0][0]+A[3])
            else:
                for j in range(3):
                    if j==0:#ここでも2こずつ規則よく飛ばすと決めた
                        dp[i][0]=max(dp[i][0],dp[i-2][0]+A[i])
                    elif j==1:#1回だけ無茶した
                        dp[i][1]=max(dp[i][1],dp[i-2][1]+A[i],dp[i-3][0]+A[i])
                    else:
                        dp[i][2]=max(dp[i][2],dp[i-2][2]+A[i],dp[i-3][1]+A[i],dp[i-4][0]+A[i])
        print(max(dp[N-1]))

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	set<int> st;
	rep(i, n){
		if(st.count(a.at(i)) == 1){
			cout << "NO" << endl;
			return 0;
		}
		st.insert(a.at(i));
	}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  int fvh = x / 500;
  x %= 500;
  x /= 5;
  int ans = fvh * 1000 + 5 * x;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans=v[0];
    for(int i=1;i<v.size();i++){
        ans=(ans+v[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {
    return (ll)min((ld)a/gcd(a,b)*b, (ld)2e18);
}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}
int main() {
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<ld> p(n);
    rep(i, n) cin >> a[i];
    rep(j, n) {
        cin >> p[j];
        p[j] /= 100.0;
    }
    vector<ll> dp(1<<n);
    rep(bit, 1<<n) {
        if(!bit) continue;
        ll mul = 1;
        rep(i, n) if((bit>>i)&1) {
            mul = lcm(mul, a[i]);
        }
        dp[bit] = m/mul;
    }
    rep(i, n) rep(bit, 1<<n) {
        if(bit>>i & 1) dp[bit] -= dp[bit^(1<<i)];
    }
    ld ans = 0;
    rep(bit, 1<<n) {
        ld pr = 1;
        rep(j, n) {
            if(bit>>j&1) {
                pr *= p[j];
            } else {
                pr *= 1-p[j];
            }
        }
        ans += pr*abs(dp[bit]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
from collections import defaultdict


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, input().split())
friend = UnionFind(n)
dataf = defaultdict(lambda: 0)

for _ in range(m):
    a, b = map(int, input().split())
    dataf[a-1] += 1
    dataf[b-1] += 1
    friend.union(a-1, b-1)

for _ in range(k):
    a, b = map(int, input().split())
    if friend.same(a-1, b-1):
        dataf[a-1] += 1
        dataf[b-1] += 1

for i in range(n):
    kouho = friend.size(i)
    print(kouho-dataf[i]-1, end=' ')


Measured memory_bytes: 119384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define MAX 100010
vector<ll> g[MAX];
ll n,s[2],d[2][MAX];
void solve(){
    cin>>n;
    repi(i,2){
        cin>>s[i];
        s[i]--;
    }
    repi(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    repi(i,2){
        fill(d[i],d[i]+n,MAX);
        queue<ll> q;
        d[i][s[i]]=0;q.push(s[i]);
        while(!q.empty()){
            ll x=q.front();q.pop();
            repi(j,g[x].size()){
                ll to=g[x][j];
                if(d[i][to]==MAX){
                    d[i][to]=d[i][x]+1;
                    q.push(to);
                }
            }
        }
    }
    ll ans=0;
    repi(i,n){
        if(d[0][i]<d[1][i])chmax(ans,d[1][i]-1);
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int main(){
    std::string s;
    while(std::getline(std::cin, s), s != "END OF INPUT"){
        s += " ";
        int prev_pos = 0, pos = 0;
        while(pos = s.find(" ", pos), pos != std::string::npos){
            printf("%d", pos - prev_pos);
            prev_pos = pos + 1;
            pos += 1;
        }
        puts("");
    }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
char a[3];
int read()
{
	char c=getchar();int x=0,f=1;
	while(c>'9'||c<'0'){if(c='-'){f=-1;}c=getchar();}
	
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*f;
}
int main()
{cin>>a;
	if(a[0]==a[2])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
	
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		
		int ans = 0;
		while(true) {
			if(X >= 500) {
				ans += X / 500 * 1000;
				X %= 500;
			} else {
				ans += X / 5 * 5;
				X %= 5;
			}
			
			if(X < 5)
				break;
		}
			
		System.out.println(ans);
	}

}

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

int main(){
  int n,m;
  cin >>n >>m;
  vector<int> a(n);
  int sum = 0;
  rep(i,n) {
    cin >>a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  int limit = (sum+4*m-1)/(4*m);
  int cnt = 0;
  rep(i,m){
    if(a[i]>=limit) cnt++;
  }
  if(cnt == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  int a=n/1000;
  int b=(n/100)%10;
  int c=(n/10)%10;
  int d=n%10;
  if(b==c&&(a==b||c==d))printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
s = list(input())
l = len(s)
a=0
m=0
for i in range(l):
  if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
    a+=1
  else:
    a=0
  m = max(m, a)

print(m)

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

const int INF = 2000000000;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> H(100105);
    for (int i = 0; i < n; i++) {
        cin >> H[i];
    }

    int dp[100105];
    for (int i = 0; i < n; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 1; j <= k; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i + j] - H[i]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>

int main(void){
	std::int64_t N,A,B;
	std::cin >> N;
	std::cin >> A;
	std::cin >> B;
	std::int64_t h[N+1];
	for(auto i = decltype(N)(1); i <= N; i++){
		std::cin >> h[i];
	}
	std::int64_t h_max=0;
	std::int64_t h_sum=0;
	for(auto i = decltype(N)(1); i <= N; i++){
		if(h[i] > h_max){
			h_max = h[i];
		}
		h_sum += h[i];
	}

	// ctr²ó¿ô¤ÎËâË¡¤ÇÁ´ÌÇ¤·¤Æ¤ë¤«
	auto func = [&](const std::int64_t ctr){
		if((h_sum - B*ctr*N - (A-B)*ctr )> 0 ){
			return false;
		}

		std::int64_t rem = ctr;
		std::int64_t tmp;
		for(auto i = decltype(N)(1); i <= N; i++){
			tmp = h[i] - B * ctr;
			/*
			while(tmp > 0){
				tmp -= (A-B);
				rem--;
			}
			*/
			if(tmp > 0){
				//tmp -= (A-B);
				if(tmp%(A-B)==0){
					rem-= tmp/(A-B);
				}
				else{
					rem-= tmp/(A-B)+1;
				}
			}
			if(rem < 0){
				return false;
			}
		}
		if(rem >= 0){
			return true;
		}
		else{
			return false;
		}
	};



	std::int64_t hi = h_max/B;
	while(func(hi) != true){
		hi *= 2;
	}
	std::int64_t lo = 0;
	while((hi - lo) > 1){
		if(func((hi+lo)/2)){
			hi = (hi+lo)/2;
		}
		else{
			lo = (hi+lo)/2;
		}
	}

	std::cout << hi << std::endl;
	return 0;
	
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <queue>
#include <string>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;

int main(void){
    int N,K;
    cin >> N >> K;
    double ans = 0;
    for(int i=1; i<=N; i++){
        double p;
        long int k = 1;
        for(int j=0; j<20; j++){
            if(j!=0){
                k *= 2l;
            }
            p = 1.0/(double)k;
            if(p <= (double)i/(double)K){
                break;
            }
        }
        if(p>=1.0){
            p = 1.0;
        }
        p = p/(double)N;
        ans += p;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    bool ans = true;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        if(A % 2 == 0 && A % 3 && A % 5){
            ans = false;
        }
    }
    if(ans){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
}


Measured memory_bytes: 256
import java.io.*;
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
String[] arr=str.split(" ");
int a=Integer.parseInt(arr[0]);
int b=Integer.parseInt(arr[1]);
int c=Integer.parseInt(arr[2]);
diviNum(a, b, c);
br.close();
}
static void diviNum(int a, int b, int c){
int x=0;
int i=b-a+1;
for(int j=0;j<i;j++){
if(c%a==0)  x++;
a++;
}
System.out.println(x);
}
}

Measured memory_bytes: 24344
#include<bits/stdc++.h>
using namespace std;
char s[105][105];
bool ignoreR[105];
bool ignoreC[105];
 
int main() {
    int n, m;
	
    cin>>n>>m;
    for(int i = 0; i < n; i++) {cin>>s[i];}
	
    for(int i = 0; i < n; i++) {
        ignoreR[i] = true;
        for(int j = 0; j < m; j++) {
            if(s[i][j] == '#') ignoreR[i] = false;
        }
    }
    for(int j = 0; j < m; j++) {
        ignoreC[j] = true;
        for(int i = 0; i < n; i++) {
            if(s[i][j] == '#') ignoreC[j] = false;
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(ignoreR[i] || ignoreC[j]) continue;
            cout<<s[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

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

int val(int num){
    int res = 0;
    while(num > 0){
        res += num % 10;
        num /= 10;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int ans = 1e9;
    for (int a = 1; a < n; a++) {
        ans = min(ans, val(a) + val(n - a));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  int ans = 0;
  if (s.size() == 1) {
    ans = 0;
  } else {
    int mid = s.size() / 2;
    string s_first, s_second;
    s_first = s.substr(0, mid);
    if (s.size() % 2 == 0) s_second = s.substr(mid, mid);
    else s_second = s.substr(mid+1, mid);
    reverse(s_second.begin(), s_second.end());
    REP(i, s_first.size()) {
      if (s_first[i] != s_second[i]) ans++;
    }
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        
//        try{
            double x = scan.nextDouble();
            double y = scan.nextDouble();
            double xx = scan.nextDouble();
            double yy = scan.nextDouble();
            int qer = scan.nextInt();
                    
            double xxx = 0;
            double yyy = 0;
            xxx = xx - x;
            yyy = yy - y;
        
            double xp[] = new double[qer];
            double yp[] = new double[qer];
            double ansx[] = new double[qer];
            double ansy[] = new double[qer];
            for(int i = 0; i < qer; i++){
                xp[i] = scan.nextDouble();
                yp[i] = scan.nextDouble();
                double xxxx = x - xp[i];
                double yyyy = y - yp[i];
                ansx[i] = x - xxx * (xxxx * xxx + yyyy * yyy) / (xxx * xxx + yyy * yyy);
                ansy[i] = y - yyy * (xxxx * xxx + yyyy * yyy) / (xxx * xxx + yyy * yyy);
                System.out.println(ansx[i] + " " + ansy[i]);
            }
//        }catch(InputMismatchException e){
//            System.out.println("Error" + e);
//        }

    }

}

Measured memory_bytes: 41844
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;

	ll s;

	if (a < c && b < c)
	{
		s = a * b / 2;
	}
	else
	{
		if (a < b)
		{
			s = a * c / 2;
		}
		else
		{
			s = b * c / 2;
		}
	}

	cout << s << endl;
}

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

int main() {
  int n = 0;
  cin >> n;
  vector<int> junin(n);
  for (int i = 0; i < n; i++) {
    cin >> junin.at(i);
  }
  
  int sum, minsum;
  
  for (int i = 1; i < 101; i++) {
    sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (junin.at(j) - i) * (junin.at(j) - i);
    }
    if (i == 1) {
      minsum = sum;
    }
    else {
      minsum = min(minsum, sum);
    }
  }
  cout << minsum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll ans;
int main(){
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	
	if(a+b>=c*2){
		ll t=min(x,y);
		ans+=2*c*t;
		x-=t;
		y-=t;
	}
	if(a>=2*c){
		ans+=2*c*x;
		y-=min(x,y);
		x=0;
	}
	if(b>=2*c){
		ans+=2*c*y;
		x-=min(x,y);
		y=0;
	}
	ans+=a*x+b*y;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
s = n.times.map{gets.to_i}.sort
sum = s.inject(:+)
s.each do |i|
  if sum % 10 == 0
    sum -= i if i % 10 != 0
  else
    break
  end
end
sum = 0 if sum % 10 == 0

puts sum

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

int main() {
   int a,b;cin>>a>>b;
   if(a==b) cout<<a+b<<endl;
   else{
       if(a-1+a>b-1+b) cout<<a-1+a;
       else cout<<b-1+b;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int MAX_M = 100005;
ll A[MAX_M],B[MAX_M];

int main()
{
	int N,M;
	ll sum = 0; 
	cin >> N >> M;
	rep(i,M) 
	{
		cin >> A[i];
	}
	sort(A,A+M);

	for (int i = 0; i < M-1; ++i)
	{
		B[i] = A[i+1] - A[i];
		//cout << B[i] << " ";
	}
	//cout << endl;
	sort(B,B+M-1);

	if (N >= M)
	{
		cout << "0" << endl;		
	}
	else
	{
		ll ans = 0;
		for (int i = 0; i < M-N; ++i)
		{
			ans += B[i];
		}

		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
#include<math.h>
using namespace std; 
#define int long long int
double s,b,l,h,ans1,ans;
signed main() 
{ 
	//int s,l,b,h;
    cin>>s;
    ans1 = s/3;
    ans = ans1*ans1*ans1;
    std::cout << std::fixed << std::setprecision(12);
    cout<<ans<<endl;
	return 0; 
} 


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

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

    int ans = 1;

    FOR (b, 2, X) FOR (p, 2, X)
    {
        int bp = (int)pow(b, p);
        if (X < bp) break;
        ans = max(ans, bp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long
int main() {
    int W,H,x,y;
    cin>>W>>H>>x>>y;
  double r=double(W)*double(H)/2*(1.0);
  int c=0;
  if(x*2==W && y*2==H) c=1;
  cout<<fixed<<setprecision(6)<<r<<" "<<c<<endl;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  string ans = "";
  rep(i,n) {
    if (s[i] != 'B') ans += s[i];
    else {
      if (ans.size() > 0) ans = ans.substr(0,ans.size()-1);
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <assert.h>
#include <algorithm>
#include <cmath>
#include <vector>

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

    int32_t X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;
    K = std::min(K, 3000);
    std::vector<int64_t> A(X), B(Y), C(Z);
    for(auto& i : A){
        std::cin >> i;
    }
    for(auto& i : B){
        std::cin >> i;
    }
    for(auto& i : C){
        std::cin >> i;
    }

    std::sort(A.begin(), A.end(), std::greater<int64_t>());
    std::sort(B.begin(), B.end(), std::greater<int64_t>());
    std::sort(C.begin(), C.end(), std::greater<int64_t>());

    std::vector<int64_t> concat_vec;
    for(int32_t i = 0; i < X; i++){
        for(int32_t j = 0; j < Y; j++){
            for(int32_t k = 0; k < Z; k++){
                if((i+1) * (j+1) * (k+1) <= K){
                    concat_vec.push_back(A[i] + B[j] + C[k]);
                }
                else{
                    break;
                }
            }
        }
    }
    //debug
    std::sort(concat_vec.begin(), concat_vec.end(), std::greater<int64_t>());
    for(int32_t i = 0; i < K; i++){
        std::cout << concat_vec[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 1404
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

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

const ll mod=1e9+7;
const int INF=0x3f3f3f3f;

int a[100006],vis[100006],n;

int main()
{
    while(~scanf("%d",&n))
    {
        CLEAN(vis,0);
        rept(i,0,n)
        {
            cin>>a[i];
            vis[a[i]]++;
        }
        int j=100002;
        rept(i,1,100003)
        {
            if (vis[i]>1)
            {
                while (vis[j]<=1&&j>i)j--;
                if (j>i)
                {
                    if (vis[i]==vis[j])vis[i]=1,vis[j]=1;
                    else if (vis[i]>vis[j])
                    {
                        vis[i]-=vis[j]-1;
                        vis[j]=1;
                        i--;
                    }
                    else if(vis[i]<vis[j])
                    {
                        vis[j]-=vis[i]-1;
                        vis[i]=1;
                        j++;
                    }
                }
            }
        }
        int output=0;
        rept(i,1,100003)
        {
            if (vis[i]==1) output++;
            if (vis[i]>1)
            {
                if (vis[i]%2==0)continue;
                else output++;
            }
        }
        cout<<output<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pa pair<int,int>
using namespace std;
priority_queue<pa>q;
vector<int>v[100005];
int A,B,a[100005];
bool used[100005],has[100005];
int main() {
	int n,i,j,k;
	scanf("%d",&n);
	for(i=1; i<n; i++) {
		scanf("%d%d",&A,&B);
		v[A].push_back(B);
		v[B].push_back(A);
	}
	scanf("%d",&k);
	for(i=0; i<k; i++) {
		scanf("%d%d",&A,&B);
		a[A]=B;
		has[A]=1;
		q.push(pa(-B,A));
	}
	while(!q.empty()) {
		B=-q.top().first,A=q.top().second;
		q.pop();
		used[A]=1;
		for(i=0; i<(int)v[A].size(); i++)
			if(!used[v[A][i]]&&has[v[A][i]]&&a[v[A][i]]!=B+1) {
				puts("No");
				return 0;
			}
			else if(!used[v[A][i]]) {
				used[v[A][i]]=1,a[v[A][i]]=B+1;
				q.push(pa(-B-1,v[A][i])),has[v[A][i]]=1;
			}
	}
	puts("Yes");
	for(int i=1; i<=n; i++)
		printf("%d\n",a[i]);
	return 0;
}

Measured memory_bytes: 8308
import Data.List
import Debug.Trace
import qualified Data.IntMap as M

k = 1000000007
maxN = 100001

toMap = M.fromList . zip [0..]

fact i = facts M.! i
  where facts = toMap $ reverse $ foldl' (\z i -> head z * i `mod` k : z) [1] [1..maxN]

nCr n r = fact n * invfact r `mod` k * invfact (n-r) `mod` k
  where invfact i = invfacts M.! i
        invfacts = toMap $ reverse $ foldl' (\z i -> head z * inv M.! i `mod` k : z) [1] [1..maxN]
          where
            inv = foldl' step (M.fromList [(0,0),(1,1)]) [2..maxN]
              where step z i = M.insert i (k - ((k `div` i) * (z M.! (k `mod` i)) `mod` k)) z

findDup xs = step 0 (sort xs)
  where
    step i xs'
      | head xs' == head xs'' = head xs'
      | otherwise = step (i+1) xs''
      where xs'' = tail xs'

solve :: [[Int]] -> IO Integer
solve ((n:_):xs:_) = step 1
  where
    (a:b:_) = elemIndices (findDup xs) xs
    m = a + n - b
    step i
      | i > n+1 = return 0
      | i-1 > m = print (nCr (n+1) i) >> step (i+1)
      | otherwise = print ((nCr (n+1) i - nCr m (i-1)) `mod` k) >> step (i+1)

main = getContents >>= solve.map (map read . words).lines


Measured memory_bytes: 107772