akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    String s=gs();
	    String co="CODEFESTIVAL2016";

        int c=0;
        for (int i=0; i<s.length();i++) {
        	if(s.charAt(i)!=co.charAt(i))c++;
        }
	    System.out.print(c);
//	    if (n%10==3) {
//	    	System.out.print("bon");
//	    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
//	    	System.out.print("pon");
//	    } else {
//	    	System.out.print("hon");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

#define int long long

#define inf 1000000007LL
#define mod 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

int d[114514];

int q[114514];
int q2[114514];

signed main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) {
    cin >> d[i];
    d[i]--;
  }
  trep(i, m) {
    q[i] = 0;
    q2[i] = 0;
  }
  int all = 0;
  rep(i, n - 1) {
    if(d[i] < d[i + 1]) {
      if(d[i] + 2 <= d[i + 1]) {
        q[d[i] + 2]++;
        q[d[i + 1] + 1]--;
        q2[d[i + 1] + 1] -= d[i + 1] - d[i] - 1;
      }
      all += d[i + 1] - d[i];
    }
    else if(d[i] == d[i + 1]) {}
    else {
      if(d[i] + 2 <= d[i + 1] + m) {
        q[d[i] + 2]++;
        if(d[i] < m - 1) {
          q[0]++;
          q2[0] += m - d[i] - 2;
        }
        else {
          q[1]++;
        }
        q[d[i + 1] + 1]--;
        q2[d[i + 1] + 1] -= d[i + 1] + m - d[i] - 1;
      }
      all += d[i + 1] + m - d[i];
    }
  }
  int ans = inf * inf;
  int now = 0;
  rep(i, m) {
    now += q[i];
    all -= now + q2[i];
    ans = min(ans, all);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import std;
import core.bitop;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "g");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    auto t = sread();
    writeln(sort!"a<b"(cast(ubyte[]) s).array() < sort!"a>b"(cast(ubyte[]) t).array() ? "Yes" : "No");
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

int main() {
    string S;
    cin >> S;
    bool j1 = true;
    bool j2 = true;
    bool j3 = true;

    if(S.at(0) != 'A'){
        j1 = false;
    }
    else{
        S.at(0) = 'a';
    }

    int count =0;
    for(int i=2; i<=S.size()-2; i++){
        if(S.at(i)=='C'){
            count++;
            S.at(i) = 'c';
        }
    }
    if(count != 1){
        j2 = false;
    }

    for(int i=0; i<S.size(); i++){
        if(isupper(S.at(i))){
            j3 = false;
        }
    }

    if(j1 && j2 && j3){
        cout << "AC" << endl;
    }
    else{
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner s = new Scanner(System.in)) {
            int n = s.nextInt();
            int k = s.nextInt();
            Set<String> set = new HashSet<>();
            for (int i = 0; i < k; i++) {
                int d = s.nextInt();
                for (int j = 0; j < d; j++) {
                    set.add(s.next());
                }
            }
            System.out.println(n - set.size());
        }
    }
}

Measured memory_bytes: 41468
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
list($N,$Y) = explode(" ",trim(fgets(STDIN)));
//$N=trim(fgets(STDIN));
//for($i=0;$i<$N;$i++) {
  //$d[]=trim(fgets(STDIN));
//}
//YがN*10000>だったりN*1000<以下ならありあえない
if ($N*10000<$Y||$N*1000>$Y) {
  printf("-1 -1 -1\n");
  exit;
}
$x = floor($Y / 10000);
$y = 0;
$z = $N-$x;
$flg=false;
for($i=$x;$i>=0;$i=$i-1) {
  if (($i*10000+$y*5000+$z*1000)==$N) {
    $flg=true;
    $x=$i;
    break;
  }
  $a = $N - $i;
  //余った数を5000円と1000円に振り分ける
  if (chk($a,$i)) {
     $flg=true;
     $x=$i;
     break;
  }
}
if ($flg) {
  printf("%d %d %d\n",$x,$y,$z);
}
else {
  printf("-1 -1 -1\n");
}

function chk($n,$x) {
  global $Y,$y,$z;
 // printf("n=%d x=%d\n",$n,$x);
  for($i=0;$i<=$n;$i++) {
    $chkval = $n*1000+$i*4000;
    if ($x*10000+$chkval==$Y) {
      $z=$n-$i;
      $y=$i;
      return true;
    }
  }
  return false;
}


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

