akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;

public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<String, Integer>();

		sc.nextLine();

		String tmp = "";
		int max = 0;
		for (int i=0; i < N; i++) {
			tmp = sc.nextLine();
			if (map.get(tmp) == null) {
				map.put(tmp, 1);
				max = Math.max(max, 1);
			} else {
				map.put(tmp, map.get(tmp) + 1);
				max = Math.max(max, map.get(tmp));
			}
		}

		LinkedHashMap<String, Integer>  map2 =  map.entrySet().stream()
        .sorted(java.util.Map.Entry.comparingByValue())
        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));

			List<String> list = new ArrayList<String>();
        for (Entry<String, Integer> entry : map2.entrySet()) {
        	if (max == entry.getValue()) {
        		list.add(entry.getKey());
        	}
        }

        Collections.sort(list);
        for (String s : list) {
        	System.out.println(s);
        }
	}
}


Measured memory_bytes: 179760
#define _USE_MATH_DEFINES 
#include <cmath>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#define rep(i,start,n) for(int i=start;i<n;i++)
#define And &&
#define Or ||
#define Lb cout<<endl
using namespace std;

int main(void) {
	int n, b, f, r, v;
	cin >> n;
	int a[4][3][10] = {};
	rep(i, 0, n) {
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	rep(i, 0, 4) {
		rep(j, 0, 3) {
			rep(k, 0, 10) {
				cout << " " << a[i][j][k];
			}
			Lb;
		}
		if (i != 3) {
			rep(l, 0, 20) cout << "#";
			Lb;
		}
	}
}

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

double norm(int x_1, int x_2, int y_1, int y_2){
    return pow(pow(x_1 - x_2, 2) + pow(y_1 - y_2, 2), 0.5);
}

int n_kai(int n){
    int ans = 1;
    for (int i = 1; i <= n; i++){
        ans = ans * i;
    }
    return ans;
}

int main(){
    int N; cin >> N;
    int x[N], y[N];
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    int city[N];
    for (int i = 0; i < N; i++) city[i] = i;
    double length;
    int nx = sizeof(city) / sizeof(city[0]);
    int pos_1;
    int pos_2;
    for (int i = 0; i < N - 1; i++){
        pos_1 = city[i];
        pos_2 = city[i +1];
        length = length + norm(x[pos_1], x[pos_2], y[pos_1], y[pos_2]);
    }
    while (next_permutation(city, city + nx)){
        for (int i = 0; i < N - 1; i++){
            pos_1 = city[i];
            pos_2 = city[i +1];
            length = length + norm(x[pos_1], x[pos_2], y[pos_1], y[pos_2]);
        }
    }

    double ans = length / (double)n_kai(N);
    cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define LL long long
LL n, m;
LL l = 0, r = 10000000000000LL;
int main()
{
    cin >> n >> m;
    while (l < r)
    {
        LL md = (l + r + 1) / 2;
        LL nd = max(0ll, md - n);
        LL ls = m - (nd * 2);
        if (ls >= md * 2) l = md; else r = md - 1;
    }
    cout << l;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    cout << r * r << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = (n/(a+b))*a;
    ans += min ( (ll) n- (ll)(n/(a+b))*(a+b),(ll)a);
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k = n%10;
  if (k==2 or k == 4 or k == 5 or k == 7 or k == 9){
    cout << "hon" << endl;
  }else if (k == 0 or k == 1 or k == 6 or k == 8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3592
#include <cstdio>
#include <algorithm>
typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int N = 2e5 + 5;
const int inf = 1e9 + 9;
const int Mod = 1e9 + 7;
int n, X, Y, c[N], w[N], idx[N], id[N], vis[N], que[N], qn, cnt[N], a[N], len;
int tot, first[N], next[N << 3], end[N << 3], ans, fac[N], Ifac[N];
inline bool compare(const int &x, const int &y) {
	return w[idx[x]] < w[idx[y]];
}
inline void AddEdge(int x, int y) {
	next[++tot] = first[x], first[x] = tot, end[tot] = y;
	next[++tot] = first[y], first[y] = tot, end[tot] = x;
} 
inline int calc(int n, int m) {
	return (ll)fac[n] * Ifac[m] % Mod * Ifac[n - m] % Mod;
}
inline int pow(int x, int k) {
	ll res = 1, r = x;
	for (; k; k >>= 1, r = r * r % Mod)
		if (k & 1) res = res * r % Mod;
	return res;
}
inline void solve(int x) {
	vis[x] = true, que[qn = 1] = x;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql)
		for (int k = first[u], v; v = end[k], k; k = next[k])
			if (!vis[v]) vis[v] = true, que[++qn] = v;
		
	len = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) 
		if (++cnt[c[u]] == 1) a[++len] = c[u];
	
	for (int i = 1, total = qn; i <= len; ++i) 
		ans = (ll)ans * calc(total, cnt[a[i]]) % Mod, total -= cnt[a[i]];
	
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) --cnt[c[u]];
}
int main() {
	n = Get(), X = Get(), Y = Get();
	for (int i = 1; i <= n; ++i) c[i] = Get(), w[i] = Get();
	
	for (int i = 1; i <= n; ++i)
		if (!idx[c[i]] || w[idx[c[i]]] > w[i]) idx[c[i]] = i;
	
	w[0] = inf;
	for (int i = 1; i <= n; ++i) id[i] = i;
	std :: sort(id + 1, id + n + 1, compare);
	
	for (int i = 1; i <= n; ++i) {
		if (w[i] + w[idx[c[i]]] <= X) AddEdge(i, idx[c[i]]);
		if (c[i] != id[1] && w[i] + w[idx[id[1]]] <= Y) AddEdge(i, idx[id[1]]);
		if (c[i] != id[2] && w[i] + w[idx[id[2]]] <= Y) AddEdge(i, idx[id[2]]);
	}
	
	
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = (ll)fac[i - 1] * i % Mod;
	Ifac[n] = pow(fac[n], Mod - 2);
	for (int i = n; i; --i) Ifac[i - 1] = (ll)Ifac[i] * i % Mod;
		
	ans = 1;
	for (int i = 1; i <= n; ++i) if (!vis[i]) solve(i);
	
	printf("%d\n", ans);
}

Measured memory_bytes: 21248
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

int main()
{
    int n;
    std::cin >> n;

    if (n % 2) {
        std::cout << "No" << std::endl;
        return 0;
    }

    std::string s;
    std::cin >> s;

    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[i + n / 2]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 888
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	mp := map[rune]int{}
	for _, v := range s {
		mp[v]++
	}
	for _, v := range mp {
		if v%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <stdio.h>

int timeTable[24*60];

int main(){
  int h, i, j, m, in, isFirst;

  for (i = 0; i < 2; ++i) {
    scanf("%d", &j);
    for (; j > 0; --j) {
      scanf("%d %d",&h, &m);
      timeTable[h*60 + m] = 1;
    }
  }

  isFirst = 1;
  for (h = 0; h < 24; ++h){
    for (m = 0; m < 60; ++m)      {
      if ( timeTable[h*60 + m] ){
        if ( !isFirst ) printf(" ");
        else isFirst = 0;
        printf("%d:%02d", h, m);
      }
    }
  }
  printf("\n");

  return 0;
}




Measured memory_bytes: 2108
import sys
sys.setrecursionlimit(10 ** 9)

def rec(i):
    if (dp[i] < float('inf')): return dp[i]
    if(i==0): return 0

    res = float('inf')
    res = rec(i-1)+abs(H[i]-H[i-1])
    if(i==1): return res

    calc = rec(i-2)+abs(H[i]-H[i-2])
    if(res > calc):
        res = calc

    dp[i] = res

    return res

N = int(input())
H = list(map(int,input().split()))
dp = [float('inf')]*N

print(rec(N-1))

#7
#2 9 4 5 1 6 10


Measured memory_bytes: 96024
/**
 *    Author:  AKASH-ALAM       
**/
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define Fast_io    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 
using namespace std;

int main(){
    Fast_io;
    char a, b;  cin >> a >> b;
    if(a == 'H' && b == 'H') cout << 'H' << endl;
    else if(a == 'H' && b == 'D') cout << 'D' << endl;
    else if(a == 'D' && b == 'H') cout << 'D' << endl;
    else if(a == 'D' && b == 'D') cout << 'H' << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int p[100001];
	string S[100001];
	int jotai[100001]={};
	int pena=0,ac=0;
	scan(N>>M);
	rep(i,M){
		scan(p[i]>>S[i]);
		p[i]--;
		if(jotai[p[i]]==-1){

		}
		else if(S[i][0]=='A'){
			ac++;
			pena+=jotai[p[i]];
			jotai[p[i]]=-1;
		}
		else{
			jotai[p[i]]++;
		}
	}
	printf("%d %d\n",ac,pena);
	return 0;
}


Measured memory_bytes: 6528
N=readline.to_i
 
sorted_a = readline.split.map(&:to_i).sort
rectangle_parts = sorted_a.group_by{|x|x}.map(&:last).reject{|group|group.size<2}

#p sorted_a.group_by{|x|x}
#p sorted_a.group_by{|x|x}.map(&:last)
#p sorted_a.group_by{|x|x}.map(&:last).reject{|group|group.size<2}
#p rectangle_parts

result = 
  if rectangle_parts.empty? || (rectangle_parts.length == 1 && rectangle_parts.last.length<4)
    0
  elsif rectangle_parts.last.length>=4
    rectangle_parts.last.first**2
  else
    rectangle_parts.last.first * rectangle_parts[-2].first
  end

p result






Measured memory_bytes: 24944
# coding: utf-8
# Your code here!

n = int(input())
l = []
for i in range(n):
    tmp = list(map(int,input().split()))
    l.append(tmp)

l.sort(key=lambda x:x[1])

now = 0
for a,b in l:
    now += a
    if now > b:
        print("No")
        exit()
print("Yes")

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

int N, A[100005];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	sort(A, A + N);
	int best = -1;
	long long sum = 0;
	for (int i = 0; i < N - 1; i++) {
		sum += A[i];
		if (sum * 2 < A[i + 1]) {
			best = i;
		}
	}
	printf("%d\n", N - best - 1);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int solve_left(const string& s, int n, int q, const vector<char>& t, const vector<char>& d) {
	int l = -1, r = n;
	while(r - l > 1) {
		int m = (l + r) / 2;
		int now = m, minidx = m;
		for (int i = 0; i < q; ++i) {
			if (s[now] == t[i]) now += (d[i] == 'L') ? -1 : 1;
			minidx = min(now, minidx);
		}
		if (minidx < 0) l = m;
		else r = m;
	}
	return l;
}

int solve_right(const string& s, int n, int q, const vector<char>& t, const vector<char>& d) {
	int l = -1, r = n;
	while(r - l > 1) {
		int m = (l + r) / 2;
		int now = m, maxidx = m;
		for (int i = 0; i < q; ++i) {
			if (s[now] == t[i]) now += (d[i] == 'L') ? -1 : 1;
			maxidx = max(now, maxidx);
		}
		if (maxidx >= n) r = m;
		else l = m;
	}
	return r;
}

int main(int argc, char const *argv[])
{
	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<char> t(q), d(q); rep(i, q) cin >> t[i] >> d[i];

	int left = solve_left(s, n, q, t, d);
	int right = solve_right(s, n, q, t, d);
	// printf("%d %d\n", left, right);

	int del = (left + 1) + (n - right);
	printf("%d\n", max(0, n - del));
	return 0;
}


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

int main(){
	while(1){
		string s;
		cin >> s;
		if(s=="#") break;
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		
		vector<vector<bool> > field(9, vector<bool>(9,false));;
		int x=0, y=0;
		for(int i=0; i<(int)s.length(); i++){
			if(s[i]=='/'){
				y++;
				x = 0;
			}else if(s[i]=='b'){
				field[y][x]=true;
				x++;
			}else{
				x += s[i]-'0';
			}
		}
		y++;		
		field[a-1][b-1] = false;
		field[c-1][d-1] = true;
		
		for(int i=0; i<y; i++){
			for(int j=0; j<x; j++){
				if(field[i][j]){
					cout << "b";
				}else{
					int count=0;
					for(int k=j; ; k++){
						if(k>=x || field[i][k]){
							cout << count;
							j=k-1;
							break;
						}else{
							count++;
						}
					}
				}
			}
			if(i<y-1) cout << "/";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
a = []
while True:
    x = map(int, raw_input().split())
    if x[0] == 0 and x[1] == 0:
        break
    if x[0] > x[1]:
        tmp = x[1]
        x[1] = x[0]
        x[0] = tmp
    a.append([x[0], x[1]])
for i in range(len(a)):
    print a[i][0], a[i][1]

Measured memory_bytes: 6552
input_line=[int(input()),input(),input(),input()]
[i_N,i_A,i_B,i_C]=input_line
cnt=0
for x in range(i_N):
  if (i_A[x]==i_B[x]) & (i_A[x]==i_C[x]):
    continue
  elif (i_A[x]==i_B[x]) | (i_A[x]==i_C[x]) |  (i_B[x]==i_C[x]):
    cnt+=1
  else:
    cnt+=2
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int dp[2001] = {};
    dp[0] = 1;

    for (int i = 3; i <= s; i++) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % P;
    }

    cout << dp[s] << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

string str;
vector<int> Xary;
string sary;
lli ans = INF;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);

	cin >> str;
	int xcnt = 0, last = 0;
	for(int i = 0; i < (int)str.size(); i++){

		if(str[i] == 'x')xcnt++;
		else{
			dbug(xcnt)dbugln;
			Xary.push_back(xcnt);
			xcnt = 0;
			sary+=str[i];
		}
	}
	dbug(xcnt)dbugln;
	Xary.push_back(xcnt);

	if(sary.size() == 0) ans = 0;
	else{
		int b = 0, e = sary.size()-1;
		while(e-b>=0){
			if(sary[b] != sary[e]){
				ans = -1;
				break;
			}
			b++;e--;
		}
	}

	if(ans > 0){
		ans = 0;

		int b = 0, e = Xary.size()-1;
		while(e-b>=0){
			if(Xary[b] != Xary[e]){
				ans += abs(Xary[b] - Xary[e]);
			}
			b++;e--;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 1100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int A,B,C,K,r;
	cin>>A>>B>>C>>K;
	
	if(A>max(B,C))
	{
		r=A*pow(2,K)+B+C;
	}
	else if(B>max(A,C))
	{
		r=B*pow(2,K)+A+C;
	}
	else
	{
		r=C*pow(2,K)+A+B;
	}
	cout<<r<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    int a, b, c, x;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int count = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            int y = x - 500 * i - 100 * j;
            if (y < 0) continue;
            if ((y / 50) <= c) count++;
        }
    }
    
    cout << count << endl;
    return 0;
}

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

int main(){
    //入力
    ll d;
    cin>>d;
    vector<ll> c;
    ll all_c=0;
    ll tmp;
    rep(i,26){
        cin>>tmp;
        c.push_back(tmp);
        all_c+=tmp;
    }
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i,d){
        rep(j,26){
            cin>>s.at(i).at(j);
        }
    }

    //初期化
    vector<ll> last;
    rep(i,26){
        last.push_back(0);
    }

    //計算
    ll now_score=0;
    ll score=0;
    ll complain;
    rep(i,d){
        //MAXのscoreを算出する
        ll ans=0;

        //1-26のコンテストを開いたときのscoreから、最大のものを選択する
        ll max_score=0;
        rep(n,26){
            score=now_score;

            complain=0;
            //不満を算出する
            rep(j,26){
                if(j!=n){
                    complain+=c[j]*(last[j]+1);
                }else{
                    last[j]=0;
                }
            }
            score = score + s[i][n] - complain;
            // cout<<n<<":"<<score<<endl;
            if(score>max_score){
                max_score=score;
                ans = n+1;
            }
        }
        cout<<ans<<endl;
        //lastの計算確定
        rep(j,26){
            if(j!=(ans-1)){
                last[j]+=1;
            }else{
                last[j]=0;
            }
        }
        now_score = score;
    }


   return 0;

}


Measured memory_bytes: 3716
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

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

  int cnt = 0;
  while (b <= a) {
    b *= 2;
    cnt++;
    if (cnt > k) {
      cout << "No" << endl;
      return 0;
    }
  }
  while (c <= b) {
    c *= 2;
    cnt++;
    if (cnt > k) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main (){
	int H,W,X;
	for(;;){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;
		X = W;
		while(X > 0){//一段目
				printf("#");
				X--;
		}

		printf("\n");
		X = W;

		while(H - 2 > 0){//最初と最後以外
			printf("#");
			while(X - 2 > 0){
				printf(".");
				X--;
			}
			X = W;
			printf("#\n");
			H--;
		} 

		X = W;

		while(X > 0){//最下段
				printf("#");
				X--;
		}
		printf("\n\n");
	}
	return 0;
}




Measured memory_bytes: 2036
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <locale>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define p_b(x) push_back(x)
#define m_p(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin>>n;
  vector<double> v(n);
  FORN(i,0,n) cin>>v[i];
  sort(v.begin(), v.end());
  FORN(i,1,n) v[i] = (v[i] + v[i-1]) / 2;
  cout<<fixed<<setprecision(10)<<v.back()<<endl;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 1; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N; cin >> N;
	double T, A; cin >> T >> A;
	vector<double> H(N+1);
	vector<double> t(N+1);
	rep(i, N+1) {
		cin >> H[i];
		t[i] = T - H[i] * 0.006;
	}

	double mi = 100000000;
	int ans = 1;
	rep(i, N+1) {
		if (abs(A - t[i]) < mi) {
			mi = abs(A - t[i]);
			ans = i;
		}
	}

	cout << ans << endl;
}

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

int main()
{
	char str[3];

	scanf("%s", str);
	if (!(strcmp(str, "RRR")))
		printf("3");
	else if (!(strcmp(str, "RRS")))
		printf("2");
	else if (!(strcmp(str, "SRR")))
		printf("2");
	else if (!(strcmp(str, "RSR")))
		printf("1");
	else if (!(strcmp(str, "SRS")))
		printf("1");
	else if (!(strcmp(str, "RSS")))
		printf("1");
	else if (!(strcmp(str, "SSR")))
		printf("1");
	else
		printf("0");
	return (0);
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
#define mp make_pair
#define fs first
#define sc second
#define pb push_back
#define mod 1000000009
using namespace std;

int n;
int a[200005];
int now[200005];
vector<int> ini[200005];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(a[i] >= i){
			cout << "-1\n";
			return 0;
		}
		ini[a[i]].pb(i);
	}

	memset(now, 0, sizeof(now));
	long long ans = 0;
	bool bisa = true;
	for(int i = 1; i <= n; i++){
		if(a[i] - a[i - 1] > 1){
			cout << "-1\n";
			return 0;
		}
		if(a[i] == a[i - 1] + 1){
			ans++;
		}else{
			ans += a[i];
		}
	}
	cout << ans << "\n";




}

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

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define MAX_N 400
#define INF 1e9
#define lt(a,b) (a-b < -EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }

double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

istream &operator >> (istream &is,Point &p){
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s),t(t) {}
};

