akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int n;
vector<vector<int>> g(1000010);
vector<bool> used(1000010,false);
vector<int> dp(1000010,-1);

int dfs(int v){
  if(used[v]) return dp[v];
  used[v]=true;
  int ret=0;
  for(auto itr:g[v]){
    int now=dfs(itr);
    if(now==-1){
      ret=-1;
      break;
    }
    chmax(ret,dfs(itr));
  }
  if(ret==-1) return -1;
  return dp[v]=ret+1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n)rep(j,n-1){
    cin>>a[i][j];
    a[i][j]--;
  }
  vector<vector<int>> num(n,vector<int>(n));
  int now=0;
  rep(i,n)FOR(j,i+1,n){
    num[i][j]=now;
    now++;
  }
  //cout<<num<<endl;
  rep(i,n)rep(j,n-2){
    int u=i,v=a[i][j];
    if(u>v) swap(u,v);
    int now=num[u][v];
    int k=i,l=a[i][j+1];
    if(k>l) swap(k,l);
    int nex=num[k][l];
    g[now].push_back(nex);
  }
  rep(i,now){
    if(!used[now]){
      int ret=dfs(i);
      if(ret==-1){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  int ans=0;
  rep(i,now){
    if(dp[i]==-1){
      cout<<-1<<endl;
      return 0;
    }
    chmax(ans,dp[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 51328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  ll N, M;
  cin >> N >> M;
  vector< vector<ll> > tree(3 * N); // We use 3 * N vertices.
  rep(i, M) {
    ll u, v;
    cin >> u >> v;
    --u; --v; // 0-indexed.
    // u -> v is treated as u0->v1, u1->v2, u2->v0.
    tree[u].push_back(v + N);
    tree[u + N].push_back(v + 2 * N);
    tree[u + 2 * N].push_back(v);
  }
  ll s, t;
  cin >> s >> t;
  --s; --t;

  // Dijkstra
  // Calculate the shortest path from s with Dijkstra.
  vector<ll> d(3 * N, INF);
  d[s] = 0;
  priority_queue<P, vector<P>, greater<P> > q;
  q.push(P(0, s));

  while (!q.empty()) {
    P p = q.top(); q.pop();
    ll v = p.second;
    if (d[v] < p.first) { continue; }  // Already updated.
    for (auto u : tree[v]) {
      if (d[u] > d[v] + 1) {
        d[u] = d[v] + 1;
        q.push(P(d[u], u));
      }
    }
  }

  if (d[t] == INF) { // can't reach
    cout << -1 << endl;
  } else {
    cout << d[t] / 3 << endl;
  }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  int result = -1; 
  rep(i,100000) if (floor((double)i*1.08)==N) result = i;
  if (result==-1) cout << ":(" << endl;
  else cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

a, b = [0] * n, [0] * n
c, d = [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())
for i in range(n):
    ans = 0
    min = 10 ** 20
    for j in range(m):
        dis = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if min > dis:
            min = dis
            ans = j + 1
    print(ans)

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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k ;
  int A = e-a ;
  if (A<=k){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            Console.WriteLine(S.Distinct().Count() == 2 && S.Count(t => t == S[0]) == 2 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
    int N;
    cin >> N;
    string S;
    vector<string> vec = { "A" };
    for (int i = 0; i < N; i++) {
        cin >> S;
        for (int j = 0; j < vec.size(); j++) {
            if (vec.at(j) == S) {
                break;
            }
            else if (vec.at(j) != S && j + 1< vec.size()) {
                continue;
            }
            else if (vec.at(j) != S && j + 1== vec.size()) {
                vec.push_back(S);
            }
        }
    }
    debug(vec.size());
    for (int j = 0; j < vec.size(); j++){
        debug(vec[j]);
    }
    
    vec.pop_back();
    if (vec.size() == 3) {
        cout << "Three" << endl;
    }
    else if (vec.size() == 4) {
        cout << "Four" << endl;
    }
}

Measured memory_bytes: 3560
n = int(input())
#h, w = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [input() for i in range(h)]

for i in range(0,n//4 + 1):
  for j in range(0,n//7+1):
    if i * 4 + j * 7 == n:
      print("Yes")
      quit()
print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
	int s;
	cin>>s;
	map<int,int> m;
	int cnt = 0;
	int r = s;
	m[r]=0;
	while(true){
		if(r % 2 == 0){
			r = r / 2;
			cnt++;
			if(m.find(r) != m.end()){
				cout<<cnt + 1<<endl;
				return 0;
			}
			m[r] = cnt;
		}
		else{
			r = r * 3 + 1;
			cnt++;
			if(m.find(r) != m.end()){
				cout<<cnt + 1<<endl;
				return 0;
			}
			m[r] = cnt;
		}
		//	cout<<r<<" ";
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int n,k,c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  string t=s;
  vector<int> f={},l={};
  int count = 0;
  rep(i,n){
    if(t.at(i)=='x') continue;
    if(t.at(i)=='o'){
      f.push_back(i);
      count++;
      if(count==k) break;
      for(int j=i+1;j<min(i+c+1,n);j++)
        t.at(j)='x';
    }
  }
  //cout<<t<<endl;
  
  reverse(all(s));
  t=s;
   rep(i,n){
    if(t.at(i)=='x') continue;
    if(t.at(i)=='o'){
      l.push_back(i);
      count++;
      if(count==k) break;
      for(int j=i+1;j<min(i+c+1,n);j++)
        t.at(j)='x';
    }
  }

  rep(i,k){
    if(f.at(i)==(n-1-l.at(k-1-i)))
      cout<<f.at(i)+1<<endl;
  }
  //rep(i,k)
    //cout<<f.at(i)<<"  "<<n-1-l.at(i)<<endl;
}

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

#define ll long long
using namespace std;

const int _M=1e5+40;

ll a[_M],t[_M],ans[_M],k=0;

struct
{
    int x,y;
} e[_M];

int fd(int x)
{
    return x==a[x]?x:a[x]=fd(a[x]);//记得要压缩路径
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)a[i]=i,t[i]=1;
    for(int i=1; i<=m; i++)
        scanf("%d%d",&e[i].x,&e[i].y);
    ll an=(ll)n*(ll)(n-1)/2;   //当将int类型的变量运算后赋值给long long 类型的变量是记得要强转
    ans[k++]=an;
    for(int i=m; i>=1; i--)
    {
        int ra=fd(e[i].x),rb=fd(e[i].y);
        if(ra!=rb)
        {
            an-=((ll)t[ra]*(ll)t[rb]);
            t[ra]+=t[rb];
            a[rb]=ra;
        }
        ans[k++]=an;
    }
    k-=2;
    while(k>=0)
        printf("%lld\n",ans[k--]);
    return 0;
}






Measured memory_bytes: 4480
S = input()
n = len(S)
ans = 0

for i in range(2**(n-1)):
    mode = ['-']*(n-1)
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            mode[j] = '+'
    
    val = S[0]
   
    for k in range(len(mode)):
        if mode[k] == '+':
            val += '+'
            val += S[k + 1]
        else:
            val += S[k + 1]

    ans += eval(val)
print(ans)   


Measured memory_bytes: 9124
n = gets.to_i
a =[]
n.times do a << gets.to_i end
a = a.sort
i = 0
s = 0
while i < n do
  if i < n-1 && a[i] == a[i+1]
    i += 1
  else
    s += 1
  end
  i += 1
end
p s


Measured memory_bytes: 4528
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
 
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    vector<int> B(n),C(n-1);
    rep(i,n-1){
        cin>>B[i];
    }
    int sum = 0;
    sum = sum + B[0];
    B[n-1] = 100000;
    rep(i,n-1){
        sum = sum + min(B[i],B[i+1]);
    }
    cout<<sum<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
import collections
h,w = map(int,input().split())
a = []
cnt = 0
for i in range(h):
    aa = list(input())
    c = collections.Counter(aa)
    cnt += c['#']
    a.append(aa)
cnt -= 1
if cnt == h+w-2:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3316
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        s:Chars,
        t:Chars,
    }
    let mut ans = 0;
    for (s, t) in s.iter().zip(t.iter()) {
        if s != t {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3940
void main()
{
    long n, k;
    rdVals(n, k);
    Pair[] pair = n.rdCol!Pair;

    pair.sort!"a.b > b.b";
    bool[] check = new bool[n+1];
    Pair[] a, b;
    foreach (p; pair)
    {
        if (check[p.a])
        {
            b ~= p;
        }
        else
        {
            a ~= p;
            check[p.a] = true;
        }
    }

    a.sort!"a.b > b.b";
    long[] c = new long[n+1];
    foreach (i, x; a)
    {
        c[i+1] = c[i] + x.b;
    }

    b.sort!"a.b > b.b";
    long[] d = new long[n+1];
    foreach (i, x; b)
    {
        if (k - i - 1 <= 0) break;
        d[k-i-1] = d[k-i] + x.b;
    }

    long result;
    foreach (i; 1 .. k+1)
    {
        if (c[i] == 0) break;
        result = max(result, c[i]+d[i]+i^^2);
    }

    result.writeln;
}

struct Pair
{
    long a, b;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 9596
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	hei(llint) r(a), g(b);
	llint ans = 0;
	hei(llint) z;
	rep(i, 0, a)cin >> r[i];
	rep(i, 0, b)cin >> g[i];
	rep(i, 0, c) {
		int d;
		cin >> d;
		z.push_back(d);
	}
	sort(r.begin(), r.end());
	reverse(r);
	sort(g.begin(), g.end());
	reverse(g);
	rep(i, 0, x)z.push_back(r[i]);
	rep(i, 0, y)z.push_back(g[i]);
	sort(z.begin(),z.end());
	reverse(z);
	rep(i, 0, (x + y)) {
		ans += z[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

struct edge {
    ll to, cost;
    edge(ll to = 0, ll cost = 0) : to(to), cost(cost) {}
};

// p : (cost, position)
using p = pair<ll, ll>;

void djikstra(vector<ll> &d, vector<vector<edge>> &g, ll start) {
    ll inf = 1LL << 60;
    fill(d.begin(), d.end(), inf);
    d[start] = 0;

    priority_queue<p, vector<p>, greater<p>> q;
    q.push(p(0, start));

    while (!q.empty()) {
        p now = q.top();
        q.pop();
        ll now_cost = now.first, now_position = now.second;
        if (d[now_position] < now_cost)
            continue;
        for (edge e : g[now_position]) {
            if (d[e.to] > d[now_position] + e.cost) {
                d[e.to] = d[now_position] + e.cost;
                q.push(p(d[e.to], e.to));
            }
        }
    }
}

const ll coin_max = 3000;
ll make_num(ll v_num, ll coin_num) {
    coin_num = min(coin_num, coin_max - 1);
    return v_num * coin_max + coin_num;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, s;
    cin >> n >> m >> s;
    vector<vector<edge>> g(n * coin_max);
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        repd(coin, a, coin_max) {
            ll from = make_num(u, coin), to = make_num(v, coin - a);
            g[from].push_back(edge(to, b));
            from = make_num(v, coin), to = make_num(u, coin - a);
            g[from].push_back(edge(to, b));
        }
    }
    rep(i, n) {
        ll c, d;
        cin >> c >> d;
        rep(coin, coin_max) {
            ll from = make_num(i, coin), to = make_num(i, coin + c);
            g[from].push_back(edge(to, d));
        }
    }

    vector<ll> d(n * coin_max);
    djikstra(d, g, make_num(0, s));

    ll inf = 1LL << 60;
    repd(t, 1, n) {
        ll ans = inf;
        rep(i, coin_max) {
            ll num = make_num(t, i);
            ans = min(ans, d[num]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 27584
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <locale>
#include<set>



using namespace std;

#define MAX 200000
int main() {

long long n,m,i,j,k,fow,pt=0,ans=0;
cin>>n>>m;

if(n==1&&m==1)ans=1;
else if(n==1)ans=m-2;
else if(m==1)ans=n-2;
else ans=(m-2)*(n-2);



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


Measured memory_bytes: 256
#include <stdio.h>
#define N 8
#define FREE 1
#define NOTFREE -1

int row[N],col[N],dpos[N+N-1],dneg[N+N-1];
int a[N][N];

void printBoard(void);

void putQueen(int i){
  int j;

  if(i == N){
    printBoard();
    return;
  }

  for(j = 0; j < N; j++){
    if(col[j] == NOTFREE || dpos[i+j] == NOTFREE || dneg[i-j+N-1] == NOTFREE){
      continue;
    }

    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOTFREE;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){
  int k,r,c;
  int i;
  int j;

  scanf("%d",&k);
  for(i = 0; i < N; i++){
    row[i] = 0;
    col[i] = 0;
  }

  for(i = 0; i < N; i++){
    for(j = 0; j< N; j++){
      a[i][j] = 0;
    }
  }

  for(i = 0; i < N+N-1; i++){
    dpos[i] = 0;
    dneg[i] = 0;
  }

  for(i = 0; i < k; i++){
    scanf("%d%d",&r,&c);
    a[r][c] = 1;
  }
  putQueen(0);

  return 0;
}

void printBoard(){
  int i, j;
  
  for(i=0; i<N; i++){
    for(j=0; j<N; j++){
      if(a[i][j]){
    if(row[i]!=j) return;
      }
    }
  }
   
  for(i=0; i< N; i++){
    for(j=0; j< N; j++){
      if(row[i]==j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }


}

Measured memory_bytes: 572
INF = float('inf')


def f(H, W):
    return min(f1(H, W), f1(W, H))


def f1(H, W):
    result = INF
    for h in range(1, H):
        t = [h * W] + f2(H - h, W)
        t.sort()
        if abs(t[0] - t[2]) < result:
            result = abs(t[0] - t[2])
        t = [h * W] + f2(W, H - h)
        t.sort()
        if abs(t[0] - t[2]) < result:
            result = abs(t[0] - t[2])
    return result


def f2(H, W):
    if H < 2:
        return [-INF, INF]
    h = H // 2
    return [h * W, (H - h) * W]


H, W = map(int, input().split())

print(f(H, W))


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

int main(){
    int r;
    double ans;
    cin >> r;
    ans = r * 2.0 * PI;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
import sys
readline = sys.stdin.readline
from operator import itemgetter
class UnionFind:
    __slots__ = ['p', 'rank']
    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n
    def find_root(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_root(self.p[x])
        return self.p[x]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)
        if u == v: return
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
        else:
            self.p[v] = u
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1
n, m = map(int, readline().split())
edges = [tuple(map(int, readline().split())) for _ in [0] * m]
edges.sort(key=itemgetter(2), reverse=True)
uf = UnionFind(n)
ans = 0
for _ in [0] * (n - 1):
    while edges:
        s, t, w = edges.pop()
        if not uf.same(s, t):
            uf.unite(s, t)
            break
    ans += w
print(ans)

Measured memory_bytes: 26396
import sys

sys.setrecursionlimit(4100000)
N = int(input())
graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    u,v,w = map(int,input().split(' '))
    graph[u].append((v,w))
    graph[v].append((u,w))

color_list = [-1]*(N+1)
color_list[1] = 0
'''
for i in range(1,N+1):
    for node in graph[i]:
        if node[1]%2 ==0:
            num =  color_list[i]
        else:
            num =  0 if color_list[i] == 1 else 1
        if color_list[node[0]] == -1:
            color_list[node[0]] = num
'''
def search(n):
    for node in graph[n]:
        if node[1]%2 ==0:
            num =  color_list[n]
        else:
            num =  0 if color_list[n] == 1 else 1
        if color_list[node[0]] == -1:
            color_list[node[0]] = num
            search(node[0]) 
search(1)
#print(color_list)
for i in range(1,N+1):
    print(color_list[i])


Measured memory_bytes: 79408
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#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
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	void solve()
	{
		ll int n;
		
		cin>>n;
		ll int all=power(10,n,mod);
		ll int no_0=power(9,n,mod);
		ll int no_9=power(9,n,mod);
		ll int no_09=power(8,n,mod);
		ll int ans=all%mod;
		ll int d=add(no_0,no_9);
		d=add(d,-no_09);
		ans=add(ans,-d);
      if (ans<0)ans+=mod;
		ans=ans%mod;


		cout<<ans<<endl;

	
	}
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

Measured memory_bytes: 3636
#include<cstdio>
    long long a[105];
    int main()
    {
        int n;scanf("%d",&n);
        a[0]=2;a[1]=1;
        for(int i=2;i<=n;i++) a[i]=a[i-1]+a[i-2];
        printf("%lld\n",a[n]);
        return 0;
    }

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll a,b,c,k;cin>>a>>b>>c>>k;
  if(k<=a+b){
    cout<<min(a,k)<<ENDL;
  }else{
    cout<<a-(k-a-b)<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Xi Lin
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int D = in.nextInt();
            int r = A * B;
            if (C * D > r) r = C * D;
            out.println(r);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 8524
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long> a(n), le(n), ri(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 1; i < n; i++) a[i] += a[i - 1];
  int l = -1, r = n - 1;
  auto query = [&](int x, int y){
    if(x > y) return 0ll;
    long long ans = a[y];
    if(x) ans -= a[x - 1];
    return ans;
  };
  auto fdx = [&](int x, int y, int z){
  	return abs(query(x, y) - query(y + 1, z));
  };
  for(int i = 0; i < n; i++){
  	while(l + 1 < i && fdx(0, l, i) >= fdx(0, l + 1, i)) l++;
    le[i] = l;
  }
  for(int i = n - 1; i >= 0; i--){
    while(r - 1 > i && fdx(i, r, n - 1) >= fdx(i, r - 1, n - 1)) r--;
    ri[i] = r;
  }
  long long ans = 1ll<<60;
  for(int i = 0; i < n - 1; i++){
    {
      long long a = query(0, le[i]);
      long long b = query(le[i] + 1, i);
      long long c = query(i + 1, ri[i + 1] - 1);
      long long d = query(ri[i + 1], n - 1);
      ans = min(ans, max({a, b, c, d}) - min({a, b, c, d}));
    }
    {
      long long a = query(0, le[i]);
      long long b = query(le[i] + 1, i);
      long long c = query(i + 1, ri[i + 1]);
      long long d = query(ri[i + 1] + 1, n - 1);
      ans = min(ans, max({a, b, c, d}) - min({a, b, c, d}));
    }
    {
      long long a = query(0, le[i] - 1);
      long long b = query(le[i], i);
      long long c = query(i + 1, ri[i + 1] - 1);
      long long d = query(ri[i + 1], n - 1);
      ans = min(ans, max({a, b, c, d}) - min({a, b, c, d}));
    }
    {
      long long a = query(0, le[i] - 1);
      long long b = query(le[i], i);
      long long c = query(i + 1, ri[i + 1]);
      long long d = query(ri[i + 1] + 1, n - 1);
      ans = min(ans, max({a, b, c, d}) - min({a, b, c, d}));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;

struct GreaterPII {
    bool operator() (const PII & a, const PII & b) const {
        return a.second > b.second;
    }
};


int main() {
    int n, s;
    char d;
    vector<PII> p_map;
    while (cin >> n >> d >> s) {
        if (n == 0 && s == 0) break;
        p_map.push_back(PII(n, s));
    }
    stable_sort(p_map.begin(), p_map.end(), GreaterPII());
    int q; int prev;
    int rank[p_map.size()];
    for (int i = 0; i < p_map.size(); i++) {
        rank[p_map[i].first] = rank[p_map[i-1].first]+1;
        if (prev == p_map[i].second) {
            rank[p_map[i].first] = rank[p_map[i-1].first];
        }
        prev = p_map[i].second;
    }
    while (cin >> q) {
        cout << rank[q] << endl;
    }
    return 0;
}
        

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


int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int tmp = a[0];
    int cnt = 1;
    if (tmp == 2) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        tmp = a[tmp-1];
        ++cnt;
        if (tmp == 2) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){
    int n;
    cin>>n;
    vector<long long> A(n);

    rep(i,n)cin>>A[i];
    sort(A.begin(),A.end());


    int q;
    cin>>q;

    long long T[n];

    rep(i,q)cin>>T[i];
    int ans=0;

    rep(i,q){
        long long target=T[i];

        long long left=0;
        long long right=n-1;
        /*
        if(left==right){
            if(A[0]==T[0])ans=1;
        }
        */
        bool exist=false;
        long long mid=(left+right)/2;

        while(left<=right){
            mid=(left+right)/2;
            if(A[mid]>target){
                right=mid-1;
            }
            else if(A[mid]<target){
                left=mid+1;
            }
            else{
                exist=true;
                //cout<<mid<<" ";
                break;
            }
            
        }
        if(exist)ans++;

    }
    //cout<<endl;
    cout<<ans<<endl;

    return 0;

}
/*

3
1 2 3
1
4
*/



Measured memory_bytes: 3952
#include <array>
#include <iostream>

using namespace std;
constexpr uint64_t mod = 1e9 + 7;

template<int N>
constexpr array<int, N + 1> factorial_table() {
  array<int, N+1> ans;
  ans[0] = 1;
  for (uint64_t i = 1; i <= N; i++)
    ans[i] = i;
  for (uint64_t i = 2; i <= N; i++) {
    ans[i] = (ans[i] * ans[i - 1]) % mod;
  }
  return ans;
}

constexpr uint64_t mod_pow(uint64_t num, uint64_t p) {
  uint64_t ans = 1;
  num %= mod;
  while (0 < p) {
    if (p & 1) {
      ans = (ans * num) % mod;
    }
    num = (num * num) % mod;
    p >>= 1;
  }
  return ans;
}

template <typename table>
uint64_t comb(const table& factorial, uint64_t x, uint64_t y) {
  if (x == 0 || y == 0)
    return 1;
  uint64_t div_num = (factorial[x - y] * factorial[y]) % mod;
  return (factorial[x] * mod_pow(div_num, mod - 2)) % mod;
}

const auto table = factorial_table<200005>();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  uint64_t h, w, a, b;
  cin >> h >> w >> a >> b;

  uint64_t count = 0;
  for (uint64_t i = 1; i <= w - b; ++i) {
    uint64_t left_upper = comb(table, (h - a - 1) + (b + i - 1), h - a - 1) % mod;
    uint64_t right_bottom = comb(table, (w - b - i) + (a - 1), a - 1) % mod;
    count = (count + left_upper * right_bottom) % mod;
  }

  cout << count << "\n";
}


Measured memory_bytes: 1152
//Love and Freedom.
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#define inf 20021225
#define ll long long
#define N 810
#define pa pair<int,int>
using namespace std;
int read()
{
	int f=1,s=0; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9')	s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int n,m,k,dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};
int F(int x,int y){return min(min((x-1+k-1)/k,(y-1+k-1)/k),min((n-x+k-1)/k,(m-y+k-1)/k));}
int ans=inf; bool vis[N][N]; int dis[N][N];
queue<pa> q;
char ch[N];
int main()
{
	n=read(),m=read(),k=read(); int x,y;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch+1);
		for(int j=1;j<=m;j++)
			if(ch[j]=='#')	vis[i][j]=1;
			else if(ch[j]=='S') q.push(make_pair(i,j));
	}
	while(!q.empty())
	{
		pa tmp=q.front(); x=tmp.first,y=tmp.second; q.pop();
		ans=min(ans,F(x,y)+1);
		if(dis[x][y]==k)	continue;
		for(int i=0;i<4;i++)
		{
			int nx=x+dx[i],ny=y+dy[i];
			if(!nx||!ny||nx>n||ny>m||vis[nx][ny])	continue;
			vis[nx][ny]=1; dis[nx][ny]=dis[x][y]+1; q.push(make_pair(nx,ny));
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3456
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int a[maxn], b[maxn], c[maxn], dp[maxn][3];

int N;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	// 
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i] >> b[i] >> c[i];
	//
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 1; i < N; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	//
	cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << "\n";
}



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

const double PI = acos(-1);

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

    cout << setprecision(10) << fixed;

    double r;   cin >> r;

    cout << 2 * PI * r << '\n';

    return 0;
}


Measured memory_bytes: 3800
#include<iostream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int n, x[100100], v[100100];

int main() {
//    freopen("ttt", "r", stdin);

    int i;
    cin >> n;
    for(i = 1; i <= n; ++i) {
        cin >> x[i];
        v[x[i]]++;
        v[x[i] + 1]++;
        if(x[i])
            v[x[i] - 1]++;
    }

    int r = 0;
    for(i = 0; i <= 100000; ++i)
        r = max(r, v[i]);

    cout << r;

    return 0;
}


Measured memory_bytes: 1024
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
k = ii()
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k]+'...')

Measured memory_bytes: 9192
# 第2回全国統一プログラミング王決定戦予選-A
if False:
    N=int(input())
    if N%2==0: print(N//2-1)
    else: print(N//2)

# 第1回同じ-A
M,D=map(int,input().split())
ans=0
for m in range(1,M+1):
    for d in range(1,D+1):
        if len(str(d))==2:
            x,y=int(str(d)[0]),int(str(d)[1])
            if x>=2 and y>=2 and x*y==m:
                ans+=1
print(ans)

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<double> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i++) {
        a[i] += a[i-1];
        a[i] /= 2;
    }
    cout << fixed << setprecision(10) << a[n-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
m,d=map(int,input().split())
ans=chk=0
for i in range(1,m+1):
    for j in range(22,d+1):
        if (j%10!=1 and j//10>1 and j%10>1 and i==((j//10)*(j%10))):
            ans+=1
print(ans)


Measured memory_bytes: 39536
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  char A[W][H];
  int cnt=0;
  int i, j, k;
  for(j=0; j<H; j++){
    for(i=0; i<W; i++){
      cin >> A[i][j];
      if(A[i][j]=='#') cnt++;
    }
  }
  if(cnt == H+W-1){
    cout << "Possible" << endl;
  }
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 384
//
//  main.c
//  q_02
//
//  Created by k19104kk on 2020/08/29.
//  Copyright © 2020 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    char s[1001], t[1001];
    scanf("%s", s);
    scanf("%s", t);
    
    long long i=0, j=0, maxcnt=0, input_t = 0;
    
    while (s[i] != '\0') {
        long long cnt=0;
        while (t[j] != '\0') {
            if (s[i+j] == '\0') {
                cnt = 0;
                break;
            }
            if (s[i+j] == t[j]) {
                cnt++;
            }
            j++;
        }
        input_t = j;
        j=0;
        if (cnt>maxcnt) {
            maxcnt = cnt;
        }
        i++;
    }
    
    while (t[j] !=0) {
        j++;
    }
    
    printf("%lld\n", j-maxcnt);
    return 0;
}


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

int main(){
    ll n, a, b;
    while(cin >> n >> a >> b){
        ll sum = a+b;
        ll ti = n/sum;
        ll rem = n%sum;
        ll blue = ti*a;
        if( rem > a ){
            rem = a;
        }
        blue += rem;
        cout << blue << "\n";
    }
    return 0;
}


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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(), M=sc.nextInt();
        int ans = ((N-M)*100+M*1900)*(1<<M);
        System.out.println(ans);
    }
}


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

using namespace std;
int n ;
long long a[200];
int main()
{
    cin >>n;
    for(int i = 1 ; i<=n ; i++)
        cin >> a[i];
    if(n == 1) return cout<<a[1] , 0;
    long long p = 1 , last = a[1];
    for(int i = 2 ; i<=n ; i++)
    {
        long long k = __gcd(last , a[i]);
        last = last/k*a[i];
    }
    cout<<last;
    return 0;
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
#define DEBUG(x) ;


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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	sort(ALL(A), greater<ll>());

	ll cnt{N-2};
	ll res{A.front()};
	
	for (ll i = 1; i < N; ++i)
	{
		if (cnt == 0) break;
		if (cnt == 1)
		{
			res += A[i];
			break;
		}
		else
		{
			res += A[i]*2;
			cnt -= 2;
		}
	}

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


Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; cin >> N;
  long long p = 1;
  bool isOver = false;
  while (N--)
    {long long A; cin >> A;
    if (A == 0) {puts("0"); return 0;}
    if (!isOver and 1000000000000000000LL / p < A) {isOver = true;}
    p *= A;}
  cout << (isOver ? -1 : p) << endl;}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main(){
    int n,k;long double t,ans=0;cin>>n>>k;
    t=1.0/n;
    for(int i=1;i<=n;i++){
        long double tmp=1;int tt=i;
        while(tt<k){
            tmp*=0.5;
            tt*=2;
        }
        ans+=t*tmp;
    }

    cout<<fixed<<setprecision(24)<<ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(N: int, S: "List[str]"):
    i = 0
    res = 1
    before = 0 # 0: h, 1: v
    while i < N:
        if S[0][i] == S[1][i]:
            if i == 0:
                res = 3
            elif before == 0:
                res = res * 2 % MOD
            else:
                res = res
            before = 0
            i += 1
        else:
            if i == 0:
                res = 6
            elif before == 0:
                res = res * 2 % MOD
            else:
                res = res * 3 % MOD
            before = 1
            i += 2
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [ next(tokens) for _ in range(2) ]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextint() int{
	sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}

func nextstirng() string{
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	var n,m int
	n = nextint()
	m = nextint()

	col := 0
	pen := 0
	a := make([]int,n+1)
	for i := 1; i <= m; i++ {
		num := nextint()
		con := nextstirng()
		if con == "WA" {
			if a[num] != -1 {
				a[num] = a[num]+1
			}
		} else {
			if a[num] != -1 {
				col++
				pen += a[num]
				a[num] = -1
			}
		}
	}

	fmt.Printf("%d %d",col,pen)
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	string s,t;
  cin>>s>>t;
  int ans = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3916
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Char
import Data.List

step :: MP.Map Int Int -> Int -> MP.Map Int Int
step m x =
    case MP.lookup x m of
        Just _ -> MP.adjust (+1) x m
        Nothing -> MP.insert x 1 m

solve :: [Int] -> Int -> Int -> Int
solve [] _ _ = 0
solve (x:xs) k l
    | l <= k = 0
    | otherwise = x + solve xs k (l-1)

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$>  B.getLine
    let m = VU.foldl' step MP.empty as
    let vs = sort $ MP.foldl (flip (:)) [] m 
    print $ solve vs k (length vs) 

Measured memory_bytes: 37244
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] count = new int[26];
        while(sc.hasNext()) {
            String s = sc.nextLine().toLowerCase();
            for(int i=0; i<s.length(); i++) {
                char ch = s.charAt(i);
                int num = ch - 'a';
                if(num >= 0 && num < 26) {
                    count[num]++;
                }
            }
        }
        for(int i=0; i<count.length; i++) {
            char ch = (char) (i + 'a');
            System.out.println(ch + " : " + count[i]);
        }
    }
}



Measured memory_bytes: 26148
def prime(x):
    if x in [2,3,5,7,11]:
        return 1
    elif x % 2 ==0:
        return 0
    else:
        p=3
        while p*p <= x:
            if x % p ==0:
                return 0
            else:
                p += 2
        return 1


N=int(input())
for i in range(100):
    if prime(N+i):
        print(N+i)
        break


Measured memory_bytes: 3060
from bisect import bisect_left
from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key=lambda x: x[1])
BC.reverse()

q = deque(A)
goukei = 0

for i in range(M):
    v = bisect_left(q, BC[i][1])
    if 0 < v <= BC[i][0]:
        for _ in range(v):
            q.popleft()
            goukei += BC[i][1]
    elif 0 < v:
        for _ in range(BC[i][0]):
            q.popleft()
            goukei += BC[i][1]
            
A = list(q)
print(sum(A) + goukei)
    

Measured memory_bytes: 33220
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = 0;

            foreach (var t in numsT)
            {
                var right = numsS.Length;
                var left = 0;
                var mid = 0;

                while (left < right)
                {
                    mid = (left + right) / 2;
                    if (t == numsS[mid])
                    {
                        ans++;
                        break;
                    }
                    else if (t < numsS[mid])
                    {
                        right = mid;
                    }
                    else
                    {
                        left = mid + 1;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 16280