akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
is_need = [[1]*N for i in range(N)]

def warshall_floyd(adj_mat: list):
    """
    ワーシャルフロイド
    隣接行列を受け取る(隣接していないノードはINF、自身へのコストは0)
    全点の間の最短距離をあらわす行列を返す(V * V)
    O(|V|**3)
    ネスト深くならないバージョン
    """
    mat = adj_mat.copy()
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if mat[i][j] > mat[i][k] + mat[k][j]:
                    return -1
                elif mat[i][j] == mat[i][k] + mat[k][j] and i != k and k != j:
                    is_need[i][j] = 0
                
    return mat

adj = warshall_floyd(A)
if adj == -1:
    print(-1)
else:
    ans = 0
    for i in range(N):
        for j in range(N):
            if is_need[i][j]:
                ans += A[i][j]
    print(ans//2)

Measured memory_bytes: 75544
N = int(input())

a = []
n = N
if n % 2 == 0:
    a.append(2)
    while n%2 == 0:
        n /= 2
        
f = 3
while f**2 <= n:
    if n % f == 0:
        a.append(f)
        while n%f == 0:
            n //= f
    f += 2
if n != 1 and n not in a:
    a.append(n)

answer = 0

for i in a:
    c = 1
    while N % i**c == 0:
        answer += 1
        N /=  i**c
        c += 1
print(answer)
    

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  double m = sqrt(n);
  ll l = (ll)m;
  print(l*l);
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  S = readline() |> strip

  k=length(S)
  c=count(1:k)do i
    S[i]=='o'
  end
  println(15-k+c>=8?"YES":"NO")
end

main()


Measured memory_bytes: 166928
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }


int main() {
    int n,k;
    int ans = 0;
    string s;
    cin>>n>>k;
    cin>>s;
    int sum = 0;
    int p = 0;
    bool f = false;
    while(p+1<n){
        if(s[p]=='R'&&s[p+1]=='R')sum++;
        p++;
    }
    p=n-1;
    while(p>0){
        if(s[p]=='R'||s[p-1]=='R')f=true;

        if(s[p]=='L'&&s[p-1]=='L')sum++;
        p--;
    }
    p=0;
    ans = sum;


    while(true){
        if(p>=n||k==0)break;
        if(p+1<n&&s[p]=='R'&&s[p+1]=='L') {
            p++;
            while (s[p] == 'L' && p < n)p++;
            if (p == n)ans++;
            else {
                ans += 2;
                k--;
            }
        }else{
            p++;
        }

    }

    if(k>0&&s[0]=='L'&&f){
        ans++;
    }
    cout<<ans<<endl;


    return 0;
}


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

int main(){
  long long N,K;
  cin>>N>>K;
  /*if(K==1){
    cout<<N*N*N<<endl;
    return 0;
  }*/
  /*if(K==2){
    if(N%2==1){
      cout<<pow(N/2,3)+pow((N/2+1),3)<<endl;
      return 0;
    }
    else{
      cout<<pow(N/2,3)*2<<endl;
      return 0;
    }
  }*/
  if(K%2!=0){
    cout<<setprecision(18)<<pow(N/K,3)<<endl;
    return 0;
  }
  else{
    cout<<setprecision(18)<<pow(N/(K/2)-N/K,3)+pow(N/K,3)<<endl;
    return 0;
  }
  return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}

template<typename T>
int sgn(T val){
  return (T(0)<val)-(val<T(0));
}

tuple<long long,long long,long long> egcd(long long a,long long b){
  if(a==0||b==0)return std::make_tuple(0LL,0LL,0LL);
  long long sa=sgn(a),sb=sgn(b);
  a=std::abs(a);b=std::abs(b);
  long long p=1,q=0,r=0,s=1;
  while(b>0){
    long long c=a/b;
    long long d;
    d=a;a=b;b=d%b;
    d=p;p=q;q=d-c*q;
    d=r;r=s;s=d-c*s;
  }
  return std::make_tuple(a,p*sa,r*sb);
}

long long inverse(long long a,long long m){
  auto b=egcd(a,m);
  if(std::get<0>(b)!=1)return 0;
  return (std::get<1>(b)<0)?std::get<1>(b)+m:std::get<1>(b);
}

long long factorial(long long a,long long m){
  long long ret=1;
  for (long long i = 1; i <= a; i++) {
    ret*=(i%m);
    ret%=m;
  }
  return ret;
}
long long partial_factorial(long long a,long long n,long long m){
  long long ret=1;
  for (long long i = 0; i < n; i++) {
    ret*=(a-i)%m;
    ret%=m;
  }
  return ret;
}
long long combination_prime(long long n,long long r,long long m){
  long long ret;
  long long fact_r=factorial(r,m);
  ret=inverse(fact_r,m);
  long long pfact_n=partial_factorial(n,r,m);
  ret*=pfact_n;
  ret%=m;
  return ret;
}
long long cache_cmb[1000000],cache_inv_fact[1000000];
bool cached=false;
long long combination_cached(long long n,long long r,long long m){
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i <= n; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    cache_cmb[0]=1;
    for (long long i = 1; i <= n/2; i++) {
      cache_cmb[i]=cache_cmb[i-1]*(n-i+1)%m*cache_inv_fact[i]%m;
    }
  }
  r=min(r,n-r);
  return cache_cmb[r];
}

