akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NAB = Sarray();
            var n = NAB[0];
            var a = NAB[1];
            var b = NAB[2];
            var cmb = new Combination((int)n, (int)Mod);
            var ans = (modpow(2, n, Mod) - 1 + Mod) % Mod;
            var jyogai = (cmb.nCk((int)a) + cmb.nCk((int)b)) % Mod;
            ans = (ans - jyogai + Mod) % Mod;
            WriteLine(ans);
            //Out.Flush();
        }
        static long modpow(long a, long n, long mod)
        {
            var res = 1L;
            while (0 < n)
            {
                if (n % 2 != 0) res = res * a % mod;
                a = a * a % mod;
                n >>= 1;
            }
            return res;
        }
        public class Combination
        {
            readonly long mod;
            readonly long[] finv, inv, com;
            public Combination(int n, int mod = 1000000007)
            {
                long max = 2 * (long)1e5 + 1;
                this.mod = mod;
                finv = new long[max];
                inv = new long[max];
                com = new long[max];
                finv[0] = finv[1] = 1;
                inv[1] = 1;
                for (int i = 2; i < max; ++i)
                {
                    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                    finv[i] = finv[i - 1] * inv[i] % mod;
                }
                com[0] = 1;
                for (int i = 1; i < max; ++i)
                {
                    com[i] = com[i - 1] * ((n - i + 1) * inv[i] % mod) % mod;
                }
            }
            public long nCk(int k) => com[k];
        }
    }
}

Measured memory_bytes: 17760
#include<bits/stdc++.h>
long long int MOD = 1000000007;
using namespace std;
//g++ -std=c++14
//setprecision(10)
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size() - 8; i++)
		cout << s[i];
	cout << endl;	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int R = scanner.nextInt();

        System.out.println((double)R * 2 * 3.141592653);
        return;
    }
}

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