static const int N = 1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i=0;i<=m;i++) c[i][0] = 0;
  for(int j=1;j<=n;j++) c[0][j] = 0;

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i] == Y[j]){
        c[i][j] = c[i-1][j-1] + 1;
      }else{
        c[i][j] = max(c[i-1][j],c[i][j-1]);
      }
      maxl = max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string s1,s2;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
  }
  return 0;
}



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


int main(){
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i,3){
        mp[s[i]]++;
    }
    if(mp['a'] && mp['b'] && mp['c']){
        cout << "Yes\n";
    }else cout << "No\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for (ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
  if (n == 0)
    return abs(m);
  return (gcd(n, m % n));
}
void putYN(bool b) {
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
void swap(ll &a, ll &b) {
  ll tmp = a;
  a = b;
  b = tmp;
}
ll combi(ll n, ll k) {
  ll r = 1, rr = 1;
  for (ll i = 0; i < k; ++i) {
    r *= (n - i);
    rr *= (i + 1);
    // r %= 1000000007;
    // rr %= 1000000007;
  }
  r /= rr;
  // r %= 1000000007;
  return r;
}
int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> A(N, vector<ll>(N - 1));
  vector<vector<ll>> B(N, vector<ll>(N));
  FOR(i, N) {
    FOR(j, N - 1) {
      cin >> A[i][j];
      A[i][j]--;
      B[i][A[i][j]]=j;
      //iが何番目に入っているかを調べる
    }
  }
  vector<vector<ll>> D(N, vector<ll>(N - 1,-1));
  //最短日数

  function<ll(ll,ll,ll)> f =[&](ll i,ll n,ll ii)->ll{//iがi番目の選手 nが見る番号
      if(ii>N*(N+1))return -2;
      if(n==-1)return 0;
      if(D[i][n]!=-1)return D[i][n];
      ll a = A[i][n];//もう一つの選手
      ll an = B[a][i];
      ll day1 = f(i,n-1,ii+1)+1;
      ll day2 = f(a,an-1,ii+1)+1;
      if(day1==-1||day2==-1){
          day1= -2;
          day2= -2;
      }
      if(day1<day2)day1=day2;
      D[i][n]=day1;
      D[a][an]=day1;
      return day1;
  };
  ll maxd=0;
  FOR(i,N){
      ll day=f(i,N-2,0);
      if(day>maxd){
          maxd=day;
      }
      if(day==-2){
          cout<<-1<<endl;
          return 0;
      }
  }
  cout<<maxd<<endl;
  return 0;
}


Measured memory_bytes: 117632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

int main(){
  int i,j;
  int a,b;
  cin>>a>>b;
  if(1<=a&&a<10&&1<=b&&b<10){
    cout<<a*b<<endl;
    return 0;
  }
  cout<<-1<<endl;


}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
s = sum(b)
for i in range(n-1):
    if a[i+1]-a[i] == 1:
        s+=c[a[i]-1]
print(s)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head, tail,n;

void enqueue(P);
P dequeue(void);
int min(int, int);

int main()
{
  int elaps = 0, c;
  int i,q;
  P u;
  
  scanf("%d %d",&n,&q);

  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n + 1;
  
  while(head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if(u.t > 0)enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }
  
  return 0;
}