ll N,A,B,K;
vector<pair<ll,ll> > pat;
const long long mod=998244353;
int main()
{
        ll n,a,b,k,ans=0;
  cin>>n>>a>>b>>k;
  for(ll i=0,j;i<=n;i++)
  {
    if(a*i>k) break;
    if((k-a*i)%b==0) j=(k-a*i)/b; else continue;
    if(j>n) continue;
    ans+=combination_cached(n,i,mod)*combination_cached(n,j,mod)%mod,ans%=mod;
  }
        printf("%lld\n",ans);
        return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{

    ll n;
    cin >> n;

    pair<ll, ll>
        a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first;
        a[i].second = i + 1;
    }

    sort(a, a + n);

    for (int i = 0; i < n; i++)
    {
        cout << a[i].second << " ";
    }
    cout << endl;
    // for (int i = 0; i < n; i++)
    // {
    //     if (i > 0)
    //     {
    //         answer += " ";
    //     }

    //     for (int k = 0; k < n; k++)
    //     {
    //         if ((i + 1) == a[k])
    //         {
    //             answer += to_string(k + 1);
    //             break;
    //         }
    //     }
    // }
}


Measured memory_bytes: 2432
while (n,x = gets.split.map(&:to_i)) != [0,0] do
    count = 0
    for i in 1..n
        for j in i+1..n
            for k in j+1..n
                count += 1 if (i+j+k == x)
            end
        end
    end
    puts count
end



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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }

  int ans = 0, cnta = 0, cntb = 0, cntab = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < s[i].size() - 1; j++) {
      if (s[i][j] == 'A' && s[i][j + 1] == 'B') {
        ans++;
      }
    }
    if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A') {
      cntab++;
    }
    else if (s[i][s[i].size() - 1] == 'A') {
      cnta++;
    }
    else if (s[i][0] == 'B') {
      cntb++;
    }
  }
  ans += max(0, cntab - 1);
  if (cntab >= 1) {
    if (cnta >= 1) {
      ans++;
      cnta--;
    }
    if (cntb >= 1){
      ans++;
      cntb--;
    }
  }
  ans += min(cnta, cntb);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

void dfs(int N, string temp, int i) {
    if (temp.size() == N) {
        cout << temp << endl;
        return;
    }

    for (int c = 0; c <= i; c++) {
        dfs(N, temp + char('a' + c), ((c == i) ? i + 1 : i));
    }
}

int main() {
    int N;
    cin >> N;
    dfs(N, "", 0);
    return 0;
}

Measured memory_bytes: 1536
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         ll a,p;
         cin>>a>>p;
         cout<<(3*a+p)/2;    
    }

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

#define maxn 6000
#define maxm 100000

struct Edge {
  int t;
  int cap;
  int next;
};
class DirectedGraph {
 public:
  void Init(int n) {
    int i;
    n_ = n;
    m_ = 0;
    for (i=0;i<n_;i++)
      a_[i]=-1;
  }
  void AddEdge(int x,int y, int cap) {
    e_[m_].t=y;
    e_[m_].cap=cap;
    e_[m_].next=a_[x];
    a_[x]=m_;
    m_++;
    e_[m_].t=x;
    e_[m_].cap=0;
    e_[m_].next=a_[y];
    a_[y]=m_;
    m_++;
  }
  
  int search(int x,int limit)
  {
    int i,j,f,now,f1;
    f=0;
    if (limit==0) return 0;
    if (x==t_) return limit;
    for (i=a_[x];i!=-1;i=e_[i].next)
    {
      if ((e_[i].cap>0)&&(dis_[e_[i].t]==dis_[x]+1))
      {
        now=limit-f;
        if (e_[i].cap<now) now=e_[i].cap;
        f1=search(e_[i].t,now);
        if (f1>0)
        {
          f+=f1;
          e_[i].cap-=f1;
          e_[i^1].cap+=f1;
        }
        if (f==limit) break;
      }
    }
    return f;
  }
  
  int MaxFlow(int s,int t) {
    int i,j,k,ans;
    s_=s;t_=t;
    ans=0;
    while (1)
    {
      memset(dis_,-1,sizeof(dis_));
      vector<int> q;
      q.clear();
      q.push_back(s);
      dis_[s]=0;
      for (i=0;i<q.size();i++)
      {
        for (j=a_[q[i]];j!=-1;j=e_[j].next)
        {
          if ((e_[j].cap>0)&&(dis_[e_[j].t]==-1))
          {
            dis_[e_[j].t]=dis_[q[i]]+1;
            q.push_back(e_[j].t);
          }
          if (dis_[t_]!=-1) break;
        }
        if (dis_[t_]!=-1) break;
      }
      if (dis_[t_]==-1) break;
      ans+=search(s,2000000000);
    }
    return ans;
  }
  
