akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define li long long int
#define inf (1LL<<60)
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define mod 1000000000+7
#define pb push_back
li n;
li dp[402][402];

li solve(li i,li j,li *a,li *p)
{
    if(i>=j)
    {
        return 0;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    li k,ans=inf;
    for(k=i;k<j;k++)
    {
        ans=min(ans,p[j]-p[i]+a[i]+solve(i,k,a,p)+solve(k+1,j,a,p));
    }

    return dp[i][j]=ans;
}

int main()
{
    cin>>n;
    li a[n],p[n];
    for(li i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)p[i]=a[i];
        else p[i]=a[i]+p[i-1];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,n-1,a,p);
    return 0;
}


Measured memory_bytes: 4932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int N=sc.nextInt();
		int[] a=new int[N];
		int i,k,cnt,ans=0;
		for(i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		for(;;) {
			cnt=0;
			for(i=0;i<N;i++) {
				if(a[i]%2==0) {
					a[i]=a[i]/2;
					cnt++;
				}else break;
			}
			if(cnt==N)ans++;
			else break;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N, M);
    vector<int> cnt(N, 1);
    vector<int> prob(N);
    prob[0] = 1;

    while (M--) {
        var(int, x, y);
        --x, --y;
        --cnt[x];
        ++cnt[y];
        if (prob[x] && cnt[x] <= 0) prob[x] = 0, prob[y] = 1;
        if (prob[x] && cnt[x] > 0) prob[y] = 1;
    }

    dump(cnt);
    dump(prob);

    int ans = 0;
    rep(i, 0, N) {
        if (prob[i]) ++ans;
    }
    print(ans);

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<int> a(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }

    int nodd = 0;
    int n4 = 0;
    int n2 = 0;
    for (int i = 0; i < N; ++i) {
        if (a[i] % 2 == 1) {
            ++nodd;
            continue;
        }
        if (a[i] % 4 == 0) {
            ++n4;
            continue;
        }
        ++n2;
    }

    bool ok = false;
    if (n2 == 0) {
        if (nodd - 1 <= n4) {
            ok = true;
        }
        else {
            ok = false;
        }
    }
    else {
        if (nodd <= n4) {
            ok = true;
        }
        else {
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <array>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

int main()
{
	string s, t;
	int a, b;
	string u;
	cin >> s >> t >> a >> b >> u;

	if (s == u)
		a--;
	else if (t == u)
		b--;

	cout << a << " " << b;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

template<class T> void chmin(T &a, T b){a=min(a, b);}
template<class T> void chmax(T &a, T b){a=max(a, b);}

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int z_alg(string s){
  int n=s.size();
  int a[n];
  a[0]=n;
  int i=1,j=0;
  while(i<n){
    while(i+j<n && s[j]==s[i+j])j++;
    a[i]=j;
    if(j==0){i++;continue;}
    int k=1;
    while (i+k<s.size() && k+a[k]<j)a[i+k]=a[k],k++;
    i+=k;j-=k;
  }
  int mx=0;
  for(i=1;i<n;i++){
    if(a[i]>i)a[i]=i;
    chmax(mx,a[i]);
  }
  return mx;
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=0;
  rep(i,n){
    chmax(ans,z_alg(s.substr(i)));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
const long long INF = 5000000000000000;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S; cin >> S;
    long long K; cin >> K;
    for(int i = 0; i < S.size(); ++i){
        if(S[i] == '1'){
            K--;
            if(K == 0) {
                cout << 1 << endl;
                return 0;
            }
            continue;
        }
        cout << S[i] << endl;
        break;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    long int n, w;

    cin >> n >> w;

    long int itens_values[n];
    long int itens_weight[n];

    for(int i = 0; i < n; i++) {
        cin >> itens_weight[i] >> itens_values[i];
    }

    long int solutions[n + 1][w + 1];

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= w; j++) {
            if (i == 0 || j == 0) {
                solutions[i][j] = 0;
            } else if (itens_weight[i - 1] <= j) {
                solutions[i][j] = max(
                    solutions[i - 1][j],
                    solutions[i - 1][j - itens_weight[i - 1]] + itens_values[i - 1]
                );
            } else {
                solutions[i][j] = solutions[i - 1][j];
            }
        }
    }

    cout << solutions[n][w] << endl;

    return 0;
}


Measured memory_bytes: 79104
import itertools

n,m,q=map(int,input().split())
lst=[]
ans=0

for i in range(q):
  a,b,c,d=map(int,input().split())
  lst.append([a,b,c,d])

for x in list(itertools.combinations_with_replacement(range(1,m+1),n)):
  cnt=0
  for i in lst:
    if x[i[1]-1]-x[i[0]-1]==i[2]:
      cnt+=i[3]

  ans=max(ans,cnt)


print(ans)

Measured memory_bytes: 84716
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int main()
{
   int a;
   scanf ("%d",&a);

   if (a==25)
   {
       printf ("Christmas\n");
   }
     else if (a==24 )
   {
       printf ("Christmas Eve\n");
   }
     else if (a==23)
   {
       printf ("Christmas Eve Eve\n");
   }
  else  if ( a==22)
   {
       printf ("Christmas Eve Eve Eve\n");
   }
   return 0;


}


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

namespace _1085
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                int a = 0;
                int[] n = new int[x[0]];
                for (int i = 0; i < x[0]; i++)
                {
                    n[i] = int.Parse(Console.ReadLine());
                }
                for (int i = 0; i < x[0] - 1; i++)
                {
                    for (int j = i + 1; j < x[0]; j++)
                    {
                        if (x[1] < n[i] + n[j])
                        {
                            a++;
                        }
                    }
                }
                Console.WriteLine(a);
            }
        }
    }
}