void enqueue(P x)
{
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(void)
{
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b)
{
  return a < b ? a : b;
}



Measured memory_bytes: 11848
import sys

(K,N)=map(int,input().split())

buf=input()
A=list(map(int,buf.split()))

diff_max=A[0]+K-A[N-1]
imax=N
for i in range(N-1):
    d=A[i+1]-A[i]
    if d>diff_max:
        diff_max=d
        imax=i

print(K-diff_max)

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

int main(){
  int Min, Max;
  cin >> Min >> Max;
  
  int p = Max - Min + 1;
  int counter = 0;
  for ( int i = 0; i < p ; i++){
    string s = to_string(Min + i);
    if (s.at(0) == s.at(4) && s.at(1) == s.at(3)){
      counter++;
        }//if
    }//for i
  cout << counter <<endl;
}//main
  

Measured memory_bytes: 256
import sys

W, H, N = map(int, sys.stdin.readline().strip().split())
opes = []
for _ in range(N):
    x, y, a = map(int, sys.stdin.readline().strip().split())
    opes.append((x, y, a))

x_min = 0
x_max = W
y_min = 0
y_max = H
for (x, y, a) in opes:
    if a == 1:
        x_min = max(x_min, x)
    elif a == 2:
        x_max = min(x_max, x)
    if a == 3:
        y_min = max(y_min, y)
    if a == 4:
        y_max = min(y_max, y)

if x_max <= x_min or y_max <= y_min:
    print(0)
else:
    print((x_max - x_min) * (y_max - y_min))

Measured memory_bytes: 38256
num = int(input())
a = [[0] * 10 for i in range(3)]
b = [[0] * 10 for i in range(3)]
c = [[0] * 10 for i in range(3)]
d = [[0] * 10 for i in range(3)]
for i in range(num):
  s = input().rstrip().split(' ')
  bild = int(s[0])
  floor = int(s[1])
  room = int(s[2])
  member = int(s[3])
  if bild == 1:
    a[floor-1][room-1] += member
  elif bild == 2:
    b[floor-1][room-1] += member
  elif bild == 3:
    c[floor-1][room-1] += member
  elif bild == 4:
    d[floor-1][room-1] += member

for j in range(3):
  ans = " "
  for k in range(9):
    ans = ans + str(a[j][k]) + " "
  ans += str(a[j][9])
  print(ans)
print("####################")
for l in range(3):
  ans = " "
  for m in range(9):
    ans = ans + str(b[l][m]) + " "
  ans += str(b[l][9])
  print(ans)
print("####################")
for n in range(3):
  ans = " "
  for o in range(9):
    ans = ans + str(c[n][o]) + " "
  ans += str(c[n][9])
  print(ans)
print("####################")
for p in range(3):
  ans = " "
  for q in range(9):
    ans = ans + str(d[p][q]) + " "
  ans += str(d[p][9])
  print(ans)


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

int main(){
    int N;
    cin>>N;
    int type1=0,type2=0,type3=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        int cnt=0;
        while(a%2==0){
            a/=2;
            cnt++;
        }
        if(cnt==0)type1++;
        else if(cnt==1)type2++;
        else type3++;
    }
    if(type2>0)type1++;
    bool f=false;
    if((type1+type3)%2==0){
        if(type1<=type3)f=true;
    }else{
        if(type1<=type3+1)f=true;
    }
    string ans=f?"Yes":"No";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(u) begin(u),end(u)
#define PB push_back
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

typedef long long int ll;
const int INF = (1<<30) - 1;
const double EPS = 1e-9;
const int MOD = 1000000007;

int N, M;

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    cin >> N >> M;
    vector<pair<int, int>> v;
    REP(i, M){
        int c, d; cin >> c >> d;
        v.PB(make_pair(c, d));
    }
    sort(v.begin(), v.end());
    
    int ans = N + 1;
    int i = 0;
    while(i<M){
        int s = i;
        int m = v[i].second;
        while(i+1<M && v[i+1].first <= m){
            i++;
            m = max(m, v[i].second);
        }
        ans += (m - v[s].first) * 2;
        i++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1212
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int A, B, H, M; cin >> A >> B >> H >> M;

    double deg_B = M/60.0 * 2 * M_PI ;
    double deg_A = (H + M/60.0)/12.0 * 2 * M_PI;
    double deg_a = fabs(deg_A - deg_B);

    double ans = A*A + B*B - 2*A*B*cos(deg_a);
    ans = sqrt(ans);

    cout << std::fixed << std::setprecision(20) << ans << endl;
}

Measured memory_bytes: 4188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int N, M;

signed main()
{
	cin >> N >> M;
	vector<pii> bridges;

	rep(i, M) {
		int a, b; cin >> a >> b;
		--a, --b;
		bridges.PB(b, a);
	}

	sort(all(bridges));

	int last = -1;

	int ans = 0;

	// 0~N-1
	rep(i, M) {
		pii br = bridges[i];
		int l = br.scd, r = br.fst;
		if (l < last and last <= r) {}
		else {
			last = r, ans++;
			//printf("i = %lld, ans++\n", i);
		}
	}

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



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

 
int main(){
	int N;
	cin >> N;
	int h[N];  	
	for(int i=0;i<N;i++){
      	cin >> h[i] ;
	}  
  	long long int a[N];
  	for(int i=0;i<N;i++){
      	a[i] = 0;
	}  
  	a[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
      	if((a[i-1] + abs(h[i]-h[i-1])) > (a[i-2]+abs(h[i]-h[i-2]))){
      	a[i] = a[i-2] + abs(h[i]-h[i-2]);
        }else{
        a[i] = a[i-1] + abs(h[i]-h[i-1]);
        }
	} 
    cout << a[N-1] << endl;
}

Measured memory_bytes: 1408
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (transpose)

main :: IO ()
main = do
  (n : k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  ps <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    (pf, sf) = splitAt k ps
    s0 = sum pf
    m = maximum . map snd . drop (pred k) . fix $ (map (flip (,) s0) pf ++) . walk s0 sf
  print . fromRational $ toRational (m + k) / 2

walk :: Int -> [Int] -> [(Int, Int)] -> [(Int, Int)]
walk s (p : ps) ((q, _) : qs) = (p, s') : walk s' ps qs
  where
    s' = s - q + p
walk _ _ _ = []

fix :: (a -> a) -> a
fix f = x
  where
    x = f x

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 55548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
    struct edge{lint y,id;};
    vector<vector<edge>> x (55);
    bool f[55];
    void dfs(lint to,lint id){
        f[to]=true;
        rep(i,x[to].size()){
            if(f[x[to][i].y]==true||id==x[to][i].id)continue;
            dfs(x[to][i].y,id);
        }

    }
  int main(){
    lint N,M;
    cin>>N>>M;
    fill(f,f+N,false);
    rep(i,M){
        lint a,b;
        cin>>a>>b;
        --a;--b;
        x[a].push_back({b,i});
        x[b].push_back({a,i});
    }
    lint ans=0;
    rep(i,M){
        dfs(0,i);
        rep(i,N){
            if(f[i]==false){
                ans++;
                break;
            }
        }
        fill(f,f+N,false);
    }
cout<<ans;
  }


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

typedef pair<LL, int> P;
struct Edge {
  int to;
  LL cost;
  Edge(LL a, int b) : to(a), cost(b) {}
};

LL prim(const vector<vector<Edge>>& G) {
  vector<bool> used(G.size(), false);
  vector<LL> d(G.size(), LLONG_MAX);
  LL total_dist = 0;

  priority_queue<P, vector<P>, greater<P>> que;
  que.push({0, 0});
  while (!que.empty()) {
    auto p = que.top(); que.pop();
    LL dist = p.first;
    int v = p.second;
    if (used[v]) continue;

    used[v] = true;
    total_dist += dist;
    for (auto e : G[v]) {
      que.push({e.cost, e.to});
    }
  }
  return total_dist;
}

int main() {
  int N; cin >> N;
  vector<pair<LL, LL>> ps(N), xs(N), ys(N);
  for (int i = 0; i < N; ++i) {
    LL x, y; cin >> x >> y;
    ps[i] = {x, y};
    xs[i] = {x, i};
    ys[i] = {y, i};
  }

  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  vector<vector<Edge>> G(N+1);
  for (size_t i = 1; i < xs.size(); ++i) {
    int n0 = xs[i-1].second;
    int n1 = xs[i].second;
    LL c = xs[i].first - xs[i-1].first;
    G[n0].push_back(Edge(n1, c));
    G[n1].push_back(Edge(n0, c));
  }
  for (size_t i = 1; i < ys.size(); ++i) {
    int n0 = ys[i-1].second;
    int n1 = ys[i].second;
    LL c = ys[i].first - ys[i-1].first;
    G[n0].push_back(Edge(n1, c));
    G[n1].push_back(Edge(n0, c));
  }

  cout << prim(G) << endl;
}


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

int main(){
	int n;
	cin >> n;
	int fg=0;
	int maxn=0;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>=maxn){
			maxn=a[i];
		}
		else if(a[i]<maxn-1){
			fg=1;
		}
	}
	if(fg==1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

namespace ConsoleApp14
{
    class Class20
    {
        static void Main()
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NK[0];
            int K = NK[1];
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var DP = new long[N + 1];
            for (int i = 0; i < N + 1; i++) DP[i] = int.MaxValue;
            DP[0] = 0;

            for(int i = 0; i < N - 1; i++)
            {
                for(int j = 1; j <= K; j++)
                {
                    if (j + i < N)
                    {
                        int k = Math.Abs(h[i] - h[i + j]);
                        DP[i + j] = Math.Min(DP[i + j], DP[i] + k);
                    }
                }
            }
            Console.WriteLine(DP[N - 1]);
        }
    }
}


Measured memory_bytes: 20576
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

void func(int be, int en, int cur, vector<vector<int>> &edg) {
	if (en - be <= 1) return;
	int th = be + (en - be) / 2;
	for (int i = be; i < en; i++) {
		if (i < th) {
			for (int j = th; j < en; j++) {
				edg[i][j] = cur;
			}
		}
		else {
			for (int j = be; j < th; j++) {
				edg[i][j] = cur;
			}
		}
	}
	func(be, th, cur + 1, edg);
	func(th, en, cur + 1, edg);
}

int main() {
	int n; cin >> n;
	vector<vector<int>> edg(n, vector<int>(n));
	func(0, n, 1, edg);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) cout << edg[i][j] << " \n"[j == n - 1];
	}
	return 0;
}

Measured memory_bytes: 1536
n = gets.to_i
x,y,h = n.times.map{gets.split.map(&:to_i)}.select{|(x,y,h)| h>0}.transpose
n = x.size

ans = []
101.times{|i|
  101.times{|j|
    w = n.times.map{|k| h[k]+((x[k]-i).abs+(y[k]-j).abs)}
    if w.uniq.size == 1
      ans << [i,j,w[0]]
    end
  }
}
 
puts ans.sort{|a,b| a[2]<=>b[2]}[0]*" "

Measured memory_bytes: 3324
import java.util.*;
import java.lang.Integer; 

public class Main {
  public static void main(String[] args){
    
    int answer = 0; // 返却値
    // 入力
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    if(!sc.hasNext()){
      System.out.println(answer);
       return;
    }
    int n = sc.nextInt();
    
    // nが0のとき
    if(n == 0){
      answer = x;
      System.out.println(answer);
      return;
    }
    
    // 入力値の読み込み
    Set<Integer> pSet = new HashSet<Integer>();
    while(sc.hasNext()){
      pSet.add(sc.nextInt());
    }
    
    // 数字を検索する
    int a = 0;
    while(true){
      if(!pSet.contains(x - a)){
        answer = x - a;
        break;
      }
      if(!pSet.contains(x + a)){
        answer = x + a;
        break;
      }
      a++;
    }
    // 出力
    System.out.println(answer);
  }
}

Measured memory_bytes: 35904
while True:
    num_hoseki=input()
    if num_hoseki==0:
        break
    
    hoseki_list=[]
    for i in range(num_hoseki):
        hoseki_list.append(map(int,raw_input().split()))
        
    num_meirei=input()
    
    keiro=[]
    x,y=[10,10]
    for i in range(num_meirei):
        meirei=raw_input()
        
        d, l=meirei.split()
        l=int(l)
        if d=='N':
            dx,dy=0,1
        elif d=='S':
            dx,dy=0,-1
        elif d=='W':
            dx,dy=-1,0
        elif d=='E':
            dx,dy=1,0

        for j in range(l):
            keiro.append([x+(j+1)*dx,y+(j+1)*dy])
        x,y=keiro[-1]
    flag=True
    for hoseki in hoseki_list:
        if not hoseki in keiro:
            flag=False
            break
    if flag:
        print 'Yes'
    else:
        print 'No'

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

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; }

