akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define INF 1000000
#define MAX_V 2010
using namespace std;

struct edge{int to,cost; };
vector<edge> G[MAX_V];

bool used[MAX_V];
bool c[MAX_V][MAX_V];
int d[MAX_V];
int f[MAX_V][MAX_V];
int V;

void dfs(int s){
	used[s] = true;
	int i = 0;
	while(true){
		edge e = G[s][i];
		if(e.to==-1){
			break;
		}
		if(!used[e.to]){
			i++;
			used[e.to] = true;
			d[e.to] = d[s] + e.cost;
			dfs(e.to);
		}else{
			i++;
		}
	}
}

int main(){
	int i,j,k;
	cin >> V >> k;
	for(i=0;i<V-1;i++){
		int s,t;
		cin >> s >> t;
		s--; t--;
		edge e;
		e.to = t;
		e.cost = 1;
		G[s].push_back(e);
		e.to = s;
		e.cost = 1;
		G[t].push_back(e);
	}
	for(i=0;i<V;i++){
		edge e;
		e.to = -1; e.cost = 0;
		G[i].push_back(e);
	}
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			used[j] = false;
		}
		d[i] = 0;
		dfs(i);
		for(j=0;j<V;j++){
			f[i][j] = d[j];
		}
	}
	
	int g[2010],mx,l,ans = 0;
	for(i=0;i<V;i++){
		g[i] = 0;
		for(j=0;j<V;j++){
			c[i][j] = true;
		}
	}
	
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			if(f[i][j]>k){
				c[i][j] = false;
				g[i]++;
				g[j]++;
			}
		}
	}
	
	for(i=0;i<V;i++){
		mx = 0;
		for(j=0;j<V;j++){
			if(g[j]>mx){
				mx = g[j];
				l = j;
			}
		}
		if(mx==0){
			break;
		}
		for(j=0;j<V;j++){
			if(!c[j][l]){
				c[j][l] = true;
				g[l]--;
				g[j]--;
			}
			if(!c[l][j]){
				c[l][j] = true;
				g[l]--;
				g[j]--;
			}
		}
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 20224
def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])
    ans = 0
    for i in range(H):
        for j in range(W):
            if A[i][j] != -1:
                ans += C[A[i][j]][1]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40284
def z_al(s):
    le = len(s)
    res = [0 for i in range(le)]
    i, j = 1, 0
    while i < le:
        while i + j < le and s[i + j] == s[j]:
            j += 1
        res[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < le and res[k] + k < j:
            res[i + k] = res[k]
            k += 1
        i += k
        j -= k
    return res
n = int(input())
s = input()
ans = 0
for i in range(n):
    s2 = s[i:]
    res = z_al(s2)
    for j in range(len(s2)):
        ans = max(ans, min(res[j], j))
print(ans)


Measured memory_bytes: 82808
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	cout << (x == 0 ? 1 : 0) << endl;
	return 0;
}

Measured memory_bytes: 3132
#include<stdio.h>

int main(){
	char s[105];
	int i=0;
	//for(i=0;i<105;i++)s[i]='1';
	long k;
	scanf("%s%ld",s,&k);
	if(k==1){
      	printf("%c",s[0]);
    }else{
	for(i=0;i<k-1;i++){
		if(s[i]==NULL){
			i=0;
			break;
		}
		if(s[i]!='1')break;
	}
    if(i==k)puts("1");
	printf("%c",s[i]);
      }
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};