int main()
{
int a[4]={-1000000000,0,0,0},b[4],c;
cin>>a[1]>>a[2]>>a[3];
for(int i=1;i<4;i++){
b[i]=a[i];
for(int j=i;j>0;j--){
if(b[j]<b[j-1]){
c=b[j-1];
b[j-1]=b[j];
b[j]=c;
}
}
}
cout<<b[1]<<' '<<b[2]<<' '<<b[3]<<endl;
return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int f[45];

int finaboch(int n){
  if(n<=1)
    return f[n]=1;
  else if(f[n]!=-1)
    return f[n];
  else
    return f[n]=finaboch(n-1)+finaboch(n-2);
}
  

int main(){
  int n,i;

  for(i=0;i<45;i++){
    f[i]=-1;
  }

  scanf("%d",&n);

  finaboch(n);

  printf("%d\n",f[n]);

  return 0;

}
  

  



Measured memory_bytes: 2112
N, M = map(int, input().split())
li = []
if N&1 == 1:
    a, b = 1, N-1
    li.append([a, b])
    for i in range(min(M-1,(N-1)//2-1)):
        a += 1
        b -= 1
        li.append([a,b])
else:
    a, b = 1, N
    li.append([a,b])
    for i in range(min(M-1,(N-1)//2-1)):
        a += 1
        b -= 1
        if b - a <= N+a-b and - b + a + N+a-b <= 2:
            b -= 1
        li.append([a,b])
for x in li:
    print(*x) 

Measured memory_bytes: 81276
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,i;
    cin>>a>>b>>c;
 if(a==b&&a!=c)
    cout<<"Yes"<<endl;
 else if(b==c&&b!=a)
    cout<<"Yes"<<endl;
 else if(a==c&&a!=b)
  cout<<"Yes"<<endl;
 else
     cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    ans = 0
    for _ in range(N):
        x, u = input().split()
        x = float(x)
        if u == "JPY":
            ans += x
        else:
            ans += x * 380000
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
number_1,number_2,number_3= map(int,input().split())
if number_1 == number_2 and  number_1 != number_3 :
      print ('Yes') 
elif  number_1 == number_3 and  number_1!= number_2 :
      print ('Yes')
elif  number_1 !=  number_2 and  number_2== number_3 :
      print ('Yes')
else :
    print ("No")
    


Measured memory_bytes: 2940
#include "iostream"
#include "vector"
#include "cmath"

using namespace std;
typedef long long ll;

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

  vector<ll> as(n + 1, 0);
  for (ll i = 0; i <= n; i++)
    cin >> as[i];

  vector<ll> sums(n + 1, 0);
  // cout << "sums: ";
  for (ll i = n; i >= 0; i--)
  {
    if (i == n)
      sums[i] = as[i];
    else
      sums[i] = as[i] + sums[i + 1];

    // cout << sums[i];
  }
  // cout << endl;

  // cout << "as: ";
  // for (auto i = 0; i <= n; i++)
  // {
  //   cout << as[i] << " ";
  // }
  // cout << endl;

  if (n == 0)
  {
    if (as[0] == 1)
    {
      cout << 1 << endl;
      return 0;
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }

  if (as[0] != 0)
  {
    cout << -1 << endl;
    return 0;
  }

  // 以下は深さ1以上.
  ll cnt = 1;
  ll last_has_child = 1;
  for (ll i = 1; i <= n; i++)
  {
    ll cap = min(2 * last_has_child, sums[i]);
    if (as[i] > cap)
    {
      cout << -1 << endl;
      return 0;
    }

    ll has_child = min(cap - as[i], sums[i]);
    // printf("i: %lld, child: %lld, leaf: %lld\n", i, has_child, as[i]);
    cnt += has_child + as[i];
    last_has_child = has_child;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n, k = 0, t, s = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &t);
    if(t%2) k--;
    else if(t%4) s = 1;
    else k++;
  }
  puts(k-s >= -1 ? "Yes" : "No");
}

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

int main() {

	ll h; cin >> h;
	ll cnt = 0;
	while (0 < h) {
		cnt++;
		h /= 2;
	}
	ll ans = 1;
	ll tmp = cnt;
	while (tmp--) {
		ans *= 2;
	}
	cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdlib.h>
#include <stdio.h>
typedef struct {
    int val;
    int pos;
}set;
int compare(const void *a,const void *b){
    set tmp1=*(set*)a,tmp2=*(set*)b;
    int* x=tmp1.val,y=tmp2.val;
    if(x>y)return 1;
    return -1;
}

int main()
{   int n;
    scanf("%d",&n);
    set a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i].val);
        a[i].pos=i;
    }
    int counter=0;
    qsort(a,n,sizeof(set),compare);
    for(int i=0;i<n;i++){
        //printf("%d ",a[i].val);
        if(i%2!=a[i].pos%2)counter++;
    }
    printf("%d",counter/2);

    return 0;
}


Measured memory_bytes: 1788
import sys
N, x = map(int, input().split())
a = sorted(map(int, input().split()))


ans = 0
score_x  = x

if score_x < a[0]:
    print(0)
    sys.exit()
    
for  i in range(N):
    if i == (N-1):
        if a[i] == score_x:
            ans = ans + 1
            score_x = (score_x - a[i])
        else:
            break      
    if score_x  >= a[i]:
        score_x = (score_x - a[i])
        ans = ans + 1


print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    string N;
    cin >> N;
    int L=N.length();
    lint dp[L+1][2]={};
    dp[0][0]=1;
    rep(i,L) rep(j,2){
        int digit=N[i]-'0';
        rep(d,2){
            int i2=i+1,j2=j;
            if(j==0){
                if(digit<d) continue;
                if(digit>d) j2=1;
            }
            dp[i2][j2]=(dp[i2][j2]+dp[i][j]*(d==1?2:1))%MOD;
        }
    }
    cout << (dp[L][0]+dp[L][1])%MOD << endl;
}

Measured memory_bytes: 2000
#include <iostream>
#include <vector>
using namespace std;
bool f(const vector<int>& A, const vector<int>& B, int C) {
  int sum = 0;
  for(int i=0; i<A.size(); ++i) sum+= A[i]*B[i];
  return sum + C > 0;
}
main() {
  int N,M,C; cin>>N>>M>>C;
  vector<int> A(M),B(M); for(auto& x:B) cin>>x;
  int sum = 0;
  for(int n=1; n<=N; ++n) {
    for(auto& x:A) cin>>x;
    if(f(A,B,C)) ++sum;
  }
  cout<< sum <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;



typedef vector<vector<ll>> matrix;

const ll mod = 1e9 + 7;

matrix matmult(matrix a, matrix& b) {
    int p = a.size(), q = a[0].size(), r = b[0].size();
    matrix c(p, vector<ll>(r, 0));
    for (int i = 0; i < p; ++i) {
        for (int j = 0; j < r; ++j) {
            for (int k = 0; k < q; ++k) {
                c[i][j] += a[i][k] * b[k][j];
                c[i][j] %= mod;
            }
        }
    }
    return c;
}

matrix matpow(matrix& a, ll b) {
    matrix res(a.size(), vector<ll>(a.size(), 0));
    for (int i = 0; i < a.size(); ++i) res[i][i] = 1;
    while (b) {
        if (b & 1) res = matmult(res, a);
        a = matmult(a, a);
        b >>= 1;
    }
    return res;
}

void Main() {
    ll N, K;
    cin >> N >> K;
    matrix A(N, vector<ll>(N));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> A[i][j];
        }
    }
    A = matpow(A, K);
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            ans += A[i][j];
            ans %= mod;
        }
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifdef _DEBUG
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif
    Main();
}