  void output()
  {
    int i,j;
    for (i=0;i<n_;i++)
      for (j=a_[i];j!=-1;j=e_[j].next)
        printf("%d %d %d\n",i,e_[j].t,e_[j].cap);
  }

  Edge e_[maxm];
  int used_[maxn];
  int a_[maxn];
  int dis_[maxn];
  int n_,m_,s_,t_;
};

char a[110][110];

int main()
{
  DirectedGraph g;
  int tmp;
  int i,j,m,n;
  scanf("%d%d",&m,&n);
  for (i=0;i<m;i++)
    scanf("%s",a[i]);
  g.Init(m+n+2);
  for (i=0;i<m;i++)
    for (j=0;j<n;j++)
      if (a[i][j]=='S')
      {
        g.AddEdge(0,i+1,20000);
        g.AddEdge(0,m+1+j,20000);
      }
      else if (a[i][j]=='T')
      {
        g.AddEdge(i+1,m+n+1,20000);
        g.AddEdge(m+1+j,m+n+1,20000);
      }
      else if (a[i][j]=='o')
      {
        g.AddEdge(i+1,m+1+j,1);
        g.AddEdge(m+1+j,i+1,1);
      }
  tmp=g.MaxFlow(0,m+n+1);
  if (tmp>=20000) printf("-1\n");
  else printf("%d\n",tmp);
  return 0;
}

Measured memory_bytes: 768
<?php
  $a = str_split(trim(fgets(STDIN)));
  for($i=0;$i<8;$i++){
          $k = $i;
    for($j=0;$j<3;$j++){

      if($k-(2**(2-$j))>=0){
        $a[$j+1]=abs($a[$j+1]);
        $k = $k -(2**(2-$j));
      }else{
        $a[$j+1]=-1*abs($a[$j+1]);
      }
    }
    
    if($a[0]+$a[1]+$a[2]+$a[3]==7){
      for($k=1;$k<=3;$k++){
        if($a[$k]>=0){
        $a[$k] = "+".$a[$k];
        }
      }
      echo $a[0].$a[1].$a[2].$a[3]."=7\n";
      exit;
    }
  }

Measured memory_bytes: 16276
A, B, C, D =  map(int, input().split())

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(a,b):
  return a*b//gcd(a,b)

def getDivNum(n, c, d):
  return n // c + n // d - (n // lcm(c, d))

print(B - A - getDivNum(B, C, D) + getDivNum(A-1, C, D) + 1)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int n;
struct date{
	int l,r;
}a[N];
bool cmp (date A,date B){
	if(A.r==B.r) return A.l<B.l;
	return A.r<B.r;
}
int main(){
	scanf("%d",&n);
	int x,L;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&x,&L);
		a[i].l=x-L;
		a[i].r=x+L;
	}
	sort(a+1,a+1+n,cmp);
	int cnt=1;
	for(int i=2;i<=n;++i){
		if(a[i].l>=a[cnt].r)
			a[++cnt]=a[i];
	}
	printf("%d\n",cnt);
	return 0;
} 

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


const string YES = "YES";
const string NO = "NO";

void solve(vector<ll>&A){
    sort(A.begin(),A.end());
    if(A[0]==5 and A[1]==5 and A[2]==7)
        cout << YES << endl;
    else
        cout << NO << endl;
    
}

signed main(){
    vector<ll> A(3);
    for (size_t i = 0; i < 3; i++)
    {
        cin >> A[i];
    }
    solve(A);
    
    return 0;
}


Measured memory_bytes: 256
INF = float('infinity')

N, K = map(int, input().split())
H = [int(c) for c in input().split()]

dp = [INF] * N
dp[0] = 0

for i in range(1, N):
    for k in range(1, K+1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i-k] + abs(H[i] - H[i-k]))

print(dp[N-1])

Measured memory_bytes: 55392
aa, bb, cc = ARGF.gets.chomp.split.collect {|el| el.to_i}
kk = ARGF.gets.chomp.to_i

ans = "No"
while 0 <= kk
  if aa < bb
    if bb < cc
      ans = "Yes"
      break
    else
      cc *= 2
      kk -= 1
    end
  else
    bb *= 2
    kk -= 1
  end
end

puts ans




Measured memory_bytes: 14368
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

int main() {
    char C; cin >> C;

    cout << char (C + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<a+b+c<<endl;
}   



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1e12
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
fast_cin;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<n;i++){
        string str1=s.substr(0,i+1);
        string str2=s.substr(i+1,n-i);
        if(str1==str2){
            cout <<"Yes\n";
            return 0;
        }
    }
    cout <<"No\n";
}