int main(){
  int N;
  while(cin >> N, N){
    Point np(0,0);
    Vector v(0,1);
    vector<Point> p(N);
    for(int i = 0 ; i < N ; i++){
      cin >> p[i];
    }
    double res = 0;
    bool visited[MAX_N] = {false};
    for(int i = 0 ; i < N ; i++){
      int idx = -1;
      double min = INF,d = INF;
      for(int j = 0 ; j < N ; j++){
        if(visited[j]){ continue; }
        Vector v2 = p[j]-np;
        double angle = acos(dot(v,v2)/abs(v)/abs(v2));
        if(lt(angle,min)){
          d = dist(np,p[j]);
          min = angle;
          idx = j;
        }else if(equal(angle,min)){
          if(lt(dist(np,p[j]),d)){
            d = dist(np,p[j]);
            min = angle;
            idx = j;
          }
        }
      }
      visited[idx] = true;
      res += dist(np,p[idx]);
      v = p[idx]-np;
      np = p[idx];
    }
    printf("%.1f\n",res);
  }
  return 0;
}

Measured memory_bytes: 1324
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

signed main() {
    Fast();

    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, n * a) << endl;
    return 0;
}



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

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

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

int main() {
    long long a, b;
    while (cin >> a >> b) {
        if (a >= b) cout << GCD(a, b) << " " << LCM(a, b) << endl;
        else cout << GCD(b, a) << " " << LCM(b, a) << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#define ENUM 26

using namespace std;

int main(void) {
	int num, i = 0, cons[ENUM] = {0};
	long long ans = 1;
	string str;
	cin >> num >> str;
	for (; i < num; i++)
		cons[str[i] - 'a']++;
	for (i = 0; i < ENUM; i++) {
		if (cons[i] == 0)
			continue;
		ans *= (cons[i] + 1);
		ans %= (int)pow(10, 9) + 7;
	}
	if (ans == 0)
		printf("%d\n", (int)pow(10, 9) + 6);
	else
		cout << ans - 1 << "\n";
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
signed main() {
	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	for(int i = 0; i < h - b; i++) {
		for (int j = 0; j < w - a; j++) {
			cout << 1;
		}
		for (int k = w - a; k < w; k++) {
			cout << 0;
		}
		cout << endl;
	}
	for (int i = h - b; i < h; i++) {
		for (int j = 0; j < w - a; j++) {
			cout << 0;
		}
		for (int k = w - a; k < w; k++) {
			cout << 1;
		}
		cout << endl;
	}
	ggr
}



Measured memory_bytes: 1280
#include <stdio.h>

int main(){
    
    int a,b,c,i,count;
    count=0;
    scanf("%d %d %d", &a, &b, &c);
    for (i=a;i<=b;i++){
        if(c % i == 0){
            count=count+1;
        }
    }
    printf("%d\n",count);
    
    
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s,t;
    cin>>s>>t;
    int n = s.length() , m = t.length();

    vector<vector<int> > dp(n, vector<int> (m));
    
    for(int i = 0; i< n ; i++)
    {
        for(int j = 0; j< m; j++)
        {
            if(s[i] == t[j])
                dp[i][j] = 1 + (i>0&&j>0 ? dp[i-1][j-1]  : 0 ); 
            else 
                dp[i][j] = max( (i>0 ? dp[i-1][j] : 0) , (j> 0 ? dp[i][j-1] : 0));
        }
    }


    int  i = n-1 , j = m-1;
    string ans = "";
    while(i>=0&& j>=0)
    {
        if(i>0&&dp[i][j] == dp[i-1][j])
            i--;
        else if(j>0 && dp[i][j] == dp[i][j-1])
            j--;
        else if(i==0 || j==0)
        {
            if(dp[i][j]==1)
                ans = t[j--]  + ans , i--;
                
            else 
                i--, j--;
        }
        else if(i>0&&j>0)
                ans = t[j--] + ans, i--;
    }

    cout<<ans<<"\n";

}

Measured memory_bytes: 35584
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)n;++i)
typedef vector<int> vi;
 
int main()
{
    map<char, int> roma;
    roma.insert(make_pair('I', 1));
    roma.insert(make_pair('V', 5));
    roma.insert(make_pair('X', 10));
    roma.insert(make_pair('L', 50));
    roma.insert(make_pair('C', 100));
    roma.insert(make_pair('D', 500));
    roma.insert(make_pair('M', 1000));
 
    char str[128];

    while(scanf("%s", str) != EOF){
        int v = 0;
        rep(i, strlen(str)){
            if(i && roma[str[i-1]]<roma[str[i]])
                v -= roma[str[i-1]]*2;
            v += roma[str[i]];
        }
        printf("%d\n", v);
    }
}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    string s; cin>>s;
    int n=s.length();
    if(s[n-1]=='s')
    {
        s+="es";
    }
    else{
        s+="s";
    }
    cout<<s;
}

Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))
Aabs=[abs(A[i]) for i in range(N)]
c=sum([A[i]<0 for i in range(N)])
if c%2==0:
    print(sum(Aabs))