Measured memory_bytes: 9892
n = int(input())
A = list(map(int, input().split()))
S = sum(A)
D = {c:0 for c in range(1, 10**5+1)}
for a in A:
  D[a] += 1
for _ in range(int(input())):
  B, C = map(int, input().split())
  S += (C-B)*D[B]
  D[C] += D[B]
  D[B] = 0
  print(S)

Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
 int n,k;
 cin >>n>>k;
if(n%k == 0)
{
  cout<<0<<endl;
}
else if(n < k)
{
  cout<<1<<endl;
}
else
{
  cout<<1<<endl;
}

return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define maxn 55
using namespace std;
long long dp[maxn][2];
int n,p;
int a[maxn];
int main(){
	cin >> n >> p;
	for(int i = 1; i <= n; i++) cin >> a[i];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 1; j++){
			dp[i][(j + a[i]) % 2] += dp[i-1][j];
			dp[i][j] += dp[i-1][j];
		}
	}
	cout << dp[n][p] << endl;
	return 0;
}


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

int n;

int main()
{
	cin >> n;
  	int v = n % 10;
  	if (v == 3) puts("bon");
  	else if (v == 0 || v == 1 || v == 6 || v == 8) puts("pon");
  	else puts("hon");
  	
  	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>> n;
  for(int i=0;i<n;i++){
    int k,p;
    int ans;
    cin>> k>> p;
    ans=k%p;
    if(ans==0) cout<< p<< endl;
    else cout<< ans<< endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);

    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }

    int count=0;
    while(true){
    bool K=false;
    for(int i=0;i<N;i++){
        if(A.at(i)%2!=0){K=true;}
    }
    if(K){break;}
    for(int i=0;i<N;i++){
        A.at(i)/=2;
    }
    count++;
    }
    cout<<count<<endl;
    return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;
int dp[100][100];
int size[100][2];