Measured memory_bytes: 256
import * as fs from 'fs';

// 4 2 9
// 8
const main = (inp: string) => {
    const [n, a, b]: number[] = inp.split(' ').map(Number);
    const train: number = n * a;
    const taxi: number = b;
    console.log(train < taxi ? train : taxi);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,i,R=0;
  long long count=0;
  cin >> N;
  vector<int> A(N+1),B(N);
  for(i=0;i<N+1;i++)cin >> A[i];
  for(i=0;i<N;i++)cin >> B[i];
  for(i=0;i<N;i++) {
    if(R+B[i] > A[i]) {
      count += A[i];
      if(B[i]+R-A[i] > B[i])R = B[i];
      else R = B[i] + R - A[i];
    } else {
      count += B[i] + R;
      R = 0;
    }
  }
  if(R > A[N]) {
    count += A[N];
  } else {
    count += R;
  }
  cout << count << endl;
}

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    for (int i = 0; i < n; i++) {
        cout << s.at(i) << t.at(i);
    }

    cout << endl;

    return 0;
}


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

namespace cysharp_test
{
    class Program
    {
        static void Main (string[] args)
        {
            new Program ().solve ();
        }

        void solve ()
        {
            ulong[] NK = Console.ReadLine ().Split (' ').Select (ulong.Parse).ToArray ();
            ulong N = NK[0];
            ulong K = NK[1];
            ulong count = 0;
            for (ulong i = K; i <= N + 1; i++)
            {
                ulong max = (N - i + 1  + N) * i / 2;
                ulong min = (0 + i - 1) * i / 2;
                count += max - min + 1;
                //Console.WriteLine(max + " " + min);
                //count += i * N - 2 * sum(i - 1) + 1;
            }

            Console.WriteLine (count%1000000007);
            Console.ReadLine();
        }

        static long sum (long n){
            long sum = 0;
            for (int i = 1; i <= n;i++){
                sum += i;
            }
            return sum;
        }

    }

    class Vector2
    {
        public Vector2 (long x, long y)
        {
            this.x = x;
            this.y = y;
        }

        long x, y;

        public static Vector2 operator + (Vector2 a, Vector2 b)
        {
            return new Vector2 (a.x + b.x, a.y + b.y);
        }

        public static Vector2 operator - (Vector2 a, Vector2 b)
        {
            return new Vector2 (a.x - b.x, a.y - b.y);
        }

        public static Vector2 operator * (Vector2 a, long scala)
        {
            return new Vector2 (a.x * scala, a.y + scala);
        }
    }
}

Measured memory_bytes: 18884
from collections import deque
import heapq
N,K = map(int,input().split())
A = list(map(int,input().split()))
res = 0
# 左からa個
for a in range(N+1):
  # 右からb個
  for b in range(N+1):
    if a+b>N or a+b>K: continue
    hands = []
    A1 = deque(A[::])
    for _ in range(a):
      hands.append(A1.popleft())
    for _ in range(b):
      hands.append(A1.pop())
    hands.sort()
    hands = deque(hands)
    rem = K - a - b
    for _ in range(rem):
      if hands and hands[0] < 0:
        hands.popleft()
      else:
        break
    res = max(res, sum(hands))

print(res)

Measured memory_bytes: 43356
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

const int inf = 2000000;
int main()
{
	bool flag;
	int A,B,C;
	cin>>A>>B>>C;
	if(A>B)
	{
		swap(A,B);
	}
	if(A<C && C<B)
	{
		flag = true;
	}
	else
	{
		flag = false;
	}

	if(flag)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int a[n][m],b[m];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int sum=0,count=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            sum+=a[i][j]*b[j];
            if(j==m-1){
                sum+=c;
             }
        }
        if(sum>0){
            count++;
        }
        sum = {};
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3592
import sys
import heapq
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
rres = 0
if N == 1:
  print(d[0])
  exit(0)
for t in range(13):
  res = True
  q = sorted(d)
  heapq.heapify(q)
  l = [0, 24]
  i = 0
  c = 0
  while len(q) and c < 2 * N ** 2:
    p = heapq.heappop(q)
    if abs(p - l[i]) < t:
      heapq.heappush(q, 24 - p)
    else:
      i += 1
      l.append(p)
      l.sort()
    c += 1
  if c >= 2 * N ** 2:
    res = False
  l.sort()
  for i in range(1, len(l)):
    if abs(l[i - 1] - l[i]) < t:
      res = False
      break
  #print(l)
  if res:
    rres = t
  else:
    break
 #print(res, t)
print(rres)

Measured memory_bytes: 42076
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>

using namespace std;