Measured memory_bytes: 384
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int dh[4]={0,1,0,-1};
int dw[4]={1,0,-1,0};

int main (){
      int N;
      cin>>N;
      P p[N];
      rep0(i,N){
            cin>>p[i].first>>p[i].second;
      }
      sort(p,p+N);
      map<P,vector<Q>> v;
      rep0(i,N){
            if(i!=(N-1)){
                  ll d = abs(p[i+1].first-p[i].first);
                  v[p[i]].push_back({d,p[i+1]});
            }
            if(i!=0){
                  ll d=abs(p[i].first-p[i-1].first);
                  v[p[i]].push_back({d,p[i-1]});
            }
      }
      rep0(i,N){
            swap(p[i].first,p[i].second);
      }
      sort(p,p+N);
      rep0(i,N){
            swap(p[i].first,p[i].second);
      }
      rep0(i,N){
            if(i!=(N-1)){
                  ll d=abs(p[i+1].second-p[i].second);
                  v[p[i]].push_back({d,p[i+1]});
            }
            if(i!=0){
                  ll d=abs(p[i].second-p[i-1].second);
                  v[p[i]].push_back({d,p[i-1]});
            }
      }
      rep0(i,N){
      sort(v[p[i]].begin(), v[p[i]].end());
      v[p[i]].erase(std::unique(v[p[i]].begin(), v[p[i]].end()), v[p[i]].end());
      }
      /*rep0(i,N){
            cout<<i<<"  ";
            rep0(j,v[p[i]].size()){
                  cout<<v[p[i]][j].first<<" "<<v[p[i]][j].second.first<<" "<<v[p[i]][j].second.second<<"  ";
            }
            cout<<endl;
      }*/
      map<P,ll> d;
      map<P,bool> merged;
      rep0(i,N){
            d[p[i]]=longinf;
            merged[p[i]]=false;
      }
      d[p[0]]=0;
      priority_queue<Q,vector<Q>,greater<Q>> q;
      q.push({d[p[0]],p[0]});
      ll ans=0;
      while(q.size()){
            Q hoge = q.top();
            q.pop();
            ll di = hoge.first;
            P node = hoge.second;
            if(merged[node]) continue;
            ans+=di;
            merged[node]=true;
            for(int i=0;i<v[node].size();i++){
                  ll nd = v[node][i].first;
                  P np =v[node][i].second;
                  d[np]=min(d[np],nd);
                  q.push({d[np],np});
            }
      }
      cout<<ans<<endl;

      return 0;
}


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

int p[200010];
int k[200010];

int main () {

int n,m;
cin>>n>>m;
int a,b;
for (int i=0; i<m; i++) {
	cin>>a>>b;
	if (a==1) {
		p[b]=1;
	}
	if (b==1) {
		p[a]=1;
	}
	if (a==n) {
		k[b]=1;
	}
	if (b==n) {
		k[a]=1;
	}
}
for (int i=2; i<n; i++) {
	if (p[i]==1 && k[i]==1) {cout<<"POSSIBLE"<<endl; return 0;}
}
cout<<"IMPOSSIBLE"<<endl;

return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
int main()
{
	vector<string> list;
	string item;
	string line;
	getline(cin, line);

	stringstream ss(line);
	while (getline(ss, item, ' ') && !item.empty()) {
		list.push_back(item);
	}
	int a = stoi(list[0].c_str());
	int b = stoi(list[1].c_str());
	cout << a*b << " "<<(a*2 + b*2)<<endl;
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;int s=1<<n;R(i,n*2)cin>>c[i/n][i%n];fill(p[1],p[s],1e9);R(B,s){int o=0,d[n];R(i,n)d[i]=~B&1<<i?o++:0;R(i,n){int k=c[(i-n+o)&1][i],&t=p[B|1<<i][k];R(j,k+1)t=min(t,p[B][j]+d[i]);a=min(a,(B|1<<i)<s-1?a:t);}}cout<<(a>1e8?-1:a);}


Measured memory_bytes: 52480
ticket = list(input())
if int(ticket[0])+int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])+int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"+"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])+int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"+"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])+int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"+"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")
elif int(ticket[0])-int(ticket[1])-int(ticket[2])-int(ticket[3])==7:
    print(ticket[0]+"-"+ticket[1]+"-"+ticket[2]+"-"+ticket[3]+"=7")

Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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



