akhauriyash/Code-Regression huggingface dataset:
import math
n, h = map(int, input().split())
a = []
b = []
ans = 0
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
a.sort(reverse=True)
b.sort(reverse=True)
max_a = a[0]
for i in range(n):
    if b[i] >= max_a:
        h -= b[i]
        ans += 1
    else:
        break
    if h <= 0:
        break
if h > 0:
    ans += math.ceil(h / max_a)
print(ans)

Measured memory_bytes: 11312
first_line = STDIN.gets.strip
given = first_line.split('')

candidate1 = Array.new(first_line.length)
candidate1.each_index do |idx|
  candidate1[idx] = idx.odd? ? '1' : '0'
end

candidate2 = Array.new(first_line.length)
candidate2.each_index do |idx|
  candidate2[idx] = idx.even? ? '1' : '0'
end

diffs1 = 0
diffs2 = 0
(0...first_line.length).each_with_index do |idx|
  diffs1 = diffs1 + 1 if given[idx] != candidate1[idx]
  diffs2 = diffs2 + 1 if given[idx] != candidate2[idx]
end

puts [diffs1, diffs2].min

Measured memory_bytes: 16892
#include<iostream>

int main() 
{
	int a,b;
  std::cin>>a;
  std::cin>>b;
	
	if (a*b%2 == 1) {
		std::cout << "Odd";
	}
	else {
		if (a*b % 2 == 0)
			std::cout << "Even";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int dp[100][10];

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

	ll N, K; cin >> N >> K;
	cout << min(N % K, K - N % K) << endl;

	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int ans =  999;
	for(int i = 0; i <= n - 3; ++i){
		int num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
		ans = min(abs(num - 753), ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    n,y = i_map()
    for m in range(0,n+1):
        for g in range(0,n-m+1):
            if 10000*m+5000*g+1000*(n-m-g) == y:
                print(m,g,n-m-g)
                exit()
    print(-1,-1,-1)



if __name__=="__main__":
    main()


Measured memory_bytes: 74936
#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

bool fun(int a,int b){
	return a > b ;
}
int32_t main(){fast ;
	int x,y,z,k ;
	cin >> x >> y >> z >> k ;
	vector<int> X(x), Y(y) , Z(z) ;
	for(int& i : X)
		cin >> i ;
	for(int& i : Y)
		cin >> i ;
	for(int& i : Z)
		cin >> i ;
	sort(all(X),fun) ;
	sort(all(Y),fun) ;
	sort(all(Z),fun) ;
	vector<int>ans ;
	int cnt = 0 ;bool ok = true ;
	F(i,0,x){
		F(j,0,y){
			F(p,0,z){
				if((i+1)*(j+1)*(p+1) <= k)
					ans.pb(X[i]+Y[j]+Z[p]) ;
				else
					break ;
			}
		}
	}
	sort(all(ans),fun) ;
	F(i,0,k)
		cout << ans[i] << endl ;
}




Measured memory_bytes: 1404
#include <stdio.h>
#include <string.h>

int main(void)
{
    int N,M;
    int j;
    int en=0, tmp;
    char Blue[100][11];
    char Red[100][11];

    scanf("%d\n",&N);
    for(int i=0; i<N; i++){
        scanf("%s\n",&Blue[i]);
        /*do{
            scanf("%c",Blue[i][j]);
            j++;
        }while(Blue[i][j] != '\0');*/
        //gets(&Blue[i]);
    }
    scanf("%d\n",&M);
    for(int i=0; i<M; i++){
        scanf("%s",&Red[i]);
        //gets(&Red[i]);
        /*do{
            scanf("%c",Red[i][j]);
            j++;
        }while(Red[i][j] != '\0');*/
    }

    //printf("N = %d,  M = %d\n",N,M);

    //全探索
    for(int i=0; i<N-1; i++){
        tmp = 1;
        for(int j=i+1; j<N; j++){
            if(strcmp(Blue[i],Blue[j]) == 0) tmp++;
        }
        for(int k=0; k<M; k++){
            if(strcmp(Blue[i],Red[k]) == 0) tmp--;
        }
        if(en < tmp) en = tmp;
    }

    printf("%d\n",en);

    return 0;
}

Measured memory_bytes: 1732
n, m = map(int, input().split())
flg = [0]*n
ac = 0
pe = [0]*n

for i in range(m):
    p, s = input().split()
    if flg[int(p)-1] == 0:
        if s == "WA":
            pe[int(p)-1] += 1
        else:
            flg[int(p)-1] = 1
            ac += 1
spe = 0
for i in range(n):
    if flg[i] == 1:
        spe += pe[i]

print(ac, spe)


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

const int MOD = 1000000007;
const int MAXN = 2005;

int N, M, S[MAXN], T[MAXN];
long long dp[MAXN][MAXN];

int main(){
    scanf("%d %d", &N, &M);
    for(int i = 0; i < N; i++)
        scanf("%d", &S[i]);
    for(int j = 0; j < M; j++)
        scanf("%d", &T[j]);

    for(int i = N; i >= 0; i--)
    for(int j = M; j >= 0; j--){
        if(i == N){
            if(j == M)dp[i][j] = 1;
            else dp[i][j] = dp[i][j + 1];
        }else if(j == M){
            dp[i][j] = dp[i + 1][j];
        }else{
            dp[i][j] = (dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1] + MOD) % MOD;
            if(S[i] == T[j])dp[i][j] = (dp[i][j] + dp[i + 1][j + 1]) % MOD;
        }
    }
    printf("%lld\n", dp[0][0]);
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PI 3.14159265359
using namespace std;

int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle = abs((30 * h) - (5.5 * m));
    double cos_ = cos(angle * PI / 180.0);
    double res = sqrt((pow(a, 2) + pow(b, 2)) - (2 * a * b * cos_));
    cout << setprecision(20) << res;
}


Measured memory_bytes: 4160
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

int w, h, xs, ys, xg, yg, n;
int board[110][110];
bool used[110][110];

int dx1[8] = {0,1,2,3,0,1,2,3};
int dy1[8] = {0,0,0,0,1,1,1,1};

int dx2[8] = {0,0,0,0,1,1,1,1};
int dy2[8] = {0,1,2,3,0,1,2,3};

bool dfs(int x, int y, int xg, int yg, int color) {
    if (board[y][x] != color || used[y][x] || x <= 0 || y <= 0 || w < x || h < y) {
        return false;
    }
    if (x == xg && y == yg) {
        return true;
    }
    used[y][x] = true;
    bool ret = false;
    ret |= dfs(x+1, y, xg, yg, color);
    ret |= dfs(x-1, y, xg, yg, color);
    ret |= dfs(x, y+1, xg, yg, color);
    ret |= dfs(x, y-1, xg, yg, color);
    return ret;
}

int main() {
    while (cin >> w >> h, (w || h)) {
        memset(board, 0, sizeof board);
        cin >> xs >> ys >> xg >> yg >> n;
        int c, d, x, y;
        for (int i=0; i<n; ++i) {
            cin >> c >> d >> x >> y;
            if (d == 0) {
                for (int i=0; i<8; ++i) {
                    board[y + dy1[i]][x + dx1[i]] = c;
                }
            } else {
                for (int i=0; i<8; ++i) {
                    board[y + dy2[i]][x + dx2[i]] = c;
                }
            }
        }
        memset(used, false, sizeof used);
        if (board[ys][xs] && dfs(xs, ys, xg, yg, board[ys][xs])) {
            cout << "OK" << endl;
        } else {
            cout << "NG" << endl;
        }
    }
    return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string s;
	int len;
	bool c = false, ans = false;

	cin >> s;
	len = s.length();

	rep(i, len) {
		if (!c && s[i] == 'C') c = true;
		else if (c && s[i] == 'F') ans = true;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string p, k;
    p = s.substr(0,(n-1)/2);
    k = s.substr((n+3)/2-1, n-1);
    string x = "";
    string y = "";
    int num = p.size();
    for(int i = 0; i < num; i++){
        x = x + p.at(num-1-i);
        y = y + k.at(num-1-i);
    }
    if(p == x && y == k && p == k && x == y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}
 

Measured memory_bytes: 256
import math
a,b=map(int,input().split())
List=[list(map(int,input().split())) for i in range(a)]
ans=10000000000000
for i in range(2**a):
  s=0
  c=0
  t=True
  x=0
  y=0
  for j in range(a):
    if (i>>j) & 1:
      s+=(a-j)*100*List[a-1-j][0]+List[a-1-j][1]
      c+=List[a-1-j][0]
    else:
      if t:
        x=(a-j)*100
        y=List[a-1-j][0]
        t=False
  if b<=s:
    if ans>c:
      ans=c
  else:
    if math.ceil((b-s)/x)<=y:
      c+=math.ceil((b-s)/x)
      if ans>c:
        ans=c
print(ans)

Measured memory_bytes: 3064
//go:generate echo "https://atcoder.jp/contests/abc175/tasks/abc175_b"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) Ints(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func solve(N int, L []int) int {
	if N < 3 {
		return 0
	}
	u := []int{}
	m := map[int]int{}
	for _, l := range L {
		if _, ok := m[l]; !ok {
			u = append(u, l)
		}
		m[l]++
	}
	sort.Ints(u)
	a := 0
	for x := 0; x < len(u); x++ {
		for y := x + 1; y < len(u); y++ {
			for z := y + 1; z < len(u); z++ {
				if u[x]+u[y] > u[z] {
					a += m[u[x]] * m[u[y]] * m[u[z]]
				}
			}
		}
	}
	return a
}

func main() {
	scan := newScanner(os.Stdin)
	N := scan.Int()
	L := scan.Ints(N)
	fmt.Println(solve(N, L))
}


Measured memory_bytes: 1816
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n, i, k;
		cin >> n >> k;
		vector <int> v;
		for(i = 0; i < n; i++){
			int x;
			cin >> x;
			v.pb(x);
		}
		sort(all(v));
		for(i = 0; i < n; i++){
			if(v[i] < k){
				cout << i;
				return 0;
			}
		}
		cout << n;
		
    return 0;
} // What is to be written here?


Measured memory_bytes: 892
import sys
s=input()
a=[int(s[i]) for i in range(4)]
for b in [a[1],-a[1]]:
    for c in[a[2],-a[2]]:
        for d in [a[3],-a[3]]:
            if a[0]+b+c+d==7:
                s=str(a[0])
                for x in [b,c,d]:
                    s+="+"+str(x) if x>=0 else str(x)
                s+="=7"
                print(s)
                sys.exit()

Measured memory_bytes: 38484
import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> countMap = new HashMap<>();
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      countMap.merge(s, 1, Integer::sum);
    }
    String[] verdicts = {"AC", "WA", "TLE", "RE"};
    for (String verdict : verdicts) {
	    System.out.println(verdict + " x " + countMap.getOrDefault(verdict, 0));
    }
  }
}