using ll = long long;
using P = pair<int,int>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

bool dp[85][85][26000];

int main() {
    int H,W;
    cin>>H>>W;
    grid A(H,vector<int>(W)),B(H,vector<int>(W));
    rep(i,H){
        rep(j,W){
            cin>>A[i][j];
        }
    }
    rep(i,H){
        rep(j,W){
            cin>>B[i][j];
        }
    }
    grid D(H,vector<int>(W));
    rep(i,H){
        rep(j,W) D[i][j] = A[i][j]-B[i][j];
    }
    dp[0][0][13000-D[0][0]] = dp[0][0][13000+D[0][0]] = true;
    rep(i,H){
        rep(j,W){
            rep(k,2){
                int nx = i + dx[k];
                int ny = j + dy[k];
                if(nx>=H||ny>=W) continue;
                rep(l,26000){
                    if(dp[i][j][l]) dp[nx][ny][l+D[nx][ny]] = dp[nx][ny][l-D[nx][ny]] = true;
                }
            }
        }
    }
    int ans = INF;
    rep(i,26000){
        if(dp[H-1][W-1][i]) chmin(ans,abs(13000-i));
    }
    cout<<ans<<endl;
}

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

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

	int a[101];
	a[n + 1] = 0;

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

	int count = 0;

	for(int l = 0; l < n; l++){
		while (a[l] > 0) {
			
			int r = l;

			while (a[r+1] > 0) {
				r++;
			}

			for (int j = 0; j <= r - l; j++) {
				a[l + j]--;
			}

			count++;
		}
	}

	cout << count;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