int main(){
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 1, 0);
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            cnt[a]++;
        }
    }
    int res = 0;
    REP(i, 1, n){
        if(cnt[i] == 0)res++;
    }
    cout << res;
}



Measured memory_bytes: 3196
#pragma GCC optimize("O3", "unroll-loops")
#include <bits/stdc++.h>

using namespace std;
const int maxn = 4 + 2;
short cnt[maxn], a, b;
bool flag = true;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	for (int i = 0; i < 3; i++)
		cin >> a >> b, cnt[a]++, cnt[b]++;
	for (int i = 1; i <= 4; i++)
		flag &= (cnt[i] < 3);
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);


		int n = sc.nextInt();
		int k = sc.nextInt();

		long total = 0;
		int mod = 1_000_000_007;

		for(int i = k; i <= n + 1; i++){
			long bottom = sumSeq(0, i - 1);
			long top = sumSeq(n - i + 1, n);

			total += top - bottom + 1;
			total %= mod;

//			System.out.println("i = "+i+" total = "+total+ " bottom = " + bottom + " top = "+top);
		}

		System.out.println(total);

	}

	static long sumSeq(int a, int b){
		return ((long)b - a + 1)*(a + b)/2;
	}
}


Measured memory_bytes: 27228
#include <stdio.h>

int main(void){
    int X; //標準入力からのXを入れる

    scanf("%d", &X);

    int i; //カウンタ
    int tmp; //i回目X度回転した時の角度を格納
    i = 0; //初期化
    tmp = 0; //初期化
    while(1){
        i++; //カウンタの更新
        tmp += X; //X度を足す．
        if(tmp%360 == 0) break;
    }

    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int n, k;
	cin >> n >> k;
	if (n % k == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
A = [int(input()) for _ in range(n)]

# 素数判定 O(n ** 0.5)
def is_prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return n != 1 # 1のときは例外

cnt = 0
for v in A:
	if is_prime(v): cnt += 1

print(cnt)


Measured memory_bytes: 5992
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for(int i = 0;i<n;i++){
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double kari = v[0];
        for(int i = 1;i<n;i++){
            kari = (kari + (double)(v[i])) / 2;
        }
        System.out.println(kari);
        sc.close();
    }
}

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

int main(){
  long long a, b, c, k, Ans = 0;
  cin >> a >> b >> c >> k;
    
  if(k <= a)	Ans = k;
  else if (k > a && k <= a+b)	Ans = a;
  else if (k > a+b)	Ans = a - (k - (a+b));

  cout << Ans << endl;
}

Measured memory_bytes: 3636
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}

typedef struct pair_{
    int a;
    int b;
}pair_t;

int asc_t(const void *a,const void *b){if(((pair_t*)a)->a < ((pair_t*)b)->a)return -1;else if(((pair_t*)a)->a == ((pair_t*)b)->a)return 0;else return 1;}
//int desc_t(const void *a,const void *b){if((struct_t*)a->a < (struct_t*)b->a)return 1;else if((struct_t*)a->a == (struct_t*)b->a)return 0;else return -1;}


int main(){
    pair_t pair[200000];
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d %d",&pair[i].a,&pair[i].b);
    }
    qsort(pair,n,sizeof(pair_t),asc_t);

    ll sum=0,cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<pair[i].b;j++){
            if(cnt==m)goto OUTPUT;
            sum+=pair[i].a;
            cnt++;
        }
    }