int main() {

	int a;

	string s;

	cin >> a >> s;
	

	
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;


	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long L,n,i,st,dr,rez,A[200005],S[200005];
int main()
{
    ios::sync_with_stdio(false);
    cin>>L>>n;
    for(i=1; i<=n; i++)
        cin>>A[i];
    for(i=1; i<=n; i++)
        S[i]=S[i-1]+A[i];
    for(i=1; i<=n; i++)
    {
        st=i-1;
        dr=n-i;
        if(dr>=st)
            dr=st;
        else
            st=dr+1;
        rez=max(rez,2LL*(S[i-1]-S[i-st-1])+2LL*(dr*L-(S[i+dr]-S[i]))+L-A[i]);
    }
    for(i=1; i<=n; i++)
        A[i]=L-A[i];
    for(i=1; i<n-i+1; i++)
        swap(A[i],A[n-i+1]);
    for(i=1; i<=n; i++)
        S[i]=S[i-1]+A[i];
    for(i=1; i<=n; i++)
    {
        st=i-1;
        dr=n-i;
        if(dr>=st)
            dr=st;
        else
            st=dr+1;
        rez=max(rez,2LL*(S[i-1]-S[i-st-1])+2LL*(dr*L-(S[i+dr]-S[i]))+L-A[i]);
    }
    cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 3328
from collections import deque
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    A = deque(A)
    B = deque()
    if n % 2 == 0:
        while A:
            B.append(A.popleft())
            B.appendleft(A.popleft())
        B = list(B)
        print(*B)
    else:
        while len(A) != 1:
            B.append(A.popleft())
            B.appendleft(A.popleft())
        B.append(A.popleft())
        B = list(B)[::-1]
        print(*B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31344
from collections import defaultdict

N = int(input())
A = sorted(map(int, input().split()))

d = defaultdict(int)
for a in A:
    d[a] += 1

ans = 0
duplicate = 0
q = list()
for k, v in d.items():
    if v % 2 == 1:
        d[k] = 1
        ans += 1
    else:
        d[k] = 2
        duplicate += 1

ans += duplicate
if duplicate % 2 == 1:
    ans -= 1

print(ans)


Measured memory_bytes: 18656
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

  int B[n-1];

  for (int i = 0; i < n-1; i++)
  {
    cin >> B[i];
  }
  int res = 0;
  res += B[0];
  res += B[n-1-1];
  for (int i = 0; i < n-2; i++)
  {
    res += min(B[i], B[i+1]);
  }
  
  cout << res << endl;  
}

Measured memory_bytes: 256
#include <stdio.h>
typedef enum BOOL {
  TRUE,
  FALSE
};
char a[101][101];
int white_row[101];
int white_col[101];
int main()
{
  int H, W, h, w;
  scanf("%d%d", &H, &W);
  for (h = 1; h <= H; h++) {
    for (w = 1; w <= W; w++) {
      scanf(" %c", &a[h][w]);
    }
  }
  for (h = 1; h <= H; h++) {
    white_row[h] = TRUE;
    for (w = 1; w <= W; w++) {
      if (a[h][w]=='#') {
        white_row[h] = FALSE;
        break;
      }
    }
  }
  for (w = 1; w <= W; w++) {
    white_col[w] = TRUE;
    for (h = 1; h <= H; h++) {
      if (a[h][w]=='#') {
        white_col[w] = FALSE;
        break;
      }
    }
  }

  // output
  for (h = 1; h <= H; h++) {
    if (white_row[h] == TRUE) continue;
    for (w = 1; w <= W; w++) {
      if (white_col[w] == TRUE) continue;
      putchar(a[h][w]);
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 128
while 1:
    try:
        s1 = raw_input()
        s2 = raw_input()
        if len(s1) < len(s2): s1,s2 = s2,s1
        l = sum(min(s1.count(i), s2.count(i)) for i in set(list(s1)) & set(list(s2)))
        if l == 0: print 0; continue
        ans = 0
        for i in range(len(s2)):
            if len(s2) - i <= ans: break
            for j in range(ans+1, min(l + 1,len(s2)-i+1)):
                if s2[i:i+j] in s1:
                    ans = j
                else: break
        print ans
    except:
        break

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

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
ll aa[n]={};
ll ab[n]={};
rep(i,n)rep(j,n){
  if(a[i]>a[j])aa[i]++;
  if(a[i]>a[j]&&i<j)ab[i]++;
}
rep(i,n){
  ll te=aa[i]*(k-1)+2*ab[i];
  te%=mo;
  if(te%2)te+=mo;
  te=te*k/2;
  te%=mo;
  ans+=te;
  ans%=mo;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<stack>

using namespace std;
typedef long long int ll;



int main()
{
     stack<char> st;
     string s;
     int n;
     cin >> n;
     cin >> s;
     st.push(s[0]);
     for(ll i=1; i< n; i++)
     {
         if(st.top()==s[i]) continue;
         st.push(s[i]);
     }
     cout << st.size();

}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

ll mod_inv(ll a)
{
	ll left=MOD-2;
	ll ret=1;
	ll ks=a;
	while(left>0)
	{
		if(left%2==1)
		{
			ret=(ret*ks)%MOD;
		}
		ks=ks*ks%MOD;
		left/=2;
	}
	return ret;
}

int main()
{
	int n;cin>>n;
	int i,j;
	vector<int> a(n);
	vector<int> bigp(n,0);
	rep(i,n)cin>>a[i];
	vector<int> count(1001,0);
	rep(i,n)
	{
		int left=a[i];
		vector<int> kcount(1001,0);
		for(j=2;j<=1000;j++)
		{
			while(left%j==0)
			{
				kcount[j]++;
				left/=j;
			}
			count[j]=max(count[j],kcount[j]);
		}
		if(left>1)bigp[i]=left;
	}
	sort(all(bigp));
	vector<ll> bign(0);
	if(bigp[0]>1) bign.emplace_back(bigp[0]);
	rep(i,n-1)
	{
		if(bigp[i+1]>1&&bigp[i+1]>bigp[i])bign.emplace_back(bigp[i+1]);
	}
	ll lcm=1;
	for(i=2;i<=1000;i++)
	{
		while(count[i]>0)
		{
			lcm=(lcm*i)%MOD;
			count[i]--;
		}
	}
	rep(i,bign.size())
	{
		lcm=(lcm*bign[i])%MOD;
	}
	ll ans=0;
	rep(i,n)
	{
		ans+=lcm*mod_inv(a[i]);
		ans%=MOD;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

vector<int> yakusu(int n){
	vector<int> ret;
	for(int i=1;i<=n;i++){
		if(n%i==0){
			ret.push_back(i);
		}
	}
	return ret;
}

int main(void){
	int n;
	cin>>n;
	ll a;
	vector<ll> A;
	A.push_back(0);
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	REPS(i,n){
		for(int j=i;j<=n;j++){
			for(int k=j;k<=n;k++){
				ll memo = 0;
				vector<ll> B;
				B.push_back(0);
				reps(ai,n){
					if(ai%i == 0 || ai%j == 0 || ai%k == 0){
						memo += A[ai];
						B.push_back(0);
					}else{
						B.push_back(A[ai]);
					}
				}
				if(memo < 0){
					A = B;
				}
			}
		}
	}
	ll ans = 0;
	reps(i,n){
		//cout<<A[i]<<" ";
		ans += A[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666,mo=1e9+7;
int n,a[N],b[N];char S[N];
int cur,res=1;
int main() {
	read(n);scanf("%s",S+1);
	rep(i,1,2*n)a[i]=S[i]=='B';
	rep(i,1,2*n)b[i]=a[i]^a[i-1];
	rep(i,1,2*n)
		if(b[i]){b[i]^=1;cur++;}
		else{b[i+1]^=1;res=1LL*res*cur%mo;cur--;}
	if(cur)res=0;
	rep(i,1,n)res=1LL*res*i%mo;
	cout<<res;
	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>


int MCXI_val_2i(){
    char c=getchar();

    switch (c){
        case 'm':
            return 1000+MCXI_val_2i();
        case 'c':
            return 100+MCXI_val_2i();
        case 'x':
            return 10+MCXI_val_2i();
        case 'i':
            return 1+MCXI_val_2i();
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
        {
            int prefix=c-'0';
            char letter=getchar();

            switch (letter){
                case 'm':
                    return prefix*1000+MCXI_val_2i();
                case 'c':
                    return prefix*100+MCXI_val_2i();
                case 'x':
                    return prefix*10+MCXI_val_2i();
                case 'i':
                    return prefix+MCXI_val_2i();

            }

        }
        default:
            return 0;
    }
}


void output_i_MCXI(int val){
    int m=(val/1000)%10,c=(val/100)%10,x=(val/10)%10,i=val%10;

    if (m==0);
    else if (m==1)
        printf("m");
    else
        printf("%dm",m);

    if (c==0);
    else if (c==1)
        printf("c");
    else
        printf("%dc",c);

    if (x==0);
    else if (x==1)
        printf("x");
    else
        printf("%dx",x);

    if (i==0);
    else if (i==1)
        printf("i");
    else
        printf("%di",i);

    printf("\n");
}


int main() {
    int ln_num=0;
    scanf("%d\n",&ln_num);

    for (int i=0;i<ln_num;i++){
        int a,b;
        a=MCXI_val_2i();
       // getchar();
        b=MCXI_val_2i();
        //getchar();
        output_i_MCXI(a+b);

    }

    return 0;
}


Measured memory_bytes: 2024
#include <iostream>

int main() {
    int N;
    std::cin >> N;
    int amari = N % 10;
    switch(amari){
        case 0:
        case 1:
        case 6:
        case 8:
            std::cout << "pon";
            break;
        case 3:
            std::cout << "bon";
            break;
        default :
            std::cout << "hon";
            break;
    }
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define N 100005
#define ll long long
#define mod 1000000007
int Pow(int a, int k)
{
	if (!k)
		return 1;
	int p = Pow(a, k / 2);
	if (k & 1)
		return (ll)p * p % mod * a % mod;
	return (ll)p * p % mod;
}
void Add(int &a, int b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}
int fac[N], inv[N];
int n, m, A[25], dp[1 << 16];
int main()
{
	fac[0] = 1;
	for (int i = 1; i <= 100000; i++)
		fac[i] = (ll)i * fac[i - 1] % mod;
	inv[100000] = Pow(fac[100000], mod - 2);
	for (int i = 100000; i >= 1; i--)
		inv[i - 1] = (ll)i * inv[i] % mod;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &A[i]);
	sort(A + 1, A + m + 1);
	dp[0] = 1;
	for (int i = m; i >= 1; i--)
	{
		for (int j = (1 << n) - 1; j >= 0; j--)
		{
			int lst = (1 << n) - A[i] + 1 - j;
			if (lst < 0)
				continue;
			for (int k = 0; k < n; k++)
				if ((lst >> k) && !((j >> k) & 1))
					Add(dp[j | (1 << k)], (ll)dp[j] * fac[lst - 1] % mod * inv[lst - (1 << k)] % mod * (1 << k) % mod);
		}
	}
	int ans = 0;
	for (int j = 0; j < (1 << n); j++)
	{
		int now = (ll)dp[j] * fac[(1 << n) - j - 1] % mod;
		int bit = 0;
		for (int k = 0; k < n; k++)
			if (j & (1 << k))
				bit++;
		if (bit & 1)
			Add(ans, mod - now);
		else
			Add(ans, now);
	}
	ans = (ll)ans * (1 << n) % mod;
	printf("%d\n", ans);
}
//

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int cnt=0;
    int ans=0;
    
    for(int i=0;i<100;++i){
            int j=100-i;
            if(a%j==0 && b%j==0) {
                cnt++;}
            if(cnt==k) {
              ans=j;
              break;}
        }
        cout << ans << endl;
        return 0;
    }


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = (a[i] + k - 1) % k;
  }

  vector<int> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + a[i]) % k;
  }

  map<int,int> cnt;
  cnt[0]++;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i - k + 1 >= 0) {
      cnt[sum[i - k + 1]]--;
    }
    ans += cnt[sum[i + 1]];
    cnt[sum[i + 1]]++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>

int main(void) {
  int a, b;
  std::cin >> a >> b;

  int cost;

  if (a > 12) {
    cost = b;
  } else if (a > 5) {
    cost = b / 2;
  } else {
    cost = 0;
  }

  std::cout << cost << std::endl;

  return 0;
}


Measured memory_bytes: 888
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long L = sc.nextLong();
        sc.close();
        System.out.println(L * 2 - 1 > N ? "NO" : "YES");
    }
}

Measured memory_bytes: 22996
#include"bits/stdc++.h"
using namespace std;

#define ld long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
void swap(int &a,int &b)
{ auto tm=a; a=b; b=tm; }
 
  //Take care of duplicates

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=(1LL<<50)-1;
  const int N=2e5+25;
  const int M=123456;
 

 void bheja_fry()
 { 
   int a,b; cin>>a>>b;
   cout<<6-a-b;
 }
                                                         
signed main()
{ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  
   int t=1;                         
 //  cin>>t;
  rep(i,1,t+1)
  { // cout<<"Case #"<<i<<": ";
   bheja_fry();
   if(i<t)
   cout<<nl;
  }
  
 return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define N 5002
int n,p,f[N],inv[N],finv[N],S[N][N],bin[N],bn[N];
inline int C(int nn,int mm)
{
	if(nn<mm)return 0;
	if(nn==mm||mm==0)return 1;
	return 1ll*f[nn]*finv[mm]%p*finv[nn-mm]%p;
}
int main()
{
	scanf("%d%d",&n,&p);
	f[1]=inv[1]=finv[1]=1;
	for(int i=2;i<=n+1;i++)
	{
		inv[i]=1ll*(p-p/i)*inv[p%i]%p;
		f[i]=1ll*f[i-1]*i%p;
		finv[i]=1ll*finv[i-1]*inv[i]%p;
	}
	S[0][0]=1;
	for(int i=1;i<=n+1;i++)for(int j=1;j<=n+1;j++)S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j]%p)%p;
	bin[0]=1;bn[0]=2;
	for(int i=1;i<=n+1;i++)bin[i]=2ll*bin[i-1]%p,bn[i]=1ll*bn[i-1]*bn[i-1]%p;
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int te=0,tb=1;
		for(int j=0;j<=i;j++)
		{
			te=(te+1ll*S[i+1][j+1]*tb%p)%p;
			tb=1ll*tb*bin[n-i]%p;
		}
		te=1ll*te*C(n,i)%p*bn[n-i]%p;
		if(i&1)ans=(ans-te+p)%p;
		else ans=(ans+te)%p;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 59264
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll  = long long;
using P = pair<int, int>;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, 0, n){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i, 0, n){
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		List<BigDecimal> list = new ArrayList<BigDecimal>();
		for (int i = 0; i < n; i++) {
			list.add(new BigDecimal(sc.next()));
		}
		Collections.sort(list);
		Collections.reverse(list);

		BigDecimal totalAmount = BigDecimal.ZERO;
		int count = 0;
		for (final BigDecimal amount : list) {
			totalAmount = totalAmount.add(count == 0 ? amount.divide(BigDecimal.valueOf(2)) : amount);
			count++;
		}

		System.out.println(totalAmount.setScale(0, RoundingMode.DOWN));

	}

}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[100000][3];
ll a[100000][3];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for (int i = 0; i + 1 < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
			}
		}
	}
	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2])) << endl;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,d; cin >> n >> d;
    vvl a(n,vl(d));
    ll res2 = 0;
    rep(i,n) rep(j,d) cin >> a[i][j];
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ll res = 0;
            rep(k,d){
                res += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
            }
            ll res1 = sqrt(res);
            if(res == (res1*res1))res2++;
        }
    }
    cout << res2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s,t;cin>>n>>s>>t;
    rep(i,n)cout<<s[i]<<t[i];cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int calc(int a,int b)
{
	int ret=0;
	while(a)
	{
		ret+=a%10;
		a/=10;
	}
	while(b)
	{
		ret+=b%10;
		b/=10;
	}
	return ret;
}