Measured memory_bytes: 51296
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll GCD(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

bool is_prime(ll x)
{
    for (ll i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    ll k = GCD(a, b);
    auto y = divisor(k);
    ll ans = 0;
    for (ll i = 0; i < (ll)y.size(); i++)
    {
        if(is_prime(y[i])){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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 * (B / gcd(A, B));
}
  
/*------------------------------------------------------------------*/
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
int n;
Graph G;
vector<int> ans;

void dfs(int v, int parent, int color){
    ans[v] = color;

    for(auto e : G[v]){
        if(e.first == parent) continue;
        if(e.second % 2 == 0) dfs(e.first, v, color);
        else dfs(e.first, v, 1 - color);
    }
}

int main(){
    cin >> n;
    G.assign(n, vector<Edge>());
    rep(i, n - 1){
        int from, to, distance; cin >> from >> to >> distance;
        from--, to--;
        G[from].push_back(Edge(to, distance));
        G[to].push_back(Edge(from, distance));
    }

    ans.assign(n, 0);
    dfs(0, -1, 1);
    
    for(auto v : ans) cout << v << endl;
}

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

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else return a.first < b.first;
}

int main() {
    int N; cin >> N;
    vector<pair<int, int>> work(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        work.at(i) = make_pair(a, b);
    }
    sort(work.begin(), work.end(), cmp);
    int time = 0;
    for (int i = 0; i < N; i++) {
        time += work.at(i).first;
        if (time <= work.at(i).second) continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
gets.to_i.times do
  p0, p1, p2, p3 = gets.split.map(&:to_i).each_slice(2).map {|a, b| a + b * 1i }
  u, v, w, z = p1 - p0, p3 - p2, p2 - p0, p3 - p0
  d, c = (u.conj * v).rect
  if c.zero?
    if (u.conj * w).imag.zero?
      ud, wd, zd = [u, w, z].map {|x| (u.conj * x).real }
      a, b = 0, ud
      a, b = b, a if b < a
      if wd < a && zd < a || wd > b && zd > b
        p [p0, p1].flat_map {|x| [p2, p3].map {|y| (x - y).abs } }.min
      else
        p 0
      end
    else
      cs = [p0, p1].flat_map {|x| [p2, p3].map {|y| (x - y).abs } }
      [[u, p2 - p0], [u, p3 - p0], [v, p0 - p2], [v, p1 - p2]].each do |x, y|
        k = (x.conj * y).real.to_f / (x.conj * x).real
        cs << (y - k * x).abs if 0 <= k && k <= 1
      end
      p cs.min
    end
  else
    # t, s are such that p0 + t * u = p2 + s * v
    t = (Complex(*v.rect.reverse!) * w).real.to_f / c
    s = (Complex(*u.rect.reverse!) * w).real.to_f / c
    if 0 <= t && t <= 1 && 0 <= s && s <= 1
      p 0
    else
      cs = [p0, p1].flat_map {|x| [p2, p3].map {|y| (x - y).abs } }
      [[u, p2 - p0], [u, p3 - p0], [v, p0 - p2], [v, p1 - p2]].each do |x, y|
        k = (x.conj * y).real.to_f / (x.conj * x).real
        cs << (y - k * x).abs if 0 <= k && k <= 1
      end
      p cs.min
    end
  end
end

Measured memory_bytes: 9008
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = l[0], Y = l[1];
            var ans = 0;
            ans += Calc(X);
            ans += Calc(Y);
            if (X == 1 && Y == 1) ans += 400000;

            Console.WriteLine(ans);
        }

        static int Calc(int a)
        {
            if (a == 1)
                return 300000;
            else if (a == 2)
                return 200000;
            else if (a == 3)
                return 100000;
            else
                return 0;
        }
    }
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.readline
def print_ans(N,input_line):
    """Test Case
    >>> print_ans(3,"3 1 2")
    11
    >>> print_ans(7,"5 0 7 8 3 3 2")
    312
    """
    arr = list(map(int,input_line.split()))
    res = 0
    for i in range(N):
        for j in range(i+1,N):
            res += arr[i] * arr[j]
    print(str(res))
if __name__ == '__main__':
    N = int(input())
    input_line = input()
    print_ans(N,input_line)

Measured memory_bytes: 3064
#include <stdio.h>

#define N 2000
#define Q 200

int solve(int, int, int *, int);

int main(){
  int A[N], n, q, x, i, B[Q];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &B[i]);
  }

  for(i = 0; i < q; i++){
    x = solve(0, B[i], A, n);
    if(x == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int m, int *A, int n){
  int res;

  if(m == 0){
    return 1;
  }

  if(i >= n){
    return 0;
  }

  res = solve(i + 1, m, A, n) || solve(i + 1, m - A[i], A, n);

  return res;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
const int N=1000005;
int i,n,a[N],b[N],c,x,y,m,p,f,g,ans;
int main()
{
	scanf("%d %d %d",&n,&m,&p);
	ans=f=g=1<<30;
	for(i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		f=min(f,a[i]);
	}
	for(i=1;i<=m;++i)
	{
		scanf("%d",&b[i]);
		g=min(g,b[i]);
	}
	ans=f+g;
	while(p--)
	{
		scanf("%d %d %d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans;
}

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

int main() {
  int n, m, tmp;
  cin >> n >> m;
  vector<int> a, aHalf;
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    a.push_back(tmp);
  }
  std::sort(a.begin(),a.end(),std::greater<int>());
  a.erase(std::unique(a.begin(), a.end()), a.end());

  for (int i = 0; i < a.size(); i++) {
    aHalf.push_back(a.at(i) / 2);
  }

  int count = 0;
  int half = (a.at(0) / 2);
  int check = 1;
  for (int x = half; x <= m; x += a.at(0)) {
    check = 1;
    for (int i = 1; i < a.size(); i++) {
      if (a.at(i) == a.at(0)) continue;
      if ((x - aHalf.at(i)) % a.at(i) != 0) {
        check = 0;
        break;
      }
    }
    if (check == 1) count++;
  }

  cout << count << endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    map<string,int> m;
    bool isgoto[N];
    for(int i = 0;i < N;i++)isgoto[i] = false;
    string to[N];
    for(int i = 0;i < N;i++){
        string tmp;
        cin >> tmp;
        if(tmp == "goto"){
            isgoto[i] = true;
            cin >> tmp;
            to[i] = tmp.substr(0,tmp.size()-1);
        }else{
            m[tmp.substr(0,tmp.size()-1)] = i;
        }
    }
    int dist[N+1];
    for(int i = 0;i < N+1;i++)dist[i] = -1;
    deque<pair<int,int>> que;
    dist[0] = 0;
    que.push_back(make_pair(0,0));
    while(que.size()){
        pair<int,int> p = que.front();
        que.pop_front();
        int tmp = p.first;
        dist[tmp] = p.second;
        if(tmp == N)break;
        if(isgoto[tmp]){
            if(dist[m[to[tmp]]] == -1){
                que.push_front(make_pair(m[to[tmp]],dist[tmp]));
            }
            if(dist[tmp+1] == -1){
                que.push_back(make_pair(tmp+1,dist[tmp]+1));
            }
        }else{
            if(dist[tmp+1] == -1){
                dist[tmp+1] = dist[tmp];
                que.push_front(make_pair(tmp+1,dist[tmp]));
            }
        }
    }
    cout << dist[N] << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int kNumContests = 26;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int num_days;
  cin >> num_days;
  vector<int64> costs(kNumContests);
  for (int i = 0; i < kNumContests; i++) {
    cin >> costs[i];
  }

  auto score_table = Make2DVector(num_days, kNumContests, 0LL);
  for (int d = 0; d < num_days; d++) {
    for (int c = 0; c < kNumContests; c++) {
      cin >> score_table[d][c];
    }
  }

  vector<int> ls(kNumContests, -1);
  for (int d = 0; d < num_days; d++) {
    int64 max_score = INT64_MIN;
    int max_c = -1;
    for (int c = 0; c < kNumContests; c++) {
      int64 score = score_table[d][c] + (d - ls[c]) * costs[c] * 5;
      if (max_score < score) {
        max_score = score;
        max_c = c;
      }
    }

    ls[max_c] = d;

    cout << (max_c + 1) << endl;
  }
}

Measured memory_bytes: 3748
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    AB = sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: x[0])
    res = AB[-1][0] + AB[-1][1]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 29864
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = '';
process.stdin.on('data', function(chunk) {
    lines += chunk;
});
process.stdin.on('end', function() {
    main(lines.split(/\r?\n/));
});
function main(inputs){
  var nums = inputs[0].split(" ");
  var a = nums[0];
  var b = nums[1];

  var product = a * b;

  if(product % 2 == 0){
    console.log("Even");
  } else {
    console.log("Odd");
  }



}

Measured memory_bytes: 21448
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    set<int> ball;
    for(int i=0; ; ++i){
        int a = i * i * i;
        if(a > 151200)
            break;
        for(int j=0; ; ++j){
            int b = j * (j+1) * (j+2) / 6;
            if(a + b > 151200)
                break;
            ball.insert(a + b);
        }
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        set<int>::iterator it = ball.upper_bound(n);
        -- it;
        cout << (*it) << endl;
    }
}

Measured memory_bytes: 0
# ABC084 B - Postal Code
a,b = map(int,input().split())
s = input()

d = ('1','2','3','4','5','6','7','8','9','0')

for i in range(len(s)):
    if i == a and s[a:a+1] != '-':
        print('No')
        exit()
    if i != a and s[i:i+1] not in d:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"YES":"NO")<<endl;

int main() {
    int n; cin >> n;
    int sum = 0;
    int memo = 0;
    rep(i, n+1) {
        sum += i;
        if (sum >= n) {
            memo = i;
            break;
        }
    }
    for (int i=1; i<=memo; ++i) {
        if (i == sum - n) continue;
        else cout << i << endl;
    }
}

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

int main(){
  set<int> s;
  int a,b,c;
  cin >> a >> b >> c;
  s.insert(a); s.insert(b); s.insert(c);
  if(s.size() == 2)
    cout << "Yes\n";
  else
    cout << "No\n";
  
  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, A, B;
  cin >> N >> A >> B;
  string s;
  cin >> s;

  int a, b;
  a = b = 0;
  for (int i = 0; i < N; i++) {
    bool flag = false;
    if (s[i] == 'a') {
      if (a + b < A + B) {
        flag = true;
        a++;
      }
    } else if (s[i] == 'b') {
      if (a + b < A + B && b < B) {
        flag = true;
        b++;
      }
    }

    cout << (flag ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 896
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: [Int] -> Int
solve as = let
    amap = IM.fromList $ zip [1..] as
    go :: Int -> S.Set Int -> Int -> Int
    go 2 done count = count
    go i done count
        | S.member i done = -1
        | otherwise = go (amap IM.! i) (S.insert i done) (count + 1)
    in
    go 1 S.empty 0




main = do
    n <- readInt
    as <- replicateM n readInt
    print $ solve as





Measured memory_bytes: 35196
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){
int N,count=0;
cin>>N;
rep3(i,N){
    int a;
    cin>>a;
    if((i%2==1)&&(a%2==1))count++;
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cmath>

int main() {
  int D, N;
  std::cin >> D >> N;
  long long int ans = N;
  if (N == 100) ans++;
  for (int i=0; i<D; i++) ans *= 100;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

#define ll long long

#define file_io 0

ll i,t,j,md=1e9+7;
ll n,k,a[105],ps[105][100005],cnt;
ll dp[105][100005];

int main() {
	if (file_io) {
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}

	scanf("%lld%lld",&n,&k);

	for (i=1; i<=n; ++i) {
		scanf("%lld",&a[i]);
	}

	//dp[i][t], from [1] to [i] person
	//totally used [t] candies
//	dp[0][0]=1;
//	for (i=1; i<=n; ++i){ //ith person
//		for (j=0; j<=k; ++j){ //to have how many
//			for (t=0; t<=a[i] && t<=j; ++t){ //take how many
//				dp[i][j]=(dp[i][j]+dp[i-1][j-t])%md;
//			}
//		}
//	}

	//use partial sum to optimize
	dp[0][0]=1;
	for (j=0; j<=k; ++j) ps[0][j]=1;

	for (i=1,cnt=a[1]; i<=n; ++i) { //ith person
		for (j=0; j<=k; ++j) { //to have how many
			if (j-a[i]<=0) dp[i][j]=(dp[i][j]+ps[i-1][j])%md;
			else dp[i][j]=(dp[i][j]+ps[i-1][j]-ps[i-1][j-a[i]-1])%md;
		
			ps[i][j]=(ps[i][j-1]+dp[i][j])%md;
		}
	}


	printf("%lld\n",(dp[n][k]+md)%md);

	return 0;
}

Measured memory_bytes: 159104
from collections import deque
H, W = map(int, input().split())
sH, sW = map(int, input().split())
sH, sW = sH - 1, sW - 1
gH, gW = map(int, input().split())
gH, gW = gH - 1, gW - 1
stage = []
scores = []
for _ in range(H):
    stage.append(list(input()))
    scores.append([float('inf')] * W)
scores[sH][sW] = 0
moveA_q = deque()
moveB_q = deque()
moveA_q.append([sW, sH])
moveB_q.append([sW, sH])
dx_list = [0, 1, 0, -1]
dy_list = [1, 0, -1, 0]
while moveA_q or moveB_q:
    if scores[gH][gW] != float('inf'):
        break
    # 移動AでBFS
    while moveA_q:
        x, y = moveA_q.pop()
        moveB_q.append([x, y])
        for dx, dy in zip(dx_list, dy_list):
            nx, ny = x + dx, y + dy
            if nx < 0 or W <= nx or ny < 0 or H <= ny or stage[ny][nx] == '#':
                continue
            # if scores[ny][nx] == float('inf'):
            if scores[ny][nx] > scores[y][x]:
                scores[ny][nx] = scores[y][x]
                moveA_q.append([nx, ny])
                # moveB_q.append([nx, ny])

    # 移動bで動けるマスをmodeA_qに格納
    while moveB_q:
        x, y = moveB_q.pop()
        for dx in range(-2, 3):
            for dy in range(-2, 3):
                nx, ny = x + dx, y + dy
                if nx < 0 or W <= nx or ny < 0 or H <= ny or stage[ny][nx] == '#':
                    continue
                # if scores[ny][nx] == float('inf'):
                if scores[ny][nx] > scores[y][x]:
                    moveA_q.append([nx, ny])
                    scores[ny][nx] = scores[y][x] + 1

# print(*scores,sep='\n')
if scores[gH][gW] == float('inf'):
    print(-1)
else:
    print(scores[gH][gW])


Measured memory_bytes: 196532
#include <cstdio>
#include <cmath>
#include <algorithm>

typedef long long llint;

using namespace std;

llint n, x, y, a, b;

int main() {
	scanf("%lld", &n);
	scanf("%lld%lld", &a, &b);
	for (int i = 0; i < n-1; ++i) {
		scanf("%lld%lld", &x, &y);
		llint mult = max(ceil((long double)b/y), ceil((long double)a/x));
		b = mult * y;
		a = mult * x;
	}

	printf("%lld\n", a+b);
	return 0;
}



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

static const int max_n = 1000;
string s1, s2;
int q, c[max_n + 1][max_n + 1];

int lcs(string X, string Y){
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for(int i = 0; i <= m; i++){
		c[i][0] = 0;
	}
	for(int j = 1; j <= n; j++){
		c[0][j] = 0;
	}
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			if(X[i] == Y[j]){
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else if(c[i - 1][j] >= c[i][j - 1]){
				c[i][j] = c[i - 1][j];
			}
			else{
				c[i][j] = c[i][j - 1];
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}

int main(void){
	cin >> q;
	for( int i = 1; i <= q; i++ ){
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 7068
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<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;
}

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}

int N;
llvec A;
ll sum=1;

void input() {
	cin>>N;
	init(A,N);
}

void solve() {
	sort(all(A));
	if(A[0]==0) {
		cout<<0<<endl;
		return;
	}
	for(int i=0; i<N; i++) {
		if(1000000000000000000ll/sum < A[i]) {
			cout<<-1<<endl;
			return;
		}
		sum*=A[i];
	}
	cout<<sum<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 4016
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int x = scan.nextInt();

        if(x >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        scan.close();
        return;
    }
}

Measured memory_bytes: 35620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz],dp[sz];

int clac(int i){
    if(i==n) return 0;
    if(dp[i]!=-1)return dp[i];
    int left=abs(arr[i]-arr[i+1])+clac(i+1);
    int right=inf;
    if(i+2<=n){
        right=abs(arr[i]-arr[i+2])+clac(i+2);
    }
    return dp[i]=min(left,right);
}

void solve(){
    cin>>n;
    reset(dp,-1);
    lp(i,1,n+1)cin>>arr[i];
    cout<<clac(1)<<"\n";
}

int main(){
    //FasterIO;
    #ifndef ONLINE_JUDGE
       // freopen("1.txt","r",stdin);
   #endif
   // int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define SENTINEL 200000000

typedef struct{
  char moji;
  int fig;
}Card;

Card L[MAX/2 + 2], R[MAX/2 + 2];

void quickSort(Card *, int, int);
void merge(Card *, int, int, int);
void mergeSort(Card *, int, int);
int partition(Card *, int, int);

int n;

int main()
{
  int i;
  int stable = 1;
  int fig;
  char s[10];
  Card A[MAX],B[MAX];

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    scanf("%s %d",s,&fig);
    A[i].moji = B[i].moji = s[0];
    A[i].fig = B[i].fig = fig;
  }

  mergeSort(A,0,n);
  quickSort(B,0,n-1);

  for(i = 0; i < n; i++){
    if(A[i].moji != B[i].moji)stable = 0;
  }

  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0; i < n; i++){
    printf("%c %d\n",B[i].moji, B[i].fig);
  }
 

  return 0;
}

void merge(Card A[], int left, int mid, int right)
{
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0; i < n1; i++)L[i] = A[left + i];
  for(i = 0; i < n2; i++)R[i] = A[mid + i];
  L[n1].fig = R[n2].fig = SENTINEL;
  i = j = 0;

  for(k = left; k < right; k++){
    if(L[i].fig <= R[j].fig){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(Card A[], int left, int right)
{
  int mid;

  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int partition(Card A[], int p, int r)
{
  int i,j;
  Card t,x;

  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j].fig <= x.fig){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;

  return i + 1;
}

void quickSort(Card A[], int p, int r)
{
  int q;

  if(p < r){
    q = partition(A,p,r);
    quickSort(A,p,q-1);
    quickSort(A,q+1,r);
  }
}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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;
}

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll c[30];
ll dp[30][50101];
void solve() {
    ll n, m;
    cin >> n >> m;

    REP(i, m) { cin >> c[i]; }
    REP(i, m + 1) {
        REP(j, n + 1) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    REP(i, m + 1) {
        REP(j, n + 1) {
            chmin(dp[i + 1][j], dp[i][j]);
            if(j - c[i] >= 0)
                chmin(dp[i + 1][j], dp[i + 1][j - c[i]] + 1);
        }
    }

    cout << dp[m][n] << en;
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 11388
using System;
using System.Collections.Generic;
public class ABC140C {
    public static void Main() {
        int N, ans = 0;
        N = int.Parse(Console.ReadLine());
        List<int> B = new List<int>();
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < str.Length; i++) {
            B.Add(int.Parse(str[i]));
        }
        
        ans += B[0];
        for (int i = 1; i < N - 1; i++) {
            ans += Math.Min(B[i - 1], B[i]);
        }
        ans += B[N - 2];
        
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define ull unsigned long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pul pair<ull,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int mod=1e9+7;
template<typename T> void chkmin(T &x,T y) {if(y<x) x=y;}
template<typename T> void chkmax(T &x,T y) {if(y>x) x=y;}
template<typename T> void upd(T &x,T y) {if((x+=y)>=mod) x-=mod;}
int n,sl,fh,f[mxn],fa[mxn],siz[mxn],fac[mxn],ifc[mxn];
int t,h[mxn];
struct Tre
{
	int to,nxt;
}e[mxn<<1];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int _pow(int k,int i)
{
	int t=1;
	for(;i;i>>=1,k=1ll*k*k%mod)
		if(i&1)
			t=1ll*t*k%mod;
	return t;
}
void init()
{
	fac[0]=1;
	for(int i=1;i<=n;++i) fac[i]=1ll*i*fac[i-1]%mod;
	ifc[n]=_pow(fac[n],mod-2);
	for(int i=n;i;--i) ifc[i-1]=1ll*i*ifc[i]%mod;
}
LL C(int x,int y) {return 1ll*fac[x]*ifc[y]%mod*ifc[x-y]%mod;}
LL iC(int x,int y) {return 1ll*ifc[x]*fac[y]%mod*fac[x-y]%mod;}
void add(int u,int v)
{
	e[++t]=(Tre){v,h[u]};h[u]=t;
	e[++t]=(Tre){u,h[v]};h[v]=t;
}
void dfs1(int u)
{
	int v;siz[u]=f[u]=1;
	for(int i=h[u];i;i=e[i].nxt)
		if((v=e[i].to)!=fa[u])
		{
			fa[v]=u;dfs1(v);siz[u]+=siz[v];
			f[u]=1ll*f[u]*f[v]%mod*C(siz[u]-1,siz[v])%mod;
		}
}
void dfs2(int u)
{
	int v;
	for(int i=h[u];i;i=e[i].nxt)
		if((v=e[i].to)!=fa[u])
		{
			f[v]=1ll*f[u]*iC(n-1,siz[v])%mod*C(n-1,n-siz[v])%mod;
			dfs2(v);
		}
}
int main()
{
	ios::sync_with_stdio(false);
	n=rd();init();
	for(int i=1;i<n;++i) add(rd(),rd());
	dfs1(1);dfs2(1);
	for(int i=1;i<=n;++i) printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
 #define ll long long
 #define ii pair<int,int>
 #define endl '\n'
using namespace std;

void solve()
{ 
    int n;
    cin >> n;
    vector<int> v(n);
    ll ans = 0;
    for(int i=0; i<n; i++)
        cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());

    ans-= v[0];
    for(int i=0, cnt=0; cnt<n; i++)
    {
        ans += v[i/2];
        cnt++;
    }
    cout << ans << endl;
}
int main(){
    std::ios_base::sync_with_stdio(false); 
    std::cin.tie(nullptr); std::cout.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3988