OUTPUT:
    printf("%lld\n",sum);
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  ll n=s.size(),m=t.size();
  ll ans=10000;
  rep(i,n-m+1){
    ll cnt=0;
    rep(j,m){
      if(s[i+j] != t[j]){
        cnt++;
      }
    }
    ans = min(ans,cnt);
  }
  
  cout << ans << endl;
  
  return(0);
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
static int result;
static List<int> s=new List<int>();
  static List<int> t=new List<int>();
  static int N;
  
    static void Main()
    {
      N=int.Parse(Console.ReadLine());
  Read();
      for(int i=1;i<N-1;i++){if(s[i-1]>s[i] && s[i+1]<s[i]){result++;}
                            if(s[i-1]<s[i] && s[i+1]>s[i]){result++;}
                            }
      
                    Console.WriteLine(result.ToString());
    }

static void Read()
{
  string[] tmp=Console.ReadLine().Split(' ');
for(int i=0;i<N;i++){s.Add(int.Parse(tmp[i]));}
}
}

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

int main(void)
{
	int i=1;
	int in;
	while (1) {
		cin >> in;
		if (in==0) {
			break;
		}
		else {
			cout << "Case" << " " << i << ":" << " " << in << endl;
			i++;
		}
	}
	return 0;
}



Measured memory_bytes: 3044
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    def count(s):
        tmp = s[0]
        cnt = 0
        for c in s:
            if c != tmp:
                cnt += 1
                tmp = c
        return cnt
    #ret = min(count(S), count(str(reversed(list(S)))))
    ret = count(S)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string s;
  cin >> s;
  bool N = false;
  bool W = false;
  bool S = false;
  bool E = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'N') {
      N = true;
    }
    if (s[i] == 'W') {
      W = true;
    } 
    if (s[i] == 'S') {
      S = true;
    } 
    if (s[i] == 'E') {
      E = true;
    } 
  }
  bool ans = true;
  if ((!N && S) || (N && !S)) {
    ans = false;
  }
  if ((!W && E) || (W && !E)) {
    ans = false;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string s;
    int n;
    cin >> n >> s;
    for (int i = 0; i < sz(s); i++){
        s[i] = s[i] + n;
        if (s[i] > 'Z') s[i] = 'A' + s[i] - 'Z' -1;
    }
    cout << s << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3596
import math
def prime(x):
  L = []
  last = math.floor(x ** 0.5) 
  for i in range(1, last + 1):
    if x % i == 0:
      L.append(i)
      if x // i != i:
        L.append(x // i)
  return L

N = int(input())

if N == 2:
  print(1)
  exit()

L = prime(N - 1)

ans = len(L) - 1

D = prime(N)

for i in D:
  if i == 1: continue
  t = N
  while (t / i == t // i):
    t //= i

  t -= 1
  if t / i == t // i:
    ans += 1

print(ans)


Measured memory_bytes: 39152
n = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

yakusu = make_divisors(n)
l_yakusu = len(yakusu)
count = 0
yakusu_idx = 0
#aの通り数でfor
for a in range(1,n):
    b = n//a
    if b < a:
        break
    if yakusu_idx < l_yakusu and a == yakusu[yakusu_idx]:
        tmp = (b-a)*2
        if tmp>0:
            count += tmp - 1
        yakusu_idx += 1
    else:
        tmp = (b-a+1)*2
        if tmp>0:
            count += tmp -1

print(count)


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

const ll mod = 1e9 + 7;

ll dfs(vector<vector<int> > &g, ll k, int v, int from) {
    int color = k - 2;
    if (from == -1) color = k - 1;
    if (k < g[v].size()) {
        return 0;
    } else {
        ll res = 1;
        for (int to : g[v]) {
            if (to == from) continue;
            res *= color;
            color--;
            res %= mod;
        }
        for (int to : g[v]) {
            if (to == from) continue;
            res *= dfs(g, k, to, v);
            res %= mod;
        }
        return res;
    }
}

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<vector<int> > g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout << (k * dfs(g, k, 0, -1)) % mod << endl;
    return 0;
}

Measured memory_bytes: 11520
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
//int[] num=new int[6];
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/
if(A%B==0){

System.out.println(0);
}else{
System.out.println(1);

}
	}
}