int main()
{
	int N;
	
	cin >> N;
	
	int ans=1e9;
	for(int i=1;i<N;i++)
		ans=min(ans,calc(i,N-i));
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveC();
    }
    
    private void solveA() {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();
	int C = sc.nextInt();
	int D = sc.nextInt();	
    	System.out.println(A+B > C+D ? "Left" : (A+B < C+D ? "Right" : "Balanced"));
    }

    private void solveB() {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
    	int A = sc.nextInt();
    	int B = sc.nextInt();
	int ans = 0;

	for(int i = 1 ; i <= N ; i++){
	    int n = i;
	    int cnt = 0;
	    while(n > 0){
		cnt += n % 10;
		n /= 10;
	    }
	    ans += (cnt>=A && cnt<=B ? i : 0);
	}
	System.out.println(ans);
    }
    private void solveC() {
	Scanner sc = new Scanner(System.in);
    	long A = sc.nextLong();
    	long B = sc.nextLong();
	int ans = 0;

	while(A<=B){
	    ans++;
	    A *= 2;   
	}
	System.out.println(ans);
    }
    private void solveD() {
    }
}

Measured memory_bytes: 21844
w, h, n = map(int, input().split())
a = [0, w, 0, h]
for i in range(n):
    xi, yi, ai = map(int, input().split())
    if ai == 1:
        a[0] = max(xi, a[0])
    elif ai == 2:
        a[1] = min(xi, a[1])
    elif ai == 3:
        a[2] = max(yi, a[2])
    else:
        a[3] = min(yi, a[3])