else:
    print(sum(Aabs)-2*min(Aabs))

Measured memory_bytes: 14412
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,x;
    string s;
    cin >> x >> a >> b; 
   if(abs(x-a) > abs(x-b))
        cout << "B" << endl;
    else cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int count = 0;
    while (true){
        if (*max_element(h.begin(), h.end()) == 0)
            break;
        int i = 0;
        while(i < n){
            if (h[i] == 0)
                i++;
            else{
                count++;
                while(i < n && h[i] > 0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

num=[]
for i in range(5):
    num.append(I())
k=I()
if num[-1]-num[0]>k:
    print(":(")
else:
    print("Yay!")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

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


int main(){
    int N;
    cin >> N;
    cout << (N + 1) / 2 << endl; 
}

Measured memory_bytes: 256
n = int(input())
x=0
while(1):
  if n ==2:
    break
  for i in range (int((-(-n**0.5//1)))):
    if n%(i+1)==0:
      x=x+1
  if x==1:
    break
  else:
    x=0
    n=n+1
print(n)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
    int N, d[55], x, i, j;
    scanf("%d", &N);
    for (i=1; i<=N; i++) scanf("%d", &d[i]);
    x=0;
    for (i=1; i<=N-1; i++) {
        for (j=i+1; j<=N; j++) {
            x+=d[i]*d[j];
            // printf("%d\n", d[i]*d[j]);
        }
    }
    printf("%d", x);
    return 0;
}


Measured memory_bytes: 128
import sys

input = sys.stdin.readline
N = int(input().strip())
alist = list(map(int,input().strip().split()))
blist = list(map(int,input().strip().split()))
clist = list(map(int,input().strip().split()))

sat = 0
prenum = 10000
for i in range(N):
	num = alist[i]-1
	sat = sat+blist[num]
	if num==prenum+1:
		sat = sat+clist[prenum]

	prenum = num


print(sat)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n;
    cin >> n;
    vi v(n);
    ll s = 0;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(rall(v));
    for(int i = 0; i < (n + 1) / 2; ++i){
        s += v[i];
    }
    for(int i = 1; i < n - (n + 1) / 2; ++i){
        s += v[i];
    }
    cout << s;
}

Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[] freq = new int[101];
		while (sc.hasNext())
			freq[sc.nextInt()]++;
		int max = 0;
		for (int i = 1; i < freq.length; i++)
			max = Math.max(max, freq[i]);
		for (int i = 1; i < freq.length; i++)
			if (freq[i] == max) System.out.println(i);
	}

}

Measured memory_bytes: 16316
#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
string a[50];
bool isw[50][50],isb[50][50],visited[50][50];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},h,w;
void dfsw(int x,int y){
	visited[x][y]=1;
	isw[x][y]=1;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx && nx<h && 0<=ny && ny<w && !visited[nx][ny] && a[nx][ny]=='.') dfsw(nx,ny);
	}
}
void dfsb(int x,int y){
	visited[x][y]=1;
	isb[x][y]=1;
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx && nx<h && 0<=ny && ny<w && !visited[nx][ny] && a[nx][ny]=='.') dfsb(nx,ny);
	}
}
int main(){
	while(true){
		cin>>w>>h;
		if(w==0)break;
		rep(i,h) rep(j,w) isw[i][j]=0,isb[i][j]=0;
		rep(i,h) cin >> a[i];
		rep(i,h) rep(j,w){
			if(a[i][j]=='W'){
				rep(ii,h) rep(jj,w) visited[ii][jj]=0;
				dfsw(i,j);
			}
			if(a[i][j]=='B'){
				rep(ii,h) rep(jj,w) visited[ii][jj]=0;
				dfsb(i,j);
			}
		}
		int cntb=0,cntw=0;
		rep(i,h) rep(j,w) if(a[i][j]=='.') {
			if(isw[i][j] && !isb[i][j]) cntw++;
			if(!isw[i][j] && isb[i][j]) cntb++;
		}
		cout << cntb << " " << cntw << endl;
	}
}

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

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	

	int a; 
	cin>>a;
	cout<<fixed<<setprecision(20)<<double(2*3.14*a);
	
	return 0;	
}