Measured memory_bytes: 22100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final FastIn in = new FastIn();
	private static final PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		var sol = new Solver();
		sol.solve();
		out.close();
	}

	private static final class Solver {
		public void solve() {
			int a = in.nextInt(), b = in.nextInt(), h = in.nextInt();
			out.println((a + b) * h / 2);
		}
	}

	private static final class FastIn {
		private BufferedReader br;
		private StringTokenizer st;

		public FastIn() {
			br = new BufferedReader(new InputStreamReader(System.in), 1 << 20);
			st = null;
		}

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

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


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

const string weather[] = {"Sunny", "Cloudy", "Rainy"};

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

    string ans;
    if (s=="Sunny") s = "Cloudy";
    else if (s=="Cloudy") s = "Rainy";
    else s = weather[0];

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b;
    char op;
    cin >> a >> op >> b;
    int ret = op == '+' ? (a + b) : (a - b);
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
A, B, C = map(int, input().split())
K = int(input())
b = B
c = C

cnt = 0
while A >= b:
    b *= 2
    cnt += 1
    
while b >= c:
    c *= 2
    cnt += 1

if(cnt <= K):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
let rec f n ans arr =
  if n = 0 then ans
  else
    let subarr = Array.sub arr 0 n in
    let c = Array.get arr n in
    let m = Array.fold_right max subarr c in
    if m <= c then f (n-1) (ans+1) arr
    else f (n-1) ans arr
let () =
  Scanf.scanf "%d\n"
    (fun n ->
       Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) |> f (n-1) 1)
  |> print_int

Measured memory_bytes: 2432
#include<stdio.h>
int main()
{
	int n,a,b,c;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d%d",&a,&b,&c);
		if(a*a+b*b==c*c || a*a+c*c==b*b || c*c+b*b==a*a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	
}

Measured memory_bytes: 1008
#include<iostream>
#include<vector>
#include<stack>
#include<map>
#include<sstream>
#include<cstdlib>
#define inf 1<<29
using namespace std;

typedef long long ll;

ll n;
string s;
char ans;
vector<string> v;
map<int,int> mp;
bool flag=false;

ll rec(int,int,ll);

void rec2(int a,int b,ll sum){
  flag=true;
  for(int i=a;i<b;i++){
    if('0'<=v[i][0] && v[i][0]<='9'){
      if(ans!='0')return;
      if(v[i+1]=="("){
	ll tmp=rec(i+2,mp[i+1],0);
	if(sum<tmp*atoi(v[i].c_str()))rec2(i+2,mp[i+1],sum%tmp);
	else sum-=tmp*atoi(v[i].c_str());
	if(ans!='0')return;
        i=mp[i+1];
      }
      else {
        ll tmp=atoi(v[i].c_str());
        if(sum<tmp){
	  ans=v[i+1][0];
	  return;
	}
	else {
	  sum-=tmp;
	  i++;
	}
      }
    }
    else if('A'<=v[i][0] && v[i][0]<='Z'){
      if(sum<v[i].length()){
	ans=v[i][sum];
	return;
      }
      else sum-=v[i].length();
    }
    else {}
  }
  return;
}

ll rec(int a,int b,ll c){
  ll sum=0;
  if(ans!='0')return inf;

  for(int i=a;i<b;i++){
    if('0'<=v[i][0] && v[i][0]<='9'){
      if(ans!='0')return inf;
      if(v[i+1]=="("){
	ll tmp=rec(i+2,mp[i+1],sum+c);
	if(ans!='0')return inf;
	sum+=atoi(v[i].c_str())*tmp;
	i=mp[i+1];
      }
      else {
	sum+=atoi(v[i].c_str())*v[i+1].length();
	i++;
      }
    }
    else if('A'<=v[i][0] && v[i][0]<='Z'){
      sum+=v[i].length();
    }
    else {}
  }
  if(n<sum && c<=n)rec2(a,b,n-c);
  return sum;
}

int main()
{
  while(1){
    cin>>s>>n;
    if(s[0]=='0' && n==0)break;
    ans='0';
    v.clear();mp.clear();
    string tmp1="",tmp2="";
    for(int i=0;i<s.length();i++){
      if('0'<=s[i] && s[i]<='9'){
	if(tmp2!="")v.push_back(tmp2);
	tmp2="";
	tmp1+=s[i];
      }
      if('A'<=s[i] && s[i]<='Z'){
	if(tmp1!="")v.push_back(tmp1);
	tmp1="";
	tmp2+=s[i];
      }
      if(s[i]=='('){
	v.push_back(tmp1);
	tmp1="";
	v.push_back("(");
      }
      if(s[i]==')'){
        v.push_back(tmp2);
        tmp2="";
        v.push_back(")");
      }
      if(i==s.length()-1 && tmp2!="")v.push_back(tmp2);
    }
    stack<int> st;
    for(int i=0;i<v.size();i++){
      if(v[i]=="(")st.push(i);
      if(v[i]==")"){
	mp[st.top()]=i;
	st.pop();
      }
    }
    flag=false;  
    rec(0,v.size(),0);
    cout<<ans<<endl;
  }
  return 0;
}

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

void solve(unsigned n, const std::vector<unsigned>& d)
{
    bool t[10] = {};
    for (const unsigned x : d)
        t[x] = true;

    const auto check = [&t](unsigned n) {
        do {
            if (t[n % 10])
                return false;
            n /= 10;
        } while (n != 0);

        return true;
    };

    while (!check(n))
        ++n;

    std::cout << n << '\n';
}

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

    size_t k;
    std::cin >> k;

    std::vector<unsigned> d(k);
    for (size_t i = 0; i < k; ++i)
        std::cin >> d[i];

    solve(n, d);

    return 0;
}