print(max(0, a[1] - a[0]) * max(0, a[3] - a[2]))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int n, m, k, ways = 0; string mp[6] = {};
bool use[12] = {};

void rs(int cr)
{
	if (cr < n + m)
	{
		rs(cr + 1);
		use[cr] = 1;
		rs(cr + 1);
		use[cr] = 0;
	}
	else
	{
		int cnt = 0;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < m; j++)
			{
				if (mp[i][j] == '#' && !use[i] && !use[n + j]) cnt++;
			}
		}
		if (cnt == k) ways++;
	}
}


int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) cin >> mp[i];
	rs(0);
	cout << ways << "\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

using namespace std;

double w, h, x, y;

signed main() {
    cin >> w >> h >> x >> y;
    double s = w;
    s *= h;
    s /= 2;
    cout << s << endl;
    int ans = 0;
    if (x == w/2 && y == h/2) ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let hwk: Vec<usize> = x
        .trim_end()
        .split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
    let h = hwk[0];
    let w = hwk[1];
    let k = hwk[2];
    let mut b: [[bool; 6]; 6] = Default::default();
    let lines = BufReader::new(io::stdin()).split(b'\n').into_iter();
    for (row, line) in b.iter_mut().zip(lines) {
        for (cell, x) in row.iter_mut().zip(line.unwrap()) {
            if x == b'#' {
                *cell = true;
            }
        }
    }
    let mut ans = 0;
    for i in 0..1 << h {
        for j in 0..1 << w {
            let mut cnt = 0;
            for r in 0..h {
                if (i >> r) & 1 == 0 {
                    for c in 0..w {
                        if (j >> c) & 1 == 0 && b[r][c] {
                            cnt += 1;
                        }
                    }
                }
            }
            if cnt == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2132