int main() {
    int n;
    cin >> n;
    REP(i, 100) REP(j, 100)
        dp[i][j] = INF;
    REP(i, n)
        cin >> size[i][0] >> size[i][1];
    REP(i, n) for(int j = 0; j < n - i; j++){
        if(i == 0){
            dp[i][j] = 0;
            continue;
        }
        if(i == 1){
            dp[i][j] = size[j][0] * size[j][1] * size[j+1][1];
            continue;
        }
        REP(k, i){
            dp[i][j] = min(dp[i][j], dp[k][j] + dp[i-1-k][j+k+1] + size[j][0] * size[j+k][1] * size[j+i][1]);
        }
    }
    cout << dp[n-1][0] << endl;
    return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<queue>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;

  priority_queue<int> q;
  rep(i,0,N-1) {
    int a;
    cin >> a;
    q.push(a);
  }

  rep(i,0,M-1) {
    int item = q.top();
    q.pop();
    item /= 2;
    q.push(item);
  }

  long ans = 0;
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }

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


Measured memory_bytes: 892
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;


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

	vector<int>v(4);
	for (auto &i : v)cin >> i;
	int ans = 10000;
	for (int i = 0; i < 4; i++) {
		for (int j = i + 1; j < 4; j++) {
			ans = min(ans, abs(accumulate(v.begin(), v.end(), 0) - (v[i] + v[j]) * 2));
		}
	}
	cout << ans << endl;
}


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

bool dp[100001];        // vector でやると，no viable overloaded '|=' って言われた

int main() {
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    for (int i = 1; i <= K; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

const int MAX_N = (int)(2e5 + 5);

int n;
ll k;

ll a[MAX_N];
ll f[MAX_N];

bool check(ll x) {
  ll tmp_k = k;

  for (int i = 0; i < n; ++i) {
    ll aifi = a[i] * f[i];

    if (aifi <= x) continue;  // already satisfied

    if (tmp_k == 0 && aifi > x) return false;

    ll times = ((aifi - x) - 1) / f[i] + 1L;

    ll actual_times = min(times, tmp_k);

    aifi -= actual_times * f[i];  // sum_i ((ai - ki) x fi_ = sum_i (ai x fi - ki x fi)
    tmp_k -= actual_times;

    if (aifi > x) {
      return false;
    }
  }

  return true;
}

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &k);

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

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &(f[i]));
  }

  sort(a, a + n);
  sort(f, f + n, greater<ll>());

  ll ok = INF;
  ll ng = -1L;

  while (abs(ok - ng) > 1) {
    ll next = (ok + ng) / 2L;

    if (check(next)) {
      ok = next;
    } else {
      ng = next;
    }
  }

  ll ans = ok;

  printf("%lld\n", ans);

  return 0;
}


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