Measured memory_bytes: 3628
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll n;
  cin >> n;
  vll a(n),b(n),c(n);

  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];

  vsort(a);
  vsort(b);
  vsort(c);

  ll ans = 0;

  rep(i,n)
  {
    ll an = lower_bound(all(a),b[i]) - a.begin();
    ll cn = c.end() - upper_bound(all(c),b[i]);

    ans += an * cn;
  }


  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
	int N, M;

    cin >> N >> M;

    if(1 < abs(N-M)){
        cout << "0" << endl;
        return 0;
    }

    long long int ans = 1, s = 1, t = 1;
    while(s <= N && t <= M){
        ans = (ans * s) % (1000000000+7);
        ans = (ans * t) % (1000000000+7);
        s++; t++;
    }

    if(N == M){
        ans = (ans * 2) % (1000000000+7);
    }else if(N < M){
        ans = (ans * M) % (1000000000+7);
    }else{
        ans = (ans * N) % (1000000000+7);
    }

    cout << ans << endl;

	return 0;
}

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

namespace ConsoleApp14
{
    class Class15
    {
        static void Main()
        {
            var nx = Console.ReadLine().Split();
            int x = int.Parse(nx[1]);
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);

            int ans = 0;
            for(int i = 0; i < a.Count(); i++)
            {
                if (a[i] <= x)
                {
                    ans++;
                    x -= a[i];
                }
                else
                {
                    x=0;break;
                }
            }
            if (x > 0) ans--;
            Console.WriteLine(ans>0?ans:0);
        }
    }
}


Measured memory_bytes: 13396
n = int(input())

m = [[] for _ in range(n+1)]

for _ in range(n):
	tmp = [int(x) for x in input().split()]
	u,k,l = tmp[0],tmp[1],tmp[2:]
	m[u] += tmp[2:]
		
dp = [float('inf') for _ in range(n+1)]
dp[1] = 0
queue = [1]

while queue:
	t = queue.pop(0)
	for x in m[t]:
		if dp[x] > dp[t] + 1:
			dp[x] = dp[t] + 1
			queue.append(x)
			
for i,x in enumerate(dp):
	if i == 0:
		pass
	else:
		if x == float('inf'):
			print(i, -1)
		else:
			print(i, x)
			

	


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	string s, t;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	cin >> s;

	rep(i, s.size()) {
		if (i == 0) continue;

		t = s.substr(0, s.size() - i);
		if (t.size() % 2 != 0) continue;

		string t1, t2;
		t1 = t.substr(0, t.size() / 2);
		t2 = t.substr(t.size() / 2, t.size() / 2);

		if (t1 == t2) {
			l_ans = t.size();
			break;
		}
	}

	cout << max(1LL, l_ans) << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_b();

	return 0;
}


Measured memory_bytes: 3664
using System;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        string[] inputnm = Console.ReadLine().Split(' ');
        int N = int.Parse(inputnm[0]);
        int M = int.Parse(inputnm[1]);


        int[] L = new int[M];
        int[] R = new int[M];
        for(int i = 0; i < M; i++)
        {
            string[] input = Console.ReadLine().Split(' ');
            L[i] = int.Parse(input[0]);
            R[i] = int.Parse(input[1]);

        }
        Array.Sort(R);
        Array.Sort(L);

        int ans = 0;
        int dif = R[0] - L[M - 1];

        if (dif < 0) { ans = 0; }
        else { ans = dif+1; }
        

Console.WriteLine(ans);
            }
} 