Measured memory_bytes: 3820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int x=Integer.parseInt(br.readLine());
		ArrayDeque<Integer> list=new ArrayDeque<Integer>();
		for (int i = 0; i < x; i++) {
			String s=br.readLine();
			if(s.charAt(0)=='i'){
				list.addFirst(Integer.parseInt(s.substring(7)));
			}
			else if(s.charAt(6)==' '){
				list.remove(Integer.parseInt(s.substring(7)));
			}else if(s.charAt(6)=='F'){
				list.removeFirst();
			}else{
				list.removeLast();
			
			}
		}
		int size=list.size();
		int i=0;
		for (Integer integer : list) {
			pw.print(integer);
			if(i<size-1)
				pw.print(" ");
			i++;
		}
		pw.println();
		pw.close();
	}

}

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

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

	int ANS = 0;
	for (int i = 0; i < 2; i++) {
		if (A >= B) {
			ANS += A;
			A--;
		}
		else {
			ANS += B;
			B--;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (;;) {
            int[] l = {sc.nextInt()-1,0,0,0,0};
            boolean[] t = new boolean[3];
            if (l[0]<0)break;
            t[l[0]] = true;
            for (int i = 1; i < 5; i++) {
                l[i] = sc.nextInt()-1;
                t[l[i]] = true;
            }
            for (int i = 0; i < 5; i++)
                if (t[0] ^ t[1] ^ t[2])
                    System.out.println(3);
                else
                    for(int j=0;j<3;j++)
                        if(l[i]!=j&&t[l[i]]&t[j])
                           System.out.println((l[i]-j+3)%3==2?1:2);
        }
    }
}