int main(){
    int n;cin >> n;
    string s;cin >>  s;
    int result = 0;

    int tmp = 0;
    for (int i=0;i<s.size();i++){
        if (s[i] == 'I'){
            tmp++;
        } else {
            tmp--;
        }

        result = max(tmp, result);
    }

    cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
N,M= map(int, input().split())
#*A = list(map(int, input.split()))
A = [int(i) for i in input().split()]
B = [0]*N

for i in range(N):
	if A[i] >= sum(A)/(4*M):
		B[i] = 1

if sum(B) >= M:
	print("Yes")
else:
	print("No")

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

int main () {
  int S;
  cin >> S;
  
  int s1 = S / 100;
  int s2 = (S - s1 * 100) / 10;
  int s3 = S - s1 * 100 - s2 * 10;
  
  cout << s1 + s2 +s3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=(1<<18);
int n, a[N+10];
pair<int,int> f[N+10];
inline void up(pair<int,int> &a,pair<int,int> b){
    if (b.second>=a.first){
        a=b;
    }
    else if (b.first>=a.first){
        a.second=a.first;
        a.first=b.first;
    }
    else if (b.first<a.first && b.first>=a.second){
        a.second=b.first;
    }
}
int main(){
    cin>>n;
    for (int i=0;i<(1<<n);++i){
        scanf("%d", &a[i]);
        f[i].first=a[i];
    }
    for (int i=0;i<n;i++){
        for (int j=0;j<(1<<n);j++){
            if (j&(1<<i)) up(f[j], f[j^(1<<i)]);
        }
    }
    int ans=0;
    for (int i=1;i<(1<<n);++i){
        ans=max(ans, f[i].first+f[i].second);
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;

Int N,K,T;
Int ceilS(Int A,Int B){
    return (A+B-1)/B;
}
int main()
{
   int t;t=1;
   while(t--){
       cin>>N>>K>>T;
       Int nums=ceilS(N,K);
       cout<<nums*T<<"\n";
   }
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip> 

using namespace std;
typedef vector<long long int> vi;
typedef vector<vi> vvi;

int main() {
    int n;
    cin >> n;
    long long int p[n], cSum[n+1];
    long long int sum = 0;
    cSum[0] = 0;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        sum += p[i];
        cSum[i+1] = cSum[i] + p[i];
    }

    vvi win(n, vi(n));
    for (int i = 0; i < n; i++) {
        win[i][i] = p[i];
    }

    for (int l = 2; l <= n; l++) {
        for (int i = 0; i < n - l + 1; i++) {
            int j = i + l - 1;
            win[i][j] = max(cSum[j] - cSum[i] - win[i][j-1] + p[j], cSum[j+1] - cSum[i+1] - win[i+1][j] + p[i]);
        }
    }
    cout << (2 * win[0][n-1] - sum) << endl;

    return 0;
}



Measured memory_bytes: 70784
N=int(input())
T,A=map(int,input().split())
W=list(map(int,input().split()))
U=100000000
c=0
for i in range(N):
  W[i]=T-W[i]*0.006
for k in range(N):
  Y=abs(W[k]-A)
  if Y<U:
    U=Y
    c=k
print(c+1)

Measured memory_bytes: 9248
from itertools import*
n,*c=map(int,open(0).read().split())
mod=10**9+7
dif=[j-i for i,j in zip(c,c[1:])]
fac=[1]*n
for i in range(1,n):
	fac[i]=fac[i-1]*i%mod
inv=[pow(i,mod-2,mod) for i in range(n)]
acc_inv=list(accumulate(inv))
ans=0
for k in range(1,n):
	ans+=dif[k-1]*acc_inv[k]
	ans%=mod
print(ans*fac[-1]%mod)

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

int N;
const int MAX_N = 1.0e5 + 100;
int M[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> M[i];

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        if (M[i] >= M[i+1]) {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }

    ans = max(ans, cnt);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i<(int)n;i++)
#define ll long long 
using namespace std;
int ten(int x){
  int a;
  rep2(i,x,x+10){
    if(i%10==0) {
      a=i;
      break;
    }
  }
      return a;
}
int main(){
  int a,b,c,d,e;
  cin >>a>>b>>c>>d>>e;
  vector<int> vec={a,b,c,d,e};
  if(a%10==0&&b%10==0&&c%10==0&&d%10==0&&e%10==0) cout<<a+b+c+d+e<<endl;
  else{
    int key=9;
  rep(i,5) {
    if(vec[i]%10==0) continue;
    if(key>vec[i]%10){
      key=vec[i]%10;
      swap(vec[i],vec[4]);
  }
  }
    int  sum=0;
    rep(i,4) sum+=ten(vec[i]);
    cout <<sum+vec[4]<<endl;
  }
}
    

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, P = MAP()

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
arr = factorization(P)
ans = 1
for x, y in arr:
	ans *= x**(y//N)

print(ans)

Measured memory_bytes: 5320
import math


def main():
    n,k,q = map(int, input().split())
    A = [int(input()) for _ in range(q)]

    score = [k-q]*n
    for i in range(q):
        score[A[i]-1] += 1
    for i in score:
        if i>0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


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

int main() {
	int N;

	std::cin >> N;

	int answer = N;
	int temp;
	int tempAns;

	for (int i = 0; i <= N; i++) {
		tempAns = 0;
		temp = i;
		while (temp > 0) {
			tempAns += temp % 6;
			temp /= 6;
		}
		temp = N - i;
		while (temp > 0) {
			tempAns += temp % 9;
			temp /= 9;
		}
		answer = std::min(answer, tempAns);
	}

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<int, int>();
        for (int i = 0; i < n; i++) d[int.Parse(Console.ReadLine().Trim())] = i;
        var ret = 1; var pre = d[1]; var te = 1;
        for (int i = 2; i <= n; i++)
        {
            if (d[i] > pre) { te++; ret = Math.Max(ret, te); }
            else te = 1;
            pre = d[i];
        }
        Console.WriteLine(n - ret);
    }
}


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0;
  for(int i=1; i<=n; i++){
    if(i%3 != 0 && i%5 !=0) ans +=i;
  }
  cout << ans << endl;
}


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

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

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

  ll a, b, c; cin >> a >> b >> c;
  if((a*b*c)%2 == 0) {
    cout << 0 << '\n';
    return 0;
  }

  cout << min({a*b, b*c, c*a}) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
int main()
{
	int n;
	std::cin >> n;
	std::vector<int>east(n, 0), west(n, 0);
	std::string str;
	std::cin >> str;
	std::stringstream ss(str);
	for (int i = 0; i < n; i++)
	{
		char foo;
		ss >> foo;
		if (foo == 'W')west[i]++;
		else east[i]++;
	}
	for (int i = 0; i < n - 1; i++)
	{
		west[i + 1] += west[i];
		east[n - 2 - i] += east[n - 1 - i];
	}
	int min = 1000000;
	for (int i = 0; i < n; i++)
	{
		int num = i == 0 ? east[1] : i == n - 1 ? west[n - 2] : west[i - 1] + east[i + 1];
		if (min > num)
		{
			min = num;
		}
	}
	std::cout << min << std::endl;
	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);



int main() {
  string s; cin >> s;
  int n = s.size();
  string ans;
  for (int i=0; i<n;i+=2) ans += s[i];
  cout << ans << endl; 
  return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    long long int v,w,d;
    char t;
    string s;
    vector<tuple<long long int,long long int,char,long long int,string>> tup;
    cin>>n;
    for (int i=0;i<n;i++) {
        cin>>v>>w>>t>>d>>s;
        tup.emplace_back(v,w,t,d,s);
    }
    sort(tup.begin(),tup.end());
    for (auto x:tup) {
        cout<<get<0>(x)<<" "<<get<1>(x)<<" "<<get<2>(x)<<" "<<get<3>(x)<<" "<<get<4>(x)<<endl;
    }
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;

    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    string s1 = S.substr(0, N / 2);
    string s2 = S.substr(N / 2, N / 2);

    cout << (s1 == s2 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#-(or child-sbcl swank)
(quit
 :unix-status
 (process-exit-code
  (run-program *runtime-pathname*
               '("--control-stack-size" "32MB"
                 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                 "--eval" "(push :child-sbcl *features*)"
                 "--script" #.(namestring *load-pathname*))
               :output t :error t :input t)))
(princ(apply'lcm(loop repeat(read)collect(read))))


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

using namespace std;
#define pii pair<int,int>
#define ll long long 

const int N = 1e5+10;

int n,k,r,s,p;
string t;
vector<int> score;
vector<vector<int> > dp;
int bet(char ch,int op){
	return (ch=='r' &&op==0) || (ch=='s' && op==1) || (ch=='p' && op==2);
}
int main(){
	score.resize(3);
	cin >> n >> k >> score[1] >> score[2] >> score[0] ;
	cin >> t;
	dp.resize(n);
	for(int i=0;i<n;++i){
		dp[i].resize(3);
	}
	int ans = 0, cm = 0;
	for(int i=0;i<k;++i){
		cm = 0;
		for(int j=0;j*k+i<n;j++){
			for(int r=0;r<3;++r){
				if(j!=0)
					dp[j][r] = max(dp[j-1][(r+1)%3],dp[j-1][(r+2)%3]);
				else
					dp[j][r] = 0; 
				if(bet(t[j*k+i],r)) 	dp[j][r] += score[r];
				cm = max(cm,dp[j][r]);
			}
		}
		ans += cm;
	}
	cout << ans <<'\n';
	return 0;
}

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

const int MAX = 1000, VMAX = 100001;
int n, mn, A[MAX], B[MAX], T[VMAX];
bool V[MAX];

int solve() {
    int res = 0;

    for (int i = 0; i < n; i++) {
        B[i] = A[i];
        V[i] = false;
    }

    sort(B, B + n);

    for (int i = 0; i < n; i++) T[B[i]] = i;
    for (int i = 0; i < n; i++) {
        if (V[i]) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while (1) {
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m, v);
            S += v;
            cur = T[v];
            if (V[cur]) break;
        }
        res += min(S + (an - 2) * m, m + S + (an + 1) * mn);
    }
    return res;
}

int main(void) {
    mn = VMAX;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        mn = min(mn, A[i]);
    }

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll s;
    cin >> s;
    ll n;
    vll v(s+1,0);
    v[0]=1;
    for (int i = 3; i <= s; ++i)
    {
    	for (int j = 3; j <= i; ++j)
    	{
    		v[i] = (v[i] + v[i-j]) % MOD;
    	}
    }
    cout<<v[s];
    

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,a[100005],x=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>=m) x++;
	}
	cout<<x;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[4];
		string[]S = new string[4]{"AC","WA","TLE","RE"};
		for(var i=0;i<N;i++){
			string s = Console.ReadLine();
			if(s==S[0]){
				A[0]++;
			} else if(s==S[1]){
				A[1]++;
			} else if(s==S[2]){
				A[2]++;
			} else if(s==S[3]){
				A[3]++;
			}
		}
		for(var i=0;i<4;i++){
			Console.WriteLine(S[i]+" x "+A[i]);
		}
	}
}

Measured memory_bytes: 20852
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// ??? c1 ??¨??? c2 ???????????¢???
int intersectCC(C c1, C c2){
    P c1p = c1.first, c2p = c2.first;
    double c1r = c1.second, c2r = c2.second;
    long double d = abs(c1p - c2p), r1 = c1r, r2 = c2r;
    if(r1 + r2 < d)            return  0; // ??¢????????????
    if(abs(r1 + r2 - d) < EPS) return -2; // ?????\
    if(abs(d + r1 - r2) < EPS) return +1; // c1 ??? c2 ????????§?????\
    if(abs(d + r2 - r1) < EPS) return -1; // c2 ??? c1 ????????§?????\
    if(d + r1 < r2)            return +3; // c1 ??? c2 ??????
    if(d + r2 < r1)            return -3; // c2 ??? c1 ??????
    return 2; // 2?????????????????????
}

int main() {
    C a, b;
    cin >> a.fr.X >> a.fr.Y >> a.sc >> b.fr.X >> b.fr.Y >> b.sc;
    map<int, int> m;
    m[0] = 4;
    m[-2] = 3;
    m[2] = 2;
    m[1] = 1;
    m[-1] = 1;
    m[3] = 0;
    m[-3] = 0;
    cout << m[intersectCC(a, b)] << endl;
    return 0;
}

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

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S << endl;
    return 0;
  }
  for(int i=0; i<K; i++){
    cout << S[i];
  }
  cout << "..." << endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A[205];
    int ans = 0;
    for (int i = 0; i < N; ++i) cin >> A[i];
    bool flg = true;
    while (flg)
    {
        for (int i = 0; i < N; ++i)
        {
            if (A[i] % 2 == 0) A[i] /= 2;
            else
            {
                flg = false;
                break;
            }
        }
        if (flg) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;




int main(void){
    ll n;
    cin>>n;
    vector<ll>a(n),ans(n);
    ll s = 0;
    for(ll i=0;i<n;i++)cin>>a[i],s^=a[i];
    for(ll i=0;i<n;i++){
        ans[i]=s^a[i];
    }
    for(ll i=0;i<n;i++){
        if(i==n-1)cout<<ans[i]<<endl;
        else cout<<ans[i]<<" ";
    }
    return 0;
}

Measured memory_bytes: 6288
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main()
{
	int x, y, z, num = 0;
	scanf("%d %d %d", &x, &y, &z);
	for(int i = z; ;) {
		i = i + y + z;
		if(i > x) break;
		num = num + 1;
	}
	printf("%d\n", num);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long amount = 100000;
			for (int i = 0; i < n; i++) {
				amount *= 1.05;
				amount += 999;
				amount /= 1000;
				amount *= 1000;
			}
			System.out.println(amount);
		}
	}
}