Measured memory_bytes: 15820
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    vector<ll>v={1};
    for(int i=1;;i++){
        ll num=pow(6,i);
        if(num>pow(10,5))break;
        v.push_back(num);
    }
    for(int i=1;;i++){
        ll num=pow(9,i);
        if(num>pow(10,5))break;
        v.push_back(num);
    }
    sort(all(v));

    // for(ll i : v)cout<<i<<endl;


    ll n;cin>>n;
    //ナップサック
    vector<ll>dp(n+1,INF);
    dp[0]=0;
    rep(i,n)rep(j,v.size()){
        //use3
        if(v[j]+i<=n)chmin(dp[v[j]+i],dp[i]+1);
    }
    // rep(i,n+1)cout<<dp[i]<<endl;
    cout<<dp[n]<<endl;

    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    char s[5];
    int cnt[4] = {0};
    scanf("%s", s);
    for (int i = 0; i < 3; i++)
        for (int j = i + 1; j < 4; j++)
            if (s[i] == s[j])
            {
                cnt[i]++;
                cnt[j]++;
            }
            
    for (int i = 0; i < 3; i++)
        if (cnt[i] != cnt[i + 1] || cnt[i] != 1 || cnt[3] != 1)
        {
            puts("No");
            return 0;
        }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("/|\n");
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.nextInt();
        if(a <= 2019 && b <= 4){
            System.out.println("Heisei");
        }else{
            System.out.println("TBD");
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
using namespace std;

int main(){
  long na, nb, nc, k;
  cin >> na >> nb >> nc >> k;
  vector<long> a(na), b(nb), c(nc);
  for(int i=0; i<na;i++) cin >> a[i];
  for(int i=0; i<nb;i++) cin >> b[i];
  for(int i=0; i<nc;i++) cin >> c[i];
  sort(a.begin(), a.end(), greater<long>());
  sort(b.begin(), b.end(), greater<long>());
  sort(c.begin(), c.end(), greater<long>());
  priority_queue<vector<long>> q;
  set<vector<long>> s;
  vector<long> dum(4);
  dum[0] = a[0]+b[0]+c[0];
  dum[1] = 0;
  dum[2] = 0;
  dum[3] = 0;
  q.push(dum);
  s.insert(dum);
  for(int i=0; i<k; i++) {
    vector<long> dv = q.top();
    cout << dv[0] << endl;
    q.pop();

    if(dv[1] < na-1){
        dum[0] = a[dv[1]+1]+b[dv[2]]+c[dv[3]];
        dum[1] = dv[1]+1;
        dum[2] = dv[2];
        dum[3] = dv[3];
        if (s.find(dum) == s.end()) {
            q.push(dum);
            s.insert(dum);
        }
    }

    if(dv[2] < nb-1){
        dum[0] = a[dv[1]]+b[dv[2]+1]+c[dv[3]];
        dum[1] = dv[1];
        dum[2] = dv[2]+1;
        dum[3] = dv[3];
        if (s.find(dum) == s.end()) {
            q.push(dum);
            s.insert(dum);    
        }
    }

    if(dv[3] < nc-1){
        dum[0] = a[dv[1]]+b[dv[2]]+c[dv[3]+1];
        dum[1] = dv[1];
        dum[2] = dv[2];
        dum[3] = dv[3]+1;
        if (s.find(dum) == s.end()) {
            q.push(dum);
            s.insert(dum);
        }
    }
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr int N = 40;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  V<lint> c(n + 1); for (int i = 0; i < n; ++i) c[i + 1] = c[i] + a[i];
  V<lint> s;
  for (int l = 0; l < n; ++l) for (int r = l + 1; r <= n; ++r) {
    s.push_back(c[r] - c[l]);
  }
  lint res = 0;
  bitset<500500> b;
  b.set();
  n = s.size();
  for (int j = N - 1; j >= 0; --j) {
    int m = 0;
    for (int i = 0; i < n; ++i) if (b[i]) m += !!(s[i] & 1LL << j);
    if (m >= k) {
      for (int i = 0; i < n; ++i) if (~s[i] & 1LL << j) b[i] = false;
      res |= 1LL << j;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 6128
def getinputdata():
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:
        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

cnt=0
for i in range(1,n+1):
     
     val=int(arr_data[1][i-1])
     
     if i==int(arr_data[1][val-1]):
         
         cnt+=1
         
print(cnt//2)

Measured memory_bytes: 10420