Measured memory_bytes: 28988
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            if (a[i] == i + 1) {
                count++;
                a[i + 1] = a[i];
            }
        }

        if (a[n - 1] == n) {
            count++;
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 50464
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include<set>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define DIVCEIL(a,b) ((a+b-1)/b)
//int CHMAX

int intpow(int a, int n) {
	// a^nのint ver
	rep(i, n - 1)
		a *= a;
	return a;
}
int MODPOW(int a, int n, int mod) {
	// a^n mod
	int ans = 1;
	while (n > 0) {
		if (n & 1)
			ans = ans * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ans;
}
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
	if (a == 0)
		return 1;
	else
		return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
int MODnPr(int n, int r, int mod) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++) {
		sum *= i;
		sum = sum % MOD;
	}
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
int NUMOFDIV(int n) {
	//約数の数（だっけ？）
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
int CEIL1(int n) {
	//1桁目切り上げ
	return (n + 9) / 10 * 10;
}
int DIGIT(int n, int k) {
	//nのk桁目
	rep(i, k - 1)
		n /= 10;
	return n % 10;
}
int DIGITSUM(int n) {
	int sum = 0, dig;
	while (n) {
		dig = n % 10;
		sum += dig;
		n /= 10;
	}
	return sum;
}
int DIVTIME(int n, int k) {
	//nをkで何回割れるか的な
	int div = 0;
	while (n % k == 0) {
		div++;
		n /= k;
	}
	return div;
}
int binary(int n) {
	//10進数→2進数
	int ans = 0;
	for (int i = 0; n > 0; i++) {
		ans += n % 2 * intpow(10, i);
		n /= 2;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool between(int x, int min, int max) {
	if (min < x && x < max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
// 順位付け
using namespace std;
#pragma endregion

signed main() {
	int N;
  	double M,sum=0;
	cin >> N >> M;
	vector <int> A(N);
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	sort(ALL(A), greater<int>());
	if (A[M - 1] < (double)sum / (4.0 * M))
		cout << "No";
	else
		cout << "Yes";
}

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

const int N_MAX = 3000;
double dp[N_MAX+1][N_MAX+1] = {0.0};

int main() {
  int N; cin >> N;
  dp[0][0] = 1.0;
  for(int i = 0; i < N; i++){
    double p; cin >> p;
    for(int j = 0; j <= i; j++){
      dp[i+1][j+1] += dp[i][j] * p;
      dp[i+1][j] += dp[i][j] * (1.0 - p);
    }
  }
  
  double ans = 0.0;
  for(int i = (N+1)/2; i <= N; i++){
    ans += dp[N][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 68864
N,W = map(int,input().split())
wv = [[int(x) for x in input().split()] for i in range(N)]
MAX_V = 1000*100 + 1
dp = [[0 if j==0 else 10**12 for j in range(MAX_V+1)] for i in range(N+1)]
for i in range(N):
    for sum_v in range(MAX_V+1):
        if wv[i][1] + sum_v < MAX_V+1 and dp[i+1][wv[i][1]+sum_v] > dp[i][sum_v] + wv[i][0]:
            dp[i+1][wv[i][1]+sum_v] = dp[i][sum_v] + wv[i][0]
        if dp[i+1][sum_v] > dp[i][sum_v]:
            dp[i+1][sum_v] = dp[i][sum_v]
result=0
for i in range(MAX_V+1):
    if dp[N][i] < W+1:
        result = i
print(result)

Measured memory_bytes: 173296