Measured memory_bytes: 26296
#include <stdio.h>
#include <stdlib.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, u, w, N, deg[100001] = {};
	long long A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%lld", &(A[i]));
	if (N == 2) {
		if (A[1] == A[2]) printf("YES\n");
		else printf("NO\n");
		fflush(stdout);
		return 0;
	}
	
	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *e = (list*)malloc(sizeof(list) * (N - 1) * 2);
	for (i = 1; i <= N; i++) adj[i] = NULL;
	for (i = 0; i < N - 1; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
		deg[u]++;
		deg[w]++;
	}
	
	int par[100001] = {}, q[100001], head, tail;
	list *p;
	for (i = 1; deg[i] == 1; i++);
	par[i] = i;
	q[0] = i;
	for (head = 0, tail = 1; head < tail; head++) {
		u = q[head];
		for (p = adj[u]; p != NULL; p = p->next) {
			if (par[p->v] == 0) {
				par[p->v] = u;
				q[tail++] = p->v;
			}
		}
	}
	
	int r;
	long long sum, max;
	list *po;
	head--;
	while (head > 0) {
		for (; head > 0 && deg[q[head]] <= 2; head--);
		r = q[head];
		for (p = adj[r], sum = 0, max = 0; p != NULL; p = p->next) {
			if (p->v == par[r]) continue;
			u = p->v;
			while (deg[u] > 1) {
				for (po = adj[u]; po->v == par[u]; po = po->next);
				if (A[po->v] != A[u]) break;
				else u = po->v;
			}
			if (deg[u] > 1) break;
			sum += A[u];
			if (A[u] > max) max = A[u];
		}
		if (p != NULL || sum < A[r] || sum > A[r] * 2 || max > A[r]) break;
		deg[r] = 1;
		A[r] -= sum - A[r];
	}
	if (head == 0 && A[r] == 0) printf("YES\n");
	else printf("NO\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7524
n = int(input())
counter = 0
cnt = [0]*(n+1)
for i in range(1,n+1):
    j = i
    while(j%2 == 0):
        j = j/2
        counter += 1
    cnt[i] = counter
    counter = 0
max_val = max(cnt[1:])
ans = cnt[1:].index(max_val)
print(ans+1)

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

int main() {
  int N, M, city1, city2;
  cin >> N >>M;

   // N要素の配列
  vector<int> city(N);

  //city 読み込み処理
  for(int i=0; i<M; i++){
   cin >>city1 >>city2;
   city.at(city1-1) ++;
   city.at(city2-1) ++;
  }
  
  // 出力
  for(int i =0; i < N; i++){
     cout << city.at(i) << endl;
  }
}


Measured memory_bytes: 256
def main(argv)
  s = gets.chomp
  n = s.size

  t = [ s[0] ]
  i = 1
  while i < n do
    if t[t.size - 1].size == 1 then
      if t[t.size - 1][0] == s[i] then
        t.push( s[i..(i + 1)] )
        i += 2
      else
        t.push( s[i] )
        i += 1
      end
    else # t[t.size - 1].size == 2
      t.push( s[i] )
      i += 1
    end
  end

  t.pop if t[t.size - 1] == t[t.size - 2]

  puts t.size.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 16508
#include<iostream>
#include<deque>
using namespace std;
const int MOD=10000007;
int dist[100000],k;
deque<int> todo;
int main()
{
	cin>>k;
	for(int i=0;i<k;i++){
		dist[i]=MOD;
	}
	dist[1]=1;
	todo.push_back(1);
	while(todo.size()){
		int u=todo.front();
		todo.pop_front();
		if(dist[(10*u)%k]>dist[u]){
			dist[(10*u)%k]=dist[u];
			todo.push_front(10*u%k);
		}
		if(dist[(u+1)%k]>dist[u]+1){
			dist[(u+1)%k]=dist[u]+1;
			todo.push_back((u+1)%k);
		}
	}
	cout<<dist[0];
	return 0;
} 

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

int main(){
    int n, i;
    int count = -1;
    vector<int> a(200);
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int end = 0;

    while(end == 0){
        count++;
        for(i = 0; i < n; i++){
            if(a.at(i) % 2 == 1){
                end = 1;
                break;
            }else{
                a.at(i) /= 2;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N >> X;
  ll m[N];
  ll min_m =1e+5;
  rep(i, N){
    cin >> m[i];
    min_m = min(min_m, m[i]);
    X -= m[i];
  };
  
  ans = N+X/min_m;

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll n;
   cin>>n;
   ll i,j;
   ll aa[n];
   for(i=0;i<n;i++)
   {
       aa[i]=i+1;
   }
   ll a[n],b[n];
   for(i=0;i<n;i++)cin>>a[i];
   for(i=0;i<n;i++)cin>>b[i];
   
   ll no1=1,no2=1;
   ll no=0;

   do{
       ll f=0;
      for(i=0;i<n;i++)
      {
          if(a[i]!=aa[i])
          {
              f=1;
              break;
          }
      }  
      if(f==0)
      {
          no1=no;
      }
      f=0;
      for(i=0;i<n;i++)
      {
          if(b[i]!=aa[i])
          {
              f=1;
              break;
          }
      }  
      if(f==0)
      {
          no2=no;
      }
     no++;
   }while(next_permutation(aa,aa+n));

   cout<<llabs(no1-no2)<<"\n";
   
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	int a, b; std::cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; ++i) {
		std::string s = std::to_string(i);
		std::string cp = s;
		std::reverse(cp.begin(), cp.end());
		if (cp == s) ++count;
	}
	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  string s[n];
  rep(i,n) R s[i];
  ll dp[n][m];
  mem(dp);
  dp[0][0]=1;
  for(ll i=0; i<n+m-1; i++) {
    ll x=max(0LL,i-m+1),y=min(m-1,i);
    while(check(n,m,x,y)) {
      if(check(n,m,x+1,y)&&s[x+1][y]=='.') {
        dp[x+1][y]+=dp[x][y];
        dp[x+1][y]%=MAX;
      }
      if(check(n,m,x,y+1)&&s[x][y+1]=='.') {
        dp[x][y+1]+=dp[x][y];
        dp[x][y+1]%=MAX;
      }
      x++;
      y--;
    }
  }
  pr(dp[n-1][m-1]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 9088
w = input()
alfa = [chr(i) for i in range(97, 97+26)]
s = [0]*len(alfa)
for i in range(len(w)):
    for j in range(len(alfa)):
        if w[i]==alfa[j]:
            s[j]+=1

ans = True
for i in range(len(s)):
    if s[i]%2 != 0:
        ans = False
if(ans):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 40432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fs ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	 ll n,k,h[100001],dp[100001];
	 cin>>n>>k;
	 for(ll i=1;i<=n;i++){
	     cin>>h[i];
	 }
	 dp[1]=0;
	 for(ll i=2;i<=n;i++){
	 	 dp[i]=abs(h[i]-h[i-1])+dp[i-1];
	 	 //cout<<dp[i]<<endl;
	 	for(ll j=2;i-j>0 && j<=k;j++){
	 	   dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i]);
	  }
	  //cout<<i<<" "<<dp[i]<<endl;
   }
	 cout<<dp[n];
}

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

int main()
{
  int a[4];
  rep(i, 4){
    cin >> a[i];
  }

  cout << min(a[0],a[1]) + min(a[2],a[3]) << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    int N; cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    for (int i = 1; i < N; i++){
        v[i] = (double)(v[i-1]+v[i])/2.0;
    }
    cout << fixed << setprecision(10) << v[N-1] << endl;
}

Measured memory_bytes: 256