template<typename T>
class DAG{
  private:
    int v;
    std::vector<std::vector<std::pair<int,T>>> to;
    std::vector<int> rank;
    std::vector<T> dp;
  public:
    DAG(int v,const T &x=T(0)):v(v){
        to.resize(v);
        rank.resize(v);
        dp.resize(v,x);
        std::iota(rank.begin(),rank.end(),0);
    }
    void add(int a,int b,const T &c=0){
        to[a].push_back(std::make_pair(b,c));
        if(rank[a]>rank[b]) std::swap(rank[a],rank[b]);
    }
    void set(int i,const T &x){
        dp[i]=x;
    }
    std::vector<T> calc(std::function<T(T,T)> f,std::function<T(ll,T)> h=[](ll a,T b){return b;},std::function<T(T,T)> g = std::plus<T>()){
        std::vector<int> vertex(v);
        std::vector<T> tmp=dp;
        for(int i=0;i<v;++i) vertex[rank[i]]=i;
        for(int i=0;i<v;++i){
            ll sz=to[vertex[i]].size();
            for(auto e:to[vertex[i]]){
                tmp[e.first]=f(tmp[e.first],g(h(sz,tmp[i]),e.second));
            }
        }
        return tmp;
    }
};

int main(){
    int N;cin>>N;
    vector<int> h(N);
    REP(i, N) cin >> h[i];
    DAG<int> D(N,1e9);
    REP(i,N){
        if(i+1<N) D.add(i,i+1,llabs(h[i+1]-h[i]));
        if(i+2<N) D.add(i,i+2,llabs(h[i+2]-h[i]));
    }
    D.set(0,0);
    cout<<D.calc([](int a,int b){return min(a,b);})[N-1]<<endl;
}