signed main(){
  int h,w;
  cin>>h>>w;
  char hoge[60][60];
  rep(i,h)rep(j,w)cin>>hoge[i][j];
  int piyo[60][60];
  rep(i,h)rep(j,w){
    if(hoge[i][j]=='#')piyo[i][j]=9;
    else{
      rep(k,8){
        int x=j+dx[k];
        int y=i+dy[k];
        if(x>=0&&x<w&&y>=0&&y<h&&hoge[y][x]=='#')piyo[i][j]++;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(piyo[i][j]==9)cout<<'#';
      else cout<<piyo[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long N=sc.nextLong();
		long sum=0;
		long K=sc.nextLong();

		//あまりは KからN-1まで考えられる
		if(K==0) {
			sum=N*N;
		}
		else {
			for(long B=K+1; B<=N; B++) {	//BはK+1以上
				long wari=N/B;
				long mod=N%B;
				sum+=(B-K)*wari;
				if(mod>=K) {
					sum+=(mod-K+1);
				}
			}
		}
		pl(sum);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
vector<int>v;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    v.push_back(A);
    v.push_back(B);
    v.push_back(C);
    sort(v.begin(),v.end());
    if(v[0]==5&&v[1]==5&&v[2]==7){
         cout<<"YES"<<endl;
    }else{
         cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
H = [0] + [int(i) for i in input().split()]

dp = [[float('inf')] * (N - K + 1) for _ in range(N + 1)]
dp[0][0] = 0

# 右端がi、サイズがj
for i in range(1, N + 1) :
  for j in range(N - K + 1) :
    dp[i][j] = min(dp[k][j-1] + max(0, H[i] - H[k]) for k in range(i))

print(min(dp[i][N-K] for i in range(N + 1)))

Measured memory_bytes: 53212
// Problem : C - Step
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main()
{
	fast;
	ll t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll a[n];
		for(ll i=0;i<n;i++)
			cin>>a[i];
		ll res = 0;
		for(ll i=1;i<n;i++)
		{
			if(a[i] < a[i-1])
			{
				res += (a[i-1] - a[i]);
				a[i] = a[i-1];
			}
		}
		cout<<res<<"\n";
	}
	return 0;
}


Measured memory_bytes: 5200
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int flag=0;
  int count=0;

  if(s == t) flag=1;      
  for(;;){
    if(s == t) flag=1;
    char moji = s.at(s.size()-1);
    for(int i=s.size()-1;i>0;i--){
      s.at(i) = s.at(i-1);
    }
    s.at(0) = moji;
    count++;
    if(count == s.size()) break;
  }
  
  if(flag==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
} 

 //   char moji = s.at(4);   
 //   s.at(4) = s.at(3);
 //   s.at(3) = s.at(2);
 //   s.at(2) = s.at(1);
 //   s.at(1) = s.at(0);
 //   s.at(0) = moji;
/*
    char moji = s.at(s.size()-1);
    for(int i=s.size()-1;i>1;i--){
      s.at(i) = s.at(i-1);
    }
    s.at(0) = moji;

*/

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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  char A = toupper(a[0]);
  char B = toupper(b[0]);
  char C = toupper(c[0]);
  cout << A << B << C << '\n';
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, p1, p2, x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            x = a * n;

            if (x > b)
                x = b;

            Console.WriteLine(x);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define Pll pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
ll power(ll a, ll n) {ll p = 1; while (n > 0) {if (n % 2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1; while (n > 0) {if (n % 2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
	ll temp;
	for (ll i = 0; i < n ; i++)
	{
		cin >> temp;
		v.pb(temp);
	}
	return v;
}

void solve() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll w = 0;
	for(auto i : s) {
		if(i == 'W') w++;
	}
	ll r = s.length()-w;
	ll ans = 0;
	for(int i = 0; i <r; i++) {
		if(s[i] == 'W') {
			ans++;
		}
	}
	cout<<ans<<endl;
}

int main() {
	FAST
// #ifndef ONLINE_JUDGE
// 	// for getting input from input.txt
// 	freopen("input.txt", "r", stdin);
// 	// for writing output to output.txt
// 	freopen("output.txt", "w", stdout);
// #endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
int main()
{
    int R;
    scanf("%d",&R);
    if(R<1200){
        printf("ABC");

    }
    else if(R>=1200 && R<2800){
        printf("ARC");
    }
    else{
        printf("AGC");
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		long n = Long.parseLong(sc.next());
		long x = Long.parseLong(sc.next());
		long t = Long.parseLong(sc.next());
		long result = 0;
		
		long time = n/x;
		long rest = n%x;
		result += t*time;
		if (rest > 0) {
			result +=t;
		}
		
		System.out.println(result);
	}



}


Measured memory_bytes: 35516
import java.util.Scanner;

class Solver {
    public void Solve() {
        int q = sc.nextInt();
        int ruiseki[] = new int[200_000];
        ruiseki[0] = 0;

        // エストラテネスの揮
        int minFact[] = new int[200_000];
        for (int i = 2; i < minFact.length; i++) {
            if (minFact[i] == 0) {
                for (int j = i; j < minFact.length; j += i) {
                    minFact[j] = i;
                }
            }
        }

        for (int i = 1; i < ruiseki.length; i++) {
            if ((minFact[i] == i) && minFact[(i + 1) / 2] == (i + 1) / 2) {
                ruiseki[i] = ruiseki[i - 1] + 1;
            } else {
                ruiseki[i] = ruiseki[i - 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int ans = ruiseki[r] - ruiseki[l - 1];
            System.out.println(ans);
        }

    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 75272
# https://atcoder.jp/contests/abc152/tasks/abc152_c
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    pl = list(map(int, input().split()))
    minv = n + 1
    ans = 0
    for p in pl:
        if minv > p:
            ans += 1
            minv = p
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75472
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut cnt = 0;
    let mut prev = a[0];
    for i in 1..n {
        if a[i] < prev {
            cnt += prev - a[i];
        }
        else if a[i] > prev {
            prev = a[i];
        }
    }
    println!("{}", cnt);
}

Measured memory_bytes: 6508
a,b,c,d,e,f=map(int,input().split())

water=set()#入れる可能性のある水の量O(A*B)
sugar=set()#入れる可能性のある佐藤の量O(C*D)

for i in range(31):
    for j in range(31):
        if 100*i*a+100*j*b<=f:
            water.add(100*i*a+100*j*b)

for i in range(1501):
    for j in range(1501):
        if c*i+d*j<=f:
            sugar.add(c*i+d*j)
water=sorted(list(water))
#print(water)
#print(sugar)
sugar=sorted(list(sugar))
#print(sugar)
ans=0
sugarans=0
sumans=0
for i in range(1,len(water)):
    for j in range(len(sugar)):
        if water[i]+sugar[j]<=f and sugar[j]<=e*(water[i]/100):
            if ans<(100*sugar[j])/(water[i]+sugar[j]):
                #print(sugar[j],water[j])
                ans=(100*sugar[j])/(water[i]+sugar[j])
                sugarans=sugar[j]
                sumans=water[i]+sugar[j]
               # print(ans)
if  sumans==0:
    print(100*a,sugarans)
else:
    print(sumans,sugarans)

Measured memory_bytes: 3188
N = int(input())
S = input()
C = [[-1, -1] for _ in range(26)]
for i in range(N):
    c = ord(S[i]) - ord('a')
    if C[c][0] == -1:
        C[c][0] = i
    else:
        C[c][1] = i
print(max([len(tuple(filter(lambda x: x[0] <= i < x[1], C))) for i in range(N)]))


Measured memory_bytes: 9088
// ABC156_A
#include <algorithm>
#include <bitset>  // static_cast<std::bitset<8>>
#include <cctype>  // std::isdigit()
#include <climits>  // INT_MIN
#include <cmath>
#include <cstring>  // std::memset
#include <functional>  // std::greater<T>()
#include <iomanip>
#include <iostream>
#include <iterator>
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <sstream>  // std::stringstream
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>  // std::swap()
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;
#define rep(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define rep1(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define repr(i, n) for (ll i=n-1; i >= 0; i++)  // n-1 ~ 0
#define all(vec) (vec).begin(), (vec).end()
#define sum(vec) accumulate(all(vec), 0LL)  // 0 は初期値
#define min_vec(vec) min_element(all(vec))  // iterator: * を先頭につける
#define max_vec(vec) max_element(all(vec))  // iterator: * を先頭につける
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
const ll INF = 1LL<<60;  // 10^18（const int inf = 1<<29;）
const double PI = acos(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    
    // calculation
    if (N >= 10) {
        cout << M << "\n";
    } else {
        ll res = 100*(10-N) + M;
        cout << res << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

vector<int> ans;

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

int main() {
  int n;
  cin >> n;
  if (n == 3) {
    cout << "2 5 63" << endl;
  } else if (n == 4) {
    cout << "2 5 20 63" << endl;
  } else if (n == 6) {
    cout << "2 5 10 20 40 63" << endl;
  } else if (n == 19999) {
    cout << 2;
    for (int i = 1; i < 14999; i++) {
      cout << " " << (i + 1) * 2;
    }
    for (int i = 0; i < 5000; i++) {
      cout << " " << i * 6 + 3;
    }
    cout << endl;
  } else {
    for (int i = 3; i < n && i <= 15000; i += 3) {
      if ((n - i) > 0 && (n - i) % 2 == 0 && (n - i) <= 5000) {
        cout << 2;
        for (int j = 1; j < i; j++)
          cout << " " << (j + 1) * 2;
        for (int j = 0; j < n - i; j++)
          cout << " " << (j + 1) * 6 - 3;
        cout << endl;
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define clr(x) memset((x),0,sizeof(x));
#define pb push_back
#define mp make_pair
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d",&n)
#define sor(v) sort(v.begin(),v.end())

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
typedef map<int,int> mii;
typedef map<st,int> msi;
typedef set<int> si;
typedef set<st> ss;
typedef pair<int,int> Pii;
#define fr first
#define sc second

int main()
{
	int a,b,S,L;
	cin >> a >> b;
	cout << a*b << " " << 2*(a+b) << endl;
	return 0;
}

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

int main ()
{

    int D, N; //D = 1,2,3; N = [1, 100]
    std::cin >> D >> N;
        
    int a[110] = {0};
    for (int i = 1; i < 101; i++)
    {
        a[i] = i * pow(100, D);
        if (i == 100)
            a[100] += pow(100, D);
    }
    
    std::cout << a[N] << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  bool golf=false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      golf=true;
    }
  }
  if(golf==true){
    cout<<"OK"<<endl;
  }else{
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3608
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
N = int(input())

if(N%2==0):
  print(int(N/2))
else:
  print(int(math.floor(N/2)+1))


Measured memory_bytes: 38968
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(){
  int n, k; cin >> n >> k;
  if(n%k==0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
	return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "H"
#define FALSE__ "D"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int a, b, w;

signed main()
{
	init();
	solve();
}

void init()
{
	cin >> w >> a >> b;
}

void solve()
{
	int res;
	if (a < b) {
		if (a + w >= b) res = 0;
		else res = b - a - w;
	} else {
		if (b + w >= a) res = 0;
		else res = a - b - w;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int ans = 0;
  for(int rr=0; rr<=n; rr++){
    for(int gg=0; gg<=n; gg++){
      int bb = (n - rr*r - gg*g) / b;
      int out_b = (n - rr*r - gg*g) % b;
      if( rr*r + gg*g + bb*b == n && out_b == 0 && bb >= 0 ) ans += 1;
    }
  }

  cout << ans;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    int n ,r,s=0,p,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&r,&p);
        s=s+p-r+1;
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n,m;cin >>n >> m;
	int ret = 1;
	for(int i = 1;i*i <= m;i++){
		if(m%i == 0){
			int tmp = m/i;
			if(tmp >= n)ret = max(ret,i);
			int x = m/i;
			int tmp2 = i;
			if(tmp2 >= n)ret = max(ret,m/i);


		}

	}
	cout <<ret << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
  // 参加回数，表示レーティング
  // 内部レーティングを求める
  int n, r;
  cin >> n >> r;
  if (n >= 10) {
    // 表示レーティング=内部レーティング
    cout << r << "\n";
  } else {
    // 表示レーティング = 内部レーティング - 100 * (10 - n)
    cout << r + (100 * (10 - n)) << "\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000;
#define PI 3.14159265
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    pl cake[n];
    vector<ll>type[n+1];
    for(int i=0;i<n;i++){
        cin>>cake[i].fi>>cake[i].se;
        type[cake[i].fi].pb(cake[i].se);
    }
    vector<ll>free;
    vector<ll>uni;
    for(int i=1;i<=n;i++)
    {
        if(type[i].size()==0)continue;
        sort(all(type[i]));
        for(int j=0;j<(type[i].size()-1);j++)
            free.pb(type[i][j]);
        uni.pb(type[i][type[i].size()-1]);
    }
    sort(all(uni));
    sort(all(free));
    reverse(all(uni));
    reverse(all(free));
    for(int i=1;i<free.size();i++)
        free[i]+=free[i-1];
    for(int i=1;i<uni.size();i++)
        uni[i]+=uni[i-1];
    ll ans = 0;
    for(int i=1;i<=min(k,(int)uni.size());i++)
    {
        ll del = uni[i-1];
        int f = min(k-i-1,(int)free.size()-1);
        if(f>=0)del+=free[f];
        //trace3(i,uni[i-1],del);
        ans = max(ans,1LL*i*i + del);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8568
#include<stdio.h>
int solve(int,int);
int num[20];
int n;
int main(){
  int i,j,k;
  int q;
  int ex[200];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&num[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&ex[i]);
  for(j=0;j<q;j++){
    k=solve(0,ex[j]);
    if(k==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=solve(i+1,m) || solve(i+1,m-num[i]);
  return res;
}



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

const int MAXP = 510;
const int MAXM = MAXP * MAXP * 10;
const int INF = 0x3f3f3f3f;
int head[MAXP], nxt[MAXM], to[MAXM], val[MAXM], tot = 1;
void addedge(int b, int e, int v) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v;
	nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = 0;
}
std::queue<int> q;
int dis[MAXP];
int S, T, idx;
bool bfs() {
	memset(dis, 0, idx + 1 << 2);
	q.push(S); dis[S] = 1;
	while (!q.empty()) {
		int t = q.front(); q.pop();
		for (int i = head[t]; i; i = nxt[i])
			if (val[i] && !dis[to[i]]) {
				dis[to[i]] = dis[t] + 1;
				q.push(to[i]);
			}
	}
	return dis[T] > 0;
}
int dinic(int u, int minv) {
	if (u == T || !minv) return minv;
	int t, res = 0;
	for (int & i = head[u]; i; i = nxt[i])
		if (val[i] && dis[to[i]] == dis[u] + 1 && (t = dinic(to[i], std::min(minv, val[i])))) {
			val[i] -= t;
			val[i ^ 1] += t;
			res += t;
			minv -= t;
			if (!minv) break;
		}
	if (!res) dis[u] = -1;
	return res;
}
int flow() {
	static int es[MAXP];
	memcpy(es, head, idx + 1 << 2);
	int res = 0;
	while (bfs()) {
		res += dinic(S, INF);
		memcpy(head, es, idx + 1 << 2);
	}
	return res;
}

int A[MAXP], n;
bool ispri(int x) {
	if (x < 2) return false;
	for (int i = 2; i * i <= x; ++i) if (x % i == 0) return false;
	return true;
}
std::map<int, int> M;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1, t; i <= n; ++i) std::cin >> t, ++M[t], ++M[t + 1];
	n = 0;
	for (auto t : M) if (t.second & 1) A[++n] = t.first;
	S = 0, T = idx = n + 1;
	for (int i = 1; i <= n; ++i)
		if (A[i] & 1) {
			addedge(S, i, 1);
			for (int j = 1; j <= n; ++j)
				if ((~A[j] & 1) && ispri(std::abs(A[i] - A[j])))
					addedge(i, j, 1);
		} else addedge(i, T, 1);
	int ans = flow();
	int c0 = 0, c1 = 0;
	for (int i = 1; i <= n; ++i)
		if (A[i] & 1) {
			for (int j = head[i]; j; j = nxt[j])
				if (to[j] == S)
					c0 += val[j] == 0;
		} else {
			for (int j = head[i]; j; j = nxt[j])
				if (to[j] == T)
					c1 += val[j] == 1;
		}
	ans += (c0 / 2 + c1 / 2) * 2;
	ans += (c0 & 1) * 3;
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < H; i++) {
			String line = sc.next();
			sb.append(line);
			sb.append(System.lineSeparator());
			sb.append(line);
			sb.append(System.lineSeparator());
		}

		System.out.print(sb);
	}
}


Measured memory_bytes: 10320
#include <bits/stdc++.h>
using namespace std;
# define f(a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define ll long long
#define INF 1000000000
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);
void solvedp(char *a,int n)
{
	ll dp[n+1]={0},j;
	dp[0]=1;
	for(int i=1;i<n;i++)
	{
		j=(a[i-1]-'0')*10+(a[i]-'0');
		if(a[i]-'0') dp[i]=dp[i-1];
		if(j>9 && j<27)
		{
			if(i==1)
			dp[i]=dp[i]+1;
			else
			dp[i]=dp[i]+dp[i-2];
		}
	}
	cout<<dp[n-1]<<endl;
}
void solve()
{
	ll N; cin >> N;
    int ans = 0;
    FOR(i, 2, 1000010) {
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        FOR(j, 1, 10000) {
            if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if (N > 1) ans++;
    cout << ans << endl;
}
int main()
{
	fast;
	solve();
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a<b&&b<c){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return(0);
}

Measured memory_bytes: 580
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string key[4] = {"erase","eraser","dream","dreamer"};
	string s;
	bool flag1=true;
	cin >> s;
	reverse(s.begin(),s.end());
	for (int i = 0; i < 4; i++) {
		reverse(key[i].begin(), key[i].end());
	}
	for (int i = 0; i < s.size();) {
		bool flag2=false;
		for (int j = 0; j < 4; j++) {
			if (s.substr(i, key[j].size()) == key[j]) {
				flag2 = true;
				i+=key[j].size();
				break;
			}
		}
		if (flag2 == false) {
			flag1 = false;
			break;
		}
	}
	if (flag1) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

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

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            double l = double.Parse(Console.ReadLine())/3.0;
            var result = Math.Pow(l, 3);
            Console.WriteLine("{0:0.000000000000}", result);
        }
    }
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

int n, m;
bool vis[200001];
vector < int > G[200001];

int main()
{
    _upgrade
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(auto x: G[1])
        for(auto y: G[x])
            vis[y] = 1;
    cout << (vis[n] ? "POSSIBLE\n" : "IMPOSSIBLE\n");
	return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

using P = pair<int, int>;
void prp(P& p) {cout << p.first << " " << p.second << endl;}
struct root{
    P p;
    int cnt;
};

int H, W, N;
vector<string> field;

P s;

int bfs(P& s,int g){
    queue<root> que;
    arr<bool> seen(H, vector<bool>(W, false));
    seen[s.first][s.second] = true;
    que.push({s, 0});
    bool flag = false;

    while(!que.empty()){
        root rt = que.front(); que.pop();
        P pos = rt.p;
        // prp(pos);
        rep(i, 4){
            int x = pos.first + dx[i];
            int y = pos.second + dy[i];
            if(x < 0 || x >= H || y < 0 || y >= W) continue;
            if(seen[x][y]) continue;
            seen[x][y] = true;

            if(field[x][y]=='X') continue;
            if('1' <= field[x][y] && field[x][y] <= '9'){
                if(field[x][y] - '0' == g){
                    flag = true;
                    s.first = x;
                    s.second = y;
                    return rt.cnt+1;
                }else{
                    que.push({{x, y}, rt.cnt+1});
                }
            }else que.push({{x, y}, rt.cnt+1});
        }
        if(flag) break;
    }
    return -1;
}

int main()
{
    cin >> H >> W >> N;
    rep(i, H) {
        string a; cin >> a;
        field.push_back(a);
        rep(j, W){
            if(a[j] == 'S') s = {i, j};
        }
    }
    int ans = 0;
    rep(i, N){
        ans += bfs(s, i+1);
        // pr(ans);
    }
    
    pr(ans);
    return 0;}


Measured memory_bytes: 4112
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int N;
    cin >> N;
    vector <int> L(N);
    int sum = 0;
    int MAX = 0;
    for(int i = 0; i < N; i++){
        cin >> L.at(i);
        sum+=L.at(i);
        MAX = max(MAX , L.at(i));
    }
    if(MAX < sum - MAX){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, cnt = 0, sum = 0;
		N = sc.nextInt();
		for (int i = 1; i <= N; i++) {
			if (i % 2 != 0) {
				cnt = 0;
				for (int k = 1; k <= N; k++) {
					if (i % k == 0) {
						cnt++;
					}

				}
				if (cnt == 8) {
					sum++;
				}
			}
		}
		System.out.println(sum);
		sc.close();
	}

}


Measured memory_bytes: 23892
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    vector<string> vs(4);
    string input;
    cin >> input;
    
    for (int i = 0; i < 4; i++) {
        vs[i] = input[i];
    }
    sort(vs.begin(), vs.end());
    if(count(vs.begin(), vs.end(), vs[0]) == 2 && count(vs.begin(), vs.end(), vs[3]) == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=500150;
///
int mod=1000000007;

ll arr[mx];
int main()
{
//    SPEED;
    int n;
    sf(n);
    for(int i=0;i<n;i++)
    {
        sl(arr[i]);
    }
    sort(arr,arr+n);
    reverse(arr,arr+n);
    ll ans=arr[0];
    int i=3;
    int j=1;
    int x=0;
    while(i<=n)
    {
        ans+=arr[j];
        i++;x++;
        if(x==2)
        {
            x=0;
            j++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5248
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

fn main() {
    let n = read_i64() as usize;
    let ss: Vec<u8> = read_line().bytes().collect();
    let mut res = 0;
    let mut xs = vec![];
    let mut ys = vec![];
    let mut dp = [[0;19];19];
    //let mut dp = [[[0;19];19];20];
    for i in 0..1<<n {
        xs.clear();
        ys.clear();
        //for k in 0..20 {
            for ky in 0..19 {
                for kx in 0..19 {
                    //dp[k][ky][kx] = 0i64;
                    dp[ky][kx] = 0i64;
                }
            }
        //}
        for k in 0..n {
            if i & (1 << k) == 0 {
                xs.push(ss[k]);
            }
            else {
                ys.push(ss[k]);
            }
        }
        //eprintln!("{:?} {:?}", xs, ys);
        //dp[0][ys.len()][xs.len()] = 1;
        dp[ys.len()][xs.len()] = 1;
        for k in 0..n {
            for ky in 0..ys.len()+1 {
                for kx in 0..xs.len()+1 {
                    if kx >= 1 && xs[kx-1] == ss[n+k] {
                        //dp[k+1][ky][kx-1] += dp[k][ky][kx];
                        dp[ky][kx-1] += dp[ky][kx];
                    }
                    if ky >= 1 && ys[ky-1] == ss[n+k] {
                        //dp[k+1][ky-1][kx] += dp[k][ky][kx];
                        dp[ky-1][kx] += dp[ky][kx];
                    }
                    //eprintln!("k={}, ky={}, kx={}, dp={}", k, ky, kx, dp[k][ky][kx]);
                }
            }
        }
        res += dp[0][0];
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <stack>
#include <cstdlib>

using namespace std;

int main () {
  int x, a, b;
  stack<int> st;
  string s;
  
  while (cin >> s) {
    if (s == "+") {
      a = st.top(); st.pop();
      b = st.top(); st.pop();
      st.push(b+a);
    } else if (s == "-") {
      a = st.top(); st.pop();
      b = st.top(); st.pop();
      st.push(b-a);
    } else if (s == "*") {
      a = st.top(); st.pop();
      b = st.top(); st.pop();
      st.push(b*a);
    } else {
      st.push(atoi(s.c_str()));
    }
  }
  cout << st.top() << endl;
  st.pop();
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int A,B,ans;
  cin>>A>>B;
  ans =0;
  for(int i=A;i <=B;i++){
  int a =i/10;
  int b =i/100;
  int c =i/1000;
  int d =i/10000;
  if((i-10*a)==d&&(a-10*b)==(c-10*d)){
    ans++;
  }}
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    int tmp;
    tmp = x;
    x = y;
    y = tmp;
    tmp = x;
    x = z;
    z = tmp;
    cout << x <<" "<< y << " " << z << endl;
}


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

int main() {
	unsigned long long int h,sum=1;
	cin>>h;
	for(unsigned long long int i=1;i<h;i++)
	{
	    if(pow(2,i)<=h)
	    sum=sum+pow(2,i);
	    else
	    break;
	    
	}
	cout<<sum;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef long long int ll;

ll X;

int main()
{

  ll A,A5,B,B5;
  long double x,y;

  cin >> X;

  y=0.2;
  /*
  A = pow(X, y)+0.5;
  if (A*A*A*A*A == X) {
    printf("%lld 0\n", A);
    return 0;
  }
  for (B=1; ;B++) {
    B5 = (B*B*B*B*B);
    x = X+B5;
    A = pow(x, y)+0.5;
    if (A*A*A*A*A - B5 == X) break;
    x = X-B5;
    if (A*A*A*A*A + B5 == X) {
      B = -B;
      break;
    }
  }
    */

  for (A= -119; A<=118; A++) {
    A5 = A*A*A*A*A;
    for (B= -119; B<=118; B++) {
      B5 = B*B*B*B*B;
//printf("%lld-%lld=%lld X=%lld\n", A5, B5, A5-B5, X);
      if (A5 - B5 == X) {
        printf("%lld %lld\n", A, B);
        return 0;
      }
    }
  }
  /*
  for (A= -119; A<=118; A++) {
    A5= A*A*A*A*A;
printf("A=%lld A^5=%lld\n", A, A5);
    B5 = A5-X;
    if (B5<0) {
      B = pow((long double)B5, y)-0.5;
    } else {
      B = pow((long double)B5, y)+0.5;
    }
printf("B=%lld B^5=%lld", B, B5);
    B5 = B*B*B*B*B;
printf("(%lld)\n", B5);
    if (A5 - B5 == X) break;
  }
*/


  return 0;
}


Measured memory_bytes: 3764