Measured memory_bytes: 7680
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  MOD=998244353
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n, m, k = 60522, 114575, 7559

  else:
    ##INPUT 
    #n = input()
    n, m, k = map(int, input().split())

  ## SUBMITION CODES HERE
  ans, N, K = 0, 1, 1
 
  for i in range(k+1):
    ans += N * pow(K, MOD-2, MOD) * pow(m-1, n-1-i, MOD)
    ans %= MOD
    N *= n-1-i
    N %= MOD
    K *= i+1
    K %= MOD
  
  ans *= m
  ans %= MOD
  print(ans)

main()

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

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

  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  cout << A[N-1]-A[0] << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
pN = list(map(int, input().split()))

ex_p = [(pi+1)/2 for pi in pN]
cum_p = [ex_p[0]]
for i in range(1,N):
    cum_p.append(cum_p[i-1]+ex_p[i])

max_ex = cum_p[K-1]
for i in range(1,N-K+1):
    if max_ex < cum_p[K+i-1] - cum_p[i-1]:
        max_ex = cum_p[K+i-1] - cum_p[i-1]

print(max_ex)




Measured memory_bytes: 112888
/*
 * atcoder/abc130/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
#define MOD 1000000007
template <class T> void madd(T &a, T b) { a += b; a %= MOD; }
template <class T> void msub(T &a, T b) { a -= b; if (a<0) a+=MOD; }

int N, M;
ll dp[2100][2100];
ll acc[2100][2100] = {0};
int S[2100], T[2100];

void solve() {
  cin >> N >> M;
  loop(i,0,N) cin >> S[i];
  loop(i,0,M) cin >> T[i];
  ll total = 1;
  for (int n=0; n<N; n++) {
    int s = S[n];
    for (int m=0; m<M; m++) {
      int t = T[m];
      if (s != t) dp[n][m] = 0;
      else {
        dp[n][m] = 1;
        if (n and m) madd(dp[n][m], acc[n-1][m-1]);
      }
      acc[n][m] = dp[n][m];
      if (n > 0) madd(acc[n][m], acc[n-1][m]);
      if (m > 0) madd(acc[n][m], acc[n][m-1]);
      if (n and m) msub(acc[n][m], acc[n-1][m-1]);
      madd(total, dp[n][m]);
    }
  }

  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 67840
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int n, n2;

int ask(VI &a){
    cout << "?";
    REP(i,n2){
        if (a[i]) cout << " " << i + 1;
    }
    cout << endl;
    string s;
    cin >> s;
    return (s == "Blue" ? 1 : 0);
}

void answer(VI ans){
    cout << "! ";
    REP(i,n2) {
        if (ans[i] == -1) cout << "?";
        else cout << "RB"[ans[i]];
    }
    cout << endl;
}

int main() {
    cin >> n;
    n2 = n * 2;
    VI a(n2);
    REP(i,n) a[i] = 1;
    int c = ask(a), x = -1;
    int same = n, diff = 0;
    VI ans(n2, -1);
    while (same - diff > 1){
        int p = (same + diff) / 2;
        VI a(n2);
        REP(i,n){
            if (i < p) a[i] = 1;
            else a[i + n] = 1;
        }
        if (ask(a) == c){
            same = p;
        }else{
            diff = p;
        }
    }
    x = diff;
    ans[x] = c;
    ans[x + n] = (c ^ 1);
    REP(i,n2){
        a[i] = (i < x || i > x + n);
    }
    FOR(i,x+1,x+n-1){
        a[i] = 1;
        ans[i] = ask(a);
        a[i] = 0;
    }
    REP(i,n2){
        a[i] = (i > x && i < x + n);
    }
    REP(i,x){
        a[i] = 1;
        ans[i] = ask(a);
        a[i] = 0;
    }
    FOR(i,x+n+1,n2-1){
        a[i] = 1;
        ans[i] = ask(a);
        a[i] = 0;
    }

    answer(ans);
    return 0;
}


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

int main(){
	string sd, t;
	cin >> sd >> t;

	vector<string>ans;
	for (int i = 0;i + t.size() - 1 < sd.size();i++) {
		bool b = true;
		for (int j = 0;j < t.size();j++) {
			if (sd[i + j] != '?'&&sd[i + j] != t[j]) {
				b = false;
			}
		}
		if (b) {
			string s = sd;
			s.replace(i, t.size(), t);
			replace(s.begin(), s.end(), '?', 'a');
			ans.push_back(s);
		}
	}
	sort(ans.begin(), ans.end());
	if (ans.empty()) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		cout << ans[0] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
e=[[]for _ in range(n)]
py=[]
for _ in range(m):
  p,y=map(int,input().split())
  py.append((p,y))
  e[p-1].append(y)
for i in range(n):e[i].sort()
xy=lambda x,y:y*1000000+x
d={}
for i in range(n):
  for j in range(len(e[i])):
    d[xy(i+1,e[i][j])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for p,y in py:
  print(d[xy(p,y)])


Measured memory_bytes: 50108
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn main() {
    
    let input:u8 = read();
    let result = if input!=0 {
        0
    }else {
        1
    };

    println!("{:?}",result);
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF 999999999
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4近傍
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

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

ll MOD = 1000000007;

void solve() {
    ll a,b; cin >> a >> b;
    if(a > 0 && b > 0) cout << "Positive" << endl;
    else if(a*b<=0) cout << "Zero" << endl;
    else{
        if((a-b)%2 == 0) cout << "Negative" << endl;
        else cout << "Positive" << endl;
    }
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

bool a[100010] = {false};
ll c[100010] = { 0 };

void Eratosthenes(){
	for (int i = 2; i <= 100000; i++) {
		if (!a[i]) for (int j = i + i; j <= 100000; j += i) a[j] = true;
	}
}

void check() {
	for (int i = 3; i <= 100000; i += 2) {
		if (!a[i] && !a[(i + 1) / 2]) c[i]++;
	}
	REP(i, 3, 100001) {
		c[i] += c[i - 1];
		//cout << c[i];
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	Eratosthenes();
	//rep(i, 100000) cout << a[i];
	check();
	ll q, ret;
	cin >> q;
	while (q--) {
		ll l, r;
		cin >> l >> r;
		cout << c[r] - c[l - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1536
from heapq import heapify, heappop, heappush

N=int(input())
V=[int(v) for v in input().split()]
V.sort()
heapify(V)

for _ in range(N-1):
  heappush(V, (heappop(V)+heappop(V))/2)

print(heappop(V))

Measured memory_bytes: 3188
N = int(input())
P = [int(input()) for i in range(N)]

T = [0] * (N + 1)
for i in P:
  if T[i - 1] == 0:
    T[i] = -1
  elif T[i - 1] < 0:
    T[i - 1] -= 1
    T[i] = i - 1
  else:
    T[T[i - 1]] -= 1
    T[i] = T[i - 1]

print(N + min(T))

Measured memory_bytes: 14736
#include <cstdio>

const int MAXN = 100000 + 10;

int n, m;
int q[MAXN], ql, qr;
int f[MAXN], pre[MAXN];
char s[MAXN];

void print(int u) {
	if(pre[u]) print(pre[u]);
	printf("%d ", u - pre[u]);
}

int main() {
	int i, j;
	
	scanf("%d %d %s", &n, &m, s);
	ql = qr = 1;
	q[1] = 0;
	for(i=1; i<=n; i++) {
		if(s[i] == '1')
			continue;
		while(ql <= qr and i - q[ql] > m)
			ql++;
		if(ql > qr) {
			printf("-1\n");
			return 0;
		}
		f[i] = f[q[ql]] + 1;
		pre[i] = q[ql];
		while(ql <= qr and f[q[qr]] > f[i])
			qr--;
		qr++;
		q[qr] = i;
	}
	print(n);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 4736
let cnt = ref 0

let insertion_sort n ?(gap=1) a =
  for i=gap to n-1 do
    let v = a.(i) in
    let j = ref (i - gap) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+gap) <- a.(!j);
      j := !j - gap;
      incr cnt;
    done;
    a.(!j+gap) <- v
  done;
  a

let shell_sort array n =
  let rec gen_gaps x = function
      [] -> gen_gaps x [1]
    | h::t when h > n -> t
    | _::_ as l -> let a,b = x.(0), x.(1) in
      x.(0) <- a*4; x.(1) <- b*2;
      gen_gaps x ((a+b+1)::l) in
  let gaps = gen_gaps [|4;3|] [] in
  let m = List.length gaps in
  let rec loop a = function
      [] -> a
    | h::t -> loop (insertion_sort n ~gap:h a) t in
  let a = loop array gaps in
  Printf.printf "%d\n" m;
  Array.iteri
    (fun i x -> Printf.printf (if i=m-1 then "%d\n" else "%d ") x)
    (Array.of_list gaps);
  Printf.printf "%d\n" !cnt;
  a

let () =
  let n = read_int () in
  let rec read a = function
      i when i = n -> a
    | i -> a.(i) <- (read_int ());
      read a (i+1) in
  let a = read (Array.make n 0) 0 in
  Array.iter (Printf.printf "%d\n") (shell_sort a n)

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

typedef struct list
{
    list *next;
    list *prev;

    int key;
} list;

list *first;
list *l_end;

void Insert(int key)
{
    list *p;
    p = new list;
    p->key = key;
    p->next = first;
    p->prev = NULL;
    if (first != NULL)
    {
        first->prev = p;
        first = p;
    }
    else
    {
        first = p;
        l_end = p;
    }
}

list *Search(int key)
{
    list *p;
    for (p = first; p != NULL; p = p->next)
    {
        if (p->key == key)
        {
            return p;
        }
    }
    return NULL;
}

void deleteEnd()
{
    list *tmp = l_end;
    l_end = l_end->prev;
    if (l_end != NULL)
    {
        l_end->next = NULL;
    }
    else
    {
        first = NULL;
    }
    delete tmp;
}

void deleteFirst()
{
    list *tmp = first;
    first = first->next;
    if (first != NULL)
    {
        first->prev = NULL;
    }
    else
    {
        l_end = NULL;
    }

    delete tmp;
}

void Print()
{
    list *p;

    if (first == NULL)
    {
        return;
    }

    if (first->next == NULL)
    {
        cout << first->key << endl;
        return;
    }

    for (p = first; p->next != NULL; p = p->next)
    {
        cout << p->key << ' ';
    }
    cout << p->key << endl;
}

void Delete(int key)
{
    list *p = Search(key);
    if (p != NULL)
    {
        if (p->next == NULL)
        {
            deleteEnd();
        }
        else if (p->prev == NULL)
        {
            deleteFirst();
        }
        else
        {
            p->prev->next = p->next;
            p->next->prev = p->prev;
            delete p;
        }
    }
}

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

    string tmp;
    string a = "insert";
    string b = "delete";
    string c = "deleteFirst";
    string d = "deleteLast";

    int num;

    first = NULL;
    l_end = NULL;
    int key;

    cin >> num;

    for (int i = 0; i < num; i++)
    {
        cin >> tmp;
        if (tmp == a)
        {
            cin >> key;
            Insert(key);
        }
        else if (tmp == b)
        {
            cin >> key;
            Delete(key);
        }
        else if (tmp == c)
        {
            deleteFirst();
        }
        else if (tmp == d)
        {
            deleteEnd();
        }
        /* Print();
        //デバッグ
        if (first != NULL)
        {
            cout << "first:" << first->key << endl;
        }
        else
        {
            cout << "first:NULL" << endl;
        }
        if (l_end != NULL)
        {
            cout << "end:" << l_end->key << endl;
        }
        else
        {
            cout << "end:NULL" << endl;
        }*/
    }

    Print();
}


Measured memory_bytes: 34428
#include <iostream>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=10000;

int main(){
	int A,B,C;
	cin>>A;
	int x;
	
	cin>>x;
	if(A<x){B=x;}
	else{B=A; A=x;}
	
  	int y;
	cin>>y;
	if(B<y){C=y;}
	else if(A<y){C=B; B=y;}
	else{C=B; B=A; A=y;}
	
	cout<<A+B+10*C;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	long a,b;
	String op;
	public void solve() {
		a = nextInt();
		op = next();
		b = nextInt();

		if(op.equals("+")){
			out.println(a + b);
		}else{
			out.println(a - b);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8276